PLearn 0.1
MeshMatch.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // MeshMatch.cc
00004 //
00005 // Copyright (C) 2004 Pascal Lamblin 
00006 // 
00007 // Redistribution and use in source and binary forms, with or without
00008 // modification, are permitted provided that the following conditions are met:
00009 // 
00010 //  1. Redistributions of source code must retain the above copyright
00011 //     notice, this list of conditions and the following disclaimer.
00012 // 
00013 //  2. Redistributions in binary form must reproduce the above copyright
00014 //     notice, this list of conditions and the following disclaimer in the
00015 //     documentation and/or other materials provided with the distribution.
00016 // 
00017 //  3. The name of the authors may not be used to endorse or promote
00018 //     products derived from this software without specific prior written
00019 //     permission.
00020 // 
00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 // 
00032 // This file is part of the PLearn library. For more information on the PLearn
00033 // library, go to the PLearn Web site at www.plearn.org
00034 
00035 /* *******************************************************      
00036    * $Id: MeshMatch.cc,v 1.4 2005/01/21 03:58:01 lamblinp Exp $ 
00037    ******************************************************* */
00038 
00039 // Authors: Pascal Lamblin
00040 
00043 #include "MeshMatch.h"
00044 
00045 namespace PLearn {
00046 using namespace std;
00047 
00048 MeshMatch::MeshMatch() :
00049   id( 0 ),
00050   model_id( 0 ),
00051 //  correspondences(),
00052   rot( 3, 3 ),
00053   trans( 3 ),
00054   angles( 3 ),
00055   error( 0 )
00056 {}
00057 
00058 /*
00059 MeshMatch::MeshMatch( const MeshMatch& m ) :
00060   id( m.id ),
00061   model_id( m.model_id ),
00062   correspondences(),
00063   rot( 3, 3 ),
00064   trans( 3 ),
00065   angles( 3 ),
00066   error( m.error )
00067 {
00068   correspondences.resize( m.correspondences.size() );
00069   correspondences << m.correspondences;
00070   rot << m.rot;
00071   trans << m.trans;
00072   angles << m.angles;
00073 }
00074 */
00075 
00076 
00077 PLEARN_IMPLEMENT_OBJECT(MeshMatch,
00078     "Object describing the match and alignment between two Meshes",
00079     ""
00080 );
00081 
00082 void MeshMatch::declareOptions(OptionList& ol)
00083 {
00084   declareOption(ol, "id", &MeshMatch::id, OptionBase::buildoption,
00085                 "match identifier");
00086 
00087   declareOption(ol, "model_id", &MeshMatch::model_id, OptionBase::buildoption,
00088                 "identifier of the model we try to match the mesh to");
00089 /*
00090   declareOption(ol, "correspondences", &MeshMatch::correspondences, 
00091                 OptionBase::buildoption,
00092                 "list of point-to-point correspondences of the match");
00093 */
00094   declareOption(ol, "rot", &MeshMatch::rot, OptionBase::buildoption,
00095                 "rotation matrix of the match"); // maybe learntoption ?
00096 
00097   declareOption(ol, "trans", &MeshMatch::trans, OptionBase::buildoption,
00098                 "translation vector of the match");
00099 
00100   declareOption(ol, "angles", &MeshMatch::angles, OptionBase::buildoption,
00101                 "angles of the rotations of the match");
00102 
00103   declareOption(ol, "error", &MeshMatch::error, OptionBase::buildoption,
00104                 "alignment error between the match and the model");
00105 
00106 
00107   // Now call the parent class' declareOptions
00108   inherited::declareOptions(ol);
00109 }
00110 
00111 void MeshMatch::build_()
00112 {
00113 }
00114 
00115 // ### Nothing to add here, simply calls build_
00116 void MeshMatch::build()
00117 {
00118   inherited::build();
00119   build_();
00120 }
00121 
00122 void MeshMatch::makeDeepCopyFromShallowCopy(CopiesMap& copies)
00123 {
00124   inherited::makeDeepCopyFromShallowCopy(copies);
00125 
00126   // ### Call deepCopyField on all "pointer-like" fields 
00127   // ### that you wish to be deepCopied rather than 
00128   // ### shallow-copied.
00129   // ### ex:
00130   // deepCopyField(trainvec, copies);
00131 
00132   // ### Remove this line when you have fully implemented this method.
00133   PLERROR("MeshMatch::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
00134 }
00135 
00136 /*
00137 MeshMatch& MeshMatch::operator=( const MeshMatch& m )
00138 {
00139   id = m.id;
00140   model_id = m.model_id;
00141   correspondences.resize( m.correspondences.size() );
00142   correspondences << m.correspondences;
00143   rot << m.rot;
00144   trans << m.trans;
00145   angles << m.angles;
00146   error = m.error;
00147 
00148   return *this;
00149 }
00150 */
00151 
00152 int MeshMatch::compare( const MeshMatch& p, const MeshMatch& q )
00153 {
00154 //  if( p.correspondences.size() < q.correspondences.size() ) return  1;
00155 //  if( p.correspondences.size() > q.correspondences.size() ) return -1;
00156   if( p.error > q.error ) return  1;
00157   if( p.error < q.error ) return -1;
00158   return 0;
00159 }
00160 
00161 
00162 } // end of namespace PLearn
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines