Disambiguated the origin of the ScalarType and CoordType in the simplex class. Now it derives from the type specified by the vertexRef component for the faces and from the Coord component for the vertexes. To be sure the ScalarType and CoordTypes are initialized to weird point3<bool> and char just to detect easisly when the wrong types shallow...

This commit is contained in:
Paolo Cignoni 2010-03-18 10:02:32 +00:00
parent 2a1aebfa3d
commit 63e21f15cb
5 changed files with 60 additions and 57 deletions

View File

@ -62,7 +62,7 @@ namespace tri {
typedef typename MeshType::FaceType FaceType;
typedef typename MeshType::FacePointer FacePointer;
typedef typename MeshType::FaceIterator FaceIterator;
typedef typename MeshType::FaceType::ScalarType ScalarType;
typedef typename MeshType::FaceType::CoordType::ScalarType ScalarType;
static void Set(FaceType &f)
{

View File

@ -151,8 +151,11 @@ template < class UserTypes,
template <typename> class I, template <typename> class J >
class FaceArityMax: public J<Arity9<FaceBase<UserTypes>, A, B, C, D, E, F, G, H, I> > {
// ----- Flags stuff -----
public:
typedef typename J<Arity9<FaceBase<UserTypes>, A, B, C, D, E, F, G, H, I> >::ScalarType ParentScalarType;
typedef J<Arity9<FaceBase<UserTypes>, A, B, C, D, E, F, G, H, I> > ParentType;
// ----- Flags stuff -----
inline int & UberFlags ()
{
@ -284,24 +287,21 @@ static int &LastBitFlag()
/// This function clear the given user bit
void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
template<class BoxType>
void GetBBox( BoxType & bb ) const
void GetBBox(Box3<typename ParentType::ScalarType>& bb )
{
if(this->IsD())
{
bb.SetNull();
return;
}
bb.Set(this->P(0));
bb.Add(this->P(1));
bb.Add(this->P(2));
if(this->IsD()) {
bb.SetNull();
return;
}
bb.Set(this->cP(0));
bb.Add(this->cP(1));
bb.Add(this->cP(2));
}
};
template < typename T=int>
class FaceDefaultDeriver : public T {};
/*
@ -338,11 +338,11 @@ FFAdj //topology: face face adj
*/
template <class UserTypes,
template <typename> class A = FaceDefaultDeriver, template <typename> class B = FaceDefaultDeriver,
template <typename> class C = FaceDefaultDeriver, template <typename> class D = FaceDefaultDeriver,
template <typename> class E = FaceDefaultDeriver, template <typename> class F = FaceDefaultDeriver,
template <typename> class G = FaceDefaultDeriver, template <typename> class H = FaceDefaultDeriver,
template <typename> class I = FaceDefaultDeriver, template <typename> class J = FaceDefaultDeriver >
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 >
class Face: public FaceArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J> {};

View File

@ -115,12 +115,12 @@ 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 * 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; }
inline typename T::VertexType * & V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * const & V( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * cV( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::CoordType & P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
inline const typename T::CoordType & P( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
inline const typename T::CoordType &cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
template <class RightF>
void ImportLocal(const RightF & rightF) {T::ImportLocal(rightF);}
inline void Alloc(const int & ns){T::Alloc(ns);}
@ -137,38 +137,41 @@ public:
v[2]=0;
}
typedef typename T::VertexType::CoordType CoordType;
typedef typename T::VertexType::ScalarType ScalarType;
inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<3); return v[j]; }
inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<3); return v[j]; }
inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3); return v[j]; }
// Shortcut per accedere ai punti delle facce
inline typename T::CoordType & P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); }
inline const typename T::CoordType & P( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); }
inline const typename T::CoordType &cP( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); }
inline CoordType & P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); }
inline const CoordType & P( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); }
inline const CoordType &cP( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); }
/** Return the pointer to the ((j+1)%3)-th vertex of the face.
@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)%3);}
inline typename T::VertexType * & V2( const int j ) { return V((j+2)%3);}
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)%3);}
inline const typename T::VertexType * const & V2( const int j ) const { return V((j+2)%3);}
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)%3);}
inline const typename T::VertexType * const & cV2( const int j ) const { return cV((j+2)%3);}
inline typename T::VertexType * & V0( const int j ) { return V(j);}
inline typename T::VertexType * & V1( const int j ) { return V((j+1)%3);}
inline typename T::VertexType * & V2( const int j ) { return V((j+2)%3);}
inline typename T::VertexType * const V0( const int j ) const { return V(j);}
inline typename T::VertexType * const V1( const int j ) const { return V((j+1)%3);}
inline typename T::VertexType * const V2( const int j ) const { return V((j+2)%3);}
inline typename T::VertexType * cV0( const int j ) const { return cV(j);}
inline typename T::VertexType * cV1( const int j ) const { return cV((j+1)%3);}
inline typename T::VertexType * cV2( const int j ) const { return cV((j+2)%3);}
/// Shortcut per accedere ai punti delle facce
inline typename T::CoordType & P0( const int j ) { return V(j)->P();}
inline typename T::CoordType & P1( const int j ) { return V((j+1)%3)->P();}
inline typename T::CoordType & P2( const int j ) { return V((j+2)%3)->P();}
inline const typename T::CoordType & P0( const int j ) const { return V(j)->P();}
inline const typename T::CoordType & P1( const int j ) const { return V((j+1)%3)->P();}
inline const typename T::CoordType & P2( const int j ) const { return V((j+2)%3)->P();}
inline const typename T::CoordType & cP0( const int j ) const { return cV(j)->P();}
inline const typename T::CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();}
inline const typename T::CoordType & cP2( const int j ) const { return cV((j+2)%3)->P();}
inline CoordType & P0( const int j ) { return V(j)->P();}
inline CoordType & P1( const int j ) { return V((j+1)%3)->P();}
inline CoordType & P2( const int j ) { return V((j+2)%3)->P();}
inline const CoordType & P0( const int j ) const { return V(j)->P();}
inline const CoordType & P1( const int j ) const { return V((j+1)%3)->P();}
inline const CoordType & P2( const int j ) const { return V((j+2)%3)->P();}
inline const CoordType & cP0( const int j ) const { return cV(j)->P();}
inline const CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();}
inline const CoordType & cP2( const int j ) const { return cV((j+2)%3)->P();}
inline typename T::VertexType * & UberV( const int j ) { assert(j>=0 && j<3); return v[j]; }
inline const typename T::VertexType * const & UberV( const int j ) const { assert(j>=0 && j<3); return v[j]; }

View File

@ -183,13 +183,13 @@ public:
class WedgeColorTypePack {
public:
WedgeColorTypePack() {
typedef typename VALUE_TYPE::ColorType::ScalarType ScalarType;
typedef typename VALUE_TYPE::ColorType::ScalarType WedgeColorScalarType;
for (int i=0; i<3; ++i)
{
wc[i][0] = ScalarType(255);
wc[i][1] = ScalarType(255);
wc[i][2] = ScalarType(255);
wc[i][3] = ScalarType(255);
wc[i][0] = WedgeColorScalarType(255);
wc[i][1] = WedgeColorScalarType(255);
wc[i][2] = WedgeColorScalarType(255);
wc[i][3] = WedgeColorScalarType(255);
}
}
@ -199,12 +199,12 @@ public:
class WedgeNormalTypePack {
public:
WedgeNormalTypePack() {
typedef typename VALUE_TYPE::NormalType::ScalarType ScalarType;
typedef typename VALUE_TYPE::NormalType::ScalarType WedgeNormalScalarType;
for (int i=0; i<3; ++i)
{
wn[i][0] = ScalarType(0);
wn[i][1] = ScalarType(0);
wn[i][2] = ScalarType(1);
wn[i][0] = WedgeNormalScalarType(0);
wn[i][1] = WedgeNormalScalarType(0);
wn[i][2] = WedgeNormalScalarType(1);
}
}

View File

@ -182,7 +182,7 @@ public:
template <class A, class T> class Coord: public T {
public:
typedef A CoordType;
typedef typename CoordType::ScalarType ScalarType;
typedef typename A::ScalarType ScalarType;
CoordType &P() { return _coord; }
const CoordType &P() const { return _coord; }
const CoordType &cP() const { return _coord; }