working on component.h and allocate.h perm

This commit is contained in:
T.Alderighi 2018-05-02 20:18:33 +02:00
parent 1b61aba402
commit 99fd7d61f7
2 changed files with 191 additions and 70 deletions

View File

@ -919,6 +919,20 @@ public:
--m.tn; --m.tn;
} }
//TODO:
// static void PermutateTetraVector(MeshType & m, PointerUpdater<TetraPointer> & pu)
// {
// if (m.tetra.empty())
// return;
// for (size_t i = 0; i < m.tetra.size(); ++i)
// {
// if (pu.remap[i] < size_t(m.tn))
// {
// }
// }
// }
/* /*
Function to rearrange the vertex vector according to a given index permutation Function to rearrange the vertex vector according to a given index permutation
the permutation is vector such that after calling this function the permutation is vector such that after calling this function

View File

@ -40,25 +40,106 @@ namespace vcg {
namespace tetra { namespace tetra {
/* /*
Some naming Rules Some naming Rules
All the Components that can be added to a vertex should be defined in the namespace vert: All the Components that can be added to a tetra should be defined in the namespace tetra:
*/ */
template <class T> class EmptyCore : public T {
/*-------------------------- VERTEX ----------------------------------------*/
template <class T> class EmptyVertexRef: public T {
public: public:
// typedef typename T::VertexType VertexType; //Empty vertexref
// typedef typename T::CoordType CoordType; inline typename T::VertexType * & V( const int j ) { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * & V( const int j ) { assert(0); static typename T::VertexType *vp=0; return vp; } inline typename T::VertexType * const & V( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * const & V( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * const cV( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; } inline typename T::VertexType * const cV( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::CoordType & P( const int j ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } inline typename T::CoordType & P( const int j ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
inline const typename T::CoordType & P( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } inline const typename T::CoordType & P( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
inline const typename T::CoordType &cP( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } inline const typename T::CoordType &cP( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
static bool HasVertexRef() { return false; }
static void Name(std::vector<std::string> & name){T::Name(name);} static bool HasVertexRef() { return false; }
static bool HasTVAdjacency() { return false; }
//Empty normals
typedef typename T::VertexType::NormalType NormalType;
NormalType &N(const int & ){ static NormalType dummynormal(0, 0, 0); assert(0); return dummynormal; }
const NormalType cN(const int & ) const { static NormalType dummynormal(0, 0, 0); assert(0); return dummynormal; }
static bool HasFaceNormal() { return false; }
static bool HasFaceNormalOcc() { return false; }
//Empty color
typedef vcg::Color4b ColorType;
ColorType &C() { static ColorType dummycolor(vcg::Color4b::White); assert(0); return dummycolor; }
ColorType cC() const { static ColorType dummycolor(vcg::Color4b::White); assert(0); return dummycolor; }
static bool HasColor() { return false; }
static bool IsColorEnabled() const { return T::TetraType::HasColor(); }
//Empty Quality
typedef float QualityType;
typedef vcg::Point3f Quality3Type;
QualityType &Q() { static QualityType dummyquality(0); assert(0); return dummyquality; }
QualityType cQ() const { static QualityType dummyquality(0); assert(0); return dummyquality; }
Quality3Type &Q3() { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; }
Quality3Type cQ3() const { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; }
static bool HasQuality() { return false; }
static bool HasQuality3() { return false; }
static bool IsQualityEnabled() const { return T::TetraType::HasQuality(); }
static bool IsQuality3Enabled() const { return T::TetraType::HasQuality3(); }
//Empty flags
int &Flags() { static int dummyflags(0); assert(0); return dummyflags; }
int cFlags() const { return 0; }
static bool HasFlags() { return false; }
static bool HasFlagsOcc() { return false; }
//Empty IMark
typedef int MarkType;
inline void InitIMark() { }
inline int & IMark() { assert(0); static int tmp=-1; return tmp;}
inline const int IMark() const {return 0;}
static bool HasMark() { return false; }
static bool HasMarkOcc() { return false; }
//Empty Adjacency
typedef int VFAdjType;
typename T::TetraPointer & VTp( const int ) { static typename T::TetraPointer tp=0; assert(0); return tp; }
typename T::TetraPointer const cVTp( const int ) const { static typename T::TetraPointer const tp=0; assert(0); return tp; }
typename T::TetraPointer & TTp( const int ) { static typename T::TetraPointer tp=0; assert(0); return tp; }
typename T::TetraPointer const cTTp( const int ) const { static typename T::TetraPointer const tp=0; assert(0); return tp; }
char & VTi( const int j ) { static char z=0; assert(0); return z; }
char & TTi( const int j ) { static char z=0; assert(0); return z; }
static bool HasVTAdjacency() { return false; }
static bool HasTTAdjacency() { return false; }
static bool HasTTAdjacencyOcc() { return false; }
static bool HasVTAdjacencyOcc() { return false; }
template <class RightValuteType>
void ImportData(const RightValuteType & ) {}
static void Name(std::vector<std::string> & name) { T::Name(name); }
}
/*-------------------------- VERTEX ----------------------------------------*/
// template <class T> class EmptyVertexRef: public T {
// public:
// // typedef typename T::VertexType VertexType;
// // typedef typename T::CoordType CoordType;
// inline typename T::VertexType * & V( const int j ) { assert(0); static typename T::VertexType *vp=0; return vp; }
// inline typename T::VertexType * const & V( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
// inline typename T::VertexType * const cV( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
// inline typename T::CoordType & P( const int j ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
// inline const typename T::CoordType & P( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
// inline const typename T::CoordType &cP( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
// static bool HasVertexRef() { return false; }
// };
};
template <class T> class VertexRef: public T { template <class T> class VertexRef: public T {
public: public:
VertexRef(){ VertexRef(){
@ -107,9 +188,13 @@ public:
inline const typename T::CoordType & cP2( const int j ) const { return cV((j+2)%4)->P();} inline const typename T::CoordType & cP2( const int j ) const { return cV((j+2)%4)->P();}
inline const typename T::CoordType & cP3( const int j ) const { return cV((j+3)%4)->P();} inline const typename T::CoordType & cP3( const int j ) const { return cV((j+3)%4)->P();}
static bool HasVertexRef() { return true; } static bool HasVertexRef() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);} static bool HasTVAdjacency() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
template <class RightValueType>
void ImportData(const RightValuteType & rTetra) { T::ImportData(rTetra); }
private: private:
typename T::VertexType *v[4]; typename T::VertexType *v[4];
@ -117,79 +202,101 @@ public:
/*------------------------- FACE NORMAL -----------------------------------------*/ /*------------------------- FACE NORMAL -----------------------------------------*/
template <class A, class T> class EmptyFaceNormal: public T { // template <class A, class T> class EmptyFaceNormal: public T {
public: // public:
typedef ::vcg::Point3<A> NormalType; // typedef ::vcg::Point3<A> NormalType;
/// Return the vector of Flags(), senza effettuare controlli sui bit // /// Return the vector of Flags(), senza effettuare controlli sui bit
NormalType N(const int & ){ static int dummynormal(0); return dummynormal; } // NormalType N(const int & ){ static int dummynormal(0); return dummynormal; }
const NormalType cN(const int & ) const { return 0; } // const NormalType cN(const int & ) const { return 0; }
static bool HasFaceNormal() { return false; } // static bool HasFaceNormal() { return false; }
static bool HasFaceNormalOcc() { return false; } // static bool HasFaceNormalOcc() { return false; }
static void Name(std::vector<std::string> & name){T::Name(name);} // static void Name(std::vector<std::string> & name){T::Name(name);}
}; // };
template <class A, class T> class FaceNormal: public T { template <class A, class T> class FaceNormal: public T {
public: public:
typedef ::vcg::Point3<A> NormalType; typedef A NormalType;
NormalType N(const int & i){ assert((i>=0)&&(i < 4)); return _facenormals[i]; } inline NormalType N(const int & i){ assert((i>=0)&&(i < 4)); return _facenormals[i]; }
const NormalType cN(const int & i) const { assert((i>=0)&&(i < 4)); return _facenormals[i]; } inline NormalType cN(const int & i) const { assert((i>=0)&&(i < 4)); return _facenormals[i]; }
static bool HasFaceNormals() { return true; } static bool HasFaceNormals() { return true; }
static bool HasFaceNormalOcc() { return false; } static bool HasFaceNormalOcc() { return false; }
template <class RightValueType>
void ImportData(const RightValueType & rightT)
{
if(rightT.IsNormalEnabled()) N().Import(rightT.cN());
T::ImportData(rightT);
}
static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal"));T::Name(name);}
private: private:
NormalType _facenormals[4]; NormalType _facenormals[4];
}; };
template <class T> class FaceNormal3f: public FaceNormal<float,T>{ template <class T> class FaceNormal3f: public FaceNormal<vcg::Point3f, T>{
public:static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal3f"));T::Name(name);} }; public:static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal3f"));T::Name(name);} };
template <class T> class FaceNormal3d: public FaceNormal<double,T>{ template <class T> class FaceNormal3d: public FaceNormal<vcg::Point3d, T>{
public:static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal3d"));T::Name(name);} }; public:static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal3d"));T::Name(name);} };
/*------------------------- FLAGS -----------------------------------------*/ /*------------------------- FLAGS -----------------------------------------*/
template <class T> class EmptyBitFlags: public T { // template <class T> class EmptyBitFlags: public T {
public: // public:
/// Return the vector of Flags(), senza effettuare controlli sui bit // /// Return the vector of Flags(), senza effettuare controlli sui bit
int &Flags() { static int dummyflags(0); return dummyflags; } // int &Flags() { static int dummyflags(0); return dummyflags; }
const int Flags() const { return 0; } // const int Flags() const { return 0; }
static bool HasFlags() { return false; } // static bool HasFlags() { return false; }
static bool HasFlagsOcc() { return false; } // static bool HasFlagsOcc() { return false; }
static void Name(std::vector<std::string> & name){T::Name(name);} // static void Name(std::vector<std::string> & name){T::Name(name);}
}; // };
template <class T> class BitFlags: public T { template <class T> class BitFlags: public T {
public: public:
BitFlags(){_flags=0;} typedef int FlagType;
int &Flags() {return _flags; } BitFlags(){_flags=0;}
const int Flags() const {return _flags; } int &Flags() {return _flags; }
static bool HasFlags() { return true; } int Flags() const {return _flags; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(RightValueType::HasFlags())
Flags() = rightT.cFlags();
T::ImportData(rightT);
}
static bool HasFlags() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
private: private:
int _flags; int _flags;
}; };
/*-------------------------- QUALITY ----------------------------------------*/
/*-------------------------- COLOR ----------------------------------------*/
/*-------------------------- INCREMENTAL MARK ----------------------------------------*/ /*-------------------------- INCREMENTAL MARK ----------------------------------------*/
template <class T> class EmptyMark: public T { // template <class T> class EmptyMark: public T {
public: // public:
typedef int MarkType; // typedef int MarkType;
static bool HasMark() { return false; } // static bool HasMark() { return false; }
static bool HasMarkOcc() { return false; } // static bool HasMarkOcc() { return false; }
inline void InitIMark() { } // inline void InitIMark() { }
inline int & IMark() { assert(0); static int tmp=-1; return tmp;} // inline int & IMark() { assert(0); static int tmp=-1; return tmp;}
inline const int IMark() const {return 0;} // inline const int IMark() const {return 0;}
static void Name(std::vector<std::string> & name){T::Name(name);} // static void Name(std::vector<std::string> & name){T::Name(name);}
// };
};
template <class T> class Mark: public T { template <class T> class Mark: public T {
public: public:
static bool HasMark() { return true; } static bool HasMark() { return true; }
static bool HasMarkOcc() { return true; } static bool HasMarkOcc() { return false; }
inline void InitIMark() { _imark = 0; } inline void InitIMark() { _imark = 0; }
inline int & IMark() { return _imark;} inline int & IMark() { return _imark;}
inline const int & IMark() const {return _imark;} inline const int & IMark() const {return _imark;}
@ -202,21 +309,21 @@ public:
/*----------------------------- VTADJ ------------------------------*/ /*----------------------------- VTADJ ------------------------------*/
template <class T> class EmptyAdj: public T { // template <class T> class EmptyAdj: public T {
public: // public:
typedef int VFAdjType; // typedef int VFAdjType;
typename T::TetraPointer & VTp( const int ) { static typename T::TetraPointer tp=0; return tp; } // typename T::TetraPointer & VTp( const int ) { static typename T::TetraPointer tp=0; return tp; }
typename T::TetraPointer const cVTp( const int ) const { static typename T::TetraPointer const tp=0; return tp; } // typename T::TetraPointer const cVTp( const int ) const { static typename T::TetraPointer const tp=0; return tp; }
typename T::TetraPointer & TTp( const int ) { static typename T::TetraPointer tp=0; return tp; } // typename T::TetraPointer & TTp( const int ) { static typename T::TetraPointer tp=0; return tp; }
typename T::TetraPointer const cTTp( const int ) const { static typename T::TetraPointer const tp=0; return tp; } // typename T::TetraPointer const cTTp( const int ) const { static typename T::TetraPointer const tp=0; return tp; }
char & VTi( const int j ) { static char z=0; return z; } // char & VTi( const int j ) { static char z=0; return z; }
char & TTi( const int j ) { static char z=0; return z; } // char & TTi( const int j ) { static char z=0; return z; }
static bool HasVTAdjacency() { return false; } // static bool HasVTAdjacency() { return false; }
static bool HasTTAdjacency() { return false; } // static bool HasTTAdjacency() { return false; }
static bool HasTTAdjacencyOcc() { return false; } // static bool HasTTAdjacencyOcc() { return false; }
static bool HasVTAdjacencyOcc() { return false; } // static bool HasVTAdjacencyOcc() { return false; }
static void Name( std::vector< std::string > & name ){ T::Name(name); } // static void Name( std::vector< std::string > & name ){ T::Name(name); }
}; // };
template <class T> class VTAdj: public T { template <class T> class VTAdj: public T {
public: public: