00001 /**************************************************************************** 00002 * VCGLib o o * 00003 * Visual and Computer Graphics Library o o * 00004 * _ O _ * 00005 * Copyright(C) 2004 \/)\/ * 00006 * Visual Computing Lab /\/| * 00007 * ISTI - Italian National Research Council | * 00008 * \ * 00009 * All rights reserved. * 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 * This program is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 00020 * for more details. * 00021 * * 00022 ****************************************************************************/ 00023 /**************************************************************************** 00024 History 00025 00026 $Log: not supported by cvs2svn $ 00027 Revision 1.5 2006/08/23 16:49:25 marfr960 00028 added typedef VertContainer VertexContainer to avoid inconsistency with pre-existing methods 00029 00030 Revision 1.4 2006/08/23 15:32:24 marfr960 00031 added bbox of the mesh 00032 vn int->size_t 00033 00034 Revision 1.3 2005/09/20 13:58:55 pietroni 00035 Modified MArk function parameter form ConstVertexPointer to VertexPointer 00036 00037 Revision 1.2 2005/08/02 11:37:29 pietroni 00038 renamed typedef VertexContainer into VertContainer (like trimesh) 00039 00040 Revision 1.1 2005/03/09 13:22:55 ganovelli 00041 creation 00042 00043 00044 ****************************************************************************/ 00045 00046 #pragma warning( disable : 4804 ) 00047 00048 #include <vcg/space/box3.h> 00049 #include <vcg/space/color4.h> 00050 00051 00052 /* 00053 People should subclass his vertex class from these one... 00054 */ 00055 00056 #ifndef __VCGLIB_VERTEXMESH 00057 #define __VCGLIB_VERTEXMESH 00058 00059 namespace vcg { 00060 namespace vrt { 00063 00068 template < class VertContainerType > 00069 class VertexMesh{ 00070 public: 00071 typedef VertContainerType VertContainer; 00072 typedef VertContainer VertexContainer; 00073 typedef typename VertContainerType::value_type VertexType; 00074 typedef typename VertContainerType::value_type::ScalarType ScalarType; 00075 typedef typename VertContainerType::value_type::CoordType CoordType; 00076 typedef typename VertContainerType::iterator VertexIterator; 00077 typedef typename VertContainerType::const_iterator ConstVertexIterator; 00078 typedef VertexType * VertexPointer; 00079 typedef const VertexType * ConstVertexPointer; 00080 typedef Box3<ScalarType> BoxType; 00081 00082 VertContainerType vert; 00083 size_t vn; 00084 00085 Box3<ScalarType> bbox; 00086 00087 private: 00088 Color4b c; 00089 public: 00090 00091 inline const Color4b & C() const 00092 { 00093 return c; 00094 } 00095 00096 inline Color4b & C() 00097 { 00098 return c; 00099 } 00100 00101 00103 VertexMesh() 00104 { 00105 vn = 0; 00106 imark = 0; 00107 } 00108 00109 inline int MemUsed() const 00110 { 00111 return sizeof(VertexMesh)*vert.size(); 00112 } 00113 00114 inline int MemNeeded() const 00115 { 00116 return sizeof(VertexMesh)*vn; 00117 } 00118 00119 00120 00122 void Clear() 00123 { 00124 vert.clear(); 00125 vn = 0; 00126 } 00127 00129 static bool HasPerVertexNormal() { return VertexType::HasNormal() ; } 00130 static bool HasPerVertexColor() { return VertexType::HasColor() ; } 00131 static bool HasPerVertexMark() { return VertexType::HasMark() ; } 00132 static bool HasPerVertexQuality() { return VertexType::HasQuality(); } 00133 static bool HasPerVertexTexCoord(){ return VertexType::HasTexCoord(); } 00134 00136 void InitPointIMark() 00137 { 00138 VertexIterator f; 00139 00140 for(f=vert.begin();f!=vert.end();++f) 00141 if( !(*f).IsDeleted() && (*f).IsR() && (*f).IsW() ) 00142 (*f).InitIMark(); 00143 } 00144 00146 void InitVertexIMark() 00147 { 00148 VertexIterator vi; 00149 00150 for(vi=vert.begin();vi!=vert.end();++vi) 00151 if( !(*vi).IsDeleted() && (*vi).IsRW() ) 00152 (*vi).InitIMark(); 00153 } 00154 00156 int imark; 00157 00160 inline bool IsMarked( ConstVertexPointer v ) const { return v->IMark() == imark; } 00163 inline void Mark( VertexPointer v ) const { v->IMark() = imark; } 00165 inline void UnMarkAll() { ++imark; } 00166 00167 }; // end class VertexMesh 00168 00170 } // end namespace 00171 } // end namespace 00172 00173 00174 #endif 00175 00176