Added zero initialization to quality component. (and corrected a small bug in the ocf quality component)
This commit is contained in:
parent
eeccd23f71
commit
df97ef0c36
|
|
@ -400,6 +400,7 @@ public: static void Name(std::vector<std::string> & name){name.push_back(std::st
|
|||
template <class A, class T> class Quality: public T {
|
||||
public:
|
||||
typedef A QualityType;
|
||||
Quality():_quality(0) {}
|
||||
QualityType &Q() { return _quality; }
|
||||
QualityType cQ() const { return _quality; }
|
||||
template <class RightValueType>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ All the Components that can be added to a faceex should be defined in the namesp
|
|||
template <class VALUE_TYPE>
|
||||
class vector_ocf: public std::vector<VALUE_TYPE> {
|
||||
typedef std::vector<VALUE_TYPE> BaseType;
|
||||
typedef typename vector_ocf<VALUE_TYPE>::iterator ThisTypeIterator;
|
||||
typedef typename vector_ocf<VALUE_TYPE>::iterator ThisTypeIterator;
|
||||
|
||||
public:
|
||||
vector_ocf():std::vector<VALUE_TYPE>()
|
||||
|
|
@ -62,9 +62,9 @@ struct AdjTypePack {
|
|||
// Needed because we need to know if adjacency is initialized or not
|
||||
// when resizing vectors and during an allocate face.
|
||||
AdjTypePack() {
|
||||
_fp[0]=0;
|
||||
_fp[1]=0;
|
||||
_fp[2]=0;
|
||||
_fp[0]=0;
|
||||
_fp[1]=0;
|
||||
_fp[2]=0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -87,13 +87,13 @@ class WedgeColorTypePack {
|
|||
public:
|
||||
WedgeColorTypePack() {
|
||||
typedef typename VALUE_TYPE::ColorType::ScalarType WedgeColorScalarType;
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
wc[i][0] = WedgeColorScalarType(255);
|
||||
wc[i][1] = WedgeColorScalarType(255);
|
||||
wc[i][2] = WedgeColorScalarType(255);
|
||||
wc[i][3] = WedgeColorScalarType(255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typename VALUE_TYPE::ColorType wc[3];
|
||||
|
|
@ -103,12 +103,12 @@ class WedgeNormalTypePack {
|
|||
public:
|
||||
WedgeNormalTypePack() {
|
||||
typedef typename VALUE_TYPE::NormalType::ScalarType WedgeNormalScalarType;
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
wn[i][0] = WedgeNormalScalarType(0);
|
||||
wn[i][1] = WedgeNormalScalarType(0);
|
||||
wn[i][2] = WedgeNormalScalarType(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typename VALUE_TYPE::NormalType wn[3];
|
||||
|
|
@ -121,55 +121,55 @@ public:
|
|||
void push_back(const VALUE_TYPE & v)
|
||||
{
|
||||
BaseType::push_back(v);
|
||||
BaseType::back()._ovp = this;
|
||||
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 (MarkEnabled) MV.push_back(0);
|
||||
if (NormalEnabled) NV.push_back(typename VALUE_TYPE::NormalType());
|
||||
if (CurvatureDirEnabled) CDV.push_back(typename VALUE_TYPE::CurvatureDirType());
|
||||
if (VFAdjacencyEnabled) AV.push_back(AdjTypePack());
|
||||
if (CurvatureDirEnabled) CDV.push_back(typename VALUE_TYPE::CurvatureDirType());
|
||||
if (VFAdjacencyEnabled) AV.push_back(AdjTypePack());
|
||||
if (FFAdjacencyEnabled) AF.push_back(AdjTypePack());
|
||||
if (WedgeTexEnabled) WTV.push_back(WedgeTexTypePack());
|
||||
if (WedgeColorEnabled) WCV.push_back(WedgeColorTypePack());
|
||||
if (WedgeNormalEnabled) WNV.push_back(WedgeNormalTypePack());
|
||||
if (WedgeTexEnabled) WTV.push_back(WedgeTexTypePack());
|
||||
if (WedgeColorEnabled) WCV.push_back(WedgeColorTypePack());
|
||||
if (WedgeNormalEnabled) WNV.push_back(WedgeNormalTypePack());
|
||||
}
|
||||
void pop_back();
|
||||
void pop_back();
|
||||
void resize(const unsigned int & _size)
|
||||
{
|
||||
unsigned int oldsize = BaseType::size();
|
||||
unsigned int oldsize = BaseType::size();
|
||||
BaseType::resize(_size);
|
||||
if(oldsize<_size){
|
||||
ThisTypeIterator firstnew = BaseType::begin();
|
||||
advance(firstnew,oldsize);
|
||||
_updateOVP(firstnew,(*this).end());
|
||||
}
|
||||
if (QualityEnabled) QV.resize(_size);
|
||||
if(oldsize<_size){
|
||||
ThisTypeIterator firstnew = BaseType::begin();
|
||||
advance(firstnew,oldsize);
|
||||
_updateOVP(firstnew,(*this).end());
|
||||
}
|
||||
if (QualityEnabled) QV.resize(_size,0);
|
||||
if (_ColorEnabled) CV.resize(_size);
|
||||
if (MarkEnabled) MV.resize(_size);
|
||||
if (NormalEnabled) NV.resize(_size);
|
||||
if (CurvatureDirEnabled)CDV.resize(_size);
|
||||
if (VFAdjacencyEnabled) AV.resize(_size);
|
||||
if (MarkEnabled) MV.resize(_size);
|
||||
if (NormalEnabled) NV.resize(_size);
|
||||
if (CurvatureDirEnabled)CDV.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);
|
||||
if (WedgeColorEnabled) WCV.resize(_size);
|
||||
if (WedgeNormalEnabled) WNV.resize(_size);
|
||||
}
|
||||
void reserve(const unsigned int & _size)
|
||||
{
|
||||
BaseType::reserve(_size);
|
||||
|
||||
if (QualityEnabled) QV.reserve(_size);
|
||||
if (_ColorEnabled) CV.reserve(_size);
|
||||
if (MarkEnabled) MV.reserve(_size);
|
||||
if (NormalEnabled) NV.reserve(_size);
|
||||
if (CurvatureDirEnabled)CDV.reserve(_size);
|
||||
if (VFAdjacencyEnabled) AV.reserve(_size);
|
||||
if (FFAdjacencyEnabled) AF.reserve(_size);
|
||||
if (WedgeTexEnabled) WTV.reserve(_size);
|
||||
if (WedgeColorEnabled) WCV.reserve(_size);
|
||||
if (WedgeNormalEnabled) WNV.reserve(_size);
|
||||
if (_ColorEnabled) CV.reserve(_size);
|
||||
if (MarkEnabled) MV.reserve(_size);
|
||||
if (NormalEnabled) NV.reserve(_size);
|
||||
if (CurvatureDirEnabled)CDV.reserve(_size);
|
||||
if (VFAdjacencyEnabled) AV.reserve(_size);
|
||||
if (FFAdjacencyEnabled) AF.reserve(_size);
|
||||
if (WedgeTexEnabled) WTV.reserve(_size);
|
||||
if (WedgeColorEnabled) WCV.reserve(_size);
|
||||
if (WedgeNormalEnabled) WNV.reserve(_size);
|
||||
|
||||
if( BaseType::empty()) return ;
|
||||
if( BaseType::empty()) return ;
|
||||
|
||||
ThisTypeIterator oldbegin=(*this).begin();
|
||||
if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end());
|
||||
|
|
@ -218,8 +218,8 @@ void ReorderFace(std::vector<size_t> &newFaceIndex )
|
|||
}
|
||||
}
|
||||
|
||||
if (QualityEnabled) QV.resize(BaseType::size());
|
||||
if (_ColorEnabled) CV.resize(BaseType::size());
|
||||
if (QualityEnabled) QV.resize(BaseType::size(),0);
|
||||
if (_ColorEnabled) CV.resize(BaseType::size());
|
||||
if (MarkEnabled) MV.resize(BaseType::size());
|
||||
if (NormalEnabled) NV.resize(BaseType::size());
|
||||
if (CurvatureDirEnabled) CDV.resize(BaseType::size());
|
||||
|
|
@ -237,7 +237,7 @@ bool IsQualityEnabled() const {return QualityEnabled;}
|
|||
void EnableQuality() {
|
||||
assert(VALUE_TYPE::HasQualityOcf());
|
||||
QualityEnabled=true;
|
||||
QV.resize((*this).size());
|
||||
QV.resize((*this).size(),0);
|
||||
}
|
||||
|
||||
void DisableQuality() {
|
||||
|
|
|
|||
|
|
@ -332,6 +332,8 @@ The Quality Component is a generic place for storing a float. The term 'quality'
|
|||
template <class A, class TT> class Quality: public TT {
|
||||
public:
|
||||
typedef A QualityType;
|
||||
Quality():_quality(0) {}
|
||||
|
||||
inline const QualityType &Q() const { return _quality; }
|
||||
inline QualityType &Q() { return _quality; }
|
||||
inline QualityType cQ() const {return _quality; }
|
||||
|
|
|
|||
|
|
@ -63,20 +63,21 @@ public:
|
|||
// All the standard methods of std::vector that can change the reallocation are
|
||||
// redefined in order to manage the additional data.
|
||||
void push_back(const VALUE_TYPE & v)
|
||||
{
|
||||
BaseType::push_back(v);
|
||||
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 (TexCoordEnabled) TV.push_back(typename VALUE_TYPE::TexCoordType());
|
||||
if (VFAdjacencyEnabled) AV.push_back(VFAdjType());
|
||||
if (CurvatureEnabled) CuV.push_back(typename VALUE_TYPE::CurvatureType());
|
||||
if (CurvatureDirEnabled) CuDV.push_back(typename VALUE_TYPE::CurvatureDirType());
|
||||
if (RadiusEnabled) RadiusV.push_back(typename VALUE_TYPE::RadiusType());
|
||||
}
|
||||
{
|
||||
BaseType::push_back(v);
|
||||
BaseType::back()._ovp = this;
|
||||
if (ColorEnabled) CV.push_back(vcg::Color4b(vcg::Color4b::White));
|
||||
if (QualityEnabled) QV.push_back(0);
|
||||
if (MarkEnabled) MV.push_back(0);
|
||||
if (NormalEnabled) NV.push_back(typename VALUE_TYPE::NormalType());
|
||||
if (TexCoordEnabled) TV.push_back(typename VALUE_TYPE::TexCoordType());
|
||||
if (VFAdjacencyEnabled) AV.push_back(VFAdjType());
|
||||
if (CurvatureEnabled) CuV.push_back(typename VALUE_TYPE::CurvatureType());
|
||||
if (CurvatureDirEnabled) CuDV.push_back(typename VALUE_TYPE::CurvatureDirType());
|
||||
if (RadiusEnabled) RadiusV.push_back(typename VALUE_TYPE::RadiusType());
|
||||
}
|
||||
|
||||
void pop_back();
|
||||
void pop_back();
|
||||
|
||||
void resize(const unsigned int & _size)
|
||||
{
|
||||
|
|
@ -88,6 +89,7 @@ public:
|
|||
_updateOVP(firstnew,(*this).end());
|
||||
}
|
||||
if (ColorEnabled) CV.resize(_size);
|
||||
if (QualityEnabled) QV.resize(_size,0);
|
||||
if (MarkEnabled) MV.resize(_size);
|
||||
if (NormalEnabled) NV.resize(_size);
|
||||
if (TexCoordEnabled) TV.resize(_size);
|
||||
|
|
@ -101,6 +103,7 @@ public:
|
|||
{
|
||||
BaseType::reserve(_size);
|
||||
if (ColorEnabled) CV.reserve(_size);
|
||||
if (QualityEnabled) QV.reserve(_size);
|
||||
if (MarkEnabled) MV.reserve(_size);
|
||||
if (NormalEnabled) NV.reserve(_size);
|
||||
if (TexCoordEnabled) TV.reserve(_size);
|
||||
|
|
@ -124,7 +127,7 @@ bool IsQualityEnabled() const {return QualityEnabled;}
|
|||
void EnableQuality() {
|
||||
assert(VALUE_TYPE::HasQualityOcf());
|
||||
QualityEnabled=true;
|
||||
QV.resize((*this).size());
|
||||
QV.resize((*this).size(),0);
|
||||
}
|
||||
void DisableQuality() {
|
||||
assert(VALUE_TYPE::HasQualityOcf());
|
||||
|
|
@ -285,9 +288,9 @@ public:
|
|||
}
|
||||
template <class RightVertexType>
|
||||
void ImportData(const RightVertexType & rightV)
|
||||
{
|
||||
T::ImportData(rightV);
|
||||
}
|
||||
{
|
||||
T::ImportData(rightV);
|
||||
}
|
||||
|
||||
static bool HasVFAdjacency() { return true; }
|
||||
static bool HasVFAdjacencyOcf() { return true; }
|
||||
|
|
@ -538,11 +541,11 @@ template <class T> class RadiusdOcf: public RadiusOcf<double, T> {};
|
|||
|
||||
template < class T> class InfoOcf: public T {
|
||||
public:
|
||||
// You should never ever try to copy a vertex that has OCF stuff.
|
||||
// You should never ever try to copy a vertex that has OCF stuff.
|
||||
// use ImportData function.
|
||||
inline InfoOcf &operator=(const InfoOcf & /*other*/) {
|
||||
assert(0); return *this;
|
||||
}
|
||||
inline InfoOcf &operator=(const InfoOcf & /*other*/) {
|
||||
assert(0); return *this;
|
||||
}
|
||||
|
||||
vector_ocf<typename T::VertexType> &Base() const { return *_ovp;}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue