From 8be6f002a3b90f04e5c824eca52bba30699df7a1 Mon Sep 17 00:00:00 2001 From: cignoni Date: Sun, 5 Apr 2009 23:33:04 +0000 Subject: [PATCH] Significant rewrote of the ImportLocal framework. Now it can really manage differently typed meshes. It still requires that for OCF meshes the user enable stuff as needed. --- vcg/simplex/face/component_ocf.h | 22 +++++++++++------ vcg/simplex/vertex/base.h | 2 +- vcg/simplex/vertex/component.h | 39 ++++++++++++++---------------- vcg/simplex/vertex/component_ocf.h | 9 ++++--- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/vcg/simplex/face/component_ocf.h b/vcg/simplex/face/component_ocf.h index b969931d..b452f6dc 100644 --- a/vcg/simplex/face/component_ocf.h +++ b/vcg/simplex/face/component_ocf.h @@ -415,7 +415,8 @@ public: template void ImportLocal(const LeftF & leftF){ - if(leftF.Base().VFAdjacencyEnabled && this->Base().VFAdjacencyEnabled){ + //if(leftF.Base().VFAdjacencyEnabled && this->Base().VFAdjacencyEnabled)// WRONG I do not know anything about leftV! + if(this->Base().VFAdjacencyEnabled){ VFp(0) = NULL; VFp(1) = NULL; VFp(2) = NULL; VFi(0) = -1; VFi(1) = -1; VFi(2) = -1; } @@ -458,7 +459,8 @@ public: template void ImportLocal(const LeftF & leftF){ - if(leftF.Base().FFAdjacencyEnabled && this->Base().FFAdjacencyEnabled) { +// if(leftF.Base().FFAdjacencyEnabled && this->Base().FFAdjacencyEnabled) // WRONG I do not know anything about leftV! + if(this->Base().FFAdjacencyEnabled) { FFp(0) = NULL; FFp(1) = NULL; FFp(2) = NULL; FFi(0) = -1; FFi(1) = -1; FFi(2) = -1; } @@ -516,8 +518,9 @@ public: template void ImportLocal(const LeftF & leftF){ - if((*this).Base().QualityEnabled && leftF.Base().QualityEnabled) - Q() = leftF.Q(); + //if((*this).Base().QualityEnabled && leftF.Base().QualityEnabled)// WRONG I do not know anything about leftV! + if((*this).Base().QualityEnabled) + Q() = leftF.cQ(); T::ImportLocal(leftF); } static bool HasFaceQuality() { return true; } @@ -542,8 +545,9 @@ public: template void ImportLocal(const LeftF & leftF){ - if((*this).Base().ColorEnabled && leftF.Base().ColorEnabled) - C() = leftF.C(); + //if((*this).Base().ColorEnabled && leftF.Base().ColorEnabled)// WRONG I do not know anything about leftV! + if((*this).Base().ColorEnabled ) + C() = leftF.cC(); T::ImportLocal(leftF); } static bool HasFaceColor() { return true; } @@ -568,7 +572,8 @@ public: template void ImportLocal(const LeftF & leftF){ - if((*this).Base().MarkEnabled && leftF.Base().MarkEnabled) + //if((*this).Base().MarkEnabled && leftF.Base().MarkEnabled)// WRONG I do not know anything about leftV! + if((*this).Base().MarkEnabled) IMark() = leftF.IMark(); T::ImportLocal(leftF); } @@ -587,7 +592,8 @@ public: TexCoordType const &cWT(const int i) const { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; } template void ImportLocal(const LeftF & leftF){ - if(this->Base().WedgeTexEnabled && leftF.Base().WedgeTexEnabled) + //if(this->Base().WedgeTexEnabled && leftF.Base().WedgeTexEnabled) // WRONG I do not know anything about leftV! + if(this->Base().WedgeTexEnabled) { WT(0) = leftF.cWT(0); WT(1) = leftF.cWT(1); WT(2) = leftF.cWT(2); } TT::ImportLocal(leftF); } diff --git a/vcg/simplex/vertex/base.h b/vcg/simplex/vertex/base.h index 4a971304..2f93f1c6 100644 --- a/vcg/simplex/vertex/base.h +++ b/vcg/simplex/vertex/base.h @@ -115,7 +115,7 @@ template class VertexBase: public vertex::EmptyTexCoord< vertex::EmptyVFAdj< vertex::EmptyVEAdj< - vertex::EmptyColorQuality< + vertex::EmptyColorMarkQuality< vertex::EmptyBitFlags< vertex::EmptyCoordNormal< vertex::EmptyCurvatureData< diff --git a/vcg/simplex/vertex/component.h b/vcg/simplex/vertex/component.h index 4adb13f6..d1fe55a1 100644 --- a/vcg/simplex/vertex/component.h +++ b/vcg/simplex/vertex/component.h @@ -163,7 +163,7 @@ public: CoordType &UberP() { return _coord; } template < class LeftV> - void ImportLocal(const LeftV & left ) { P().Import(left.cP()); T::ImportLocal( left); } + void ImportLocal(const LeftV & left ) { if(LeftV::HasCoord()) P().Import(left.cP()); T::ImportLocal( left); } static bool HasCoord() { return true; } static void Name(std::vector & name){name.push_back(std::string("Coord"));T::Name(name);} @@ -185,7 +185,7 @@ public: NormalType &N() { return _norm; } const NormalType &cN() const { return _norm; } template < class LeftV> - void ImportLocal(const LeftV & left ) { N() = left.cN(); T::ImportLocal( left); } + void ImportLocal(const LeftV & left ) { if(LeftV::HasNormal()) N() = left.cN(); T::ImportLocal( left); } static bool HasNormal() { return true; } static void Name(std::vector & name){name.push_back(std::string("Normal"));T::Name(name);} @@ -206,27 +206,16 @@ public: static void Name(std::vector & name){name.push_back(std::st /*-------------------------- INCREMENTAL MARK ----------------------------------------*/ -template class EmptyMark: public T { -public: - static bool HasMark() { return false; } - static bool HasMarkOcc() { return false; } - inline void InitIMark() { } - inline int & IMark() { assert(0); static int tmp=-1; return tmp;} - inline const int & IMark() const {return 0;} - template < class LeftV> - void ImportLocal(const LeftV & left ) { T::ImportLocal( left); } - static void Name(std::vector & name){T::Name(name);} - -}; template class Mark: public T { public: static bool HasMark() { return true; } static bool HasMarkOcc() { return true; } inline void InitIMark() { _imark = 0; } + inline const int & cIMark() const { return _imark;} inline int & IMark() { return _imark;} inline const int & IMark() const {return _imark;} template < class LeftV> - void ImportLocal(const LeftV & left ) { IMark() = left.IMark(); T::ImportLocal( left); } + void ImportLocal(const LeftV & left ) { if(LeftV::HasMark()) IMark() = left.IMark(); T::ImportLocal( left); } static void Name(std::vector & name){name.push_back(std::string("Mark"));T::Name(name);} private: @@ -251,7 +240,7 @@ public: TexCoordType &T() { return _t; } const TexCoordType &cT() const { return _t; } template < class LeftV> - void ImportLocal(const LeftV & left ) { T() = left.cT(); TT::ImportLocal( left); } + void ImportLocal(const LeftV & left ) { if(LeftV::HasTexCoord()) T() = left.cT(); TT::ImportLocal( left); } static bool HasTexCoord() { return true; } static void Name(std::vector & name){name.push_back(std::string("TexCoord"));TT::Name(name);} @@ -291,7 +280,7 @@ public: int &Flags() {return _flags; } const int Flags() const {return _flags; } template < class LeftV> - void ImportLocal(const LeftV & left ) { Flags() = left.Flags(); T::ImportLocal( left); } + void ImportLocal(const LeftV & left ) { if(LeftV::HasFlags()) Flags() = left.Flags(); T::ImportLocal( left); } static bool HasFlags() { return true; } static void Name(std::vector & name){name.push_back(std::string("BitFlags"));T::Name(name);} @@ -301,16 +290,24 @@ private: /*-------------------------- EMPTY COLOR & QUALITY ----------------------------------*/ -template class EmptyColorQuality: public T { +template class EmptyColorMarkQuality: public T { public: typedef float QualityType; QualityType &Q() { static QualityType dummyQuality(0); assert(0); return dummyQuality; } + const QualityType &cQ() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; } const static bool HasQuality() { return false; } 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; } + static bool HasMark() { return false; } + static bool HasMarkOcc() { return false; } + inline void InitIMark() { } + inline const int & cIMark() const { assert(0); static int tmp=-1; return tmp;} + inline int & IMark() { assert(0); static int tmp=-1; return tmp;} + inline const int & IMark() const {return 0;} + template < class LeftV> void ImportLocal(const LeftV & left ) { T::ImportLocal( left); } static bool HasColor() { return false; } @@ -327,7 +324,7 @@ public: const ColorType &C() const { return _color; } const ColorType &cC() const { return _color; } template < class LeftV> - void ImportLocal(const LeftV & left ) { C() = left.cC(); T::ImportLocal( left); } + void ImportLocal(const LeftV & left ) { if(LeftV::HasColor()) C() = left.cC(); T::ImportLocal( left); } static bool HasColor() { return true; } static void Name(std::vector & name){name.push_back(std::string("Color"));T::Name(name);} @@ -347,7 +344,7 @@ public: QualityType &Q() { return _quality; } const QualityType & cQ() const {return _quality; } template < class LeftV> - void ImportLocal(const LeftV & left ) { Q() = left.cQ(); TT::ImportLocal( left); } + void ImportLocal(const LeftV & left ) { if(LeftV::HasQuality()) Q() = left.cQ(); TT::ImportLocal( left); } static bool HasQuality() { return true; } static void Name(std::vector & name){name.push_back(std::string("Quality"));TT::Name(name);} @@ -518,7 +515,7 @@ public: RadiusType &R() { return _radius; } const RadiusType & cR() const {return _radius; } template < class LeftV> - void ImportLocal(const LeftV & left ) { R() = left.cR(); TT::ImportLocal( left); } + void ImportLocal(const LeftV & left ) { if(LeftV::HasRadius()) R() = left.cR(); TT::ImportLocal( left); } static bool HasRadius() { return true; } static void Name(std::vector & name){name.push_back(std::string("Radius"));TT::Name(name);} diff --git a/vcg/simplex/vertex/component_ocf.h b/vcg/simplex/vertex/component_ocf.h index 4a589ba0..cfcedb68 100644 --- a/vcg/simplex/vertex/component_ocf.h +++ b/vcg/simplex/vertex/component_ocf.h @@ -466,7 +466,8 @@ public: template void ImportLocal(const LeftV & leftV) { - if((*this).Base().MarkEnabled && leftV.Base().MarkEnabled ) // copy the data only if they are enabled in both vertices + //if((*this).Base().MarkEnabled && leftV.Base().MarkEnabled ) // WRONG I do not know anything about leftV! + if((*this).Base().MarkEnabled) // copy the data only if they are enabled in both vertices IMark() = leftV.IMark(); T::ImportLocal(leftV); } @@ -490,7 +491,8 @@ public: template void ImportLocal(const LeftV & leftV){ - if((*this).Base().CurvatureEnabled && leftV.Base().CurvatureEnabled ) // copy the data only if they are enabled in both vertices +// if((*this).Base().CurvatureEnabled && leftV.Base().CurvatureEnabled ) // WRONG I do not know anything about leftV! + if((*this).Base().CurvatureEnabled) { (*this).Base().CuV[(*this).Index()][0] = leftV.cKh(); (*this).Base().CuV[(*this).Index()][1] = leftV.cKg(); @@ -564,7 +566,8 @@ public: template void ImportLocal(const LeftV & leftV) { - if ((*this).Base().RadiusEnabled && leftV.Base().RadiusEnabled ) + //if ((*this).Base().RadiusEnabled && leftV.Base().RadiusEnabled ) // WRONG I do not know anything about leftV! + if ((*this).Base().RadiusEnabled) (*this).Base().RadiusV[(*this).Index()] = leftV.cR(); TT::ImportLocal(leftV); }