CMeshO数据结构1
CMeshO是meshlab中存储mesh数据的类,继承自vcg中的类
class CMeshO : public vcg::tri::TriMesh< vcg::vertex::vector_ocf<CVertexO>, vcg::face::vector_ocf<CFaceO> >
{
public :
int sfn; //The number of selected faces.
int svn; //The number of selected vertices.
vcg::Matrix44f Tr; // Usually it is the identity. It is applied in rendering and filters can or cannot use it. (most of the filter will ignore this)
const vcg::Box3f &trBB()
{
static vcg::Box3f bb;
bb.SetNull();
bb.Add(Tr,bbox);
return bb;
}
};
主要分析基类vcg::tri::TriMesh
设T1=vcg::vertex::vector_ocf<CVertexO>
T2=vcg::face::vector_ocf<CFaceO>
X=BaseMeshTypeHolder<typename T1::value_type::TypesPool>
class TriMesh
: public MArity4< X, T1, Der ,T2, Der, Container2, Der, Container3, Der>
大致继承关系如下
TriMesh:MArity4<X, T1, Der ,T2, Der, Container2, Der, Container3, Der>: 13
Der<MArity3<X, T1, Der ,T2, Der, Container2, Der>,Container3>: 12
MeshTypeHolder<T,Container3, Container3::value_type::IAm>: 11
MArity3<X, T1, Der ,T2, Der, Container2, Der>: 10
Der<MArity2<X, T1, Der ,T2, Der>,Container2>: 9
MeshTypeHolder<T,Container2, Container2::value_type::IAm>: 8
MArity2<X, T1, Der ,T2, Der>: 7
Der<MArity1<X, T1, Der>,T2>: 6
MeshTypeHolder<T,T2, T2::value_type::IAm>: 5
MArity1<X, T1, Der>: 4
Der<X, T1>: 3
MeshTypeHolder<X,T1, T1::value_type::IAm>: 2
BaseMeshTypeHolder<typename T1::value_type::TypesPool> 1
从1开始分析,这是最底层的基类
template <class TYPESPOOL>
struct BaseMeshTypeHolder
定义了与TYPESPOOL相关的一些类型,此时
TYPESPOOL=vcg::vertex::vector_ocf<CVertexO>::value_type::TypesPool
也就是CVertexO::TypesPool,对于CVertexO之后分析
接着是第二行MeshTypeHolder
MeshTypeHolder<X,T1, T1::value_type::IAm>,对应特化模板类:
template <class T, typename CONT>
struct MeshTypeHolder<T, CONT, AllTypes::AVertexType>: public T
定义了一些vector_ocf<CVertexO>相关的类型
第五行对应特化模板类:
template <typename T, class CONT>
struct MeshTypeHolder< T, CONT, AllTypes::AFaceType>:public T
定义了一些vector_ocf<CFaceO>相关的类型
第八行和第十一行,因为Container3与Container4都对应默认的参数
struct DummyContainer{struct value_type{ typedef int IAm;}; };
所以MeshTypeHolder对应一般模板类
template <class T, typename CONT, class TRAIT >
struct MeshTypeHolder: public T {};
也就是空类
总的来说,参数vcg::vertex::vector_ocf<CVertexO>
与vcg::face::vector_ocf<CFaceO>
覆盖了基类BaseMeshTypeHolder中对于顶点容器与面容器的一些类型定义,而CVertexO::TypesPool则决定了顶点、面、边、HEdge的具体类型