diff --git a/vcg/simplex/face/base.h b/vcg/simplex/face/base.h index 7d474ce1..9f63333c 100644 --- a/vcg/simplex/face/base.h +++ b/vcg/simplex/face/base.h @@ -50,7 +50,7 @@ template // prot - int VN() const { return 3;} + inline int VN() const { return 3;} inline int Prev(const int & i) const { return (i+(3-1))%3;} inline int Next(const int & i) const { return (i+1)%3;} inline void Alloc(const int & ){} @@ -70,16 +70,8 @@ we have to build the type a step a time (deriving from a single ancestor at a ti */ template -class FaceBase: public face::EmptyPolyInfo< - face::EmptyVertexRef< - face::EmptyAdj< - face::EmptyColorMarkQuality< - face::EmptyNormal< - face::EmptyCurvatureDir< - face::EmptyBitFlags< - face::EmptyWedgeTexCoord< - FaceTypeHolder > > > > > > > >{ - +class FaceBase: public + face::EmptyCore< FaceTypeHolder > { }; diff --git a/vcg/simplex/face/component.h b/vcg/simplex/face/component.h index fd7314ca..5ccd6798 100644 --- a/vcg/simplex/face/component.h +++ b/vcg/simplex/face/component.h @@ -37,32 +37,130 @@ Some naming Rules All the Components that can be added to a vertex should be defined in the namespace vert: */ +/*------------------------- EMPTY CORE COMPONENTS -----------------------------------------*/ -/*-------------------------- VertexRef ----------------------------------------*/ -template class EmptyVertexRef: public T { +template class EmptyCore: public T { public: - // typedef typename T::VertexType VertexType; - // typedef typename T::CoordType CoordType; 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::VertexType * & FVp( const int i ) { return this->V(i); } - inline typename T::VertexType * const & FVp( const int i) const { return this->V(i); } - inline typename T::VertexType * cFVp( const int i ) const { return this->cV(i); } - + inline typename T::VertexType * & FVp( const int i ) { return this->V(i); } + inline typename T::VertexType * cFVp( const int i ) const { return this->cV(i); } 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 ImportData(const RightF & rightF) {T::ImportData(rightF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasVertexRef() { return false; } - static bool HasFVAdjacency() { return false; } - static void Name(std::vector & name){T::Name(name);} -}; + static bool HasVertexRef() { return false; } + static bool HasFVAdjacency() { return false; } + + typedef typename T::VertexType::NormalType NormalType; + NormalType &N() { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; } + const NormalType &cN() const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } + NormalType &WN(int) { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; } + const NormalType cWN(int) const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } + + static bool HasWedgeNormal() { return false; } + static bool HasFaceNormal() { return false; } + static bool HasWedgeNormalOcf() { return false; } + static bool HasFaceNormalOcf() { return false; } + + + typedef int WedgeTexCoordType; + typedef vcg::TexCoord2 TexCoordType; + TexCoordType &WT(const int) { static TexCoordType dummy_texture; assert(0); return dummy_texture;} + TexCoordType const &cWT(const int) const { static TexCoordType dummy_texture; return dummy_texture;} + + static bool HasWedgeTexCoord() { return false; } + static bool HasWedgeTexCoordOcf() { return false; } + + int &Flags() { static int dummyflags(0); assert(0); return dummyflags; } + int Flags() const { return 0; } + static bool HasFlags() { return false; } + static bool HasFlagsOcf() { return false; } + + inline void InitIMark() { } + inline int & IMark() { assert(0); static int tmp=-1; return tmp;} + inline int IMark() const {return 0;} + + typedef int MarkType; + typedef float QualityType; + typedef Point3f Quality3Type; + typedef vcg::Color4b ColorType; + + ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } + const ColorType &cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } + ColorType &WC(const int) { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } + const ColorType &cWC(const int) const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } + QualityType &Q() { static QualityType dummyQuality(0); assert(0); return dummyQuality; } + const QualityType &cQ() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; } + Quality3Type &Q3() { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; } + const Quality3Type &cQ3() const { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; } + + static bool HasFaceColor() { return false; } + static bool HasFaceColorOcf() { return false;} + + static bool HasWedgeColor() { return false; } + static bool HasWedgeColorOcf() { return false; } + + static bool HasFaceQuality() { return false; } + static bool HasFaceQualityOcf() { return false;} + + static bool HasFaceQuality3() { return false; } + static bool HasFaceQuality3Ocf() { return false;} + + static bool HasMark() { return false; } + static bool HasMarkOcf() { return false; } + + typedef int VFAdjType; + typename T::FacePointer &VFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; } + typename T::FacePointer const cVFp(const int) const { static typename T::FacePointer const fp=0; return fp; } + typename T::FacePointer &FFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; } + typename T::FacePointer const cFFp(const int) const { static typename T::FacePointer const fp=0; return fp; } + typename T::EdgePointer &FEp(const int) { static typename T::EdgePointer fp=0; assert(0); return fp; } + typename T::EdgePointer const cFEp(const int) const { static typename T::EdgePointer const fp=0; return fp; } + typename T::HEdgePointer &FHp() { static typename T::HEdgePointer fp=0; assert(0); return fp; } + typename T::HEdgePointer const cFHp() const { static typename T::HEdgePointer const fp=0; assert(0);return fp; } + char &VFi(const int j){(void)j; static char z=0; assert(0); return z;} + char &FFi(const int j){(void)j; static char z=0; assert(0); return z;} + const char &cVFi(const int j){(void)j; static char z=0; return z;} + const char &cFFi(const int j) const {(void)j; static char z=0; return z;} + + static bool HasVFAdjacency() { return false; } + static bool HasFFAdjacency() { return false; } + static bool HasFEAdjacency() { return false; } + static bool HasFHAdjacency() { return false; } + + static bool HasFFAdjacencyOcf() { return false; } + static bool HasVFAdjacencyOcf() { return false; } + static bool HasFEAdjacencyOcf() { return false; } + static bool HasFHAdjacencyOcf() { return false; } + + typedef int CurvatureDirType; + + Point3f &PD1(){static Point3f dummy(0,0,0); return dummy;} + Point3f &PD2(){static Point3f dummy(0,0,0); return dummy;} + const Point3f &cPD1() const {static Point3f dummy(0,0,0); return dummy;} + const Point3f &cPD2()const {static Point3f dummy(0,0,0); return dummy;} + + float &K1(){ static float dummy(0);assert(0);return dummy;} + float &K2(){ static float dummy(0);assert(0);return dummy;} + const float &cK1()const { static float dummy(0);assert(0);return dummy;} + const float &cK2()const { static float dummy(0);assert(0);return dummy;} + + static bool HasCurvatureDir() { return false; } + static bool HasCurvatureDirOcf() { return false; } + + inline void SetVN(const int & /*n*/) {assert(0);} + + static bool HasPolyInfo() { return false; } + + template + void ImportData(const RightF & rightF) {T::ImportData(rightF);} + inline void Alloc(const int & ns){T::Alloc(ns);} + inline void Dealloc(){T::Dealloc();} + static void Name(std::vector & name){T::Name(name);} + }; + + /*-------------------------- VertexRef ----------------------------------------*/ + template class VertexRef: public T { public: VertexRef(){ @@ -128,51 +226,6 @@ public: typename T::VertexType *v[3]; }; - - -/*-------------------------- Normal ----------------------------------------*/ - -template class EmptyNormal: public T { -public: - //typedef vcg::Point3s NormalType; - typedef typename T::VertexType::NormalType NormalType; - NormalType &N() { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; } - const NormalType &cN() const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } - NormalType &WN(int) { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; } - const NormalType cWN(int) const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; } - - template - void ImportData(const RightF & rightF){ T::ImportData(rightF);} - static bool HasWedgeNormal() { return false; } - static bool HasFaceNormal() { return false; } - static bool HasWedgeNormalOcc() { return false; } - static bool HasFaceNormalOcc() { return false; } - static bool HasWedgeNormalOcf() { return false; } - static bool HasFaceNormalOcf() { return false; } -// void ComputeNormal() {assert(0);} -// void ComputeNormalizedNormal() {assert(0);} - static void Name(std::vector & name){ T::Name(name);} - -}; -template class NormalFromVert: public T { -public: - typedef typename T::VertexType::NormalType NormalType; - NormalType &N() { return _norm; } - NormalType &cN() const { return _norm; } - template - void ImportData(const RightF & rightF){ N() = rightF.cN(); T::ImportData(rightF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasFaceNormal() { return true; } -// void ComputeNormal() { _norm = vcg::Normal(*(static_cast(this))); } -// void ComputeNormalizedNormal() { _norm = vcg::NormalizedNormal(*this);} - static void Name(std::vector & name){name.push_back(std::string("NormalFromVert"));T::Name(name);} - -private: - NormalType _norm; -}; - - template void ComputeNormal(T &f) { f.N().Import(vcg::Normal(f)); } @@ -234,14 +287,11 @@ private: template class WedgeRealNormal3s: public WedgeRealNormal { public: static void Name(std::vector & name){name.push_back(std::string("WedgeRealNormal2s"));TT::Name(name);}}; - template class WedgeRealNormal3f: public WedgeRealNormal { public: static void Name(std::vector & name){name.push_back(std::string("WedgeRealNormal2f"));TT::Name(name);}}; - template class WedgeRealNormal3d: public WedgeRealNormal { public: static void Name(std::vector & name){name.push_back(std::string("WedgeRealNormal2d"));TT::Name(name);}}; - template class Normal3s: public NormalAbs { public:static void Name(std::vector & name){name.push_back(std::string("Normal3s"));T::Name(name);} }; @@ -255,21 +305,6 @@ public: static void Name(std::vector & name){name.push_back(std::st /*-------------------------- TexCoord ----------------------------------------*/ -template class EmptyWedgeTexCoord: public T { -public: - typedef int WedgeTexCoordType; - typedef vcg::TexCoord2 TexCoordType; - TexCoordType &WT(const int) { static TexCoordType dummy_texture; assert(0); return dummy_texture;} - TexCoordType const &cWT(const int) const { static TexCoordType dummy_texture; return dummy_texture;} - template - void ImportData(const RightF & rightF){ T::ImportData(rightF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasWedgeTexCoord() { return false; } - static bool HasWedgeTexCoordOcc() { return false; } - static void Name(std::vector & name){T::Name(name);} - -}; template class WedgeTexCoord: public T { public: typedef int WedgeTexCoordType; @@ -298,21 +333,6 @@ public: static void Name(std::vector & name){name.push_back(std::st }; /*------------------------- BitFlags -----------------------------------------*/ -template class EmptyBitFlags: public T { -public: - /// Return the vector of Flags(), senza effettuare controlli sui bit - int &Flags() { static int dummyflags(0); assert(0); return dummyflags; } - int Flags() const { return 0; } - template - void ImportData(const RightF & rightF){ T::ImportData(rightF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasFlags() { return false; } - static bool HasFlagsOcc() { return false; } - static void Name(std::vector & name){T::Name(name);} - -}; - template class BitFlags: public T { public: BitFlags(){_flags=0;} @@ -332,54 +352,6 @@ private: }; /*-------------------------- Color Mark Quality ----------------------------------*/ - -template class EmptyColorMarkQuality: public T { -public: - typedef int MarkType; - inline void InitIMark() { } - inline int & IMark() { assert(0); static int tmp=-1; return tmp;} - inline int IMark() const {return 0;} - - typedef float QualityType; - typedef Point3f Quality3Type; - typedef vcg::Color4b ColorType; - - ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } - const ColorType &cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } - ColorType &WC(const int) { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } - const ColorType &cWC(const int) const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } - QualityType &Q() { static QualityType dummyQuality(0); assert(0); return dummyQuality; } - const QualityType &cQ() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; } - Quality3Type &Q3() { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; } - const Quality3Type &cQ3() const { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; } - - static bool HasFaceColor() { return false; } - static bool HasFaceColorOcc() { return false;} - static bool HasFaceColorOcf() { return false;} - - static bool HasWedgeColor() { return false; } - static bool HasWedgeColorOcc() { return false; } - static bool HasWedgeColorOcf() { return false; } - - static bool HasFaceQuality() { return false; } - static bool HasFaceQualityOcc() { return false; } - static bool HasFaceQualityOcf() { return false;} - - static bool HasFaceQuality3() { return false; } - static bool HasFaceQuality3Occ() { return false; } - static bool HasFaceQuality3Ocf() { return false;} - - static bool HasMark() { return false; } - static bool HasMarkOcc() { return false; } - static bool HasMarkOcfb() { return false; } - - static void Name(std::vector & name){T::Name(name);} - template - void ImportData(const RightF & rightF){ T::ImportData(rightF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - -}; template class Color: public T { public: typedef A ColorType; @@ -416,17 +388,14 @@ private: template class WedgeColor4b: public WedgeColor { public: static void Name(std::vector & name){name.push_back(std::string("WedgeColor4b"));T::Name(name);} }; - template class WedgeColor4f: public WedgeColor { public: static void Name(std::vector & name){name.push_back(std::string("WedgeColor4f"));T::Name(name);} }; - template class Color4b: public Color { public: public: static void Name(std::vector & name){name.push_back(std::string("Color4b"));T::Name(name);} }; /*-------------------------- Quality ----------------------------------*/ - template class Quality: public T { public: typedef A QualityType; @@ -453,8 +422,7 @@ template class Qualityd: public Quality { public: static void Name(std::vector & name){name.push_back(std::string("Qualityd"));T::Name(name);} }; -/*-------------------------- Quality ----------------------------------*/ - +/*-------------------------- Quality3 ----------------------------------*/ template class Quality3: public T { public: typedef vcg::Point3 Quality3Type; @@ -480,12 +448,11 @@ public: static void Name(std::vector & name){name.push_back(std::s template class Quality3d: public Quality3 { public: static void Name(std::vector & name){name.push_back(std::string("Quality3d"));T::Name(name);} }; -/*-------------------------- INCREMENTAL MARK ----------------------------------------*/ +/*-------------------------- INCREMENTAL MARK ----------------------------------------*/ template class Mark: public T { public: static bool HasMark() { return true; } - static bool HasMarkOcc() { return true; } inline void InitIMark() { _imark = 0; } inline int & IMark() { return _imark;} inline const int & IMark() const {return _imark;} @@ -498,7 +465,6 @@ public: }; /*-------------------------- Curvature Direction ----------------------------------*/ - template struct CurvatureDirBaseType{ typedef Point3 VecType; @@ -508,26 +474,6 @@ public: S k1,k2;// max and min curvature values }; -template class EmptyCurvatureDir: public TT { -public: - typedef CurvatureDirBaseType CurvatureDirType; - - Point3f &PD1(){static Point3f dummy(0,0,0); return dummy;} - Point3f &PD2(){static Point3f dummy(0,0,0); return dummy;} - const Point3f &cPD1() const {static Point3f dummy(0,0,0); return dummy;} - const Point3f &cPD2()const {static Point3f dummy(0,0,0); return dummy;} - - float &K1(){ static float dummy(0);assert(0);return dummy;} - float &K2(){ static float dummy(0);assert(0);return dummy;} - const float &cK1()const { static float dummy(0);assert(0);return dummy;} - const float &cK2()const { static float dummy(0);assert(0);return dummy;} - - static bool HasCurvatureDir() { return false; } - template < class LeftV> - void ImportData(const LeftV & left ) { TT::ImportData( left); } - static void Name(std::vector & name){TT::Name(name);} -}; - template class CurvatureDir: public TT { public: typedef A CurvatureDirType; @@ -567,43 +513,7 @@ template class CurvatureDird: public CurvatureDir & name){name.push_back(std::string("CurvatureDird"));T::Name(name);} }; - /*----------------------------- VFADJ ------------------------------*/ - - -template class EmptyAdj: public T { -public: - typedef int VFAdjType; - typename T::FacePointer &VFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; } - typename T::FacePointer const cVFp(const int) const { static typename T::FacePointer const fp=0; return fp; } - typename T::FacePointer &FFp(const int) { static typename T::FacePointer fp=0; assert(0); return fp; } - typename T::FacePointer const cFFp(const int) const { static typename T::FacePointer const fp=0; return fp; } - typename T::EdgePointer &FEp(const int) { static typename T::EdgePointer fp=0; assert(0); return fp; } - typename T::EdgePointer const cFEp(const int) const { static typename T::EdgePointer const fp=0; return fp; } - typename T::HEdgePointer &FHp() { static typename T::HEdgePointer fp=0; assert(0); return fp; } - typename T::HEdgePointer const cFHp() const { static typename T::HEdgePointer const fp=0; assert(0);return fp; } - char &VFi(const int j){(void)j; static char z=0; assert(0); return z;}; - char &FFi(const int j){(void)j; static char z=0; assert(0); return z;}; - const char &cVFi(const int j){(void)j; static char z=0; return z;}; - const char &cFFi(const int j) const {(void)j; static char z=0; return z;}; - template - void ImportData(const RightF & rightF){ T::ImportData(rightF);} - inline void Alloc(const int & ns){T::Alloc(ns);} - inline void Dealloc(){T::Dealloc();} - static bool HasVFAdjacency() { return false; } - static bool HasFFAdjacency() { return false; } - static bool HasFEAdjacency() { return false; } - static bool HasFHAdjacency() { return false; } - - static bool HasFFAdjacencyOcc() { return false; } - static bool HasVFAdjacencyOcc() { return false; } - static bool HasFEAdjacencyOcc() { return false; } - static bool HasFHAdjacencyOcc() { return false; } - - static void Name(std::vector & name){T::Name(name);} - -}; - template class VFAdj: public T { public: VFAdj(){ @@ -629,7 +539,6 @@ private: }; /*----------------------------- FFADJ ------------------------------*/ - template class FFAdj: public T { public: FFAdj(){ @@ -663,7 +572,6 @@ private: /*----------------------------- FEADJ ------------------------------*/ - template class FEAdj: public T { public: FEAdj(){ @@ -696,7 +604,6 @@ private: /*----------------------------- FHADJ ------------------------------*/ - template class FHAdj: public T { public: FHAdj(){_fh=0;} diff --git a/vcg/simplex/face/component_polygon.h b/vcg/simplex/face/component_polygon.h index 53ec9391..af874814 100644 --- a/vcg/simplex/face/component_polygon.h +++ b/vcg/simplex/face/component_polygon.h @@ -38,28 +38,6 @@ All the Components that can be added to a vertex should be defined in the namesp */ /*-------------------------- PolInfo -------------------------------------------*/ -template class EmptyPolyInfo: public T { -protected: - inline void SetVN(const int & /*n*/) {assert(0);} -public: - typedef typename T::HEdgeType HEdgeType; - typedef typename T::HEdgePointer HEdgePointer; - - /* Note: the destructor will not be called in general because there are no virtual destructors. - Instead, the job of deallocating the memory will be done bu the edge allocator. - This destructor is only done for those who istance a face alone (outside a mesh) - */ - static bool HasPolyInfo() { return false; } - inline void Alloc(const int & ns){T::Alloc(ns);};// it should be useless - inline void Dealloc(){T::Dealloc();};// it should be useless - - // EmptyPFHAdj - HEdgePointer &FHp( ) { static typename T::HEdgePointer fp=0; assert(0); return fp; } - HEdgePointer const cFHp( ) const { static typename T::HEdgePointer const fp=0; return fp; } - static bool HasFHAdjacency() { return false; } -}; - - template class PolyInfo: public T {