[EDGE SUPPORT]

Added default template to TriMesh to include the edges.
Added peredge attributes.
These modification do not require any change to the code using TriMesh, but it allows
to specify a real type of edge in case you want to use it.
This commit is contained in:
ganovelli 2008-11-12 15:51:01 +00:00
parent 1aa88e635b
commit e37cca54a3
1 changed files with 69 additions and 38 deletions

View File

@ -141,7 +141,7 @@ Initial commit
#include <vcg/math/shot.h> #include <vcg/math/shot.h>
#include <vcg/container/simple_temporary_data.h> #include <vcg/container/simple_temporary_data.h>
#include <vcg/simplex/edgeplus/base.h>
/* /*
People should subclass his vertex class from these one... People should subclass his vertex class from these one...
*/ */
@ -159,34 +159,48 @@ namespace tri {
@param VertContainerType (Template Parameter) Specifies the type of the vertices container any the vertex type. @param VertContainerType (Template Parameter) Specifies the type of the vertices container any the vertex type.
@param FaceContainerType (Template Parameter) Specifies the type of the faces container any the face type. @param FaceContainerType (Template Parameter) Specifies the type of the faces container any the face type.
*/ */
template < class VertContainerType, class FaceContainerType >
template < class VertContainerType, class FaceContainerType,
class EdgeContainerType = std::vector<vcg::EdgeSimp2<typename VertContainerType::value_type,typename,typename FaceContainerType::value_type> >
>
class TriMesh{ class TriMesh{
public: public:
typedef TriMesh<VertContainerType, FaceContainerType> MeshType; typedef TriMesh<VertContainerType, FaceContainerType> MeshType;
typedef FaceContainerType FaceContainer; typedef FaceContainerType FaceContainer;
typedef VertContainerType VertContainer; typedef VertContainerType VertContainer;
typedef EdgeContainerType EdgeContainer;
typedef typename VertContainer::value_type VertexType; typedef typename VertContainer::value_type VertexType;
typedef typename FaceContainer::value_type FaceType; typedef typename FaceContainer::value_type FaceType;
typedef typename EdgeContainer::value_type EdgeType;
typedef typename VertexType::ScalarType ScalarType; typedef typename VertexType::ScalarType ScalarType;
typedef typename VertexType::CoordType CoordType; typedef typename VertexType::CoordType CoordType;
typedef typename VertContainer::iterator VertexIterator; typedef typename VertContainer::iterator VertexIterator;
typedef typename FaceContainer::iterator FaceIterator; typedef typename FaceContainer::iterator FaceIterator;
typedef typename EdgeContainer::iterator EdgeIterator;
typedef typename VertContainer::const_iterator ConstVertexIterator; typedef typename VertContainer::const_iterator ConstVertexIterator;
typedef typename FaceContainer::const_iterator ConstFaceIterator; typedef typename FaceContainer::const_iterator ConstFaceIterator;
typedef typename EdgeContainer::const_iterator ConstEdgeIterator;
typedef VertexType * VertexPointer; typedef VertexType * VertexPointer;
typedef const VertexType * ConstVertexPointer; typedef const VertexType * ConstVertexPointer;
typedef FaceType * FacePointer; typedef FaceType * FacePointer;
typedef const FaceType * ConstFacePointer; typedef const FaceType * ConstFacePointer;
typedef EdgeType * EdgePointer;
typedef const EdgeType * ConstEdgePointer;
typedef Box3<ScalarType> BoxType; typedef Box3<ScalarType> BoxType;
/// Set of vertices /// Set of vertices
VertContainer vert; VertContainer vert;
/// Real number of vertices /// Actual number of vertices
int vn; int vn;
/// Set of faces /// Set of faces
FaceContainer face; FaceContainer face;
/// Real number of faces /// Actual number of faces
int fn; int fn;
/// Set of edges
EdgeContainer edge;
/// Actual number of faces
int en;
/// Bounding box of the mesh /// Bounding box of the mesh
Box3<ScalarType> bbox; Box3<ScalarType> bbox;
@ -224,6 +238,16 @@ class TriMesh{
ATTR_TYPE & operator [](const RefType & i){return (*_handle)[i];} ATTR_TYPE & operator [](const RefType & i){return (*_handle)[i];}
}; };
template <class ATTR_TYPE>
class PerEdgeAttributeHandle{
public:
PerEdgeAttributeHandle(){}
PerEdgeAttributeHandle(void *ah):_handle ( (SimpleTempData<EdgeContainer,ATTR_TYPE> *)ah ){}
SimpleTempData<EdgeContainer,ATTR_TYPE> * _handle;
template <class RefType>
ATTR_TYPE & operator [](const RefType & i){return (*(SimpleTempData<EdgeContainer,ATTR_TYPE>*)_handle)[i];}
};
template <class ATTR_TYPE> template <class ATTR_TYPE>
class PerMeshAttributeHandle{ class PerMeshAttributeHandle{
public: public:
@ -234,6 +258,7 @@ class TriMesh{
}; };
std::set< HandlesWrapper > vert_attr; std::set< HandlesWrapper > vert_attr;
std::set< HandlesWrapper > edge_attr;
std::set< HandlesWrapper > face_attr; std::set< HandlesWrapper > face_attr;
std::set< HandlesWrapper > mesh_attr; std::set< HandlesWrapper > mesh_attr;
@ -422,56 +447,62 @@ private:
}; // end class Mesh }; // end class Mesh
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType , class EdgeContainerType>
bool HasPerVertexQuality (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return VertContainerType::value_type::HasQuality();} bool HasPerVertexQuality (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return VertContainerType::value_type::HasQuality();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerVertexCurvature (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return VertContainerType::value_type::HasCurvature();} bool HasPerVertexCurvature (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return VertContainerType::value_type::HasCurvature();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType , class EdgeContainerType>
bool HasPerVertexCurvatureDir (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return VertContainerType::value_type::HasCurvatureDir();} bool HasPerVertexCurvatureDir (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return VertContainerType::value_type::HasCurvatureDir();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType , class EdgeContainerType>
bool HasPerVertexColor (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return VertContainerType::value_type::HasColor();} bool HasPerVertexColor (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return VertContainerType::value_type::HasColor();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerVertexTexCoord (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return VertContainerType::value_type::HasTexCoord();} bool HasPerVertexTexCoord (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return VertContainerType::value_type::HasTexCoord();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerVertexFlags (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return VertContainerType::value_type::HasFlags();} bool HasPerVertexFlags (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return VertContainerType::value_type::HasFlags();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerVertexNormal (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return VertContainerType::value_type::HasNormal();} bool HasPerVertexNormal (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return VertContainerType::value_type::HasNormal();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerWedgeTexCoord (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return FaceContainerType::value_type::HasWedgeTexCoord();} bool HasPerWedgeTexCoord (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return FaceContainerType::value_type::HasWedgeTexCoord();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerWedgeNormal (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return FaceContainerType::value_type::HasWedgeNormal();} bool HasPerWedgeNormal (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return FaceContainerType::value_type::HasWedgeNormal();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerWedgeColor (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return FaceContainerType::value_type::HasWedgeColor();} bool HasPerWedgeColor (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return FaceContainerType::value_type::HasWedgeColor();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerFaceFlags (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return FaceContainerType::value_type::HasFlags();} bool HasPerFaceFlags (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return FaceContainerType::value_type::HasFlags();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerFaceNormal (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return FaceContainerType::value_type::HasFaceNormal();} bool HasPerFaceNormal (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return FaceContainerType::value_type::HasFaceNormal();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerFaceColor (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return FaceContainerType::value_type::HasFaceColor();} bool HasPerFaceColor (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return FaceContainerType::value_type::HasFaceColor();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerFaceMark (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return FaceContainerType::value_type::HasMark();} bool HasPerFaceMark (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return FaceContainerType::value_type::HasMark();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasPerFaceQuality (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return FaceContainerType::value_type::HasFaceQuality();} bool HasPerFaceQuality (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return FaceContainerType::value_type::HasFaceQuality();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasFFAdjacency (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) {return FaceContainerType::value_type::HasFFAdjacency();} bool HasFFAdjacency (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return FaceContainerType::value_type::HasFFAdjacency();}
template < class VertContainerType, class FaceContainerType > template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasVFAdjacency (const TriMesh < VertContainerType , FaceContainerType> & /*m*/) { bool HasFVAdjacency (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return FaceContainerType::value_type::HasFVAdjacency();}
template < class VertContainerType, class FaceContainerType, class EdgeContainerType >
bool HasEFAdjacency (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {return EdgeContainerType::value_type::HasEFAdjacency();}
template < class VertContainerType, class FaceContainerType , class EdgeContainerType>
bool HasVFAdjacency (const TriMesh < VertContainerType , FaceContainerType, EdgeContainerType> & /*m*/) {
assert(FaceContainerType::value_type::HasVFAdjacency() == VertContainerType::value_type::HasVFAdjacency()); assert(FaceContainerType::value_type::HasVFAdjacency() == VertContainerType::value_type::HasVFAdjacency());
return FaceContainerType::value_type::HasVFAdjacency(); return FaceContainerType::value_type::HasVFAdjacency();
} }