34 #include<vcg/complex/complex.h>
36 #include<vcg/complex/algorithms/create/platonic.h>
37 #include<vcg/complex/algorithms/update/curvature.h>
38 #include <vcg/complex/algorithms/refine_loop.h>
39 #include <wrap/io_trimesh/export_off.h>
44 struct MyUsedTypes:
public vcg::UsedTypes<
45 vcg::Use<MyVertex>::AsVertexType,
46 vcg::Use<MyFace >::AsFaceType>{};
48 class MyVertex :
public vcg::Vertex< MyUsedTypes,
49 vcg::vertex::Coord3f, vcg::vertex::Qualityf,
50 vcg::vertex::Color4b, vcg::vertex::BitFlags,
51 vcg::vertex::Normal3f, vcg::vertex::VFAdj >{};
53 class MyFace :
public vcg::Face< MyUsedTypes,
54 vcg::face::FFAdj, vcg::face::VFAdj,
55 vcg::face::Color4b, vcg::face::VertexRef,
56 vcg::face::BitFlags, vcg::face::Normal3f > {};
57 class MyMesh :
public vcg::tri::TriMesh< std::vector<MyVertex >, std::vector<MyFace > > {};
63 struct MyUsedTypesOcf:
public vcg::UsedTypes<
64 vcg::Use<MyVertexOcf>::AsVertexType,
65 vcg::Use<MyFaceOcf>::AsFaceType>{};
67 class MyVertexOcf :
public vcg::Vertex< MyUsedTypesOcf,
69 vcg::vertex::Coord3f, vcg::vertex::QualityfOcf,
70 vcg::vertex::Color4b, vcg::vertex::BitFlags,
71 vcg::vertex::Normal3f, vcg::vertex::VFAdjOcf >{};
73 class MyFaceOcf :
public vcg::Face< MyUsedTypesOcf,
75 vcg::face::FFAdjOcf, vcg::face::VFAdjOcf,
76 vcg::face::Color4bOcf, vcg::face::VertexRef,
77 vcg::face::BitFlags, vcg::face::Normal3fOcf > {};
80 class MyMeshOcf :
public vcg::tri::TriMesh< vcg::vertex::vector_ocf<MyVertexOcf>, vcg::face::vector_ocf<MyFaceOcf> > {};
86 int main(
int ,
char **)
94 printf(
"Generated mesh has %i vertices and %i triangular faces\n",cm.VN(),cm.FN());
96 assert(tri::HasFFAdjacency(cmof) ==
false);
97 cmof.face.EnableFFAdjacency();
98 assert(tri::HasFFAdjacency(cmof) ==
true);
100 assert(tri::HasVFAdjacency(cmof) ==
false);
101 cmof.vert.EnableVFAdjacency();
102 cmof.face.EnableVFAdjacency();
103 assert(tri::HasVFAdjacency(cmof) ==
true);
112 cmof.face.EnableNormal();
115 cmof.vert.EnableQuality();
118 printf(
"cmof IsColorEnabled() %s\n",cmof.face.back().IsColorEnabled()?
"Yes":
"No");
119 cmof.face.EnableColor();
121 cmof.vert[0].C()=Color4b::Red;
123 printf(
"cmof IsColorEnabled() %s\n",cmof.face.back().IsColorEnabled()?
"Yes":
"No");
124 printf(
"cm IsColorEnabled() %s\n",cm.face.back().IsColorEnabled()?
"Yes":
"No");
125 printf(
"cm IsColorEnabled() %s\n",cm.face.back().HasColor()?
"Yes":
"No");
127 printf(
"Normal of face 0 is %f %f %f\n\n",cm.face[0].N()[0],cm.face[0].N()[1],cm.face[0].N()[2]);
129 while(
float(t1-t0)/CLOCKS_PER_SEC < 0.1f)
132 tri::RefineOddEven<MyMesh> (cm, tri::OddPointLoop<MyMesh>(cm), tri::EvenPointLoop<MyMesh>(), 0);
134 tri::RefineOddEven<MyMeshOcf> (cmof, tri::OddPointLoop<MyMeshOcf>(cmof), tri::EvenPointLoop<MyMeshOcf>(), 0);
137 printf(
"Last Iteration: Refined a tetra up to a mesh of %i faces in:\n"
138 "Standard Component %5.2f sec\n"
139 "OCF Component %5.2f sec\n",cm.FN(),float(t1-t0)/CLOCKS_PER_SEC,float(t2-t1)/CLOCKS_PER_SEC);
140 tri::io::ExporterOFF<MyMeshOcf>::Save(cmof,
"test.off",tri::io::Mask::IOM_VERTCOLOR);