Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00032 #include<vcg/complex/complex.h>
00033 #include<vcg/complex/algorithms/create/platonic.h>
00034
00035 class MyEdge;
00036 class MyFace;
00037 class MyVertex;
00038 struct MyUsedTypes : public vcg::UsedTypes< vcg::Use<MyVertex> ::AsVertexType,
00039 vcg::Use<MyFace> ::AsFaceType>{};
00040
00041 class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f,vcg::vertex::Normal3f>{};
00042 class MyFace : public vcg::Face< MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f> {};
00043
00044 class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
00045
00046 int main()
00047 {
00048 MyMesh m;
00049 MyMesh::VertexIterator vi = vcg::tri::Allocator<MyMesh>::AddVertices(m,3);
00050 MyMesh::FaceIterator fi = vcg::tri::Allocator<MyMesh>::AddFaces(m,1);
00051
00052 MyMesh::VertexPointer ivp[4];
00053 ivp[0]=&*vi; vi->P()=MyMesh::CoordType ( 0.0, 0.0, 0.0); ++vi;
00054 ivp[1]=&*vi; vi->P()=MyMesh::CoordType ( 1.0, 0.0, 0.0); ++vi;
00055 ivp[2]=&*vi; vi->P()=MyMesh::CoordType ( 0.0, 1.0, 0.0); ++vi;
00056
00057 fi->V(0)=ivp[0];
00058 fi->V(1)=ivp[1];
00059 fi->V(2)=ivp[2];
00060
00061
00062 ivp[3]= &*vcg::tri::Allocator<MyMesh>::AddVertex(m,MyMesh::CoordType ( 1.0, 1.0, 0.0));
00063
00064
00065 vcg::tri::Allocator<MyMesh>::AddFace(m, ivp[1],ivp[0],ivp[3]);
00066
00067
00068 MyMesh::FacePointer fp = &m.face[0];
00069 vcg::tri::Allocator<MyMesh>::PointerUpdater<MyMesh::FacePointer> pu;
00070
00071
00072 vcg::tri::Allocator<MyMesh>::AddVertices(m,3);
00073 vcg::tri::Allocator<MyMesh>::AddFaces(m,1,pu);
00074
00075
00076 if(pu.NeedUpdate()) pu.Update(fp);
00077
00078
00079 vcg::tri::Icosahedron(m);
00080 vcg::tri::Allocator<MyMesh>::DeleteFace(m,m.face[1]);
00081 vcg::tri::Allocator<MyMesh>::DeleteFace(m,m.face[3]);
00082
00083
00084 for(fi = m.face.begin(); fi!=m.face.end(); ++fi )
00085 {
00086 if(!fi->IsD())
00087 {
00088 MyMesh::CoordType b = vcg::Barycenter(*fi);
00089 }
00090 }
00091
00092
00093 for(int i=0;i<m.FN();++i)
00094 {
00095 if(!fi->IsD())
00096 {
00097 MyMesh::CoordType b = vcg::Barycenter(*fi);
00098 }
00099 }
00100
00101
00102 vcg::tri::Allocator<MyMesh>::CompactFaceVector(m);
00103 vcg::tri::Allocator<MyMesh>::CompactVertexVector(m);
00104
00105
00106 vcg::tri::Allocator<MyMesh>::CompactEveryVector(m);
00107
00108
00109 MyMesh m2;
00110 vcg::tri::Append<MyMesh,MyMesh>::MeshCopy(m2,m);
00111
00112 }