00001 #include <vector>
00002
00003 #include<vcg/simplex/vertex/base.h>
00004 #include<vcg/simplex/face/base.h>
00005 #include<vcg/simplex/face/topology.h>
00006 #include<vcg/complex/trimesh/base.h>
00007 #include<vcg/complex/trimesh/create/platonic.h>
00008
00009
00010 #include<vcg/complex/trimesh/update/topology.h>
00011
00012
00013 #include<vcg/simplex/face/pos.h>
00014
00015
00016
00017 using namespace vcg;
00018
00019 class MyEdge;
00020 class MyFace;
00021 class MyVertex;
00022 struct MyUsedTypes : public UsedTypes< Use<MyVertex>::AsVertexType,
00023 Use<MyFace>::AsFaceType>{};
00024
00025 class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::BitFlags >{};
00026 class MyFace : public Face < MyUsedTypes, face::VertexRef,face::FFAdj, face::Mark, face::BitFlags > {};
00027 class MyMesh : public tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace > >{};
00028
00029
00030 int main(int ,char ** ){
00031
00032 MyMesh m;
00033
00034
00035 vcg::tri::Icosahedron(m);
00036
00037
00038 vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
00039
00040
00041
00042 if(face::IsBorder(m.face[0],0)) printf("Edge 0 of face 0 is a border\n");
00043 else printf("Edge 0 of face 0 is NOT a border\n");
00044
00045 vcg::face::FFDetach<MyFace>(m.face[0],0);
00046 vcg::face::FFDetach<MyFace>(m.face[0],1);
00047 vcg::face::FFDetach<MyFace>(m.face[0],2);
00048
00049 if(face::IsBorder(m.face[0],0)) printf("Edge 0 of face 0 is a border\n");
00050 else printf("Edge 0 of face 0 is NOT a border\n");
00051
00052 m.face[0].SetD();
00053
00054
00055
00056 vcg::face::Pos<MyMesh::FaceType> he, hei;
00057
00058
00059 MyMesh::FaceIterator fi;
00060 UnMarkAll(m);
00061 int BorderEdgeNum=0;
00062 int HoleNum=0;
00063 for(fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD())
00064 {
00065 for(int j=0;j<3;j++)
00066 {
00067 if ( face::IsBorder(*fi,j) && tri::IsMarked(m,&*fi))
00068 {
00069 tri::Mark(m,&*fi);
00070 hei.Set(&*fi,j,fi->V(j));
00071 he=hei;
00072 do
00073 {
00074 BorderEdgeNum++;
00075 he.NextB();
00076 tri::Mark(m,he.f);
00077 }
00078 while (he.f!=hei.f);
00079 HoleNum++;
00080 }
00081 }
00082 }
00083
00084 printf("Mesh has %i holes and %i border edges\n",HoleNum,BorderEdgeNum);
00085 return 0;
00086 }
00087