From 63e21f15cbbad8525d1e853dbdff5ab21439e9b9 Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 18 Mar 2010 10:02:32 +0000 Subject: [PATCH] Disambiguated the origin of the ScalarType and CoordType in the simplex class. Now it derives from the type specified by the vertexRef component for the faces and from the Coord component for the vertexes. To be sure the ScalarType and CoordTypes are initialized to weird point3 and char just to detect easisly when the wrong types shallow... --- vcg/complex/trimesh/update/edges.h | 2 +- vcg/simplex/face/base.h | 38 ++++++++++---------- vcg/simplex/face/component.h | 57 ++++++++++++++++-------------- vcg/simplex/face/component_ocf.h | 18 +++++----- vcg/simplex/vertex/component.h | 2 +- 5 files changed, 60 insertions(+), 57 deletions(-) diff --git a/vcg/complex/trimesh/update/edges.h b/vcg/complex/trimesh/update/edges.h index 7c772ba4..5d3ede6f 100644 --- a/vcg/complex/trimesh/update/edges.h +++ b/vcg/complex/trimesh/update/edges.h @@ -62,7 +62,7 @@ namespace tri { typedef typename MeshType::FaceType FaceType; typedef typename MeshType::FacePointer FacePointer; typedef typename MeshType::FaceIterator FaceIterator; - typedef typename MeshType::FaceType::ScalarType ScalarType; + typedef typename MeshType::FaceType::CoordType::ScalarType ScalarType; static void Set(FaceType &f) { diff --git a/vcg/simplex/face/base.h b/vcg/simplex/face/base.h index 4579a5f6..d337ec59 100644 --- a/vcg/simplex/face/base.h +++ b/vcg/simplex/face/base.h @@ -151,8 +151,11 @@ template < class UserTypes, template class I, template class J > class FaceArityMax: public J, A, B, C, D, E, F, G, H, I> > { -// ----- Flags stuff ----- public: + typedef typename J, A, B, C, D, E, F, G, H, I> >::ScalarType ParentScalarType; + typedef J, A, B, C, D, E, F, G, H, I> > ParentType; + +// ----- Flags stuff ----- inline int & UberFlags () { @@ -284,25 +287,22 @@ static int &LastBitFlag() /// This function clear the given user bit void ClearUserBit(int userBit){this->Flags() &= (~userBit);} - template - void GetBBox( BoxType & bb ) const + + void GetBBox(Box3& bb ) { - if(this->IsD()) - { - bb.SetNull(); - return; - } - bb.Set(this->P(0)); - bb.Add(this->P(1)); - bb.Add(this->P(2)); + if(this->IsD()) { + bb.SetNull(); + return; + } + bb.Set(this->cP(0)); + bb.Add(this->cP(1)); + bb.Add(this->cP(2)); } }; -template < typename T=int> -class FaceDefaultDeriver : public T {}; - + /* These are the three main classes that are used by the library user to define its own Facees. @@ -338,11 +338,11 @@ FFAdj //topology: face face adj */ template class A = FaceDefaultDeriver, template class B = FaceDefaultDeriver, - template class C = FaceDefaultDeriver, template class D = FaceDefaultDeriver, - template class E = FaceDefaultDeriver, template class F = FaceDefaultDeriver, - template class G = FaceDefaultDeriver, template class H = FaceDefaultDeriver, - template class I = FaceDefaultDeriver, template class J = FaceDefaultDeriver > + template class A = DefaultDeriver, template class B = DefaultDeriver, + template class C = DefaultDeriver, template class D = DefaultDeriver, + template class E = DefaultDeriver, template class F = DefaultDeriver, + template class G = DefaultDeriver, template class H = DefaultDeriver, + template class I = DefaultDeriver, template class J = DefaultDeriver > class Face: public FaceArityMax {}; diff --git a/vcg/simplex/face/component.h b/vcg/simplex/face/component.h index 40fd94d2..b964cd4b 100644 --- a/vcg/simplex/face/component.h +++ b/vcg/simplex/face/component.h @@ -115,12 +115,12 @@ template class EmptyVertexRef: public T { public: // typedef typename T::VertexType VertexType; // typedef typename T::CoordType CoordType; - inline typename T::VertexType * & V( const int j ) { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * const & V( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * cV( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::CoordType & P( const int j ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - inline const typename T::CoordType & P( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - inline const typename T::CoordType &cP( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } + inline typename T::VertexType * & V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; } + inline typename T::VertexType * const & V( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } + inline typename T::VertexType * cV( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } + inline typename T::CoordType & P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } + inline const typename T::CoordType & P( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } + inline const typename T::CoordType &cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } template void ImportLocal(const RightF & rightF) {T::ImportLocal(rightF);} inline void Alloc(const int & ns){T::Alloc(ns);} @@ -137,38 +137,41 @@ public: v[2]=0; } + typedef typename T::VertexType::CoordType CoordType; + typedef typename T::VertexType::ScalarType ScalarType; + inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<3); return v[j]; } inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<3); return v[j]; } inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3); return v[j]; } // Shortcut per accedere ai punti delle facce - inline typename T::CoordType & P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); } - inline const typename T::CoordType & P( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); } - inline const typename T::CoordType &cP( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); } + inline CoordType & P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); } + inline const CoordType & P( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); } + inline const CoordType &cP( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); } /** Return the pointer to the ((j+1)%3)-th vertex of the face. @param j Index of the face vertex. */ - inline typename T::VertexType * & V0( const int j ) { return V(j);} - inline typename T::VertexType * & V1( const int j ) { return V((j+1)%3);} - inline typename T::VertexType * & V2( const int j ) { return V((j+2)%3);} - inline const typename T::VertexType * const & V0( const int j ) const { return V(j);} - inline const typename T::VertexType * const & V1( const int j ) const { return V((j+1)%3);} - inline const typename T::VertexType * const & V2( const int j ) const { return V((j+2)%3);} - inline const typename T::VertexType * const & cV0( const int j ) const { return cV(j);} - inline const typename T::VertexType * const & cV1( const int j ) const { return cV((j+1)%3);} - inline const typename T::VertexType * const & cV2( const int j ) const { return cV((j+2)%3);} + inline typename T::VertexType * & V0( const int j ) { return V(j);} + inline typename T::VertexType * & V1( const int j ) { return V((j+1)%3);} + inline typename T::VertexType * & V2( const int j ) { return V((j+2)%3);} + inline typename T::VertexType * const V0( const int j ) const { return V(j);} + inline typename T::VertexType * const V1( const int j ) const { return V((j+1)%3);} + inline typename T::VertexType * const V2( const int j ) const { return V((j+2)%3);} + inline typename T::VertexType * cV0( const int j ) const { return cV(j);} + inline typename T::VertexType * cV1( const int j ) const { return cV((j+1)%3);} + inline typename T::VertexType * cV2( const int j ) const { return cV((j+2)%3);} /// Shortcut per accedere ai punti delle facce - inline typename T::CoordType & P0( const int j ) { return V(j)->P();} - inline typename T::CoordType & P1( const int j ) { return V((j+1)%3)->P();} - inline typename T::CoordType & P2( const int j ) { return V((j+2)%3)->P();} - inline const typename T::CoordType & P0( const int j ) const { return V(j)->P();} - inline const typename T::CoordType & P1( const int j ) const { return V((j+1)%3)->P();} - inline const typename T::CoordType & P2( const int j ) const { return V((j+2)%3)->P();} - inline const typename T::CoordType & cP0( const int j ) const { return cV(j)->P();} - inline const typename T::CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();} - inline const typename T::CoordType & cP2( const int j ) const { return cV((j+2)%3)->P();} + inline CoordType & P0( const int j ) { return V(j)->P();} + inline CoordType & P1( const int j ) { return V((j+1)%3)->P();} + inline CoordType & P2( const int j ) { return V((j+2)%3)->P();} + inline const CoordType & P0( const int j ) const { return V(j)->P();} + inline const CoordType & P1( const int j ) const { return V((j+1)%3)->P();} + inline const CoordType & P2( const int j ) const { return V((j+2)%3)->P();} + inline const CoordType & cP0( const int j ) const { return cV(j)->P();} + inline const CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();} + inline const CoordType & cP2( const int j ) const { return cV((j+2)%3)->P();} inline typename T::VertexType * & UberV( const int j ) { assert(j>=0 && j<3); return v[j]; } inline const typename T::VertexType * const & UberV( const int j ) const { assert(j>=0 && j<3); return v[j]; } diff --git a/vcg/simplex/face/component_ocf.h b/vcg/simplex/face/component_ocf.h index 0346c99f..723ad2cf 100644 --- a/vcg/simplex/face/component_ocf.h +++ b/vcg/simplex/face/component_ocf.h @@ -183,13 +183,13 @@ public: class WedgeColorTypePack { public: WedgeColorTypePack() { - typedef typename VALUE_TYPE::ColorType::ScalarType ScalarType; + typedef typename VALUE_TYPE::ColorType::ScalarType WedgeColorScalarType; for (int i=0; i<3; ++i) { - wc[i][0] = ScalarType(255); - wc[i][1] = ScalarType(255); - wc[i][2] = ScalarType(255); - wc[i][3] = ScalarType(255); + wc[i][0] = WedgeColorScalarType(255); + wc[i][1] = WedgeColorScalarType(255); + wc[i][2] = WedgeColorScalarType(255); + wc[i][3] = WedgeColorScalarType(255); } } @@ -199,12 +199,12 @@ public: class WedgeNormalTypePack { public: WedgeNormalTypePack() { - typedef typename VALUE_TYPE::NormalType::ScalarType ScalarType; + typedef typename VALUE_TYPE::NormalType::ScalarType WedgeNormalScalarType; for (int i=0; i<3; ++i) { - wn[i][0] = ScalarType(0); - wn[i][1] = ScalarType(0); - wn[i][2] = ScalarType(1); + wn[i][0] = WedgeNormalScalarType(0); + wn[i][1] = WedgeNormalScalarType(0); + wn[i][2] = WedgeNormalScalarType(1); } } diff --git a/vcg/simplex/vertex/component.h b/vcg/simplex/vertex/component.h index b83f7295..48514078 100644 --- a/vcg/simplex/vertex/component.h +++ b/vcg/simplex/vertex/component.h @@ -182,7 +182,7 @@ public: template class Coord: public T { public: typedef A CoordType; - typedef typename CoordType::ScalarType ScalarType; + typedef typename A::ScalarType ScalarType; CoordType &P() { return _coord; } const CoordType &P() const { return _coord; } const CoordType &cP() const { return _coord; }