From 30b1d99a4c99f35faa988b1f474eaa0a6bb0f298 Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 3 May 2006 21:37:02 +0000 Subject: [PATCH] Added Optional Mark --- vcg/simplex/faceplus/component_ocf.h | 82 +++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 13 deletions(-) diff --git a/vcg/simplex/faceplus/component_ocf.h b/vcg/simplex/faceplus/component_ocf.h index 01ab52b3..5ee5ce09 100644 --- a/vcg/simplex/faceplus/component_ocf.h +++ b/vcg/simplex/faceplus/component_ocf.h @@ -24,6 +24,11 @@ History $Log: not supported by cvs2svn $ +Revision 1.11 2006/02/28 11:59:39 ponchio +g++ compliance: + +begin() -> (*this).begin() and for end(), size(), Base(), Index() + Revision 1.10 2006/01/30 08:47:40 cignoni Corrected HasPerWedgeTexture @@ -88,6 +93,7 @@ class vector_ocf: public std::vector { public: vector_ocf():std::vector(){ ColorEnabled=false; + MarkEnabled=false; NormalEnabled=false; WedgeTexEnabled=false; VFAdjacencyEnabled=false; @@ -128,10 +134,12 @@ public: if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end()); else _updateOVP(oldend, (*this).end()); - if(NormalEnabled) NV.push_back(typename VALUE_TYPE::NormalType()); - if(VFAdjacencyEnabled) AV.push_back(AdjTypePack()); - if(FFAdjacencyEnabled) AF.push_back(AdjTypePack()); - if(WedgeTexEnabled) WTV.push_back(WedgeTexTypePack()); + if (ColorEnabled) CV.push_back(vcg::Color4b(vcg::Color4b::White)); + if (MarkEnabled) MV.push_back(0); + if (NormalEnabled) NV.push_back(typename VALUE_TYPE::NormalType()); + if (VFAdjacencyEnabled) AV.push_back(AdjTypePack()); + if (FFAdjacencyEnabled) AF.push_back(AdjTypePack()); + if (WedgeTexEnabled) WTV.push_back(WedgeTexTypePack()); } void pop_back(); void resize(const unsigned int & _size) @@ -141,10 +149,12 @@ public: BaseType::resize(_size); if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end()); else _updateOVP(oldend, (*this).end()); - if(ColorEnabled) CV.resize(_size); - if(NormalEnabled) NV.resize(_size); - if(VFAdjacencyEnabled) AV.resize(_size); - if(FFAdjacencyEnabled) AF.resize(_size); + + if (ColorEnabled) CV.resize(_size); + if (MarkEnabled) MV.resize(_size); + if (NormalEnabled) NV.resize(_size); + if (VFAdjacencyEnabled) AV.resize(_size); + if (FFAdjacencyEnabled) AF.resize(_size); if (WedgeTexEnabled) WTV.resize(_size,WedgeTexTypePack()); } @@ -152,11 +162,14 @@ public: { ThisTypeIterator oldbegin=(*this).begin(); BaseType::reserve(_size); + if (ColorEnabled) CV.reserve(_size); + if (MarkEnabled) MV.reserve(_size); if (NormalEnabled) NV.reserve(_size); if (VFAdjacencyEnabled) AV.reserve(_size); if (FFAdjacencyEnabled) AF.reserve(_size); - if (WedgeTexEnabled) WTV.reserve(_size); + if (WedgeTexEnabled) WTV.reserve(_size); + if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end()); } @@ -168,7 +181,7 @@ public: (*fi)._ovp=this; } //////////////////////////////////////// -// Enabling Eunctions +// Enabling Functions bool IsColorEnabled() const {return ColorEnabled;} void EnableColor() { @@ -183,6 +196,19 @@ void DisableColor() { CV.clear(); } +bool IsMarkEnabled() const {return MarkEnabled;} +void EnableMark() { + assert(VALUE_TYPE::HasFaceMarkOcf()); + MarkEnabled=true; + MV.resize((*this).size()); +} + +void DisableMark() { + assert(VALUE_TYPE::HasFaceMarkOcf()); + MarkEnabled=false; + MV.clear(); +} + bool IsNormalEnabled() const {return NormalEnabled;} void EnableNormal() { assert(VALUE_TYPE::HasFaceNormalOcf()); @@ -238,12 +264,14 @@ void DisableWedgeTex() { public: std::vector CV; + std::vector MV; std::vector NV; std::vector AV; std::vector AF; std::vector WTV; bool ColorEnabled; + bool MarkEnabled; bool NormalEnabled; bool WedgeTexEnabled; bool VFAdjacencyEnabled; @@ -337,13 +365,34 @@ template class Normal3dOcf: public NormalOcf {}; template class ColorOcf: public T { public: typedef A ColorType; - ColorType &C() { assert((*this).Base().NormalEnabled); return (*this).Base().CV[(*this).Index()]; } + ColorType &C() { + assert((*this).Base().ColorEnabled); + return (*this).Base().CV[(*this).Index()]; + } static bool HasFaceColor() { return true; } static bool HasFaceColorOcf() { return true; } }; template class Color4bOcf: public ColorOcf {}; +///*-------------------------- MARK ----------------------------------*/ + +template class MarkOcf: public T { +public: + inline int & IMark() { + assert((*this).Base().MarkEnabled); + return (*this).Base().MV[(*this).Index()]; + } + + inline int IMark() const { + assert((*this).Base().MarkEnabled); + return (*this).Base().MV[(*this).Index()]; + } ; + + static bool HasFaceMark() { return true; } + static bool HasFaceMarkOcf() { return true; } + inline void InitIMark() { _imark = 0; } +}; ///*-------------------------- WEDGE TEXCOORD ----------------------------------*/ @@ -393,8 +442,15 @@ public: template < class VertContainerType, class FaceType > bool HasPerFaceColor (const TriMesh < VertContainerType , face::vector_ocf< FaceType > > & m) { - if(face::vector_ocf< FaceType >::HasPerFaceColorOcf()) return m.face.FaceColor(); - else return face::vector_ocf< FaceType > ::HasFaceColor(); + if(FaceType::HasFaceColorOcf()) return m.face.IsColorEnabled(); + else return FaceType::HasFaceColor(); + } + + template < class VertContainerType, class FaceType > + bool HasPerFaceMark (const TriMesh < VertContainerType , face::vector_ocf< FaceType > > & m) + { + if(FaceType::HasFaceMarkOcf()) return m.face.IsMarkEnabled(); + else return FaceType::HasFaceMark(); } } }// end namespace vcg