diff --git a/vcg/simplex/faceplus/component_ocf.h b/vcg/simplex/faceplus/component_ocf.h index 0632aa60..aedce687 100644 --- a/vcg/simplex/faceplus/component_ocf.h +++ b/vcg/simplex/faceplus/component_ocf.h @@ -140,7 +140,8 @@ class vector_ocf: public std::vector { public: vector_ocf():std::vector(){ ColorEnabled=false; - MarkEnabled=false; + QualityEnabled=false; + MarkEnabled=false; NormalEnabled=false; WedgeTexEnabled=false; VFAdjacencyEnabled=false; @@ -186,6 +187,7 @@ public: { BaseType::push_back(v); BaseType::back()._ovp = this; + if (QualityEnabled) QV.push_back(0); 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()); @@ -203,6 +205,7 @@ public: advance(firstnew,oldsize); _updateOVP(firstnew,(*this).end()); } + if (QualityEnabled) QV.resize(_size); if (ColorEnabled) CV.resize(_size); if (MarkEnabled) MV.resize(_size); if (NormalEnabled) NV.resize(_size); @@ -216,6 +219,7 @@ public: ThisTypeIterator oldbegin=(*this).begin(); BaseType::reserve(_size); + if (QualityEnabled) QV.reserve(_size); if (ColorEnabled) CV.reserve(_size); if (MarkEnabled) MV.reserve(_size); if (NormalEnabled) NV.reserve(_size); @@ -240,6 +244,7 @@ public: void ReorderFace(std::vector &newFaceIndex ) { size_t i=0; + if (QualityEnabled) assert( QV.size() == newFaceIndex.size() ); if (ColorEnabled) assert( CV.size() == newFaceIndex.size() ); if (MarkEnabled) assert( MV.size() == newFaceIndex.size() ); if (NormalEnabled) assert( NV.size() == newFaceIndex.size() ); @@ -252,6 +257,7 @@ void ReorderFace(std::vector &newFaceIndex ) if(newFaceIndex[i] != std::numeric_limits::max() ) { assert(newFaceIndex[i] <= i); + if (QualityEnabled) QV[newFaceIndex[i]] = QV[i]; if (ColorEnabled) CV[newFaceIndex[i]] = CV[i]; if (MarkEnabled) MV[newFaceIndex[i]] = MV[i]; if (NormalEnabled) NV[newFaceIndex[i]] = NV[i]; @@ -261,6 +267,7 @@ void ReorderFace(std::vector &newFaceIndex ) } } + if (QualityEnabled) QV.resize(BaseType::size()); if (ColorEnabled) CV.resize(BaseType::size()); if (MarkEnabled) MV.resize(BaseType::size()); if (NormalEnabled) NV.resize(BaseType::size()); @@ -271,7 +278,20 @@ void ReorderFace(std::vector &newFaceIndex ) //////////////////////////////////////// // Enabling Functions + +bool IsQualityEnabled() const {return QualityEnabled;} +void EnableQuality() { + assert(VALUE_TYPE::HasFaceQualityOcf()); + QualityEnabled=true; + QV.resize((*this).size()); +} +void DisableQuality() { + assert(VALUE_TYPE::HasFaceQualityOcf()); + QualityEnabled=false; + QV.clear(); +} + bool IsColorEnabled() const {return ColorEnabled;} void EnableColor() { assert(VALUE_TYPE::HasFaceColorOcf()); @@ -352,6 +372,7 @@ void DisableWedgeTex() { } public: + std::vector QV; std::vector CV; std::vector MV; std::vector NV; @@ -359,6 +380,7 @@ public: std::vector AF; std::vector WTV; + bool QualityEnabled; bool ColorEnabled; bool MarkEnabled; bool NormalEnabled; @@ -477,6 +499,32 @@ public: template class Normal3sOcf: public NormalOcf {}; template class Normal3fOcf: public NormalOcf {}; template class Normal3dOcf: public NormalOcf {}; + +///*-------------------------- QUALITY ----------------------------------*/ + +template class QualityOcf: public T { +public: + typedef A QualityType; + QualityType &Q() { + assert((*this).Base().QualityEnabled); + return (*this).Base().QV[(*this).Index()]; + } + const QualityType Q() const { + assert((*this).Base().QualityEnabled); + return (*this).Base().QV[(*this).Index()]; + } + + template + void ImportLocal(const LeftF & leftF){ + if((*this).Base().QualityEnabled && leftF.Base().QualityEnabled) + Q() = leftF.Q(); + T::ImportLocal(leftF); + } + static bool HasFaceQuality() { return true; } + static bool HasFaceQualityOcf() { return true; } +}; + +template class QualityfOcf: public QualityOcf {}; ///*-------------------------- COLOR ----------------------------------*/ @@ -610,7 +658,14 @@ public: if(FaceType::HasFaceColorOcf()) return m.face.IsColorEnabled(); else return FaceType::HasFaceColor(); } - + + template < class VertContainerType, class FaceType > + bool HasPerFaceQuality (const TriMesh < VertContainerType , face::vector_ocf< FaceType > > & m) + { + if(FaceType::HasFaceQualityOcf()) return m.face.IsQualityEnabled(); + else return FaceType::HasFaceQuality(); + } + template < class VertContainerType, class FaceType > bool HasPerFaceMark (const TriMesh < VertContainerType , face::vector_ocf< FaceType > > & m) {