#include #include #include "mesh_definition.h" #include #include #include #include #include #include #include using namespace vcg; using namespace std; int main(int , char **) { CMesh cm; CMeshOcf cmof; tri::Tetrahedron(cm); tri::Tetrahedron(cmof); printf("Generated mesh has %i vertices and %i triangular faces\n",cm.vn,cm.fn); /// Calculates both vertex and face normals. /// The normal of a vertex v is the weigthed average of the normals of the faces incident on v. /// normals are not normalized cmof.face.EnableFFAdjacency(); vcg::tri::UpdateTopology::FaceFace(cm); vcg::tri::UpdateTopology::FaceFace(cmof); vcg::tri::UpdateFlags::FaceBorderFromFF(cm); vcg::tri::UpdateFlags::FaceBorderFromFF(cmof); vcg::tri::UpdateNormals::PerVertexNormalized(cm); vcg::tri::UpdateNormals::PerVertexNormalized(cmof); 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]); int t0=0,t1=0; while(t1-t0<200) { t0=clock(); Refine(cm,MidPointButterfly(),0); t1=clock(); Refine(cmof,MidPointButterfly(),0); } cmof.vert.EnableRadius(); cmof.vert.EnableQuality(); unsigned int hh = 0; for(CMeshOcf::VertexIterator vi = cmof.vert.begin(); vi!=cmof.vert.end();++vi,++hh){ if(hh%3==0) vcg::tri::Allocator::DeleteVertex(cmof,*vi); } for(CMeshOcf::VertexIterator vi = cmof.vert.begin(); vi!=cmof.vert.end();++vi) { if(!(*vi).IsD()) { float q =vi->Q(); float r =vi->R(); // int ii = vcg::tri::Index(cmof, *vi); assert(q==r); } } tri::Allocator::CompactVertexVector(cmof); tri::UpdateBounding::Box(cmof); for(CMeshOcf::VertexIterator vi = cmof.vert.begin(); vi!=cmof.vert.end();++vi) { if(!(*vi).IsD()) { float q =vi->Q(); float r =vi->R(); // int ii = vcg::tri::Index(cmof, *vi); assert(q==r); } } return 0; }