VCG Library
trimesh_optional_ocf.cpp
1 #include <vector>
2 #include <vcg/simplex/vertex/base.h>
3 #include <vcg/simplex/vertex/component_occ.h>
4 #include <vcg/simplex/face/base.h>
5 #include <vcg/simplex/face/component.h>
6 
7 #include <vcg/complex/complex.h>
8 
9 #include<vcg/complex/algorithms/create/platonic.h>
10 
11 class MyEdge;
12 class MyFace;
13 
14 class MyVertex: public vcg::VertexSimp2<MyVertex,MyEdge,MyFace, vcg::vert::InfoOcf,vcg::vert::Coord3d, vcg::vert::Normal3fOcc>{};
15 class MyFace: public vcg::FaceSimp2<MyVertex,MyEdge,MyFace,vcg::face::VertexRef>{};
16 class MyMesh: public vcg::tri::TriMesh< vcg::vert::vector_occ<MyVertex>, std::vector<MyFace> >{};
17 
18 int main()
19 {
20  MyMesh m;
22  MyMesh::VertexIterator vi = m.vert.begin();
23 
24  (*vi).N() = vcg::Point3f(1.0,1.0,1.0); // ERROR
25  m.vert.EnableAttribute<vcg::vert::Normal3fOcc::NormalType>(); // this allocate the memory to store the normal
26  (*vi).N() = vcg::Point3f(1.0,1.0,1.0); // OK
27  m.vert.DisableAttribute<vcg::vert::Normal3fOcc::NormalType>(); // this deallocate the memory to store the normal
28 
29  (*vi).N() = vcg::Point3f(1.0,1.0,1.0); // ERROR (again)!
30  return 0;
31 }