VCG Library
trimesh_simpdata_simp.cpp
1 #include <vector>
2 
3 #include <vcg/simplex/vertex/base.h>
4 #include <vcg/simplex/vertex/component.h>
5 #include <vcg/simplex/face/base.h>
6 #include <vcg/simplex/face/component.h>
7 
8 #include <vcg/complex/complex.h>
9 #include<vcg/container/simple_temporary_data.h>
10 
11 #include<vcg/complex/algorithms/create/platonic.h>
12 
13 class MyEdge;
14 class MyFace;
15 
16 class MyVertex: public vcg::VertexSimp2<MyVertex,MyEdge,MyFace, vcg::vert::Coord3d, vcg::vert::Normal3f>{};
17 class MyFace: public vcg::FaceSimp2<MyVertex,MyEdge,MyFace, vcg::face::VertexRef>{};
18 
19 class MyMesh: public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
20 
21 
22 int main()
23 {
24  MyMesh m;
26  vcg::SimpleTempData<MyMesh::VertContainer, short> MyTempData(m.vert);
27 
28  MyTempData.Start(); // enable the user defined attribute (memory is allocated)
29 
30  MyMesh::VertexIterator vi; // declare the iterator over the vertices
31  for(vi = m.vert.begin(); vi != m.vert.end(); ++vi)
32  {
33  MyTempData[*vi] = 10; // assign the value for the 'short' attribute
34  MyTempData[vi] = 10; // you can pass the element or an iterator to it
35  }
36 
37  MyTempData.Stop(); // disable the user defined attribute (memory is freed)
38 
39  return 0;
40 }