Added Optional Mark

This commit is contained in:
Paolo Cignoni 2006-05-03 21:37:02 +00:00
parent 3cb1b4442d
commit 30b1d99a4c
1 changed files with 69 additions and 13 deletions

View File

@ -24,6 +24,11 @@
History History
$Log: not supported by cvs2svn $ $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 Revision 1.10 2006/01/30 08:47:40 cignoni
Corrected HasPerWedgeTexture Corrected HasPerWedgeTexture
@ -88,6 +93,7 @@ class vector_ocf: public std::vector<VALUE_TYPE> {
public: public:
vector_ocf():std::vector<VALUE_TYPE>(){ vector_ocf():std::vector<VALUE_TYPE>(){
ColorEnabled=false; ColorEnabled=false;
MarkEnabled=false;
NormalEnabled=false; NormalEnabled=false;
WedgeTexEnabled=false; WedgeTexEnabled=false;
VFAdjacencyEnabled=false; VFAdjacencyEnabled=false;
@ -128,10 +134,12 @@ public:
if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end()); if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end());
else _updateOVP(oldend, (*this).end()); else _updateOVP(oldend, (*this).end());
if(NormalEnabled) NV.push_back(typename VALUE_TYPE::NormalType()); if (ColorEnabled) CV.push_back(vcg::Color4b(vcg::Color4b::White));
if(VFAdjacencyEnabled) AV.push_back(AdjTypePack()); if (MarkEnabled) MV.push_back(0);
if(FFAdjacencyEnabled) AF.push_back(AdjTypePack()); if (NormalEnabled) NV.push_back(typename VALUE_TYPE::NormalType());
if(WedgeTexEnabled) WTV.push_back(WedgeTexTypePack()); if (VFAdjacencyEnabled) AV.push_back(AdjTypePack());
if (FFAdjacencyEnabled) AF.push_back(AdjTypePack());
if (WedgeTexEnabled) WTV.push_back(WedgeTexTypePack());
} }
void pop_back(); void pop_back();
void resize(const unsigned int & _size) void resize(const unsigned int & _size)
@ -141,10 +149,12 @@ public:
BaseType::resize(_size); BaseType::resize(_size);
if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end()); if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end());
else _updateOVP(oldend, (*this).end()); else _updateOVP(oldend, (*this).end());
if(ColorEnabled) CV.resize(_size);
if(NormalEnabled) NV.resize(_size); if (ColorEnabled) CV.resize(_size);
if(VFAdjacencyEnabled) AV.resize(_size); if (MarkEnabled) MV.resize(_size);
if(FFAdjacencyEnabled) AF.resize(_size); if (NormalEnabled) NV.resize(_size);
if (VFAdjacencyEnabled) AV.resize(_size);
if (FFAdjacencyEnabled) AF.resize(_size);
if (WedgeTexEnabled) WTV.resize(_size,WedgeTexTypePack()); if (WedgeTexEnabled) WTV.resize(_size,WedgeTexTypePack());
} }
@ -152,11 +162,14 @@ public:
{ {
ThisTypeIterator oldbegin=(*this).begin(); ThisTypeIterator oldbegin=(*this).begin();
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); if (VFAdjacencyEnabled) AV.reserve(_size);
if (FFAdjacencyEnabled) AF.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()); if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end());
} }
@ -168,7 +181,7 @@ public:
(*fi)._ovp=this; (*fi)._ovp=this;
} }
//////////////////////////////////////// ////////////////////////////////////////
// Enabling Eunctions // Enabling Functions
bool IsColorEnabled() const {return ColorEnabled;} bool IsColorEnabled() const {return ColorEnabled;}
void EnableColor() { void EnableColor() {
@ -183,6 +196,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::HasFaceNormalOcf()); assert(VALUE_TYPE::HasFaceNormalOcf());
@ -238,12 +264,14 @@ void DisableWedgeTex() {
public: public:
std::vector<typename VALUE_TYPE::ColorType> CV; std::vector<typename VALUE_TYPE::ColorType> CV;
std::vector<int> MV;
std::vector<typename VALUE_TYPE::NormalType> NV; std::vector<typename VALUE_TYPE::NormalType> NV;
std::vector<struct AdjTypePack> AV; std::vector<struct AdjTypePack> AV;
std::vector<struct AdjTypePack> AF; std::vector<struct AdjTypePack> AF;
std::vector<class WedgeTexTypePack> WTV; std::vector<class WedgeTexTypePack> WTV;
bool ColorEnabled; bool ColorEnabled;
bool MarkEnabled;
bool NormalEnabled; bool NormalEnabled;
bool WedgeTexEnabled; bool WedgeTexEnabled;
bool VFAdjacencyEnabled; bool VFAdjacencyEnabled;
@ -337,13 +365,34 @@ template <class T> class Normal3dOcf: public NormalOcf<vcg::Point3d, T> {};
template <class A, class T> class ColorOcf: public T { template <class A, class T> class ColorOcf: public T {
public: public:
typedef A ColorType; 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 HasFaceColor() { return true; }
static bool HasFaceColorOcf() { return true; } static bool HasFaceColorOcf() { return true; }
}; };
template <class T> class Color4bOcf: public ColorOcf<vcg::Color4b, T> {}; template <class T> class Color4bOcf: public ColorOcf<vcg::Color4b, 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()];
} ;
static bool HasFaceMark() { return true; }
static bool HasFaceMarkOcf() { return true; }
inline void InitIMark() { _imark = 0; }
};
///*-------------------------- WEDGE TEXCOORD ----------------------------------*/ ///*-------------------------- WEDGE TEXCOORD ----------------------------------*/
@ -393,8 +442,15 @@ public:
template < class VertContainerType, class FaceType > template < class VertContainerType, class FaceType >
bool HasPerFaceColor (const TriMesh < VertContainerType , face::vector_ocf< FaceType > > & m) bool HasPerFaceColor (const TriMesh < VertContainerType , face::vector_ocf< FaceType > > & m)
{ {
if(face::vector_ocf< FaceType >::HasPerFaceColorOcf()) return m.face.FaceColor(); if(FaceType::HasFaceColorOcf()) return m.face.IsColorEnabled();
else return face::vector_ocf< FaceType > ::HasFaceColor(); 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 }// end namespace vcg