added WedgeNormalOcf and WedgeColorOcf.

This commit is contained in:
Marco Di Benedetto 2009-06-28 03:17:42 +00:00
parent 86c2311130
commit 35189992a9
1 changed files with 146 additions and 30 deletions

View File

@ -146,6 +146,8 @@ public:
WedgeTexEnabled=false;
VFAdjacencyEnabled=false;
FFAdjacencyEnabled=false;
WedgeColorEnabled=false;
WedgeNormalEnabled=false;
}
// Auxiliary types to build internal vectors
@ -178,7 +180,36 @@ public:
typename VALUE_TYPE::TexCoordType wt[3];
};
class WedgeColorTypePack {
public:
WedgeColorTypePack() {
typedef typename VALUE_TYPE::ColorType::ScalarType ScalarType;
for (int i=0; i<3; ++i)
{
wc[i][0] = ScalarType(255);
wc[i][1] = ScalarType(255);
wc[i][2] = ScalarType(255);
wc[i][3] = ScalarType(255);
}
}
typename VALUE_TYPE::ColorType wc[3];
};
class WedgeNormalTypePack {
public:
WedgeNormalTypePack() {
typedef typename VALUE_TYPE::NormalType::ScalarType ScalarType;
for (int i=0; i<3; ++i)
{
wn[i][0] = ScalarType(0);
wn[i][1] = ScalarType(0);
wn[i][2] = ScalarType(1);
}
}
typename VALUE_TYPE::NormalType wn[3];
};
// override di tutte le funzioni che possono spostare
@ -188,12 +219,14 @@ 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 (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 (VFAdjacencyEnabled) AV.push_back(AdjTypePack());
if (FFAdjacencyEnabled) AF.push_back(AdjTypePack());
if (WedgeTexEnabled) WTV.push_back(WedgeTexTypePack());
if (WedgeTexEnabled) WTV.push_back(WedgeTexTypePack());
if (WedgeColorEnabled) WCV.push_back(WedgeColorTypePack());
if (WedgeNormalEnabled) WNV.push_back(WedgeNormalTypePack());
}
void pop_back();
void resize(const unsigned int & _size)
@ -206,13 +239,14 @@ public:
_updateOVP(firstnew,(*this).end());
}
if (QualityEnabled) QV.resize(_size);
if (ColorEnabled) CV.resize(_size);
if (MarkEnabled) MV.resize(_size);
if (NormalEnabled) NV.resize(_size);
if (VFAdjacencyEnabled) AV.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());
if (WedgeColorEnabled) WCV.resize(_size);
if (WedgeNormalEnabled) WNV.resize(_size);
}
void reserve(const unsigned int & _size)
{
@ -220,12 +254,14 @@ public:
BaseType::reserve(_size);
if (QualityEnabled) QV.reserve(_size);
if (ColorEnabled) CV.reserve(_size);
if (MarkEnabled) MV.reserve(_size);
if (NormalEnabled) NV.reserve(_size);
if (VFAdjacencyEnabled) AV.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 (WedgeColorEnabled) WCV.reserve(_size);
if (WedgeNormalEnabled) WNV.reserve(_size);
if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end());
}
@ -244,14 +280,16 @@ public:
void ReorderFace(std::vector<size_t> &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() );
if (VFAdjacencyEnabled)assert( AV.size() == newFaceIndex.size() );
if (FFAdjacencyEnabled)assert( AF.size() == newFaceIndex.size() );
if (WedgeTexEnabled) assert(WTV.size() == newFaceIndex.size() );
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() );
if (VFAdjacencyEnabled) assert( AV.size() == newFaceIndex.size() );
if (FFAdjacencyEnabled) assert( AF.size() == newFaceIndex.size() );
if (WedgeTexEnabled) assert(WTV.size() == newFaceIndex.size() );
if (WedgeColorEnabled) assert(WCV.size() == newFaceIndex.size() );
if (WedgeNormalEnabled) assert(WNV.size() == newFaceIndex.size() );
for(i=0;i<newFaceIndex.size();++i)
{
if(newFaceIndex[i] != std::numeric_limits<size_t>::max() )
@ -264,16 +302,20 @@ void ReorderFace(std::vector<size_t> &newFaceIndex )
if (VFAdjacencyEnabled) AV[newFaceIndex[i]] = AV[i];
if (FFAdjacencyEnabled) AF[newFaceIndex[i]] = AF[i];
if (WedgeTexEnabled) WTV[newFaceIndex[i]] = WTV[i];
if (WedgeColorEnabled) WCV[newFaceIndex[i]] = WCV[i];
if (WedgeNormalEnabled) WNV[newFaceIndex[i]] = WNV[i];
}
}
if (QualityEnabled) QV.resize(BaseType::size());
if (ColorEnabled) CV.resize(BaseType::size());
if (MarkEnabled) MV.resize(BaseType::size());
if (NormalEnabled) NV.resize(BaseType::size());
if (VFAdjacencyEnabled) AV.resize(BaseType::size());
if (FFAdjacencyEnabled) AF.resize(BaseType::size());
if (WedgeTexEnabled) WTV.resize(BaseType::size());
if (QualityEnabled) QV.resize(BaseType::size());
if (ColorEnabled) CV.resize(BaseType::size());
if (MarkEnabled) MV.resize(BaseType::size());
if (NormalEnabled) NV.resize(BaseType::size());
if (VFAdjacencyEnabled) AV.resize(BaseType::size());
if (FFAdjacencyEnabled) AF.resize(BaseType::size());
if (WedgeTexEnabled) WTV.resize(BaseType::size());
if (WedgeColorEnabled) WCV.resize(BaseType::size());
if (WedgeNormalEnabled) WNV.resize(BaseType::size());
}
////////////////////////////////////////
@ -371,6 +413,32 @@ void DisableWedgeTex() {
WTV.clear();
}
bool IsWedgeColorEnabled() const {return WedgeColorEnabled;}
void EnableWedgeColor() {
assert(VALUE_TYPE::HasWedgeColorOcf());
WedgeColorEnabled=true;
WCV.resize((*this).size(),WedgeColorTypePack());
}
void DisableWedgeColor() {
assert(VALUE_TYPE::HasWedgeColorOcf());
WedgeColorEnabled=false;
WCV.clear();
}
bool IsWedgeNormalEnabled() const {return WedgeNormalEnabled;}
void EnableWedgeNormal() {
assert(VALUE_TYPE::HasWedgeNormalOcf());
WedgeNormalEnabled=true;
WNV.resize((*this).size(),WedgeNormalTypePack());
}
void DisableWedgeNormal() {
assert(VALUE_TYPE::HasWedgeNormalOcf());
WedgeNormalEnabled=false;
WNV.clear();
}
public:
std::vector<float> QV;
std::vector<typename VALUE_TYPE::ColorType> CV;
@ -379,6 +447,8 @@ public:
std::vector<struct AdjTypePack> AV;
std::vector<struct AdjTypePack> AF;
std::vector<class WedgeTexTypePack> WTV;
std::vector<class WedgeColorTypePack> WCV;
std::vector<class WedgeNormalTypePack> WNV;
bool QualityEnabled;
bool ColorEnabled;
@ -387,6 +457,8 @@ public:
bool WedgeTexEnabled;
bool VFAdjacencyEnabled;
bool FFAdjacencyEnabled;
bool WedgeColorEnabled;
bool WedgeNormalEnabled;
}; // end class vector_ocf
@ -607,7 +679,51 @@ public:
template <class T> class WedgeTexCoordfOcf: public WedgeTexCoordOcf<TexCoord2<float,1>, T> {};
///*-------------------------- InfoOpt ----------------------------------*/
///*-------------------------- WEDGE COLOR ----------------------------------*/
template <class A, class TT> class WedgeColorOcf: public TT {
public:
WedgeColorOcf(){ }
typedef A ColorType;
ColorType &WC(const int i) { assert((*this).Base().WedgeColorEnabled); return (*this).Base().WCV[(*this).Index()].wc[i]; }
const ColorType & cWC(const int i) const { assert((*this).Base().WedgeColorEnabled); return (*this).Base().WCV[(*this).Index()].wc[i]; }
template <class LeftF>
void ImportLocal(const LeftF & leftF){
//if(this->Base().WedgeColorEnabled && leftF.Base().WedgeColorEnabled) // WRONG I do not know anything about leftV!
if(this->Base().WedgeColorEnabled)
{ WC(0) = leftF.cWC(0); WC(1) = leftF.cWC(1); WC(2) = leftF.cWC(2); }
TT::ImportLocal(leftF);
}
static bool HasWedgeColor() { return true; }
static bool HasWedgeColorOcf() { return true; }
};
template <class T> class WedgeColor4bOcf: public WedgeColorOcf<vcg::Color4b, T> {};
///*-------------------------- WEDGE NORMAL ----------------------------------*/
template <class A, class TT> class WedgeNormalOcf: public TT {
public:
WedgeNormalOcf(){ }
typedef A NormalType;
NormalType &WN(const int i) { assert((*this).Base().WedgeNormalEnabled); return (*this).Base().WNV[(*this).Index()].wn[i]; }
NormalType const &cWN(const int i) const { assert((*this).Base().WedgeNormalEnabled); return (*this).Base().WNV[(*this).Index()].wn[i]; }
template <class LeftF>
void ImportLocal(const LeftF & leftF){
//if(this->Base().WedgeNormalEnabled && leftF.Base().WedgeNormalEnabled) // WRONG I do not know anything about leftV!
if(this->Base().WedgeNormalEnabled)
{ WN(0) = leftF.cWN(0); WN(1) = leftF.cWN(1); WN(2) = leftF.cWN(2); }
TT::ImportLocal(leftF);
}
static bool HasWedgeNormal() { return true; }
static bool HasWedgeNormalOcf() { return true; }
};
template <class T> class WedgeNormal3sOcf: public WedgeNormalOcf<vcg::Point3s, T> {};
template <class T> class WedgeNormal3fOcf: public WedgeNormalOcf<vcg::Point3f, T> {};
template <class T> class WedgeNormal3dOcf: public WedgeNormalOcf<vcg::Point3d, T> {};
///*-------------------------- InfoOpt ----------------------------------*/
template < class T> class InfoOcf: public T {
public: