PLearn 0.1
|
00001 // -*- C++ -*- 00002 00003 // MeshVertex.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: MeshVertex.cc,v 1.3 2005/12/14 20:41:11 lamblinp Exp $ 00037 ******************************************************* */ 00038 00039 // Authors: Pascal Lamblin 00040 00044 #include "MeshVertex.h" 00045 00046 namespace PLearn { 00047 using namespace std; 00048 00049 MeshVertex::MeshVertex() : 00050 region( 0 ), 00051 bf( 0 ), 00052 coord( 3 ), 00053 norm( 3 ), 00054 error( 0 ) 00055 {} 00056 00057 /* 00058 MeshVertex::MeshVertex( const MeshVertex& p ) : 00059 region( p.region ), 00060 bf( p.bf ), 00061 coord( p.coord ), 00062 norm( p.norm ), 00063 error( p.error ) 00064 {} 00065 */ 00066 00067 00068 PLEARN_IMPLEMENT_OBJECT(MeshVertex, 00069 "Point element of a SurfaceMesh", 00070 "" 00071 ); 00072 00073 void MeshVertex::declareOptions(OptionList& ol) 00074 { 00075 declareOption(ol, "region", &MeshVertex::region, OptionBase::buildoption, 00076 "region the point belongs to"); 00077 00078 declareOption(ol, "bf", &MeshVertex::bf, OptionBase::buildoption, 00079 "boundary flag"); 00080 00081 declareOption(ol, "coord", &MeshVertex::coord, OptionBase::buildoption, 00082 "(3D) coordinates of the point"); 00083 00084 declareOption(ol, "norm", &MeshVertex::norm, OptionBase::buildoption, 00085 "(3D) coordinates of the normal vector at the point"); 00086 00087 declareOption(ol, "error", &MeshVertex::error, OptionBase::buildoption, 00088 "dunno, sure it has something to do with an error measure..."); 00089 00090 declareOption(ol, "features", &MeshVertex::features, OptionBase::buildoption, 00091 "Vector containing the (chemical) features of this vertex"); 00092 00093 // Now call the parent class' declareOptions 00094 inherited::declareOptions(ol); 00095 } 00096 00097 void MeshVertex::build_() 00098 {} 00099 00100 void MeshVertex::build() 00101 { 00102 inherited::build(); 00103 build_(); 00104 } 00105 00106 void MeshVertex::makeDeepCopyFromShallowCopy(CopiesMap& copies) 00107 { 00108 inherited::makeDeepCopyFromShallowCopy(copies); 00109 00110 deepCopyField(coord, copies); 00111 deepCopyField(norm, copies); 00112 deepCopyField(features, copies); 00113 } 00114 00115 /* 00116 MeshVertex& MeshVertex::operator=( const MeshVertex& p ) 00117 { 00118 region = p.region; 00119 bf = p.bf; 00120 coord = p.coord; 00121 norm = p.norm; 00122 error = p.error; 00123 return *this; 00124 } 00125 */ 00126 00127 int MeshVertex::compare( const MeshVertex& p, const MeshVertex& q ) 00128 { 00129 int answer; 00130 00131 if( p.error > q.error ) 00132 { answer = -1; } 00133 else if( p.error < q.error ) 00134 { answer = 1; } 00135 else 00136 { answer = 0; } 00137 00138 return answer; 00139 } 00140 00141 real dist3D( const MeshVertex& p, const MeshVertex& q ) 00142 { 00143 return dist( p.coord, q.coord, 2 ); 00144 } 00145 00146 } // end of namespace PLearn