From ae83ca17eddcedcb7a7cafc809ebdd309f08101d Mon Sep 17 00:00:00 2001 From: ganovelli Date: Mon, 15 Mar 2010 10:44:40 +0000 Subject: [PATCH] [ Changes in definition of TriMesh: PART I ] Note for the developers: the change to make to existing projects is very little but strictly necessary to compile. This change IS NOT backward compliant. ==== OLD ==== way to define a TriMesh: // forward declarations class MyVertex; class MyEdge; class MyFace; class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{}; class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{}; class MyMesh: public TriMesh,vector >{}; ==== NEW ==== way to define a TriMesh: // forward declarations class MyVertex; class MyEdge; class MyFace; // declaration of which types is used as VertexType, which type is used as FaceType and so on... class MyUsedTypes: public vcg::UsedType < vcg::Use::AsVertexType, vcg::Use::AsFaceType>{}; class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{}; class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{}; class MyMesh: public TriMesh,vector >{}; ===== classes introduced [vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So ::AsVertexType, vcg::Use::AsEdgeType, vcg::Use::AsFaceType>{}; is the same as: class MyUsedTypes: public vcg::UsedType ::AsFaceType, vcg::Use::AsEdgeType, vcg::Use::AsVertexType>{}; Note 3: you only need to specify the type you use. If you do not have edges you do not need to include vcg::Use::AsEdgeType in the template list of UsedTypes. ==== the Part II will be a tiny change to the class TriMesh it self. --- .../aabb_binary_tree/aabb_binary_tree.cpp | 10 +++- apps/sample/polygonmesh_base/polygonmesh.cpp | 23 +++++--- apps/sample/trimesh_QT/glarea.h | 11 +++- apps/sample/trimesh_SDL/trimesh_sdl.cpp | 11 ++-- .../trimesh_attribute/trimesh_attribute.cpp | 10 +++- .../trimesh_ball_pivoting.cpp | 8 ++- apps/sample/trimesh_base/trimesh_base.cpp | 50 ++++++++++------- .../trimesh_clustering/trimesh_clustering.cpp | 8 ++- apps/sample/trimesh_hole/trimesh_hole.cpp | 9 ++- .../trimesh_intersection.cpp | 13 ++++- .../trimesh_isosurface/trimesh_isosurface.cpp | 9 ++- apps/sample/trimesh_join/trimesh_join.cpp | 8 ++- .../trimesh_optional/trimesh_optional.cpp | 56 ++++++------------- apps/sample/trimesh_refine/trimesh_refine.cpp | 9 ++- apps/sample/trimesh_smooth/trimesh_smooth.cpp | 7 ++- .../trimesh_split_vertex.cpp | 32 +++++++---- .../trimesh_topology/trimesh_topology.cpp | 8 ++- 17 files changed, 162 insertions(+), 120 deletions(-) diff --git a/apps/sample/aabb_binary_tree/aabb_binary_tree.cpp b/apps/sample/aabb_binary_tree/aabb_binary_tree.cpp index d4bf5c85..e5fdfc9e 100644 --- a/apps/sample/aabb_binary_tree/aabb_binary_tree.cpp +++ b/apps/sample/aabb_binary_tree/aabb_binary_tree.cpp @@ -25,10 +25,14 @@ typedef float AScalarType; using namespace vcg; -class AEdge; +class AVertex; class AFace; -class AVertex : public VertexSimp2< AVertex, AEdge, AFace, vertex::Normal3f, vertex::Coord3f,vertex::BitFlags >{}; -class AFace : public FaceSimp2< AVertex, AEdge, AFace, face::VertexRef, face::Normal3f, face::EdgePlane, face::BitFlags> {}; + +struct MyUsedTypes : public vcg::UsedTypes< vcg::Use ::AsVertexType, + vcg::Use ::AsFaceType>{}; + +class AVertex : public Vertex< MyUsedTypes, vertex::Normal3f, vertex::Coord3f,vertex::BitFlags >{}; +class AFace : public Face< MyUsedTypes, face::VertexRef, face::Normal3f, face::EdgePlane, face::BitFlags> {}; //class AVertex : public vcg::Vertex< AScalarType, AEdge, AFace > { }; //class AFace : public vcg::FaceRTFMFN< AVertex, AEdge, AFace > { }; diff --git a/apps/sample/polygonmesh_base/polygonmesh.cpp b/apps/sample/polygonmesh_base/polygonmesh.cpp index 5a760c80..05377866 100644 --- a/apps/sample/polygonmesh_base/polygonmesh.cpp +++ b/apps/sample/polygonmesh_base/polygonmesh.cpp @@ -69,15 +69,19 @@ class CEdge; class DummyEdge; class MyPolyVertex; +struct CUsedTypes: public vcg::UsedTypes< vcg::Use::AsVertexType, vcg::Use::AsFaceType >{}; + + + /* Definition of a mesh of triangles */ -class CVertex : public VertexSimp2< CVertex, DummyEdge, CFace, +class CVertex : public Vertex< CUsedTypes, vertex::BitFlags, vertex::Coord3f, vertex::Normal3f, vertex::Mark >{}; -class CFace : public FaceSimp2< CVertex, DummyEdge, CFace, +class CFace : public Face< CUsedTypes, face::VertexRef, // three pointers to vertices face::Normal3f, // normal face::BitFlags, // flags @@ -91,15 +95,20 @@ class CMesh : public vcg::tri::TriMesh< vector, vector > {}; /* Definition of a mesh of polygons that also supports half-edges */ class MyPolyFace; +class MyPolyVertex; +struct PolyUsedTypes: public vcg::UsedTypes< vcg::Use::AsVertexType, + vcg::Use::AsEdgeType, + vcg::Use::AsFaceType >{}; -class MyPolyVertex:public vcg::VertexSimp2{} ; -class CEdge : public EdgeSimp2< MyPolyVertex, CEdge, MyPolyFace, edge::BitFlags, +class CEdge : public Edge< PolyUsedTypes, edge::BitFlags, //edge::EFAdj, // pointer to the face //edge::HEOppAdj, // pointer to the opposite edge //edge::HEVAdj, // pointer to the vertex @@ -108,10 +117,8 @@ class CEdge : public EdgeSimp2< MyPolyVertex, CEdge, MyPolyFace, edge::BitFlags, //,edge::HEPrevAdj // pointer to the previous halfedge >{}; -class MyPolyFace:public vcg::FaceSimp2< - MyPolyVertex - ,CEdge - ,MyPolyFace +class MyPolyFace:public vcg::Face< + PolyUsedTypes ,vcg::face::PolyInfo // this is necessary if you use component in vcg/simplex/face/component_polygon.h // It says "this class is a polygon and the memory for its components (e.g. pointer to its vertices // will be allocated dynamically") diff --git a/apps/sample/trimesh_QT/glarea.h b/apps/sample/trimesh_QT/glarea.h index 1f641946..e174ec51 100644 --- a/apps/sample/trimesh_QT/glarea.h +++ b/apps/sample/trimesh_QT/glarea.h @@ -51,12 +51,17 @@ Initial release. #include /// declaring edge and face type -class CEdge; + +using namespace vcg; class CFace; +class CVertex; + +struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, + Use ::AsFaceType>{}; /// compositing wanted proprieties -class CVertex : public vcg::VertexSimp2< CVertex, CEdge, CFace, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags>{}; -class CFace : public vcg::FaceSimp2< CVertex, CEdge, CFace, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::BitFlags > {}; +class CVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags>{}; +class CFace : public vcg::Face< MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::BitFlags > {}; class CMesh : public vcg::tri::TriMesh< std::vector, std::vector > {}; class GLArea:public QGLWidget diff --git a/apps/sample/trimesh_SDL/trimesh_sdl.cpp b/apps/sample/trimesh_SDL/trimesh_sdl.cpp index 763b3d10..babee31a 100644 --- a/apps/sample/trimesh_SDL/trimesh_sdl.cpp +++ b/apps/sample/trimesh_SDL/trimesh_sdl.cpp @@ -39,7 +39,7 @@ Initial Relase ****************************************************************************/ #include -#include +#include #include /*include the base definition for the vertex */ @@ -69,16 +69,19 @@ otherwise you'll get linking errors */ using namespace vcg; using namespace std; -class CEdge; // dummy prototype never used + class CFace; +class CVertex; +struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, + Use ::AsFaceType>{}; /* define a vertex passing the attributes you want it to have. Each attributes has its own class. Check vcg/simplex/vertex/component.h to find out the existing attributes. Note: then you could also personalized attributes */ -class CVertex : public VertexSimp2< CVertex, CEdge, CFace, vertex::Coord3f, vertex::Normal3f >{}; +class CVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::Normal3f >{}; /*same as for the vertes */ -class CFace : public FaceSimp2< CVertex, CEdge, CFace, face::VertexRef, face::Normal3f > {}; +class CFace : public Face< MyUsedTypes, face::VertexRef, face::Normal3f > {}; /*the mesh is a container of vertices and a container of faces */ class CMesh : public vcg::tri::TriMesh< vector, vector > {}; diff --git a/apps/sample/trimesh_attribute/trimesh_attribute.cpp b/apps/sample/trimesh_attribute/trimesh_attribute.cpp index 71f1ba86..f0f781e4 100644 --- a/apps/sample/trimesh_attribute/trimesh_attribute.cpp +++ b/apps/sample/trimesh_attribute/trimesh_attribute.cpp @@ -6,11 +6,15 @@ #include #include + +class MyEdge; class MyFace; class MyVertex; -class MyEdge; // dummy prototype never used -class MyVertex : public vcg::VertexSimp2< MyVertex, MyEdge, MyFace, vcg::vertex::Coord3f,vcg::vertex::Normal3f>{}; -class MyFace : public vcg::FaceSimp2< MyVertex, MyEdge, MyFace, vcg::face::VertexRef, vcg::face::Normal3f> {}; +struct MyUsedTypes : public vcg::UsedTypes< vcg::Use ::AsVertexType, + vcg::Use ::AsFaceType>{}; + +class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f,vcg::vertex::Normal3f>{}; +class MyFace : public vcg::Face< MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f> {}; class MyMesh : public vcg::tri::TriMesh< std::vector, std::vector > {}; diff --git a/apps/sample/trimesh_ball_pivoting/trimesh_ball_pivoting.cpp b/apps/sample/trimesh_ball_pivoting/trimesh_ball_pivoting.cpp index 69b4df00..4497b07b 100644 --- a/apps/sample/trimesh_ball_pivoting/trimesh_ball_pivoting.cpp +++ b/apps/sample/trimesh_ball_pivoting/trimesh_ball_pivoting.cpp @@ -28,12 +28,14 @@ using namespace vcg; using namespace std; -class MyEdge; // dummy prototype never used class MyFace; class MyVertex; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags, vertex::Mark>{}; -class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef, face::Normal3f, face::BitFlags > {}; +struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, + Use ::AsFaceType>{}; + +class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags, vertex::Mark>{}; +class MyFace : public Face < MyUsedTypes, face::VertexRef, face::Normal3f, face::BitFlags > {}; class MyMesh : public vcg::tri::TriMesh< vector, vector > {}; bool callback(int percent, const char *str) { diff --git a/apps/sample/trimesh_base/trimesh_base.cpp b/apps/sample/trimesh_base/trimesh_base.cpp index 7f8976a7..d44ab0c0 100644 --- a/apps/sample/trimesh_base/trimesh_base.cpp +++ b/apps/sample/trimesh_base/trimesh_base.cpp @@ -23,8 +23,12 @@ #include #include + +#include + #include #include + #include #include @@ -36,40 +40,44 @@ #include // normals -#include //class UpdateNormals +#include //class UpdateNormals using namespace vcg; using namespace std; -class MyEdge; // dummy prototype +class MyEdge; class MyFace; class MyVertex; +struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, + Use ::AsEdgeType, + Use ::AsFaceType>{}; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{}; -class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::FFAdj, face::VertexRef, face::BitFlags > {}; -class MyMesh : public vcg::tri::TriMesh< vector, vector > {}; +class MyVertex : public Vertex{}; +class MyFace : public Face< MyUsedTypes, face::FFAdj, face::VertexRef, face::BitFlags > {}; +class MyEdge : public Edge{}; +class MyMesh : public vcg::tri::TriMesh< vector, vector , vector > {}; int main( int argc, char **argv ) { - if(argc<2) - { - printf("Usage trimesh_base \n"); - return -1; - } + if(argc<2) + { + printf("Usage trimesh_base \n"); + return -1; + } - MyMesh m; + MyMesh m; - if(vcg::tri::io::ImporterPLY::Open(m,argv[1])!=0) - { - printf("Error reading file %s\n",argv[1]); - exit(0); - } + if(vcg::tri::io::ImporterPLY::Open(m,argv[1])!=0) + { + printf("Error reading file %s\n",argv[1]); + exit(0); + } - vcg::tri::UpdateTopology::FaceFace(m); - vcg::tri::UpdateFlags::FaceBorderFromFF(m); - vcg::tri::UpdateNormals::PerVertexNormalized(m); - printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn); - printf( "Mesh has %i vert and %i faces\n", m.vn, m.fn ); + vcg::tri::UpdateTopology::FaceFace(m); + vcg::tri::UpdateFlags::FaceBorderFromFF(m); + vcg::tri::UpdateNormals::PerVertexNormalized(m); + printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn); + printf( "Mesh has %i vert and %i faces\n", m.vn, m.fn ); return 0; } diff --git a/apps/sample/trimesh_clustering/trimesh_clustering.cpp b/apps/sample/trimesh_clustering/trimesh_clustering.cpp index 1417f646..ad00bdbc 100644 --- a/apps/sample/trimesh_clustering/trimesh_clustering.cpp +++ b/apps/sample/trimesh_clustering/trimesh_clustering.cpp @@ -27,12 +27,14 @@ using namespace vcg; using namespace std; -class MyEdge; // dummy prototype never used class MyFace; class MyVertex; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{}; -class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef, face::Normal3f, face::BitFlags > {}; +struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, + Use ::AsFaceType>{}; + +class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{}; +class MyFace : public Face < MyUsedTypes, face::VertexRef, face::Normal3f, face::BitFlags > {}; class MyMesh : public vcg::tri::TriMesh< vector, vector > {}; int main(int argc, char **argv) diff --git a/apps/sample/trimesh_hole/trimesh_hole.cpp b/apps/sample/trimesh_hole/trimesh_hole.cpp index fe509fdd..60af1995 100644 --- a/apps/sample/trimesh_hole/trimesh_hole.cpp +++ b/apps/sample/trimesh_hole/trimesh_hole.cpp @@ -32,12 +32,15 @@ using namespace vcg; using namespace std; -class MyEdge; // dummy prototype never used + class MyFace; class MyVertex; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f, vertex::BitFlags, vertex::Normal3f, vertex::Mark, vertex::Color4b >{}; -class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,face::FFAdj, face::Mark, face::BitFlags, face::Normal3f> {}; +struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, + Use ::AsFaceType>{}; + +class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::BitFlags, vertex::Normal3f, vertex::Mark, vertex::Color4b >{}; +class MyFace : public Face < MyUsedTypes, face::VertexRef,face::FFAdj, face::Mark, face::BitFlags, face::Normal3f> {}; class MyMesh : public tri::TriMesh< vector, vector >{}; diff --git a/apps/sample/trimesh_intersection/trimesh_intersection.cpp b/apps/sample/trimesh_intersection/trimesh_intersection.cpp index 69e009af..9036c34e 100644 --- a/apps/sample/trimesh_intersection/trimesh_intersection.cpp +++ b/apps/sample/trimesh_intersection/trimesh_intersection.cpp @@ -33,9 +33,16 @@ using namespace vcg; class MyFace; class MyEdge; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f, vertex::BitFlags, vertex::Normal3f, vertex::Mark>{}; -class MyEdge : public EdgeSimp2< MyVertex,MyEdge, MyFace, edge::VertexRef, edge::EVAdj> {}; -class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,face::FFAdj, face::BitFlags, face::Normal3f> {}; +class MyVertex; + +struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, + Use ::AsEdgeType, + Use ::AsFaceType>{}; + + +class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::BitFlags, vertex::Normal3f, vertex::Mark>{}; +class MyEdge : public Edge< MyUsedTypes, edge::VertexRef, edge::EVAdj> {}; +class MyFace : public Face {}; class MyEdgeMesh: public vcg::edg::EdgeMesh< vector, vector > {}; class MyMesh : public tri::TriMesh< vector, vector >{}; diff --git a/apps/sample/trimesh_isosurface/trimesh_isosurface.cpp b/apps/sample/trimesh_isosurface/trimesh_isosurface.cpp index 4ab83eb7..07001b84 100644 --- a/apps/sample/trimesh_isosurface/trimesh_isosurface.cpp +++ b/apps/sample/trimesh_isosurface/trimesh_isosurface.cpp @@ -19,11 +19,14 @@ using namespace vcg; typedef float ScalarType; -class MyEdge; class MyFace; +class MyVertex; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f>{}; -class MyFace : public FaceSimp2< MyVertex, MyEdge, MyFace, face::VertexRef, face::BitFlags> {}; +struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, + Use ::AsFaceType>{}; + +class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f>{}; +class MyFace : public Face< MyUsedTypes, face::VertexRef, face::BitFlags> {}; //class MyVertex : public vcg::Vertex< ScalarType, MyEdge, MyFace > {}; //class MyFace : public vcg::Face< MyVertex, MyEdge, MyFace> {}; diff --git a/apps/sample/trimesh_join/trimesh_join.cpp b/apps/sample/trimesh_join/trimesh_join.cpp index 3b6d118a..a21e2b8a 100644 --- a/apps/sample/trimesh_join/trimesh_join.cpp +++ b/apps/sample/trimesh_join/trimesh_join.cpp @@ -21,12 +21,14 @@ using namespace vcg; using namespace std; -class MyEdge; // dummy prototype never used class MyFace; class MyVertex; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f, vertex::BitFlags >{}; -class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef, face::BitFlags > {}; +struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, + Use ::AsFaceType>{}; + +class MyVertex : public Vertex {}; +class MyFace : public Face < MyUsedTypes, face::VertexRef, face::BitFlags > {}; class MyMesh : public vcg::tri::TriMesh< vector, vector > {}; diff --git a/apps/sample/trimesh_optional/trimesh_optional.cpp b/apps/sample/trimesh_optional/trimesh_optional.cpp index bb6ce707..425135e5 100644 --- a/apps/sample/trimesh_optional/trimesh_optional.cpp +++ b/apps/sample/trimesh_optional/trimesh_optional.cpp @@ -1,17 +1,8 @@ #include #include -#include -#include -#include - -#include -#include - -#include -#include - -#include +#include "mesh_definition.h" +#include #include #include #include @@ -21,36 +12,23 @@ using namespace vcg; using namespace std; -class CEdge; // dummy prototype never used -class CFace; -class CFaceOcf; -class CFaceOcc; -class CVertex; -class CVertexOcf; - -// Optional stuff has two suffixes: -// OCF Optional Component Fast -// OCC Optional Component Compact - -class CVertex : public VertexSimp2< CVertex, CEdge, CFace, vertex::Coord3f, vertex::BitFlags,vertex::Normal3f >{}; -class CVertexOcf : public VertexSimp2< CVertexOcf, CEdge, CFaceOcf, vertex::Coord3f, vertex::BitFlags,vertex::Normal3f >{}; -class CVertexOcc : public VertexSimp2< CVertexOcc, CEdge, CFaceOcc, vertex::Coord3f, vertex::BitFlags,vertex::Normal3f >{}; - -class CFace : public FaceSimp2< CVertex, CEdge, CFace, face::FFAdj, face::VertexRef, face::BitFlags, face::Normal3f > {}; -class CFaceOcf : public FaceSimp2< CVertexOcf, CEdge, CFaceOcf, face::InfoOcf, face::FFAdjOcf, face::VertexRef, face::BitFlags, face::Normal3fOcf > {}; -class CFaceOcc : public FaceSimp2< CVertexOcc, CEdge, CFaceOcc, face::FFAdjOcc, face::VertexRef, face::BitFlags, face::Normal3fOcc > {}; - -class CMesh : public vcg::tri::TriMesh< vector, vector > {}; -class CMeshOcf : public vcg::tri::TriMesh< vector, face::vector_ocf > {}; -class CMeshOcc : public vcg::tri::TriMesh< vector_occ, vector_occ > {}; - - - int main(int , char **) { - CMesh cm; - CMeshOcf cmof; - CMeshOcc cmoc; + + vcg::tri::Allocator::NameTypeScope bounds; + vcg::tri::Allocator::AddNameTypeBound(bounds,"myfloat"); + + + CMesh cm; + CMeshOcf cmof; + CMeshOcc cmoc; + + CMesh::VertexPointer v = cm.face[0].V(0); + + + cmoc.face.EnableAttribute(); + CMeshOcc::FaceIterator fi = vcg::tri::Allocator::AddFaces(cmoc,1); + (*fi).N() = vcg::Point3f(9,9,9); tri::Tetrahedron(cm); diff --git a/apps/sample/trimesh_refine/trimesh_refine.cpp b/apps/sample/trimesh_refine/trimesh_refine.cpp index 7eb74624..81f33edf 100644 --- a/apps/sample/trimesh_refine/trimesh_refine.cpp +++ b/apps/sample/trimesh_refine/trimesh_refine.cpp @@ -32,8 +32,11 @@ class MyEdge; // dummy prototype never used class MyFace; class MyVertex; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{}; -class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::FFAdj, face::VertexRef, face::BitFlags > {}; +struct MyUsedTypes : public UsedTypes< Use::AsVertexType, + Use::AsFaceType>{}; + +class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{}; +class MyFace : public Face < MyUsedTypes, face::FFAdj, face::VertexRef, face::BitFlags > {}; class MyMesh : public vcg::tri::TriMesh< vector, vector > {}; @@ -90,7 +93,7 @@ int main(int argc, char **argv) for(i=0;i < n_steps;++i) { switch(RefMode){ - case FLAT: Refine >(m,MidPoint(),length); break; + case FLAT: Refine >(m,MidPoint(&m),length); break; case BUTTERFLY: Refine >(m,MidPointButterfly(),length); break; } } diff --git a/apps/sample/trimesh_smooth/trimesh_smooth.cpp b/apps/sample/trimesh_smooth/trimesh_smooth.cpp index c3c2ed5d..9f2532fc 100644 --- a/apps/sample/trimesh_smooth/trimesh_smooth.cpp +++ b/apps/sample/trimesh_smooth/trimesh_smooth.cpp @@ -21,12 +21,13 @@ using namespace vcg; using namespace std; -class MyEdge; // dummy prototype never used class MyFace; class MyVertex; +struct MyUsedTypes : public UsedTypes< Use::AsVertexType, + Use::AsFaceType>{}; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::VFAdj, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{}; -class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VFAdj, face::Normal3f, face::VertexRef, face::BitFlags > {}; +class MyVertex : public Vertex< MyUsedTypes, vertex::VFAdj, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{}; +class MyFace : public Face < MyUsedTypes, face::VFAdj, face::Normal3f, face::VertexRef, face::BitFlags > {}; class MyMesh : public vcg::tri::TriMesh, vector > {}; int main(int argc,char ** argv) diff --git a/apps/sample/trimesh_split_vertex/trimesh_split_vertex.cpp b/apps/sample/trimesh_split_vertex/trimesh_split_vertex.cpp index 71b1220b..044e8abf 100644 --- a/apps/sample/trimesh_split_vertex/trimesh_split_vertex.cpp +++ b/apps/sample/trimesh_split_vertex/trimesh_split_vertex.cpp @@ -14,25 +14,28 @@ this sample shows how to transfer per wedge attributes from wedges to vertices. during the process new vertices could be created. */ +using namespace vcg; #define TEST_IN_PLACE_SPLIT #ifdef TEST_IN_PLACE_SPLIT class SrcVertex; -class SrcEdge; class SrcFace; -class SrcVertex : public vcg::VertexSimp2 -< SrcVertex, SrcEdge, SrcFace, +struct ScrUsedTypes : public UsedTypes< Use::AsVertexType, + Use::AsFaceType>{}; + +class SrcVertex : public vcg::Vertex +< ScrUsedTypes, vcg::vertex::InfoOcf, vcg::vertex::Coord3f, vcg::vertex::TexCoordfOcf, vcg::vertex::BitFlags > { }; -class SrcFace : public vcg::FaceSimp2 -< SrcVertex, SrcEdge, SrcFace, +class SrcFace : public vcg::Face +< ScrUsedTypes, vcg::face::InfoOcf, vcg::face::VertexRef, vcg::face::WedgeTexCoordfOcf @@ -48,21 +51,26 @@ typedef SrcMesh DstMesh; // source mesh type: per-wedge texture coordinates class SrcVertex; -class SrcEdge; class SrcFace; -class SrcVertex : public vcg::VertexSimp2 { }; -class SrcFace : public vcg::FaceSimp2 { }; + +struct SrcUsedTypes : public UsedTypes< Use::AsVertexType, + Use::AsFaceType>{}; + +class SrcVertex : public vcg::Vertex { }; +class SrcFace : public vcg::Face { }; class SrcMesh : public vcg::tri::TriMesh , std::vector > { }; // destination mesh type: per-vertex texture coordinates -class DstVertex; -class DstEdge; +class DstVertex; class DstFace; -class DstVertex : public vcg::VertexSimp2 { }; -class DstFace : public vcg::FaceSimp2 { }; +struct DstUsedTypes : public UsedTypes< Use::AsVertexType, + Use::AsFaceType>{}; + +class DstVertex : public vcg::Vertex { }; +class DstFace : public vcg::Face { }; class DstMesh : public vcg::tri::TriMesh , std::vector > { }; #endif diff --git a/apps/sample/trimesh_topology/trimesh_topology.cpp b/apps/sample/trimesh_topology/trimesh_topology.cpp index 550981e5..eabd110f 100644 --- a/apps/sample/trimesh_topology/trimesh_topology.cpp +++ b/apps/sample/trimesh_topology/trimesh_topology.cpp @@ -16,12 +16,14 @@ using namespace vcg; -class MyEdge; // dummy prototype never used +class MyEdge; class MyFace; class MyVertex; +struct MyUsedTypes : public UsedTypes< Use::AsVertexType, + Use::AsFaceType>{}; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f, vertex::BitFlags >{}; -class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,face::FFAdj, face::Mark, face::BitFlags > {}; +class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::BitFlags >{}; +class MyFace : public Face < MyUsedTypes, face::VertexRef,face::FFAdj, face::Mark, face::BitFlags > {}; //class MyVertex:public Vertex{};