added optional mark and cleaned up some nasty type bugs.

This commit is contained in:
Paolo Cignoni 2008-04-03 23:15:40 +00:00
parent 242e5ab82a
commit 89a4321cdf
1 changed files with 78 additions and 15 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.15 2008/03/17 11:39:15 ganovelli
added curvature and curvatruredir (compiled .net 2005 and gcc)
Revision 1.14 2008/03/11 09:22:07 cignoni Revision 1.14 2008/03/11 09:22:07 cignoni
Completed the garbage collecting functions CompactVertexVector and CompactFaceVector. Completed the garbage collecting functions CompactVertexVector and CompactFaceVector.
@ -104,10 +107,10 @@ public:
vector_ocf():std::vector<VALUE_TYPE>(){ vector_ocf():std::vector<VALUE_TYPE>(){
QualityEnabled=false; QualityEnabled=false;
ColorEnabled=false; ColorEnabled=false;
MarkEnabled = false;
NormalEnabled=false; NormalEnabled=false;
VFAdjacencyEnabled=false; VFAdjacencyEnabled=false;
CurvatureEnabled = false; CurvatureEnabled = false;
} }
// override di tutte le funzioni che possono spostare // override di tutte le funzioni che possono spostare
@ -116,6 +119,10 @@ public:
{ {
BaseType::push_back(v); BaseType::push_back(v);
BaseType::back()._ovp = this; BaseType::back()._ovp = this;
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(VFAdjType());
} }
void pop_back(); void pop_back();
void resize(const unsigned int & _size) void resize(const unsigned int & _size)
@ -128,14 +135,20 @@ public:
_updateOVP(firstnew,(*this).end()); _updateOVP(firstnew,(*this).end());
} }
if (ColorEnabled) CV.resize(_size); if (ColorEnabled) CV.resize(_size);
if (MarkEnabled) MV.resize(_size);
if (NormalEnabled) NV.resize(_size); if (NormalEnabled) NV.resize(_size);
if (VFAdjacencyEnabled) AV.resize(_size);
} }
void reserve(const unsigned int & _size) void reserve(const unsigned int & _size)
{ {
BaseType::reserve(_size); BaseType::reserve(_size);
if (ColorEnabled) CV.reserve(_size); if (ColorEnabled) CV.reserve(_size);
if (MarkEnabled) MV.reserve(_size);
if (NormalEnabled) NV.reserve(_size); if (NormalEnabled) NV.reserve(_size);
if (VFAdjacencyEnabled) AV.reserve(_size);
} }
void _updateOVP(ThisTypeIterator lbegin, ThisTypeIterator lend) void _updateOVP(ThisTypeIterator lbegin, ThisTypeIterator lend)
@ -151,7 +164,9 @@ void ReorderVert(std::vector<size_t> &newVertIndex )
size_t pos=0; size_t pos=0;
size_t i=0; size_t i=0;
if (ColorEnabled) assert( CV.size() == newVertIndex.size() ); if (ColorEnabled) assert( CV.size() == newVertIndex.size() );
if (MarkEnabled) assert( MV.size() == newVertIndex.size() );
if (NormalEnabled) assert( NV.size() == newVertIndex.size() ); if (NormalEnabled) assert( NV.size() == newVertIndex.size() );
if (VFAdjacencyEnabled) assert( AV.size() == newVertIndex.size() );
for(i=0;i<newVertIndex.size();++i) for(i=0;i<newVertIndex.size();++i)
{ {
@ -159,9 +174,17 @@ void ReorderVert(std::vector<size_t> &newVertIndex )
{ {
assert(newVertIndex[i] <= i); assert(newVertIndex[i] <= i);
if (ColorEnabled) CV[newVertIndex[i]] = CV[i]; if (ColorEnabled) CV[newVertIndex[i]] = CV[i];
if(NormalEnabled) NV[newVertIndex[i]] = NV[i];; if (MarkEnabled) MV[newVertIndex[i]] = MV[i];
if (NormalEnabled) NV[newVertIndex[i]] = NV[i];
if (VFAdjacencyEnabled) AV[newVertIndex[i]] = AV[i];
} }
} }
if (ColorEnabled) CV.resize(BaseType::size());
if (MarkEnabled) MV.resize(BaseType::size());
if (NormalEnabled) NV.resize(BaseType::size());
if (VFAdjacencyEnabled) AV.resize(BaseType::size());
} }
@ -195,6 +218,19 @@ void DisableColor() {
CV.clear(); 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;} bool IsNormalEnabled() const {return NormalEnabled;}
void EnableNormal() { void EnableNormal() {
assert(VALUE_TYPE::HasNormalOcf()); assert(VALUE_TYPE::HasNormalOcf());
@ -259,6 +295,7 @@ public:
std::vector<typename VALUE_TYPE::ColorType> CV; std::vector<typename VALUE_TYPE::ColorType> CV;
std::vector<typename VALUE_TYPE::NormalType> NV; std::vector<typename VALUE_TYPE::NormalType> NV;
std::vector<struct VFAdjType> AV; std::vector<struct VFAdjType> AV;
std::vector<int> MV;
bool QualityEnabled; bool QualityEnabled;
bool ColorEnabled; bool ColorEnabled;
@ -266,7 +303,7 @@ public:
bool VFAdjacencyEnabled; bool VFAdjacencyEnabled;
bool CurvatureEnabled; bool CurvatureEnabled;
bool CurvatureDirEnabled; bool CurvatureDirEnabled;
bool MarkEnabled;
}; };
@ -296,7 +333,7 @@ public:
void ImportLocal(const LeftV & leftV){VFp() = NULL; VFi() = -1; T::ImporLocal(leftV);} void ImportLocal(const LeftV & leftV){VFp() = NULL; VFi() = -1; T::ImporLocal(leftV);}
static bool HasVFAdjacency() { return true; } static bool HasVFAdjacency() { return true; }
static bool HasVFAdjacencyOcf() { return true; } static bool HasVFAdjacencyOcf() {assert(!T::HasVFAdjacencyOcf()); return true; }
private: private:
}; };
@ -336,7 +373,7 @@ public:
template <class LeftV> template <class LeftV>
void ImportLocal(const LeftV & leftV){ C() = leftV.cC(); T::ImporLocal(leftV);} void ImportLocal(const LeftV & leftV){ C() = leftV.cC(); T::ImporLocal(leftV);}
static bool HasColor() { return true; } static bool HasColor() { return true; }
static bool HasColorOcf() { return true; } static bool HasColorOcf() { assert(!T::HasColorOcf()); return true; }
}; };
template <class T> class Color4bOcf: public ColorOcf<vcg::Color4b, T> {}; template <class T> class Color4bOcf: public ColorOcf<vcg::Color4b, T> {};
@ -350,11 +387,32 @@ public:
template <class LeftV> template <class LeftV>
void ImportLocal(const LeftV & leftV){ Q() = leftV.cQ(); T::ImporLocal(leftV);} void ImportLocal(const LeftV & leftV){ Q() = leftV.cQ(); T::ImporLocal(leftV);}
static bool HasQuality() { return true; } static bool HasQuality() { return true; }
static bool HasQualityOcf() { return true; } static bool HasQualityOcf() { assert(!T::HasQualityOcf()); return true; }
}; };
template <class T> class QualityfOcf: public QualityOcf<float, T> {}; template <class T> class QualityfOcf: public QualityOcf<float, T> {};
///*-------------------------- MARK ----------------------------------*/
template <class T> 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()];
} ;
template <class LeftF>
void ImportLocal(const LeftF & leftF){IMark() = leftF.cIMark(); T::ImportLocal(leftF);}
static bool HasFaceMark() { return true; }
static bool HasFaceMarkOcf() { return true; }
inline void InitIMark() { IMark() = 0; }
};
///*-------------------------- CURVATURE ----------------------------------*/ ///*-------------------------- CURVATURE ----------------------------------*/
@ -438,15 +496,20 @@ public:
} }
public: public:
vector_ocf<typename T::VertType> *_ovp; vector_ocf<typename T::VertType> *_ovp;
static bool HasQualityOcf() { return false; }
static bool HasVFAdjacencyOcf() { return false; }
}; };
} // end namespace vert } // end namespace vert
template < class, class > class TriMesh;
namespace tri namespace tri
{ {
template < class, class > class TriMesh;
template < class VertexType, class FaceContainerType > template < class VertexType, class FaceContainerType >
bool HasPerVertexQuality (const TriMesh < vert::vector_ocf< VertexType > , FaceContainerType > & m) bool HasPerVertexQuality (const TriMesh < vert::vector_ocf< VertexType > , FaceContainerType > & m)
{ {