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())
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);
}
}

View File

@ -44,30 +44,6 @@ added
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.
// 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).
// */
// 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>
class TetraTypeHolder: public UserTypes {
public:
template <class LeftT>
void ImportData(const LeftT & ){}
template <class RightT>
void ImportData(const RightT & ){}
static void Name(std::vector<std::string> & /* name */){}
@ -209,6 +112,7 @@ public:
BORDER1 = 0x00000080,
BORDER2 = 0x00000100,
BORDER3 = 0x00000200,
BORDER0123 = BORDER0 | BORDER1 | BORDER2 | BORDER3,
// Crease _flags, it is assumed that FEATUREi = FEATURE0<<i
// First user bit
USER0 = 0x00004000
@ -260,7 +164,7 @@ public:
void ClearV() {this->Flags() &= ~VISITED;}
/// 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
void SetB(int i) {this->Flags() |=(BORDER0<<i);}
/// 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 <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver,
template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver,
template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver,
template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver,
template <typename> class I = DefaultDeriver, template <typename> class J = 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> {
template <typename> class I = DefaultDeriver, template <typename> class J = 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> {
public: typedef AllTypes::ATetraType IAm; typedef UserTypes TypesPool;};
}// end namespace

View File

@ -8,7 +8,7 @@
* \ *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
@ -31,108 +31,108 @@ added
****************************************************************************/
#ifndef __VCG_TETRAHEDRON_PLUS_COMPONENT
#define __VCG_TETRAHEDRON_PLUS_COMPONENT
#define __VCG_TETRAHEDRON_PLUS_COMPONENT
#include <vector>
#include <vcg/space/tetra3.h>
namespace vcg {
namespace tetrahedron {
namespace tetrahedron {
/*
Some naming Rules
All the Components that can be added to a tetra should be defined in the namespace tetra:
*/
template <class T> class EmptyCore : public T {
public:
//Empty vertexref
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; }
static bool HasTVAdjacency() { return false; }
//Empty vertexref
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; }
// //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; }
static bool HasVertexRef() { return false; }
static bool HasTVAdjacency() { 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; }
// //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 HasColor() { return false; }
static bool IsColorEnabled() { return T::TetraType::HasColor(); }
// static bool HasFaceNormal() { return false; }
// static bool HasFaceNormalOcc() { return false; }
//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; }
//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 HasQuality() { return false; }
static bool HasQuality3() { return false; }
inline bool IsQualityEnabled() const { return T::TetraType::HasQuality(); }
inline bool IsQuality3Enabled() const { return T::TetraType::HasQuality3(); }
static bool HasColor() { return false; }
static bool IsColorEnabled() { return T::TetraType::HasColor(); }
//Empty flags
int &Flags() { static int dummyflags(0); assert(0); return dummyflags; }
int cFlags() const { return 0; }
//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 HasFlags() { return false; }
static bool HasFlagsOcc() { return false; }
static bool HasQuality() { 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
typedef int MarkType;
//Empty flags
int &Flags() { static int dummyflags(0); assert(0); return dummyflags; }
int cFlags() const { return 0; }
inline void InitIMark() { }
inline int & IMark() { assert(0); static int tmp=-1; return tmp;}
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; }
static bool HasFlags() { return false; }
static bool HasFlagsOcc() { return false; }
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; }
//Empty IMark
typedef int MarkType;
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; }
inline void InitIMark() { }
inline int & IMark() { assert(0); static int tmp=-1; return tmp;}
inline int cIMark() const {return 0;}
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 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 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 HasTTAdjacency() { return false; }
static bool HasTTAdjacencyOcc() { return false; }
static bool HasVTAdjacencyOcc() { return false; }
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 & ) {}
template <class 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 {
// public:
// // 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 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 {
public:
VertexRef(){
v[0]=0;
v[1]=0;
v[2]=0;
v[3]=0;
VertexRef(){
v[0]=0;
v[1]=0;
v[2]=0;
v[3]=0;
/******* vertex and faces indices scheme*********
*
/******* vertex and faces indices scheme*********
*
* /2\`
* / \ `
* / \ `
@ -164,69 +164,69 @@ public:
* / _ \ '
* / _ \ '
* /0___________1\'
*
*/
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[2][0] = 0; findices[2][1] = 2; findices[2][2] = 3;
findices[3][0] = 1; findices[3][1] = 3; findices[3][2] = 2;
}
typedef typename T::VertexType::CoordType CoordType;
typedef typename T::VertexType::ScalarType ScalarType;
*
*/
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[2][0] = 0; findices[2][1] = 2; findices[2][2] = 3;
findices[3][0] = 1; findices[3][1] = 3; findices[3][2] = 2;
}
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]; }
typedef typename T::VertexType::CoordType CoordType;
typedef typename T::VertexType::ScalarType ScalarType;
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 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(); }
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]; }
/** Return the pointer to the ((j+1)%4)-th vertex of the tetra.
@param j Index of the face vertex.
*/
inline typename T::VertexType * & V0( const int j ) { return V(j);}
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 for tetra points
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(); }
/// Shortcut to get vertex values
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(); }
/** Return the pointer to the ((j+1)%4)-th vertex of the tetra.
@param j Index of the face vertex.
*/
inline typename T::VertexType * & V0( const int j ) { return V(j);}
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);}
static bool HasVertexRef() { return true; }
static bool HasTVAdjacency() { return true; }
/// Shortcut to get vertex values
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);}
template <class RightValueType>
void ImportData(const RightValueType & rTetra) { T::ImportData(rTetra); }
static bool HasVertexRef() { return true; }
static bool HasTVAdjacency() { return true; }
private:
typename T::VertexType *v[4];
size_t findices[4][3];
static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
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);}
// private:
// NormalType _facenormals[4];
// NormalType _facenormals[4];
// };
//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>{
//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 {
// public:
// /// Return the vector of Flags(), senza effettuare controlli sui bit
@ -285,45 +285,46 @@ public:
template <class T> class BitFlags: public T {
public:
typedef int FlagType;
BitFlags(){_flags=0;}
int &Flags() {return _flags; }
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; }
typedef int FlagType;
BitFlags(){_flags=0;}
inline int &Flags() {return _flags; }
inline int cFlags() const {return _flags; }
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsQualityEnabled())
Q() = rightT.cQ();
T::ImportData(rightT);
if(RightValueType::HasFlags())
Flags() = rightT.cFlags();
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);}
static bool HasFlags() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
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> {
@ -336,19 +337,19 @@ public: static void Name(std::vector<std::string> & name){name.push_back(std::s
/*-------------------------- Quality3 ----------------------------------*/
template <class A, class T> class Quality3: public T {
public:
typedef vcg::Point3<A> Quality3Type;
Quality3Type &Q3() { return _quality; }
Quality3Type cQ3() const { return _quality; }
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsQuality3Enabled()) Q3() = rightT.cQ3();
T::ImportData(rightT);
}
typedef vcg::Point3<A> Quality3Type;
Quality3Type &Q3() { return _quality; }
Quality3Type cQ3() const { return _quality; }
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsQuality3Enabled()) Q3() = rightT.cQ3();
T::ImportData(rightT);
}
static bool HasQuality3() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3"));T::Name(name);}
static bool HasQuality3() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3"));T::Name(name);}
private:
Quality3Type _quality;
Quality3Type _quality;
};
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);}
};
/*-------------------------- COLOR ----------------------------------------*/
/*-------------------------- COLOR ----------------------------------------*/
template <class A, class T> class Color: public T {
public:
typedef A ColorType;
Color():_color(vcg::Color4b::White) {}
ColorType &C() { return _color; }
ColorType cC() const { return _color; }
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsColorEnabled()) C() = rightT.cC();
T::ImportData(rightT);
}
typedef A ColorType;
Color():_color(vcg::Color4b::White) {}
ColorType &C() { return _color; }
ColorType cC() const { return _color; }
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsColorEnabled()) C() = rightT.cC();
T::ImportData(rightT);
}
static bool HasColor() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
static bool HasColor() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
private:
ColorType _color;
ColorType _color;
};
/*-------------------------- INCREMENTAL MARK ----------------------------------------*/
/*-------------------------- INCREMENTAL MARK ----------------------------------------*/
// template <class T> class EmptyMark: public T {
// public:
@ -393,26 +394,26 @@ private:
template <class T> class Mark: public T {
public:
static bool HasMark() { return true; }
static bool HasMarkOcc() { return false; }
inline void InitIMark() { _imark = 0; }
inline int & IMark() { return _imark;}
inline int cIMark() const {return _imark;}
static bool HasMark() { return true; }
static bool HasMarkOcc() { return false; }
inline void InitIMark() { _imark = 0; }
inline int & IMark() { return _imark;}
inline int cIMark() const {return _imark;}
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsMarkEnabled()) IMark() = rightT.cIMark();
T::ImportData(rightT);
}
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsMarkEnabled()) IMark() = rightT.cIMark();
T::ImportData(rightT);
}
static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
private:
int _imark;
static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
private:
int _imark;
};
/*----------------------------- VTADJ ------------------------------*/
/*----------------------------- VTADJ ------------------------------*/
// template <class T> class EmptyAdj: public T {
// public:
@ -432,73 +433,73 @@ public:
template <class T> class VTAdj: public T {
public:
VTAdj() {
_vtp[0]=0;
_vtp[1]=0;
_vtp[2]=0;
_vtp[3]=0;
_vti[0]=-1;
_vti[1]=-1;
_vti[2]=-1;
_vti[3]=-1;
}
VTAdj() {
_vtp[0]=0;
_vtp[1]=0;
_vtp[2]=0;
_vtp[3]=0;
_vti[0]=-1;
_vti[1]=-1;
_vti[2]=-1;
_vti[3]=-1;
}
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 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); }
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 cVTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; }
template <class RightValueType>
void ImportData(const RightValueType & rightT){T::ImportData(rightT);}
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>
void ImportData(const RightValueType & rightT){T::ImportData(rightT);}
private:
typename T::TetraPointer _vtp[4];
char _vti[4];
typename T::TetraPointer _vtp[4];
char _vti[4];
};
/*----------------------------- TTADJ ------------------------------*/
/*----------------------------- TTADJ ------------------------------*/
template <class T> class TTAdj: public T {
public:
TTAdj(){
_ttp[0]=0;
_ttp[1]=0;
_ttp[2]=0;
_ttp[3]=0;
}
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 cTTp(const int j) const { assert(j>=0 && j<4); return _ttp[j]; }
char &TTi(const int j) { return _tti[j]; }
const char &cTTi(const int j) const { return _tti[j]; }
TTAdj(){
_ttp[0]=0;
_ttp[1]=0;
_ttp[2]=0;
_ttp[3]=0;
}
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 cTTp(const int j) const { assert(j>=0 && j<4); return _ttp[j]; }
char &TTi(const int j) { 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 &TTp2( const int j ) { return TTp((j+2)%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 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 &TTp1( const int j ) { return TTp((j+1)%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 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 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 HasTTAdjacencyOcc() { return false; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("TTAdj"));T::Name(name);}
static bool HasTTAdjacency() { return true; }
static bool HasTTAdjacencyOcc() { return false; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("TTAdj"));T::Name(name);}
template <class RightValueType>
void ImportData(const RightValueType & rightT){T::ImportData(rightT);}
template <class RightValueType>
void ImportData(const RightValueType & rightT){T::ImportData(rightT);}
private:
typename T::TetraPointer _ttp[4] ;
char _tti[4] ;
typename T::TetraPointer _ttp[4] ;
char _tti[4] ;
};
} // end namespace vert
} // end namespace vert
}// end namespace vcg
#endif

View File

@ -42,7 +42,53 @@ inline bool IsBorder(TetraType const & t, const int j )
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