00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __VCG_MESH
00024 #error "This file should not be included alone. It is automatically included by complex.h"
00025 #endif
00026 #ifndef __VCG_COMPLEX_BASE
00027 #define __VCG_COMPLEX_BASE
00028
00029 namespace vcg {
00030
00031 class PointerToAttribute
00032 {
00033 public:
00034 SimpleTempDataBase * _handle;
00035 std::string _name;
00036 int _sizeof;
00037 int _padding;
00038
00039 int n_attr;
00040
00041 void Resize(size_t sz){((SimpleTempDataBase *)_handle)->Resize(sz);}
00042 void Reorder(std::vector<size_t> & newVertIndex){((SimpleTempDataBase *)_handle)->Reorder(newVertIndex);}
00043 bool operator<(const PointerToAttribute b) const { return(_name.empty()&&b._name.empty())?(_handle < b._handle):( _name < b._name);}
00044 };
00045
00046
00047 namespace tri {
00050
00051
00052
00053
00054
00055 template <class TYPESPOOL>
00056 struct BaseMeshTypeHolder{
00057
00058 typedef bool ScalarType;
00059 typedef std::vector< typename TYPESPOOL::VertexType > CONTV;
00060 typedef std::vector< typename TYPESPOOL::EdgeType > CONTE;
00061 typedef std::vector< typename TYPESPOOL::FaceType > CONTF;
00062 typedef std::vector< typename TYPESPOOL::HEdgeType > CONTH;
00063
00064 typedef CONTV VertContainer;
00065 typedef _Vertex VertexType;
00066 typedef typename TYPESPOOL::VertexPointer VertexPointer;
00067 typedef const typename TYPESPOOL::VertexPointer ConstVertexPointer;
00068 typedef bool CoordType;
00069 typedef typename CONTV::iterator VertexIterator;
00070 typedef typename CONTV::const_iterator ConstVertexIterator;
00071
00072 typedef CONTE EdgeContainer;
00073 typedef typename CONTE::value_type EdgeType;
00074 typedef typename TYPESPOOL::EdgePointer EdgePointer;
00075 typedef typename CONTE::iterator EdgeIterator;
00076 typedef typename CONTE::const_iterator ConstEdgeIterator;
00077
00078 typedef CONTF FaceContainer;
00079 typedef typename CONTF::value_type FaceType;
00080 typedef typename CONTF::const_iterator ConstFaceIterator;
00081 typedef typename CONTF::iterator FaceIterator;
00082 typedef typename TYPESPOOL::FacePointer FacePointer;
00083 typedef const typename TYPESPOOL::FacePointer ConstFacePointer;
00084
00085 typedef CONTH HEdgeContainer;
00086 typedef typename CONTH::value_type HEdgeType;
00087 typedef typename TYPESPOOL::HEdgePointer HEdgePointer;
00088 typedef typename CONTH::iterator HEdgeIterator;
00089 typedef typename CONTH::const_iterator ConstHEdgeIterator;
00090
00091
00092 };
00093
00094
00095
00096 template <class T, typename CONT, class TRAIT >
00097 struct MeshTypeHolder: public T {};
00098
00099 template <class T, typename CONT>
00100 struct MeshTypeHolder<T, CONT, AllTypes::AVertexType>: public T {
00101 typedef CONT VertContainer;
00102 typedef typename VertContainer::value_type VertexType;
00103 typedef VertexType * VertexPointer;
00104 typedef const VertexType * ConstVertexPointer;
00105 typedef typename VertexType::ScalarType ScalarType;
00106 typedef typename VertexType::CoordType CoordType;
00107 typedef typename VertContainer::iterator VertexIterator;
00108 typedef typename VertContainer::const_iterator ConstVertexIterator;
00109 };
00110
00111
00112 template <typename T, class CONT>
00113 struct MeshTypeHolder< T, CONT, AllTypes::AEdgeType>: public T{
00114 typedef CONT EdgeContainer;
00115 typedef typename EdgeContainer::value_type EdgeType;
00116 typedef typename EdgeContainer::value_type * EdgePointer;
00117 typedef typename EdgeContainer::iterator EdgeIterator;
00118 typedef typename EdgeContainer::const_iterator ConstEdgeIterator;
00119 };
00120
00121 template <typename T, class CONT>
00122 struct MeshTypeHolder< T, CONT, AllTypes::AFaceType>:public T {
00123 typedef CONT FaceContainer;
00124 typedef typename FaceContainer::value_type FaceType;
00125 typedef typename FaceContainer::const_iterator ConstFaceIterator;
00126 typedef typename FaceContainer::iterator FaceIterator;
00127 typedef FaceType * FacePointer;
00128 typedef const FaceType * ConstFacePointer;
00129 };
00130
00131 template <typename T, class CONT>
00132 struct MeshTypeHolder< T, CONT, AllTypes::AHEdgeType>: public T{
00133 typedef CONT HEdgeContainer;
00134 typedef typename HEdgeContainer::value_type HEdgeType;
00135 typedef typename HEdgeContainer::value_type * HEdgePointer;
00136 typedef typename HEdgeContainer::iterator HEdgeIterator;
00137 typedef typename HEdgeContainer::const_iterator ConstHEdgeIterator;
00138 };
00139
00140 template <typename T, typename CONT> struct Der: public MeshTypeHolder<T,CONT, typename CONT::value_type::IAm>{};
00141 struct DummyContainer{struct value_type{ typedef int IAm;}; };
00147 template < class Container0 = DummyContainer, class Container1 = DummyContainer, class Container2 = DummyContainer, class Container3 = DummyContainer >
00148 class TriMesh
00149 : public MArity4< BaseMeshTypeHolder<typename Container0::value_type::TypesPool>, Container0, Der ,Container1, Der, Container2, Der, Container3, Der>{
00150 public:
00151
00152 typedef typename TriMesh::ScalarType ScalarType;
00153 typedef typename TriMesh::VertContainer VertContainer;
00154 typedef typename TriMesh::EdgeContainer EdgeContainer;
00155 typedef typename TriMesh::FaceContainer FaceContainer;
00156
00157
00158 typedef typename TriMesh::VertexType VertexType;
00159 typedef typename TriMesh::VertexPointer VertexPointer;
00160 typedef typename TriMesh::ConstVertexPointer ConstVertexPointer;
00161 typedef typename TriMesh::CoordType CoordType;
00162 typedef typename TriMesh::VertexIterator VertexIterator;
00163 typedef typename TriMesh::ConstVertexIterator ConstVertexIterator;
00164
00165
00166 typedef typename TriMesh::EdgeType EdgeType;
00167 typedef typename TriMesh::EdgePointer EdgePointer;
00168 typedef typename TriMesh::EdgeIterator EdgeIterator;
00169 typedef typename TriMesh::ConstEdgeIterator ConstEdgeIterator;
00170
00171
00172 typedef typename TriMesh::FaceType FaceType;
00173 typedef typename TriMesh::ConstFaceIterator ConstFaceIterator;
00174 typedef typename TriMesh::FaceIterator FaceIterator;
00175 typedef typename TriMesh::FacePointer FacePointer;
00176 typedef typename TriMesh::ConstFacePointer ConstFacePointer;
00177
00178
00179 typedef typename TriMesh::HEdgeType HEdgeType;
00180 typedef typename TriMesh::HEdgePointer HEdgePointer;
00181 typedef typename TriMesh::HEdgeIterator HEdgeIterator;
00182 typedef typename TriMesh::HEdgeContainer HEdgeContainer;
00183 typedef typename TriMesh::ConstHEdgeIterator ConstHEdgeIterator;
00184
00185 typedef vcg::PointerToAttribute PointerToAttribute;
00186
00187 typedef TriMesh<Container0, Container1,Container2,Container3> MeshType;
00188
00189 typedef Box3<ScalarType> BoxType;
00190
00192 VertContainer vert;
00194 int vn;
00196 inline int VN() const { return vn; }
00197
00199 EdgeContainer edge;
00201 int en;
00203 inline int EN() const { return en; }
00204
00206 FaceContainer face;
00208 int fn;
00210 inline int FN() const { return fn; }
00211
00213 HEdgeContainer hedge;
00215 int hn;
00217 inline int HN() const { return hn; }
00218
00220 Box3<typename TriMesh::VertexType::CoordType::ScalarType> bbox;
00221
00223
00224 std::vector<std::string> textures;
00225
00226 std::vector<std::string> normalmaps;
00227
00228 int attrn;
00229
00230
00231 std::set< PointerToAttribute > vert_attr;
00232 std::set< PointerToAttribute > edge_attr;
00233 std::set< PointerToAttribute > face_attr;
00234 std::set< PointerToAttribute > mesh_attr;
00235
00236
00237
00238 template <class ATTR_TYPE, class CONT>
00239 class AttributeHandle{
00240 public:
00241 AttributeHandle(){_handle=(SimpleTempData<CONT,ATTR_TYPE> *)NULL;}
00242 AttributeHandle( void *ah,const int & n):_handle ( (SimpleTempData<CONT,ATTR_TYPE> *)ah ),n_attr(n){}
00243 AttributeHandle operator = ( const PointerToAttribute & pva){
00244 _handle = (SimpleTempData<CONT,ATTR_TYPE> *)pva._handle;
00245 n_attr = pva.n_attr;
00246 return (*this);
00247 }
00248
00249
00250 SimpleTempData<CONT,ATTR_TYPE> * _handle;
00251
00252
00253 int n_attr;
00254
00255
00256 template <class RefType>
00257 ATTR_TYPE & operator [](const RefType & i){return (*_handle)[i];}
00258 void resize(size_t ) { };
00259 };
00260
00261 template <class ATTR_TYPE>
00262 class PerVertexAttributeHandle: public AttributeHandle<ATTR_TYPE,VertContainer>{
00263 public:
00264 PerVertexAttributeHandle():AttributeHandle<ATTR_TYPE,VertContainer>(){}
00265 PerVertexAttributeHandle( void *ah,const int & n):AttributeHandle<ATTR_TYPE,VertContainer>(ah,n){}
00266 };
00267
00268
00269 template <class ATTR_TYPE>
00270 class PerFaceAttributeHandle: public AttributeHandle<ATTR_TYPE,FaceContainer>{
00271 public:
00272 PerFaceAttributeHandle():AttributeHandle<ATTR_TYPE,FaceContainer>(){}
00273 PerFaceAttributeHandle( void *ah,const int & n):AttributeHandle<ATTR_TYPE,FaceContainer>(ah,n){}
00274 };
00275
00276 template <class ATTR_TYPE>
00277 class PerEdgeAttributeHandle: public AttributeHandle<ATTR_TYPE,EdgeContainer>{
00278 public:
00279 PerEdgeAttributeHandle():AttributeHandle<ATTR_TYPE,EdgeContainer>(){}
00280 PerEdgeAttributeHandle( void *ah,const int & n):AttributeHandle<ATTR_TYPE,EdgeContainer>(ah,n){}
00281 };
00282
00283 template <class ATTR_TYPE>
00284 class PerMeshAttributeHandle{
00285 public:
00286 PerMeshAttributeHandle(){_handle=NULL;}
00287 PerMeshAttributeHandle(void *ah,const int & n):_handle ( (Attribute<ATTR_TYPE> *)ah ),n_attr(n){}
00288 PerMeshAttributeHandle operator = ( const PerMeshAttributeHandle & pva){
00289 _handle = (Attribute<ATTR_TYPE> *)pva._handle;
00290 n_attr = pva.n_attr;
00291 return (*this);
00292 }
00293
00294 Attribute<ATTR_TYPE> * _handle;
00295 int n_attr;
00296 ATTR_TYPE & operator ()(){ return *((Attribute<ATTR_TYPE> *)_handle)->attribute;}
00297 };
00298
00299
00300 typedef typename MeshType::template PerVertexAttributeHandle<ScalarType> PerVertexScalarHandle;
00301 typedef typename MeshType::template PerVertexAttributeHandle<int> PerVertexIntHandle;
00302 typedef typename MeshType::template PerVertexAttributeHandle<bool> PerVertexBoolHandle;
00303 typedef typename MeshType::template PerVertexAttributeHandle<CoordType> PerVertexCoordHandle;
00304
00305 typedef typename MeshType::template PerFaceAttributeHandle<ScalarType> PerFaceScalarHandle;
00306 typedef typename MeshType::template PerFaceAttributeHandle<int> PerFaceIntHandle;
00307 typedef typename MeshType::template PerFaceAttributeHandle<bool> PerFaceBoolHandle;
00308 typedef typename MeshType::template PerFaceAttributeHandle<CoordType> PerFaceCoordHandle;
00309
00310
00311
00312
00313 Shot<ScalarType> shot;
00314
00315 private:
00317 Color4b c;
00318 public:
00319
00320 inline const Color4b &C() const { return c; }
00321 inline Color4b &C() { return c; }
00322 inline Color4b cC() const { return c; }
00323
00325 TriMesh()
00326 {
00327 Clear();
00328 }
00329
00331 ~TriMesh()
00332 {
00333 Clear();
00334 }
00335
00336 int Mem(const int & nv, const int & nf) const {
00337 typename std::set< PointerToAttribute>::const_iterator i;
00338 int size = 0;
00339 size += sizeof(TriMesh)+sizeof(VertexType)*nv+sizeof(FaceType)*nf;
00340
00341 for( i = vert_attr.begin(); i != vert_attr.end(); ++i)
00342 size += ((SimpleTempDataBase*)(*i)._handle)->SizeOf()*nv;
00343 for( i = edge_attr.begin(); i != edge_attr.end(); ++i)
00344 size += ((SimpleTempDataBase*)(*i)._handle)->SizeOf()*en;
00345 for( i = face_attr.begin(); i != face_attr.end(); ++i)
00346 size += ((SimpleTempDataBase*)(*i)._handle)->SizeOf()*nf;
00347 for( i = mesh_attr.begin(); i != mesh_attr.end(); ++i)
00348 size += ((SimpleTempDataBase*)(*i)._handle)->SizeOf();
00349
00350 return size;
00351 }
00352 int MemUsed() const {return Mem(vert.size(),face.size());}
00353 inline int MemNeeded() const {return Mem(vn,fn);}
00354
00355
00356
00358 void Clear()
00359 {
00360 for(FaceIterator fi = face.begin(); fi != face.end(); ++fi)
00361 (*fi).Dealloc();
00362 vert.clear();
00363 face.clear();
00364 edge.clear();
00365
00366
00367 vn = 0;
00368 en = 0;
00369 fn = 0;
00370 hn = 0;
00371 imark = 0;
00372 C()=Color4b::Gray;
00373 }
00374
00375
00376 void ClearAttributes()
00377 {
00378
00379 typename std::set< PointerToAttribute>::iterator i;
00380 for (i = vert_attr.begin(); i != vert_attr.end(); ++i)
00381 delete ((SimpleTempDataBase*)(*i)._handle);
00382 vert_attr.clear();
00383
00384 for (i = edge_attr.begin(); i != edge_attr.end(); ++i)
00385 delete ((SimpleTempDataBase*)(*i)._handle);
00386 edge_attr.clear();
00387
00388 for (i = face_attr.begin(); i != face_attr.end(); ++i)
00389 delete ((SimpleTempDataBase*)(*i)._handle);
00390 face_attr.clear();
00391
00392 for (i = mesh_attr.begin(); i != mesh_attr.end(); ++i)
00393 delete ((SimpleTempDataBase*)(*i)._handle);
00394 mesh_attr.clear();
00395 attrn = 0;
00396 }
00397
00398 bool IsEmpty() const
00399 {
00400 return vert.empty() && edge.empty() && face.empty();
00401 }
00402
00403 int & SimplexNumber(){ return fn;}
00404 int & VertexNumber(){ return vn;}
00405
00407 int imark;
00408
00409 private:
00410
00411 TriMesh operator =(const TriMesh & ){assert(0);return TriMesh();}
00412 TriMesh(const TriMesh & ){}
00413
00414 };
00415
00417 template <class MeshType> inline void InitFaceIMark(MeshType & m)
00418 {
00419 typename MeshType::FaceIterator f;
00420
00421 for(f=m.face.begin();f!=m.face.end();++f)
00422 if( !(*f).IsD() && (*f).IsR() && (*f).IsW() )
00423 (*f).InitIMark();
00424 }
00425
00427 template <class MeshType> inline void InitVertexIMark(MeshType & m)
00428 {
00429 typename MeshType::VertexIterator vi;
00430
00431 for(vi=m.vert.begin();vi!=m.vert.end();++vi)
00432 if( !(*vi).IsD() && (*vi).IsRW() )
00433 (*vi).InitIMark();
00434 }
00438 template <class MeshType> inline int & IMark(MeshType & m){return m.imark;}
00439
00443 template <class MeshType> inline bool IsMarked(MeshType & m, typename MeshType::ConstVertexPointer v ) { return v->cIMark() == m.imark; }
00444
00448 template <class MeshType> inline bool IsMarked( MeshType & m,typename MeshType::ConstFacePointer f ) { return f->cIMark() == m.imark; }
00449
00453 template <class MeshType> inline void Mark(MeshType & m, typename MeshType::VertexPointer v ) { v->IMark() = m.imark; }
00454
00458 template <class MeshType> inline void Mark(MeshType & m, typename MeshType::FacePointer f ) { f->IMark() = m.imark; }
00459
00460
00467 template <class MeshType> inline void UnMarkAll(MeshType & m)
00468 {
00469 ++m.imark;
00470 }
00471
00472
00473
00474
00475
00476
00477
00478 template < class VertexType> bool VertexVectorHasVFAdjacency (const std::vector<VertexType> &) { return VertexType::HasVFAdjacency(); }
00479 template < class VertexType> bool VertexVectorHasVEAdjacency (const std::vector<VertexType> &) { return VertexType::HasVEAdjacency(); }
00480 template < class EdgeType > bool EdgeVectorHasVEAdjacency (const std::vector<EdgeType > &) { return EdgeType::HasVEAdjacency(); }
00481 template < class EdgeType > bool EdgeVectorHasEEAdjacency (const std::vector<EdgeType> &) { return EdgeType::HasEEAdjacency(); }
00482 template < class FaceType > bool FaceVectorHasVFAdjacency (const std::vector<FaceType > &) { return FaceType::HasVFAdjacency(); }
00483
00484 template < class TriMeshType> bool HasPerVertexVFAdjacency (const TriMeshType &m) { return tri::VertexVectorHasVFAdjacency(m.vert); }
00485 template < class TriMeshType> bool HasPerVertexVEAdjacency (const TriMeshType &m) { return tri::VertexVectorHasVEAdjacency(m.vert); }
00486 template < class TriMeshType> bool HasPerEdgeVEAdjacency (const TriMeshType &m) { return tri::EdgeVectorHasVEAdjacency (m.edge); }
00487 template < class TriMeshType> bool HasPerFaceVFAdjacency (const TriMeshType &m) { return tri::FaceVectorHasVFAdjacency (m.face); }
00488
00489
00490 template < class VertexType> bool VertexVectorHasPerVertexQuality (const std::vector<VertexType> &) { return VertexType::HasQuality (); }
00491 template < class VertexType> bool VertexVectorHasPerVertexNormal (const std::vector<VertexType> &) { return VertexType::HasNormal (); }
00492 template < class VertexType> bool VertexVectorHasPerVertexColor (const std::vector<VertexType> &) { return VertexType::HasColor (); }
00493 template < class VertexType> bool VertexVectorHasPerVertexMark (const std::vector<VertexType> &) { return VertexType::HasMark (); }
00494 template < class VertexType> bool VertexVectorHasPerVertexFlags (const std::vector<VertexType> &) { return VertexType::HasFlags (); }
00495 template < class VertexType> bool VertexVectorHasPerVertexRadius (const std::vector<VertexType> &) { return VertexType::HasRadius (); }
00496 template < class VertexType> bool VertexVectorHasPerVertexCurvature (const std::vector<VertexType> &) { return VertexType::HasCurvature (); }
00497 template < class VertexType> bool VertexVectorHasPerVertexCurvatureDir(const std::vector<VertexType> &) { return VertexType::HasCurvatureDir(); }
00498 template < class VertexType> bool VertexVectorHasPerVertexTexCoord (const std::vector<VertexType> &) { return VertexType::HasTexCoord (); }
00499
00500 template < class TriMeshType> bool HasPerVertexQuality (const TriMeshType &m) { return tri::VertexVectorHasPerVertexQuality (m.vert); }
00501 template < class TriMeshType> bool HasPerVertexNormal (const TriMeshType &m) { return tri::VertexVectorHasPerVertexNormal (m.vert); }
00502 template < class TriMeshType> bool HasPerVertexColor (const TriMeshType &m) { return tri::VertexVectorHasPerVertexColor (m.vert); }
00503 template < class TriMeshType> bool HasPerVertexMark (const TriMeshType &m) { return tri::VertexVectorHasPerVertexMark (m.vert); }
00504 template < class TriMeshType> bool HasPerVertexFlags (const TriMeshType &m) { return tri::VertexVectorHasPerVertexFlags (m.vert); }
00505 template < class TriMeshType> bool HasPerVertexRadius (const TriMeshType &m) { return tri::VertexVectorHasPerVertexRadius (m.vert); }
00506 template < class TriMeshType> bool HasPerVertexCurvature (const TriMeshType &m) { return tri::VertexVectorHasPerVertexCurvature (m.vert); }
00507 template < class TriMeshType> bool HasPerVertexCurvatureDir(const TriMeshType &m) { return tri::VertexVectorHasPerVertexCurvatureDir(m.vert); }
00508 template < class TriMeshType> bool HasPerVertexTexCoord (const TriMeshType &m) { return tri::VertexVectorHasPerVertexTexCoord (m.vert); }
00509
00510 template < class EdgeType> bool EdgeVectorHasPerEdgeQuality (const std::vector<EdgeType> &) { return EdgeType::HasQuality (); }
00511 template < class EdgeType> bool EdgeVectorHasPerEdgeNormal (const std::vector<EdgeType> &) { return EdgeType::HasNormal (); }
00512 template < class EdgeType> bool EdgeVectorHasPerEdgeColor (const std::vector<EdgeType> &) { return EdgeType::HasColor (); }
00513 template < class EdgeType> bool EdgeVectorHasPerEdgeMark (const std::vector<EdgeType> &) { return EdgeType::HasMark (); }
00514 template < class EdgeType> bool EdgeVectorHasPerEdgeFlags (const std::vector<EdgeType> &) { return EdgeType::HasFlags (); }
00515
00516 template < class TriMeshType> bool HasPerEdgeQuality (const TriMeshType &m) { return tri::EdgeVectorHasPerEdgeQuality (m.edge); }
00517 template < class TriMeshType> bool HasPerEdgeNormal (const TriMeshType &m) { return tri::EdgeVectorHasPerEdgeNormal (m.edge); }
00518 template < class TriMeshType> bool HasPerEdgeColor (const TriMeshType &m) { return tri::EdgeVectorHasPerEdgeColor (m.edge); }
00519 template < class TriMeshType> bool HasPerEdgeMark (const TriMeshType &m) { return tri::EdgeVectorHasPerEdgeMark (m.edge); }
00520 template < class TriMeshType> bool HasPerEdgeFlags (const TriMeshType &m) { return tri::EdgeVectorHasPerEdgeFlags (m.edge); }
00521
00522
00523 template < class FaceType> bool FaceVectorHasPerWedgeColor (const std::vector<FaceType> &) { return FaceType::HasWedgeColor (); }
00524 template < class FaceType> bool FaceVectorHasPerWedgeNormal (const std::vector<FaceType> &) { return FaceType::HasWedgeNormal (); }
00525 template < class FaceType> bool FaceVectorHasPerWedgeTexCoord(const std::vector<FaceType> &) { return FaceType::HasWedgeTexCoord(); }
00526
00527 template < class TriMeshType> bool HasPerWedgeColor (const TriMeshType &m) { return tri::FaceVectorHasPerWedgeColor (m.face); }
00528 template < class TriMeshType> bool HasPerWedgeNormal (const TriMeshType &m) { return tri::FaceVectorHasPerWedgeNormal (m.face); }
00529 template < class TriMeshType> bool HasPerWedgeTexCoord(const TriMeshType &m) { return tri::FaceVectorHasPerWedgeTexCoord(m.face); }
00530
00531 template < class CType0, class CType1, class CType2 , class CType3>
00532 bool HasPolyInfo (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh < CType0 , CType1, CType2, CType3>::FaceContainer::value_type::HasPolyInfo();}
00533
00534 template < class FaceType> bool FaceVectorHasPerFaceFlags (const std::vector<FaceType> &) { return FaceType::HasFlags (); }
00535 template < class FaceType> bool FaceVectorHasPerFaceNormal (const std::vector<FaceType> &) { return FaceType::HasNormal (); }
00536 template < class FaceType> bool FaceVectorHasPerFaceColor (const std::vector<FaceType> &) { return FaceType::HasColor (); }
00537 template < class FaceType> bool FaceVectorHasPerFaceMark (const std::vector<FaceType> &) { return FaceType::HasMark (); }
00538 template < class FaceType> bool FaceVectorHasPerFaceQuality(const std::vector<FaceType> &) { return FaceType::HasQuality(); }
00539 template < class FaceType> bool FaceVectorHasFFAdjacency (const std::vector<FaceType> &) { return FaceType::HasFFAdjacency(); }
00540 template < class FaceType> bool FaceVectorHasFEAdjacency (const std::vector<FaceType> &) { return FaceType::HasFEAdjacency(); }
00541 template < class FaceType> bool FaceVectorHasFVAdjacency (const std::vector<FaceType> &) { return FaceType::HasFVAdjacency(); }
00542 template < class FaceType> bool FaceVectorHasPerFaceCurvatureDir (const std::vector<FaceType> &) { return FaceType::HasCurvatureDir(); }
00543
00544 template < class TriMeshType> bool HasPerFaceFlags (const TriMeshType &m) { return tri::FaceVectorHasPerFaceFlags (m.face); }
00545 template < class TriMeshType> bool HasPerFaceNormal (const TriMeshType &m) { return tri::FaceVectorHasPerFaceNormal (m.face); }
00546 template < class TriMeshType> bool HasPerFaceColor (const TriMeshType &m) { return tri::FaceVectorHasPerFaceColor (m.face); }
00547 template < class TriMeshType> bool HasPerFaceMark (const TriMeshType &m) { return tri::FaceVectorHasPerFaceMark (m.face); }
00548 template < class TriMeshType> bool HasPerFaceQuality (const TriMeshType &m) { return tri::FaceVectorHasPerFaceQuality (m.face); }
00549 template < class TriMeshType> bool HasPerFaceCurvatureDir(const TriMeshType &m) { return tri::FaceVectorHasPerFaceCurvatureDir(m.face); }
00550 template < class TriMeshType> bool HasFFAdjacency (const TriMeshType &m) { return tri::FaceVectorHasFFAdjacency (m.face); }
00551 template < class TriMeshType> bool HasEEAdjacency (const TriMeshType &m) { return tri::EdgeVectorHasEEAdjacency (m.edge); }
00552 template < class TriMeshType> bool HasFEAdjacency (const TriMeshType &m) { return tri::FaceVectorHasFEAdjacency (m.face); }
00553 template < class TriMeshType> bool HasFVAdjacency (const TriMeshType &m) { return tri::FaceVectorHasFVAdjacency (m.face); }
00554
00555 template < class TriMeshType> bool HasVFAdjacency (const TriMeshType &m) { return tri::FaceVectorHasVFAdjacency (m.face) && tri::VertexVectorHasVFAdjacency(m.vert); }
00556 template < class TriMeshType> bool HasVEAdjacency (const TriMeshType &m) { return tri::EdgeVectorHasVEAdjacency (m.edge) && tri::VertexVectorHasVEAdjacency(m.vert); }
00557
00558
00559
00560
00561
00562
00563 template < class CType0, class CType1, class CType2 , class CType3>
00564 bool HasVHAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh < CType0 , CType1, CType2, CType3>::VertContainer::value_type::HasVHAdjacency();}
00565
00566 template < class CType0, class CType1, class CType2 , class CType3>
00567 bool HasEVAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh < CType0 , CType1, CType2, CType3>::EdgeType::HasEVAdjacency();}
00568
00569
00570
00571
00572 template < class CType0, class CType1, class CType2 , class CType3>
00573 bool HasEFAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh < CType0 , CType1, CType2, CType3>::EdgeType::HasEFAdjacency();}
00574
00575 template < class CType0, class CType1, class CType2 , class CType3>
00576 bool HasEHAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh < CType0 , CType1, CType2, CType3>::EdgeType::HasEHAdjacency();}
00577
00578 template < class CType0, class CType1, class CType2 , class CType3>
00579 bool HasFHAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh < CType0 , CType1, CType2, CType3>::FaceType::HasFHAdjacency();}
00580
00581 template < class CType0, class CType1, class CType2 , class CType3>
00582 bool HasHVAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh < CType0 , CType1, CType2, CType3>::HEdgeType::HasHVAdjacency();}
00583
00584 template < class CType0, class CType1, class CType2 , class CType3>
00585 bool HasHEAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh < CType0 , CType1, CType2, CType3>::HEdgeType::HasHEAdjacency();}
00586
00587 template < class CType0, class CType1, class CType2 , class CType3>
00588 bool HasHFAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh < CType0 , CType1, CType2, CType3>::HEdgeType::HasHFAdjacency();}
00589
00590 template < class CType0, class CType1, class CType2 , class CType3>
00591 bool HasHNextAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh< CType0, CType1, CType2 , CType3>::HEdgeType::HasHNextAdjacency();}
00592
00593 template < class CType0, class CType1, class CType2 , class CType3>
00594 bool HasHPrevAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh< CType0, CType1, CType2 , CType3>::HEdgeType::HasHPrevAdjacency();}
00595
00596 template < class CType0, class CType1, class CType2 , class CType3>
00597 bool HasHOppAdjacency (const TriMesh < CType0, CType1, CType2, CType3> & ) {return TriMesh< CType0, CType1, CType2 , CType3>::HEdgeType::HasHOppAdjacency();}
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614 template <class MeshType>
00615 bool HasPerVertexAttribute(const MeshType &m, std::string name){
00616 typename std::set< typename MeshType::PointerToAttribute>::const_iterator ai;
00617 typename MeshType::PointerToAttribute h;
00618 h._name = name;
00619 ai = m.vert_attr.find(h);
00620 return (ai!= m.vert_attr.end() ) ;
00621 }
00622 template <class MeshType>
00623 bool HasPerFaceAttribute(const MeshType &m, std::string name){
00624 typename std::set< typename MeshType::PointerToAttribute>::const_iterator ai;
00625 typename MeshType::PointerToAttribute h;
00626 h._name = name;
00627 ai = m.face_attr.find(h);
00628 return (ai!= m.face_attr.end() ) ;
00629 }
00630
00631 template <class MeshType>
00632 bool HasPerMeshAttribute(const MeshType &m, std::string name){
00633 typename std::set< typename MeshType::PointerToAttribute>::const_iterator ai;
00634 typename MeshType::PointerToAttribute h;
00635 h._name = name;
00636 ai = m.mesh_attr.find(h);
00637 return (ai!= m.mesh_attr.end() ) ;
00638 }
00639
00640 template <class MeshType> void RequireCompactness (MeshType &m) {
00641 if(m.vert.size()!=size_t(m.vn)) throw vcg::MissingCompactnessException("Vertex Vector Contains deleted elements");
00642 if(m.edge.size()!=size_t(m.en)) throw vcg::MissingCompactnessException("Edge Vector Contains deleted elements");
00643 if(m.face.size()!=size_t(m.fn)) throw vcg::MissingCompactnessException("Face Vector Contains deleted elements");
00644 }
00645
00646 template <class MeshType> void RequireTriangularMesh (MeshType &m ) { if( tri::HasPolyInfo( m ) ) throw vcg::MissingTriangularRequirementException("");}
00647 template <class MeshType> void RequirePolygonalMesh (MeshType &m ) { if(!tri::HasPolyInfo( m ) ) throw vcg::MissingPolygonalRequirementException("");}
00648
00649 template <class MeshType> void RequireVFAdjacency (MeshType &m) { if(!tri::HasVFAdjacency (m)) throw vcg::MissingComponentException("VFAdjacency"); }
00650 template <class MeshType> void RequireVEAdjacency (MeshType &m) { if(!tri::HasVEAdjacency (m)) throw vcg::MissingComponentException("VEAdjacency"); }
00651 template <class MeshType> void RequireFFAdjacency (MeshType &m) { if(!tri::HasFFAdjacency (m)) throw vcg::MissingComponentException("FFAdjacency"); }
00652 template <class MeshType> void RequireEEAdjacency (MeshType &m) { if(!tri::HasEEAdjacency (m)) throw vcg::MissingComponentException("EEAdjacency"); }
00653 template <class MeshType> void RequireFEAdjacency (MeshType &m) { if(!tri::HasFEAdjacency (m)) throw vcg::MissingComponentException("FEAdjacency"); }
00654 template <class MeshType> void RequireFHAdjacency (MeshType &m) { if(!tri::HasFHAdjacency (m)) throw vcg::MissingComponentException("FHAdjacency"); }
00655
00656 template <class MeshType> void RequirePerVertexQuality (MeshType &m) { if(!tri::HasPerVertexQuality (m)) throw vcg::MissingComponentException("PerVertexQuality "); }
00657 template <class MeshType> void RequirePerVertexNormal (MeshType &m) { if(!tri::HasPerVertexNormal (m)) throw vcg::MissingComponentException("PerVertexNormal "); }
00658 template <class MeshType> void RequirePerVertexColor (MeshType &m) { if(!tri::HasPerVertexColor (m)) throw vcg::MissingComponentException("PerVertexColor "); }
00659 template <class MeshType> void RequirePerVertexMark (MeshType &m) { if(!tri::HasPerVertexMark (m)) throw vcg::MissingComponentException("PerVertexMark "); }
00660 template <class MeshType> void RequirePerVertexFlags (MeshType &m) { if(!tri::HasPerVertexFlags (m)) throw vcg::MissingComponentException("PerVertexFlags "); }
00661 template <class MeshType> void RequirePerVertexRadius (MeshType &m) { if(!tri::HasPerVertexRadius (m)) throw vcg::MissingComponentException("PerVertexRadius "); }
00662 template <class MeshType> void RequirePerVertexCurvature (MeshType &m) { if(!tri::HasPerVertexCurvature (m)) throw vcg::MissingComponentException("PerVertexCurvature "); }
00663 template <class MeshType> void RequirePerVertexCurvatureDir(MeshType &m) { if(!tri::HasPerVertexCurvatureDir(m)) throw vcg::MissingComponentException("PerVertexCurvatureDir"); }
00664 template <class MeshType> void RequirePerVertexTexCoord (MeshType &m) { if(!tri::HasPerVertexTexCoord (m)) throw vcg::MissingComponentException("PerVertexTexCoord "); }
00665
00666 template <class MeshType> void RequirePerEdgeQuality (MeshType &m) { if(!tri::HasPerEdgeQuality (m)) throw vcg::MissingComponentException("PerEdgeQuality "); }
00667 template <class MeshType> void RequirePerEdgeNormal (MeshType &m) { if(!tri::HasPerEdgeNormal (m)) throw vcg::MissingComponentException("PerEdgeNormal "); }
00668 template <class MeshType> void RequirePerEdgeColor (MeshType &m) { if(!tri::HasPerEdgeColor (m)) throw vcg::MissingComponentException("PerEdgeColor "); }
00669 template <class MeshType> void RequirePerEdgeMark (MeshType &m) { if(!tri::HasPerEdgeMark (m)) throw vcg::MissingComponentException("PerEdgeMark "); }
00670 template <class MeshType> void RequirePerEdgeFlags (MeshType &m) { if(!tri::HasPerEdgeFlags (m)) throw vcg::MissingComponentException("PerEdgeFlags "); }
00671
00672 template <class MeshType> void RequirePerFaceFlags (MeshType &m) { if(!tri::HasPerFaceFlags (m)) throw vcg::MissingComponentException("PerFaceFlags "); }
00673 template <class MeshType> void RequirePerFaceNormal (MeshType &m) { if(!tri::HasPerFaceNormal (m)) throw vcg::MissingComponentException("PerFaceNormal "); }
00674 template <class MeshType> void RequirePerFaceColor (MeshType &m) { if(!tri::HasPerFaceColor (m)) throw vcg::MissingComponentException("PerFaceColor "); }
00675 template <class MeshType> void RequirePerFaceMark (MeshType &m) { if(!tri::HasPerFaceMark (m)) throw vcg::MissingComponentException("PerFaceMark "); }
00676 template <class MeshType> void RequirePerFaceQuality (MeshType &m) { if(!tri::HasPerFaceQuality (m)) throw vcg::MissingComponentException("PerFaceQuality "); }
00677 template <class MeshType> void RequirePerFaceCurvatureDir(MeshType &m) { if(!tri::HasPerFaceCurvatureDir(m)) throw vcg::MissingComponentException("PerFaceCurvatureDir"); }
00678
00679 template <class MeshType> void RequirePerFaceWedgeColor (MeshType &m) { if(!tri::HasPerWedgeColor (m)) throw vcg::MissingComponentException("PerFaceWedgeColor "); }
00680 template <class MeshType> void RequirePerFaceWedgeNormal (MeshType &m) { if(!tri::HasPerWedgeNormal (m)) throw vcg::MissingComponentException("PerFaceWedgeNormal "); }
00681 template <class MeshType> void RequirePerFaceWedgeTexCoord(MeshType &m) { if(!tri::HasPerWedgeTexCoord(m)) throw vcg::MissingComponentException("PerFaceWedgeTexCoord"); }
00682
00683 template <class MeshType> void RequirePerVertexAttribute(MeshType &m, const char *name) { if(!HasPerVertexAttribute(m,name)) throw vcg::MissingComponentException("PerVertex attribute"); }
00684 template <class MeshType> void RequirePerEdgeAttribute(MeshType &m, const char *name) { if(!HasPerEdgeAttribute(m,name)) throw vcg::MissingComponentException("PerEdge attribute"); }
00685 template <class MeshType> void RequirePerFaceAttribute(MeshType &m, const char *name) { if(!HasPerFaceAttribute(m,name)) throw vcg::MissingComponentException("PerFace attribute"); }
00686 template <class MeshType> void RequirePerMeshAttribute(MeshType &m, const char *name) { if(!HasPerMeshAttribute(m,name)) throw vcg::MissingComponentException("PerMesh attribute"); }
00687
00690 }
00691 }
00692
00693
00694
00695
00696 #endif // BASE_H