2005-10-14 19:52:07 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include<vcg/simplex/vertexplus/base.h>
|
|
|
|
#include<vcg/simplex/faceplus/base.h>
|
|
|
|
#include<vcg/simplex/face/topology.h>
|
|
|
|
|
|
|
|
#include<vcg/simplex/vertexplus/component_ocf.h>
|
|
|
|
#include<vcg/simplex/faceplus/component_ocf.h>
|
|
|
|
|
2005-10-15 18:20:09 +02:00
|
|
|
#include<vcg/simplex/vertexplus/component_occ.h>
|
|
|
|
#include<vcg/simplex/faceplus/component_occ.h>
|
|
|
|
|
2005-10-14 19:52:07 +02:00
|
|
|
#include<vcg/complex/trimesh/base.h>
|
|
|
|
#include<vcg/complex/trimesh/create/platonic.h>
|
|
|
|
#include<vcg/complex/trimesh/update/topology.h>
|
|
|
|
#include<vcg/complex/trimesh/update/flag.h>
|
|
|
|
#include<vcg/complex/trimesh/update/normal.h>
|
|
|
|
#include <vcg/complex/trimesh/refine.h>
|
|
|
|
|
|
|
|
using namespace vcg;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class CEdge; // dummy prototype never used
|
|
|
|
class CFace;
|
|
|
|
class CFaceOcf;
|
2005-12-02 01:49:50 +01:00
|
|
|
class CFaceOcc;
|
2005-10-14 19:52:07 +02:00
|
|
|
class CVertex;
|
|
|
|
class CVertexOcf;
|
|
|
|
|
2005-12-02 01:49:50 +01:00
|
|
|
// Optional stuff has two suffixes:
|
2005-10-15 18:20:09 +02:00
|
|
|
// OCF Optional Component Fast
|
2005-12-02 01:49:50 +01:00
|
|
|
// OCC Optional Component Compact
|
|
|
|
|
2006-10-27 15:59:54 +02:00
|
|
|
class CVertex : public VertexSimp2< CVertex, CEdge, CFace, vert::Coord3f, vert::BitFlags,vert::Normal3f >{};
|
|
|
|
class CVertexOcf : public VertexSimp2< CVertexOcf, CEdge, CFaceOcf, vert::Coord3f, vert::BitFlags,vert::Normal3f >{};
|
|
|
|
class CVertexOcc : public VertexSimp2< CVertexOcc, CEdge, CFaceOcc, vert::Coord3f, vert::BitFlags,vert::Normal3f >{};
|
2005-10-14 19:52:07 +02:00
|
|
|
|
2005-12-02 01:49:50 +01:00
|
|
|
class CFace : public FaceSimp2< CVertex, CEdge, CFace, face::FFAdj, face::VertexRef, face::BitFlags, face::Normal3f > {};
|
|
|
|
class CFaceOcf : public FaceSimp2< CVertexOcf, CEdge, CFaceOcf, face::InfoOcf, face::FFAdjOcf, face::VertexRef, face::BitFlags, face::Normal3fOcf > {};
|
|
|
|
class CFaceOcc : public FaceSimp2< CVertexOcc, CEdge, CFaceOcc, face::FFAdjOcc, face::VertexRef, face::BitFlags, face::Normal3fOcc > {};
|
2005-10-14 19:52:07 +02:00
|
|
|
|
2005-12-02 01:49:50 +01:00
|
|
|
class CMesh : public vcg::tri::TriMesh< vector<CVertex >, vector<CFace > > {};
|
|
|
|
class CMeshOcf : public vcg::tri::TriMesh< vector<CVertexOcf>, face::vector_ocf<CFaceOcf> > {};
|
|
|
|
class CMeshOcc : public vcg::tri::TriMesh< vector_occ<CVertexOcc>, vector_occ<CFaceOcc > > {};
|
2005-10-14 19:52:07 +02:00
|
|
|
|
2005-10-15 18:20:09 +02:00
|
|
|
|
2005-10-14 19:52:07 +02:00
|
|
|
|
|
|
|
int main(int , char **)
|
|
|
|
{
|
|
|
|
CMesh cm;
|
2005-12-02 01:49:50 +01:00
|
|
|
CMeshOcf cmof;
|
2006-12-04 12:10:02 +01:00
|
|
|
CMeshOcc cmoc;
|
2005-10-15 18:20:09 +02:00
|
|
|
|
|
|
|
|
2005-10-14 19:52:07 +02:00
|
|
|
tri::Tetrahedron(cm);
|
2005-12-02 01:49:50 +01:00
|
|
|
tri::Tetrahedron(cmof);
|
2006-12-04 12:10:02 +01:00
|
|
|
tri::Tetrahedron(cmoc);
|
2005-10-15 18:20:09 +02:00
|
|
|
|
2005-10-14 19:52:07 +02:00
|
|
|
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
|
|
|
|
|
2006-12-04 12:10:02 +01:00
|
|
|
cmoc.face.EnableAttribute<CFaceOcc::FFAdjType>();
|
2005-12-02 01:49:50 +01:00
|
|
|
cmof.face.EnableFFAdjacency();
|
2005-10-15 18:20:09 +02:00
|
|
|
|
2005-10-14 19:52:07 +02:00
|
|
|
|
2005-10-15 18:20:09 +02:00
|
|
|
printf("Size of CFace %3i\n",sizeof(CFace));
|
|
|
|
printf("Size of CFaceOcf %3i\n",sizeof(CFaceOcf));
|
2006-12-04 12:10:02 +01:00
|
|
|
printf("Size of CFaceOcc %3i\n",sizeof(CFaceOcc));
|
2005-10-14 19:52:07 +02:00
|
|
|
|
|
|
|
vcg::tri::UpdateTopology<CMesh >::FaceFace(cm);
|
2005-12-02 01:49:50 +01:00
|
|
|
vcg::tri::UpdateTopology<CMeshOcf>::FaceFace(cmof);
|
2006-12-04 12:10:02 +01:00
|
|
|
vcg::tri::UpdateTopology<CMeshOcc>::FaceFace(cmoc);
|
2005-10-14 19:52:07 +02:00
|
|
|
|
|
|
|
vcg::tri::UpdateFlags<CMesh >::FaceBorderFromFF(cm);
|
2005-12-02 01:49:50 +01:00
|
|
|
vcg::tri::UpdateFlags<CMeshOcf>::FaceBorderFromFF(cmof);
|
2006-12-04 12:10:02 +01:00
|
|
|
vcg::tri::UpdateFlags<CMeshOcc>::FaceBorderFromFF(cmoc);
|
2005-10-14 19:52:07 +02:00
|
|
|
|
|
|
|
vcg::tri::UpdateNormals<CMesh >::PerVertexNormalized(cm);
|
2005-12-02 01:49:50 +01:00
|
|
|
vcg::tri::UpdateNormals<CMeshOcf>::PerVertexNormalized(cmof);
|
2006-12-04 12:10:02 +01:00
|
|
|
vcg::tri::UpdateNormals<CMeshOcc>::PerVertexNormalized(cmoc);
|
2005-10-14 19:52:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
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]);
|
2005-10-15 18:20:09 +02:00
|
|
|
int t0=0,t1=0,t2=0,t3=0;
|
|
|
|
while(t3-t0<3000)
|
2005-10-14 19:52:07 +02:00
|
|
|
{
|
|
|
|
t0=clock();
|
|
|
|
Refine(cm,MidPointButterfly<CMesh>(),0);
|
|
|
|
t1=clock();
|
2005-12-02 01:49:50 +01:00
|
|
|
Refine(cmof,MidPointButterfly<CMeshOcf>(),0);
|
2005-10-14 19:52:07 +02:00
|
|
|
t2=clock();
|
2006-12-04 12:10:02 +01:00
|
|
|
Refine(cmoc,MidPointButterfly<CMeshOcc>(),0);
|
2005-10-15 18:20:09 +02:00
|
|
|
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);
|
2005-10-14 19:52:07 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|