PLearn 0.1
Correspondence.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Correspondence.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: Correspondence.cc,v 1.2 2004/08/26 05:56:35 lamblinp Exp $ 
00037    ******************************************************* */
00038 
00039 // Authors: Pascal Lamblin
00040 
00044 #include "Correspondence.h"
00045 
00046 namespace PLearn {
00047 using namespace std;
00048 
00049 Correspondence::Correspondence() :
00050   sid( 0 ),
00051   mid( 0 ),
00052   model_id( 0 ),
00053   votes( 0 ),
00054   correlation( 0 )
00055 {}
00056 
00057 Correspondence::Correspondence( const Correspondence& c ) :
00058   sid( c.sid ),
00059   mid( c.mid ),
00060   model_id( c.model_id ),
00061   votes( c.votes ),
00062   correlation( c.correlation )
00063 {}
00064 
00065 PLEARN_IMPLEMENT_OBJECT(Correspondence,
00066     "Correspondence / Comparison between points on two meshes",
00067     ""
00068 );
00069 
00070 void Correspondence::declareOptions(OptionList& ol)
00071 {
00072   declareOption(ol, "sid", &Correspondence::sid, OptionBase::buildoption,
00073                 "dunno yet...");
00074 
00075   declareOption(ol, "mid", &Correspondence::mid, OptionBase::buildoption,
00076                 "dunno yet...");
00077 
00078   declareOption(ol, "model_id", &Correspondence::model_id, 
00079                 OptionBase::buildoption,
00080                 "dunno, probably something to do with a model identifier...");
00081 
00082   declareOption(ol, "votes", &Correspondence::votes, OptionBase::buildoption,
00083                 "dunno, probably something to do with a number of votes...");
00084 
00085   declareOption(ol, "correlation", &Correspondence::correlation, 
00086                 OptionBase::buildoption,
00087                 "dunno, probably the correlation value itself...");
00088 
00089   // Now call the parent class' declareOptions
00090   inherited::declareOptions(ol);
00091 }
00092 
00093 void Correspondence::build_()
00094 {}
00095 
00096 void Correspondence::build()
00097 {
00098   inherited::build();
00099   build_();
00100 }
00101 
00102 void Correspondence::makeDeepCopyFromShallowCopy(CopiesMap& copies)
00103 {
00104   inherited::makeDeepCopyFromShallowCopy(copies);
00105 
00106   // ### Call deepCopyField on all "pointer-like" fields 
00107   // ### that you wish to be deepCopied rather than 
00108   // ### shallow-copied.
00109   // ### ex:
00110   // deepCopyField(trainvec, copies);
00111 
00112   // ### Remove this line when you have fully implemented this method.
00113   PLERROR("Correspondence::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
00114 }
00115 
00116 Correspondence& Correspondence::operator=( const Correspondence& c )
00117 {
00118   sid = c.sid;
00119   mid = c.mid;
00120   model_id = c.model_id;
00121   votes = c.votes;
00122   correlation = c.correlation;
00123 
00124   return *this;
00125 }
00126 
00127 int Correspondence::compare( const Correspondence& p, const Correspondence& q )
00128 {
00129   if( p.model_id < q.model_id ) return -1;
00130   if( p.model_id > q.model_id ) return  1;
00131   if( p.sid < q.sid ) return -1;
00132   if( p.sid > q.sid ) return  1;
00133   if( p.mid < q.mid ) return -1;
00134   if( p.mid > q.mid ) return  1;
00135 
00136   return 0;
00137 }
00138 
00139 
00140 bool operator<( const Correspondence& p, const Correspondence& q )
00141 {
00142   if( p.model_id < q.model_id ) return true;
00143   if( p.model_id > q.model_id ) return false;
00144   if( p.sid < q.sid ) return true;
00145   if( p.sid > q.sid ) return false;
00146   if( p.mid < q.mid ) return true;
00147   if( p.mid > q.mid ) return false;
00148 
00149   return false;
00150 }
00151 
00152 } // end of namespace PLearn
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines