#include #include #include "mesh_definition.h" #include #include #include #include #include #include using namespace vcg; using namespace std; int main(int , char **) { vcg::tri::Allocator::NameTypeScope bounds; vcg::tri::Allocator::AddNameTypeBound(bounds,"myfloat"); CMesh cm; CMeshOcf cmof; CMeshOcc cmoc; CMesh::VertexPointer v = cm.face[0].V(0); cmoc.face.EnableAttribute(); CMeshOcc::FaceIterator fi = vcg::tri::Allocator::AddFaces(cmoc,1); (*fi).N() = vcg::Point3f(9,9,9); tri::Tetrahedron(cm); tri::Tetrahedron(cmof); tri::Tetrahedron(cmoc); 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 cmoc.face.EnableAttribute(); cmof.face.EnableFFAdjacency(); printf("Size of CFace %3i\n",sizeof(CFace)); printf("Size of CFaceOcf %3i\n",sizeof(CFaceOcf)); printf("Size of CFaceOcc %3i\n",sizeof(CFaceOcc)); vcg::tri::UpdateTopology::FaceFace(cm); vcg::tri::UpdateTopology::FaceFace(cmof); vcg::tri::UpdateTopology::FaceFace(cmoc); vcg::tri::UpdateFlags::FaceBorderFromFF(cm); vcg::tri::UpdateFlags::FaceBorderFromFF(cmof); vcg::tri::UpdateFlags::FaceBorderFromFF(cmoc); vcg::tri::UpdateNormals::PerVertexNormalized(cm); vcg::tri::UpdateNormals::PerVertexNormalized(cmof); vcg::tri::UpdateNormals::PerVertexNormalized(cmoc); 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,t2=0,t3=0; while(t3-t0<3000) { t0=clock(); Refine(cm,MidPointButterfly(),0); t1=clock(); Refine(cmof,MidPointButterfly(),0); t2=clock(); Refine(cmoc,MidPointButterfly(),0); t3=clock(); printf("Mesh is %i %i in Std:%i Ocf:%i Occ:%i\n",cm.vn,cm.fn,t1-t0,t2-t1,t3-t2); } return 0; }