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.7 2007/03/12 15:38:02 tarini 00028 Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD. 00029 00030 Revision 1.6 2005/09/14 14:09:16 spinelli 00031 ConstVertexPointer --> VertexPointer 00032 ConstEdgePointer --> EdgePointer 00033 00034 Revision 1.5 2005/05/17 21:19:37 ganovelli 00035 some std::and typename missing (CRS4) 00036 00037 Revision 1.4 2004/10/28 00:47:42 cignoni 00038 Better Doxygen documentation 00039 00040 Revision 1.3 2004/09/20 09:30:03 cignoni 00041 Better Doxygen docs 00042 00043 Revision 1.2 2004/05/10 14:41:45 ganovelli 00044 name of adhacency function updated 00045 00046 Revision 1.1 2004/04/26 19:10:04 ganovelli 00047 created 00048 00049 00050 ****************************************************************************/ 00051 00052 #pragma warning( disable : 4804 ) 00053 00054 /* 00055 People should subclass his vertex class from these one... 00056 */ 00057 00058 #ifndef __VCGLIB_EDGEMESH 00059 #define __VCGLIB_EDGEMESH 00060 00061 namespace vcg { 00062 namespace edg { 00065 00071 template < class VertContainerType, class EdgeContainerType > 00072 class EdgeMesh{ 00073 public: 00074 typedef EdgeContainerType EdgeContainer; 00075 typedef VertContainerType VertContainer; 00076 typedef typename VertContainer::value_type VertexType; 00077 typedef typename EdgeContainerType::value_type EdgeType; 00078 typedef typename VertexType::ScalarType ScalarType; 00079 typedef typename VertexType::CoordType CoordType; 00080 typedef typename VertContainer::iterator VertexIterator; 00081 typedef typename EdgeContainerType::iterator EdgeIterator; 00082 typedef typename VertContainer::const_iterator ConstVertexIterator; 00083 typedef typename EdgeContainerType::const_iterator ConstEdgeIterator; 00084 typedef VertexType * VertexPointer; 00085 typedef const VertexType * ConstVertexPointer; 00086 typedef EdgeType * EdgePointer; 00087 typedef const EdgeType * ConstEdgePointer; 00088 typedef Box3<ScalarType> BoxType; 00089 00091 VertContainer vert; 00093 int vn; 00095 EdgeContainer edges; 00097 int en; 00099 Box3<ScalarType> bbox; 00100 00102 //std::vector<string> textures; 00103 //std::vector<string> normalmaps; 00104 00106 //Camera<ScalarType> camera; 00107 00109 private: 00110 Color4b c; 00111 public: 00112 00113 inline const Color4b & C() const 00114 { 00115 return c; 00116 } 00117 00118 inline Color4b & C() 00119 { 00120 return c; 00121 } 00122 00123 00125 EdgeMesh() 00126 { 00127 en = vn = 0; 00128 imark = 0; 00129 } 00130 00131 inline int MemUsed() const 00132 { 00133 return sizeof(EdgeMesh)+sizeof(VertexType)*vert.size()+sizeof(EdgeType)*edges.size(); 00134 } 00135 00136 inline int MemNeeded() const 00137 { 00138 return sizeof(EdgeMesh)+sizeof(VertexType)*vn+sizeof(EdgeType)*en; 00139 } 00140 00141 00142 00144 void Clear() 00145 { 00146 vert.clear(); 00147 edges.clear(); 00148 // textures.clear(); 00149 // normalmaps.clear(); 00150 vn = 0; 00151 en = 0; 00152 } 00153 00155 static bool HasPerVertexNormal() { return VertexType::HasNormal() ; } 00156 static bool HasPerVertexColor() { return VertexType::HasColor() ; } 00157 static bool HasPerVertexMark() { return VertexType::HasMark() ; } 00158 static bool HasPerVertexQuality() { return VertexType::HasQuality(); } 00159 static bool HasPerVertexTexCoord(){ return VertexType::HasTexCoord(); } 00160 00161 static bool HasPerEdgeColor() { return EdgeType::HasEdgeColor() ; } 00162 static bool HasPerEdgeNormal() { return EdgeType::HasEdgeNormal() ; } 00163 static bool HasPerEdgeMark() { return EdgeType::HasEdgeMark() ; } 00164 static bool HasPerEdgeQuality() { return EdgeType::HasEdgeQuality(); } 00165 00166 static bool HasEETopology() { return EdgeType::HasEEAdjacency(); } 00167 static bool HasVETopology() { return EdgeType::HasVEAdjacency(); } 00168 static bool HasTopology() { return HasEETopology() || HasVETopology(); } 00169 00170 00172 void InitEdgeIMark() 00173 { 00174 EdgeIterator f; 00175 00176 for(f=edges.begin();f!=edges.end();++f) 00177 if( !(*f).IsDeleted() && (*f).IsR() && (*f).IsW() ) 00178 (*f).InitIMark(); 00179 } 00180 00182 void InitVertexIMark() 00183 { 00184 VertexIterator vi; 00185 00186 for(vi=vert.begin();vi!=vert.end();++vi) 00187 if( !(*vi).IsDeleted() && (*vi).IsRW() ) 00188 (*vi).InitIMark(); 00189 } 00190 00192 int imark; 00193 00196 inline bool IsMarked( ConstVertexPointer v ) const { return v->IMark() == imark; } 00199 inline bool IsMarked( ConstEdgePointer f ) const { return f->IMark() == imark; } 00202 inline void Mark( VertexPointer v ) const { v->IMark() = imark; } 00205 inline void Mark( EdgePointer f ) const { f->IMark() = imark; } 00207 inline void UnMarkAll() { ++imark; } 00208 00209 }; // end class EdgeMesh 00210 00212 } // end namespace 00213 } // end namespace 00214 00215 00216 #endif 00217