small updates

This commit is contained in:
T.Alderighi 2018-05-08 13:16:07 +02:00
parent 239dfce517
commit 25339718d9
4 changed files with 322 additions and 387 deletions

View File

@ -192,7 +192,7 @@ public:
if(!(*ti).IsD()) if(!(*ti).IsD())
for(int j = 0; j < 4; ++j) for(int j = 0; j < 4; ++j)
{ {
if (tetrahedron::IsBorder(*fi,j)) (*ti).SetB(j); if (tetrahedron::IsBorder(*ti,j)) (*ti).SetB(j);
else (*ti).ClearB(j); else (*ti).ClearB(j);
} }
} }

View File

@ -44,30 +44,6 @@ added
namespace vcg { namespace vcg {
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/*
The base class of all the recusive definition chain. It is just a container of the typenames of the various simplexes.
These typenames must be known form all the derived classes.
*/
// template <class BVT, class BET, class BFT, class BTT>
// class TetraTypeHolder{
// public:
// typedef BVT VertexType;
// typedef typename VertexType::CoordType CoordType;
// typedef typename VertexType::ScalarType ScalarType;
// typedef BET EdgeType;
// typedef BFT FaceType;
// typedef BTT TetraType;
// typedef BVT *VertPointer;
// typedef BET *EdgePointer;
// typedef BFT *FacePointer;
// typedef BTT *TetraPointer;
// static void Name(std::vector<std::string> & name){}
// // prot
// };
// /* The base class form which we start to add our components. // /* The base class form which we start to add our components.
// it has the empty definition for all the standard members (coords, color flags) // it has the empty definition for all the standard members (coords, color flags)
@ -80,87 +56,14 @@ These typenames must be known form all the derived classes.
// we have to build the type a step a time (deriving from a single ancestor at a time). // we have to build the type a step a time (deriving from a single ancestor at a time).
// */
// template <class BVT, class BET=DumET, class BFT=DumFT, class BTT=DumTT>
// class TetraBase: public tetra::EmptyCore<
// TetraTypeHolder <BVT, BET, BFT, BTT> > {
// };
// // Metaprogramming Core
// template <class BVT, class BET, class BFT,class BTT,
// template <typename> class A>
// class TetraArity1: public A<TetraBase<BVT,BET,BFT,BTT> > {};
// template <class BVT, class BET, typename BFT, class BTT,
// template <typename> class A, template <typename> class B>
// class TetraArity2: public B<TetraArity1<BVT,BET,BFT,BTT, A> > {};
// template <class BVT, class BET, typename BFT,class BTT,
// template <typename> class A, template <typename> class B,
// template <typename> class C >
// class TetraArity3: public C<TetraArity2<BVT,BET,BFT,BTT, A, B> > {};
// template <class BVT, class BET, typename BFT,class BTT,
// template <typename> class A, template <typename> class B,
// template <typename> class C, template <typename> class D>
// class TetraArity4: public D<TetraArity3<BVT,BET,BFT,BTT, A, B, C> > {};
// template <class BVT, class BET, typename BFT,class BTT,
// template <typename> class A, template <typename> class B,
// template <typename> class C, template <typename> class D,
// template <typename> class E >
// class TetraArity5: public E<TetraArity4<BVT,BET,BFT,BTT, A, B, C, D> > {};
// template <class BVT, class BET, typename BFT,class BTT,
// template <typename> class A, template <typename> class B,
// template <typename> class C, template <typename> class D,
// template <typename> class E, template <typename> class F >
// class TetraArity6: public F<TetraArity5<BVT,BET,BFT,BTT, A, B, C, D, E> > {};
// template <class BVT, class BET, typename BFT,class BTT,
// template <typename> class A, template <typename> class B,
// template <typename> class C, template <typename> class D,
// template <typename> class E, template <typename> class F,
// template <typename> class G >
// class TetraArity7: public G<TetraArity6<BVT,BET,BFT,BTT, A, B, C, D, E, F> > {};
// template <class BVT, class BET, typename BFT,class BTT,
// template <typename> class A, template <typename> class B,
// template <typename> class C, template <typename> class D,
// template <typename> class E, template <typename> class F,
// template <typename> class G, template <typename> class H >
// class TetraArity8: public H<TetraArity7<BVT,BET,BFT,BTT, A, B, C, D, E, F, G> > {};
// /* The Real Big Face class;
// The class __FaceArityMax__ is the one that is the Last to be derived,
// and therefore is the only one to know the real members
// (after the many overrides) so all the functions with common behaviour
// using the members defined in the various Empty/nonEmpty component classes
// MUST be defined here.
// I.e. IsD() that uses the overridden Flags() member must be defined here.
// */
// template <class BVT, class BET, typename BFT,class BTT,
// template <typename> class A, template <typename> class B,
// template <typename> class C, template <typename> class D,
// template <typename> class E, template <typename> class F,
// template <typename> class G, template <typename> class H,
// template <typename> class I >
// class TetraArityMax: public I<TetraArity8<BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H> > {
template <class UserTypes> template <class UserTypes>
class TetraTypeHolder: public UserTypes { class TetraTypeHolder: public UserTypes {
public: public:
template <class LeftT> template <class RightT>
void ImportData(const LeftT & ){} void ImportData(const RightT & ){}
static void Name(std::vector<std::string> & /* name */){} static void Name(std::vector<std::string> & /* name */){}
@ -209,6 +112,7 @@ public:
BORDER1 = 0x00000080, BORDER1 = 0x00000080,
BORDER2 = 0x00000100, BORDER2 = 0x00000100,
BORDER3 = 0x00000200, BORDER3 = 0x00000200,
BORDER0123 = BORDER0 | BORDER1 | BORDER2 | BORDER3,
// Crease _flags, it is assumed that FEATUREi = FEATURE0<<i // Crease _flags, it is assumed that FEATUREi = FEATURE0<<i
// First user bit // First user bit
USER0 = 0x00004000 USER0 = 0x00004000
@ -260,7 +164,7 @@ public:
void ClearV() {this->Flags() &= ~VISITED;} void ClearV() {this->Flags() &= ~VISITED;}
/// This function checks if the face is selected /// This function checks if the face is selected
bool IsB(int i) const {return (this->Flags() & (BORDER0<<i)) != 0;} bool IsB(int i) const {return (this->cFlags() & (BORDER0<<i)) != 0;}
/// This function select the face /// This function select the face
void SetB(int i) {this->Flags() |=(BORDER0<<i);} void SetB(int i) {this->Flags() |=(BORDER0<<i);}
/// This funcion execute the inverse operation of SetS() /// This funcion execute the inverse operation of SetS()
@ -345,30 +249,14 @@ TTAdj //topology: face face adj
*/ */
// template <class BVT, class BET, class BFT, class BTT,
// template <typename> class A = TetraDefaultDeriver, template <typename> class B = TetraDefaultDeriver,
// template <typename> class C = TetraDefaultDeriver, template <typename> class D = TetraDefaultDeriver,
// template <typename> class E = TetraDefaultDeriver, template <typename> class F = TetraDefaultDeriver,
// template <typename> class G = TetraDefaultDeriver, template <typename> class H = TetraDefaultDeriver,
// template <typename> class I = TetraDefaultDeriver >
// class TetraSimp3: public TetraArityMax<BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H, I> {};
// class DumTT;
// template <class BVT, class BET, class BFT,
// template <typename> class A = TetraDefaultDeriver, template <typename> class B = TetraDefaultDeriver,
// template <typename> class C = TetraDefaultDeriver, template <typename> class D = TetraDefaultDeriver,
// template <typename> class E = TetraDefaultDeriver, template <typename> class F = TetraDefaultDeriver,
// template <typename> class G = TetraDefaultDeriver, template <typename> class H = TetraDefaultDeriver,
// template <typename> class I = TetraDefaultDeriver >
// class TetraSimp2: public TetraArityMax<BVT,BET,BFT,DumTT, A, B, C, D, E, F, G, H, I> {};
template <class UserTypes, template <class UserTypes,
template <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver, template <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver,
template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver, template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver,
template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver, template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver,
template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver, template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver,
template <typename> class I = DefaultDeriver, template <typename> class J = DefaultDeriver, template <typename> class I = DefaultDeriver, template <typename> class J = DefaultDeriver,
template <typename> class K = DefaultDeriver, template <typename> class L = DefaultDeriver> template <typename> class K = DefaultDeriver, template <typename> class L = DefaultDeriver>
class TetraSimp: public TetraArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J, K, L> { class TetraSimp : public TetraArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J, K, L> {
public: typedef AllTypes::ATetraType IAm; typedef UserTypes TypesPool;}; public: typedef AllTypes::ATetraType IAm; typedef UserTypes TypesPool;};
}// end namespace }// end namespace

View File

@ -8,7 +8,7 @@
* \ * * \ *
* All rights reserved. * * All rights reserved. *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
@ -31,108 +31,108 @@ added
****************************************************************************/ ****************************************************************************/
#ifndef __VCG_TETRAHEDRON_PLUS_COMPONENT #ifndef __VCG_TETRAHEDRON_PLUS_COMPONENT
#define __VCG_TETRAHEDRON_PLUS_COMPONENT #define __VCG_TETRAHEDRON_PLUS_COMPONENT
#include <vector> #include <vector>
#include <vcg/space/tetra3.h> #include <vcg/space/tetra3.h>
namespace vcg { namespace vcg {
namespace tetrahedron { namespace tetrahedron {
/* /*
Some naming Rules Some naming Rules
All the Components that can be added to a tetra should be defined in the namespace tetra: All the Components that can be added to a tetra should be defined in the namespace tetra:
*/ */
template <class T> class EmptyCore : public T { template <class T> class EmptyCore : public T {
public: public:
//Empty vertexref //Empty vertexref
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 bool HasTVAdjacency() { return false; }
// //Empty normals static bool HasVertexRef() { return false; }
// typedef typename T::VertexType::NormalType NormalType; static bool HasTVAdjacency() { return false; }
// 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 // //Empty normals
typedef vcg::Color4b ColorType; // typedef typename T::VertexType::NormalType NormalType;
ColorType &C() { static ColorType dummycolor(vcg::Color4b::White); assert(0); return dummycolor; } // NormalType &N(const int & ){ static NormalType dummynormal(0, 0, 0); assert(0); return dummynormal; }
ColorType cC() const { static ColorType dummycolor(vcg::Color4b::White); assert(0); return dummycolor; } // const NormalType cN(const int & ) const { static NormalType dummynormal(0, 0, 0); assert(0); return dummynormal; }
static bool HasColor() { return false; } // static bool HasFaceNormal() { return false; }
static bool IsColorEnabled() { return T::TetraType::HasColor(); } // static bool HasFaceNormalOcc() { return false; }
//Empty Quality //Empty color
typedef float QualityType; typedef vcg::Color4b ColorType;
typedef vcg::Point3f Quality3Type; ColorType &C() { static ColorType dummycolor(vcg::Color4b::White); assert(0); return dummycolor; }
QualityType &Q() { static QualityType dummyquality(0); assert(0); return dummyquality; } ColorType cC() const { static ColorType dummycolor(vcg::Color4b::White); assert(0); return dummycolor; }
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 HasColor() { return false; }
static bool HasQuality3() { return false; } static bool IsColorEnabled() { return T::TetraType::HasColor(); }
inline bool IsQualityEnabled() const { return T::TetraType::HasQuality(); }
inline bool IsQuality3Enabled() const { return T::TetraType::HasQuality3(); }
//Empty flags //Empty Quality
int &Flags() { static int dummyflags(0); assert(0); return dummyflags; } typedef float QualityType;
int cFlags() const { return 0; } 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 HasFlags() { return false; } static bool HasQuality() { return false; }
static bool HasFlagsOcc() { return false; } static bool HasQuality3() { return false; }
inline bool IsQualityEnabled() const { return T::TetraType::HasQuality(); }
inline bool IsQuality3Enabled() const { return T::TetraType::HasQuality3(); }
//Empty IMark //Empty flags
typedef int MarkType; int &Flags() { static int dummyflags(0); assert(0); return dummyflags; }
int cFlags() const { return 0; }
inline void InitIMark() { } static bool HasFlags() { return false; }
inline int & IMark() { assert(0); static int tmp=-1; return tmp;} static bool HasFlagsOcc() { return false; }
inline int cIMark() 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; } //Empty IMark
typename T::TetraPointer const cTTp( const int ) const { static typename T::TetraPointer const tp=0; assert(0); return tp; } typedef int MarkType;
char & VTi( const int j ) { static char z=0; assert(0); return z; } inline void InitIMark() { }
char cVTi( const int j ) const { static char z=0; assert(0); return z; } inline int & IMark() { assert(0); static int tmp=-1; return tmp;}
char & TTi( const int j ) { static char z=0; assert(0); return z; } inline int cIMark() const {return 0;}
char cTTi( const int j ) const { static char z=0; assert(0); return z; }
bool IsVTInitialized(const int j) const {return static_cast<const typename T::TetraType *>(this)->cVTi(j)!=-1;} static bool HasMark() { return false; }
void VTClear(int j) { static bool HasMarkOcc() { return false; }
if(IsVTInitialized(j)) {
static_cast<typename T::TetraPointer>(this)->VTp(j)=0; //Empty Adjacency
static_cast<typename T::TetraPointer>(this)->VTi(j)=-1; 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 cVTi( const int j ) const { static char z=0; assert(0); return z; }
char & TTi( const int j ) { static char z=0; assert(0); return z; }
char cTTi( const int j ) const { static char z=0; assert(0); return z; }
bool IsVTInitialized(const int j) const {return static_cast<const typename T::TetraType *>(this)->cVTi(j)!=-1;}
void VTClear(int j) {
if(IsVTInitialized(j)) {
static_cast<typename T::TetraPointer>(this)->VTp(j)=0;
static_cast<typename T::TetraPointer>(this)->VTi(j)=-1;
}
} }
}
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; }
template <class RightValuteType> template <class RightValuteType>
void ImportData(const RightValuteType & ) {} void ImportData(const RightValuteType & ) {}
static void Name(std::vector<std::string> & name) { T::Name(name); } static void Name(std::vector<std::string> & name) { T::Name(name); }
}; };
/*-------------------------- VERTEX ----------------------------------------*/ /*-------------------------- VERTEX ----------------------------------------*/
// template <class T> class EmptyVertexRef: public T { // template <class T> class EmptyVertexRef: public T {
// public: // public:
// // typedef typename T::VertexType VertexType; // // typedef typename T::VertexType VertexType;
@ -143,20 +143,20 @@ public:
// 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 bool HasVertexRef() { return false; }
// }; // };
template <class T> class VertexRef: public T { template <class T> class VertexRef: public T {
public: public:
VertexRef(){ VertexRef(){
v[0]=0; v[0]=0;
v[1]=0; v[1]=0;
v[2]=0; v[2]=0;
v[3]=0; v[3]=0;
/******* vertex and faces indices scheme********* /******* vertex and faces indices scheme*********
* *
* /2\` * /2\`
* / \ ` * / \ `
* / \ ` * / \ `
@ -164,69 +164,69 @@ public:
* / _ \ ' * / _ \ '
* / _ \ ' * / _ \ '
* /0___________1\' * /0___________1\'
* *
*/ */
findices[0][0] = 0; findices[0][1] = 1; findices[0][2] = 2; findices[0][0] = 0; findices[0][1] = 1; findices[0][2] = 2;
findices[1][0] = 0; findices[1][1] = 3; findices[1][2] = 1; findices[1][0] = 0; findices[1][1] = 3; findices[1][2] = 1;
findices[2][0] = 0; findices[2][1] = 2; findices[2][2] = 3; findices[2][0] = 0; findices[2][1] = 2; findices[2][2] = 3;
findices[3][0] = 1; findices[3][1] = 3; findices[3][2] = 2; findices[3][0] = 1; findices[3][1] = 3; findices[3][2] = 2;
} }
typedef typename T::VertexType::CoordType CoordType;
typedef typename T::VertexType::ScalarType ScalarType;
inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<4); return v[j]; } typedef typename T::VertexType::CoordType CoordType;
inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<4); return v[j]; } typedef typename T::VertexType::ScalarType ScalarType;
inline typename T::VertexType * const cV( const int j ) const { assert(j>=0 && j<4); return v[j]; }
inline typename size_t const cFtoVi (const int f, const int j) const { assert(f >= 0 && f < 4); assert(j >= 0 && j < 3); return findices[f][j]; } inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<4); return v[j]; }
inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<4); return v[j]; }
inline typename T::VertexType * const cV( const int j ) const { assert(j>=0 && j<4); return v[j]; }
// Shortcut for tetra points inline typename size_t const cFtoVi (const int f, const int j) const { assert(f >= 0 && f < 4); assert(j >= 0 && j < 3); return findices[f][j]; }
inline typename CoordType & P( const int j ) { assert(j>=0 && j<4); return v[j]->P(); }
inline const typename CoordType & P( const int j ) const { assert(j>=0 && j<4); return v[j]->cP(); }
inline const typename CoordType &cP( const int j ) const { assert(j>=0 && j<4); return v[j]->cP(); }
/** Return the pointer to the ((j+1)%4)-th vertex of the tetra. // Shortcut for tetra points
@param j Index of the face vertex. inline typename CoordType & P( const int j ) { assert(j>=0 && j<4); return v[j]->P(); }
*/ inline const typename CoordType & P( const int j ) const { assert(j>=0 && j<4); return v[j]->cP(); }
inline typename T::VertexType * & V0( const int j ) { return V(j);} inline const typename CoordType &cP( const int j ) const { assert(j>=0 && j<4); return v[j]->cP(); }
inline typename T::VertexType * & V1( const int j ) { return V((j+1)%4);}
inline typename T::VertexType * & V2( const int j ) { return V((j+2)%4);}
inline typename T::VertexType * & V3( const int j ) { return V((j+3)%4);}
inline const typename T::VertexType * const & V0( const int j ) const { return V(j);}
inline const typename T::VertexType * const & V1( const int j ) const { return V((j+1)%4);}
inline const typename T::VertexType * const & V2( const int j ) const { return V((j+2)%4);}
inline const typename T::VertexType * const & V3( const int j ) const { return V((j+3)%4);}
inline const typename T::VertexType * const & cV0( const int j ) const { return cV(j);}
inline const typename T::VertexType * const & cV1( const int j ) const { return cV((j+1)%4);}
inline const typename T::VertexType * const & cV2( const int j ) const { return cV((j+2)%4);}
inline const typename T::VertexType * const & cV3( const int j ) const { return cV((j+3)%4);}
/// Shortcut to get vertex values /** Return the pointer to the ((j+1)%4)-th vertex of the tetra.
inline typename CoordType &P0 (const int j) { return V(j)->P(); } @param j Index of the face vertex.
inline typename CoordType &P2 (const int j) { return V((j + 2) % 4)->P(); } */
inline typename CoordType &P3 (const int j) { return V((j + 3) % 4)->P(); } inline typename T::VertexType * & V0( const int j ) { return V(j);}
inline typename CoordType &P1 (const int j) { return V((j + 1) % 4)->P(); } inline typename T::VertexType * & V1( const int j ) { return V((j+1)%4);}
inline const typename CoordType &P0 (const int j) const { return V(j)->P(); } inline typename T::VertexType * & V2( const int j ) { return V((j+2)%4);}
inline const typename CoordType &P1 (const int j) const { return V((j + 1) % 4)->P(); } inline typename T::VertexType * & V3( const int j ) { return V((j+3)%4);}
inline const typename CoordType &P2 (const int j) const { return V((j + 2) % 4)->P(); } inline const typename T::VertexType * const & V0( const int j ) const { return V(j);}
inline const typename CoordType &P3 (const int j) const { return V((j + 3) % 4)->P(); } inline const typename T::VertexType * const & V1( const int j ) const { return V((j+1)%4);}
inline const typename CoordType &cP0(const int j) const { return cV(j)->P(); } inline const typename T::VertexType * const & V2( const int j ) const { return V((j+2)%4);}
inline const typename CoordType &cP1(const int j) const { return cV((j + 1) % 4)->P(); } inline const typename T::VertexType * const & V3( const int j ) const { return V((j+3)%4);}
inline const typename CoordType &cP2(const int j) const { return cV((j + 2) % 4)->P(); } inline const typename T::VertexType * const & cV0( const int j ) const { return cV(j);}
inline const typename CoordType &cP3(const int j) const { return cV((j + 3) % 4)->P(); } inline const typename T::VertexType * const & cV1( const int j ) const { return cV((j+1)%4);}
inline const typename T::VertexType * const & cV2( const int j ) const { return cV((j+2)%4);}
inline const typename T::VertexType * const & cV3( const int j ) const { return cV((j+3)%4);}
static bool HasVertexRef() { return true; } /// Shortcut to get vertex values
static bool HasTVAdjacency() { return true; } inline typename CoordType &P0 (const int j) { return V(j)->P(); }
inline typename CoordType &P2 (const int j) { return V((j + 2) % 4)->P(); }
inline typename CoordType &P3 (const int j) { return V((j + 3) % 4)->P(); }
inline typename CoordType &P1 (const int j) { return V((j + 1) % 4)->P(); }
inline const typename CoordType &P0 (const int j) const { return V(j)->P(); }
inline const typename CoordType &P1 (const int j) const { return V((j + 1) % 4)->P(); }
inline const typename CoordType &P2 (const int j) const { return V((j + 2) % 4)->P(); }
inline const typename CoordType &P3 (const int j) const { return V((j + 3) % 4)->P(); }
inline const typename CoordType &cP0(const int j) const { return cV(j)->P(); }
inline const typename CoordType &cP1(const int j) const { return cV((j + 1) % 4)->P(); }
inline const typename CoordType &cP2(const int j) const { return cV((j + 2) % 4)->P(); }
inline const typename CoordType &cP3(const int j) const { return cV((j + 3) % 4)->P(); }
static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);} static bool HasVertexRef() { return true; }
static bool HasTVAdjacency() { return true; }
template <class RightValueType>
void ImportData(const RightValueType & rTetra) { T::ImportData(rTetra); }
private: static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
typename T::VertexType *v[4];
size_t findices[4][3]; template <class RightValueType>
void ImportData(const RightValueType & rTetra) { T::ImportData(rTetra); }
private:
typename T::VertexType *v[4];
size_t findices[4][3];
}; };
@ -260,9 +260,9 @@ public:
// } // }
// 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<vcg::Point3f, T>{ //template <class T> class FaceNormal3f: public FaceNormal<vcg::Point3f, T>{
@ -271,7 +271,7 @@ public:
//template <class T> class FaceNormal3d: public FaceNormal<vcg::Point3d, 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
@ -285,45 +285,46 @@ public:
template <class T> class BitFlags: public T { template <class T> class BitFlags: public T {
public: public:
typedef int FlagType; typedef int FlagType;
BitFlags(){_flags=0;} BitFlags(){_flags=0;}
int &Flags() {return _flags; }
int cFlags() const {return _flags; } inline int &Flags() {return _flags; }
inline int cFlags() const {return _flags; }
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:
int _flags;
};
/*-------------------------- QUALITY ----------------------------------------*/
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> template <class RightValueType>
void ImportData(const RightValueType & rightT){ void ImportData(const RightValueType & rightT){
if(rightT.IsQualityEnabled()) if(RightValueType::HasFlags())
Q() = rightT.cQ(); Flags() = rightT.cFlags();
T::ImportData(rightT); T::ImportData(rightT);
} }
static bool HasQuality() { return true; } static bool HasFlags() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
private: private:
QualityType _quality; int _flags;
};
/*-------------------------- QUALITY ----------------------------------------*/
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>
void ImportData(const RightValueType & rightT){
if(rightT.IsQualityEnabled())
Q() = rightT.cQ();
T::ImportData(rightT);
}
static bool HasQuality() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality"));T::Name(name);}
private:
QualityType _quality;
}; };
template <class T> class Qualityf: public Quality<float, T> { template <class T> class Qualityf: public Quality<float, T> {
@ -336,19 +337,19 @@ public: static void Name(std::vector<std::string> & name){name.push_back(std::s
/*-------------------------- Quality3 ----------------------------------*/ /*-------------------------- Quality3 ----------------------------------*/
template <class A, class T> class Quality3: public T { template <class A, class T> class Quality3: public T {
public: public:
typedef vcg::Point3<A> Quality3Type; typedef vcg::Point3<A> Quality3Type;
Quality3Type &Q3() { return _quality; } Quality3Type &Q3() { return _quality; }
Quality3Type cQ3() const { return _quality; } Quality3Type cQ3() const { return _quality; }
template <class RightValueType> template <class RightValueType>
void ImportData(const RightValueType & rightT){ void ImportData(const RightValueType & rightT){
if(rightT.IsQuality3Enabled()) Q3() = rightT.cQ3(); if(rightT.IsQuality3Enabled()) Q3() = rightT.cQ3();
T::ImportData(rightT); T::ImportData(rightT);
} }
static bool HasQuality3() { return true; } static bool HasQuality3() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3"));T::Name(name);}
private: private:
Quality3Type _quality; Quality3Type _quality;
}; };
template <class T> class Quality3f: public Quality3<float, T> { template <class T> class Quality3f: public Quality3<float, T> {
@ -358,26 +359,26 @@ template <class T> class Quality3d: public Quality3<double, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3d"));T::Name(name);} public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3d"));T::Name(name);}
}; };
/*-------------------------- COLOR ----------------------------------------*/ /*-------------------------- COLOR ----------------------------------------*/
template <class A, class T> class Color: public T { template <class A, class T> class Color: public T {
public: public:
typedef A ColorType; typedef A ColorType;
Color():_color(vcg::Color4b::White) {} Color():_color(vcg::Color4b::White) {}
ColorType &C() { return _color; } ColorType &C() { return _color; }
ColorType cC() const { return _color; } ColorType cC() const { return _color; }
template <class RightValueType> template <class RightValueType>
void ImportData(const RightValueType & rightT){ void ImportData(const RightValueType & rightT){
if(rightT.IsColorEnabled()) C() = rightT.cC(); if(rightT.IsColorEnabled()) C() = rightT.cC();
T::ImportData(rightT); T::ImportData(rightT);
} }
static bool HasColor() { return true; } static bool HasColor() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
private: private:
ColorType _color; ColorType _color;
}; };
/*-------------------------- INCREMENTAL MARK ----------------------------------------*/ /*-------------------------- INCREMENTAL MARK ----------------------------------------*/
// template <class T> class EmptyMark: public T { // template <class T> class EmptyMark: public T {
// public: // public:
@ -393,26 +394,26 @@ private:
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 false; } 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 int cIMark() const {return _imark;} inline int cIMark() const {return _imark;}
template <class RightValueType> template <class RightValueType>
void ImportData(const RightValueType & rightT){ void ImportData(const RightValueType & rightT){
if(rightT.IsMarkEnabled()) IMark() = rightT.cIMark(); if(rightT.IsMarkEnabled()) IMark() = rightT.cIMark();
T::ImportData(rightT); T::ImportData(rightT);
} }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
private: private:
int _imark; int _imark;
}; };
/*----------------------------- VTADJ ------------------------------*/ /*----------------------------- VTADJ ------------------------------*/
// template <class T> class EmptyAdj: public T { // template <class T> class EmptyAdj: public T {
// public: // public:
@ -432,73 +433,73 @@ public:
template <class T> class VTAdj: public T { template <class T> class VTAdj: public T {
public: public:
VTAdj() { VTAdj() {
_vtp[0]=0; _vtp[0]=0;
_vtp[1]=0; _vtp[1]=0;
_vtp[2]=0; _vtp[2]=0;
_vtp[3]=0; _vtp[3]=0;
_vti[0]=-1; _vti[0]=-1;
_vti[1]=-1; _vti[1]=-1;
_vti[2]=-1; _vti[2]=-1;
_vti[3]=-1; _vti[3]=-1;
} }
typename T::TetraPointer & VTp( const int j ) { assert( j >= 0 && j < 4 ); return _vtp[j]; } typename T::TetraPointer & VTp( const int j ) { assert( j >= 0 && j < 4 ); return _vtp[j]; }
typename T::TetraPointer const VTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; } typename T::TetraPointer const VTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; }
typename T::TetraPointer const cVTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; } typename T::TetraPointer const cVTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; }
char & VTi( const int j ) { return _vti[j]; }
const char & cVTi( const int j ) const { return _vti[j]; }
static bool HasVTAdjacency() { return true; }
static bool HasVTAdjacencyOcc() { return false; }
static void Name( std::vector< std::string > & name ) { name.push_back( std::string("VTAdj") ); T::Name(name); }
template <class RightValueType> char & VTi( const int j ) { return _vti[j]; }
void ImportData(const RightValueType & rightT){T::ImportData(rightT);} const char & cVTi( const int j ) const { return _vti[j]; }
static bool HasVTAdjacency() { return true; }
static bool HasVTAdjacencyOcc() { return false; }
static void Name( std::vector< std::string > & name ) { name.push_back( std::string("VTAdj") ); T::Name(name); }
template <class RightValueType>
void ImportData(const RightValueType & rightT){T::ImportData(rightT);}
private: private:
typename T::TetraPointer _vtp[4]; typename T::TetraPointer _vtp[4];
char _vti[4]; char _vti[4];
}; };
/*----------------------------- TTADJ ------------------------------*/ /*----------------------------- TTADJ ------------------------------*/
template <class T> class TTAdj: public T { template <class T> class TTAdj: public T {
public: public:
TTAdj(){ TTAdj(){
_ttp[0]=0; _ttp[0]=0;
_ttp[1]=0; _ttp[1]=0;
_ttp[2]=0; _ttp[2]=0;
_ttp[3]=0; _ttp[3]=0;
} }
typename T::TetraPointer &TTp(const int j) { assert(j>=0 && j<4); return _ttp[j]; } typename T::TetraPointer &TTp(const int j) { assert(j>=0 && j<4); return _ttp[j]; }
typename T::TetraPointer const TTp(const int j) const { assert(j>=0 && j<4); return _ttp[j]; } typename T::TetraPointer const TTp(const int j) const { assert(j>=0 && j<4); return _ttp[j]; }
typename T::TetraPointer const cTTp(const int j) const { assert(j>=0 && j<4); return _ttp[j]; } typename T::TetraPointer const cTTp(const int j) const { assert(j>=0 && j<4); return _ttp[j]; }
char &TTi(const int j) { return _tti[j]; } char &TTi(const int j) { return _tti[j]; }
const char &cTTi(const int j) const { return _tti[j]; } const char &cTTi(const int j) const { return _tti[j]; }
typename T::TetraPointer &TTp1( const int j ) { return TTp((j+1)%4);} typename T::TetraPointer &TTp1( const int j ) { return TTp((j+1)%4);}
typename T::TetraPointer &TTp2( const int j ) { return TTp((j+2)%4);} typename T::TetraPointer &TTp2( const int j ) { return TTp((j+2)%4);}
typename T::TetraPointer &TTp3( const int j ) { return TTp((j+3)%4);} typename T::TetraPointer &TTp3( const int j ) { return TTp((j+3)%4);}
typename T::TetraPointer const TTp1( const int j ) const { return TTp((j+1)%4);} typename T::TetraPointer const TTp1( const int j ) const { return TTp((j+1)%4);}
typename T::TetraPointer const TTp2( const int j ) const { return TTp((j+2)%4);} typename T::TetraPointer const TTp2( const int j ) const { return TTp((j+2)%4);}
typename T::TetraPointer const TTp3( const int j ) const { return TTp((j+3)%4);} typename T::TetraPointer const TTp3( const int j ) const { return TTp((j+3)%4);}
bool IsBorderF(const int & i) const { assert( (i>=0) && (i < 4)); { return TTp(i) == this;}} bool IsBorderF(const int & i) const { assert( (i>=0) && (i < 4)); { return TTp(i) == this;}}
static bool HasTTAdjacency() { return true; } static bool HasTTAdjacency() { return true; }
static bool HasTTAdjacencyOcc() { return false; } static bool HasTTAdjacencyOcc() { return false; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("TTAdj"));T::Name(name);} static void Name(std::vector<std::string> & name){name.push_back(std::string("TTAdj"));T::Name(name);}
template <class RightValueType> template <class RightValueType>
void ImportData(const RightValueType & rightT){T::ImportData(rightT);} void ImportData(const RightValueType & rightT){T::ImportData(rightT);}
private: private:
typename T::TetraPointer _ttp[4] ; typename T::TetraPointer _ttp[4] ;
char _tti[4] ; char _tti[4] ;
}; };
} // end namespace vert } // end namespace vert
}// end namespace vcg }// end namespace vcg
#endif #endif

View File

@ -42,7 +42,53 @@ inline bool IsBorder(TetraType const & t, const int j )
return true; return true;
} }
template <class TetraMesh, class TriMesh>
inline void TriMeshFromBorder(TetraMesh & tetramesh, TriMesh & trimesh)
{
RequireTTAdjacency(tetramesh);
tri::UpdateTopology<TetraMesh>::TetraTetra(tetramesh);
trimesh.Clear();
std::vector<TriMesh::VertexPointer> verts;
std::vector<TriMesh::FacePointer> faces;
ForEachTetra(tetramesh, [&] (TetraMesh::TetraType & t) {
for (int i = 0; i < 4; ++i)
if (IsBorder(t, i))
{
verts.push_back(t.V(Tetra::VofF(i, 0)));
verts.push_back(t.V(Tetra::VofF(i, 1)));
verts.push_back(t.V(Tetra::VofF(i, 2)));
}
});
TriMesh::VertexIterator vi = tri::Allocator<TriMesh>::AddVertices(trimesh, verts.size());
TriMesh::FaceIterator fi = tri::Allocator<TriMesh>::AddFaces(trimesh, verts.size() / 3);
for (int i = 0; i < verts.size(); i += 3)
{
fi->Alloc(3);
vi->P() = verts[i + 0]->P();
fi->V(0) = &*vi;
++vi;
vi->P() = verts[i + 1]->P();
fi->V(1) = &*vi;
++vi;
vi->P() = verts[i + 2]->P();
fi->V(2) = &*vi;
++vi;
++fi;
}
tri::Clean<TriMesh>::RemoveDuplicateVertex(trimesh);
}
} }
} }
#endif #endif