Updated a number of sample app for the vcg lib
This commit is contained in:
parent
a437952298
commit
2bb91ac57a
|
@ -45,13 +45,11 @@ class MyEdge : public Edge<MyUsedTypes,edge::VertexRef, edge::VEAdj, edge::EE
|
||||||
class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector<MyEdge> > {};
|
class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector<MyEdge> > {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char **argv )
|
int main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
if(argc<2)
|
if(argc<2)
|
||||||
{
|
{
|
||||||
printf("Usage trimesh_base <meshfilename.obj> radius\n");
|
printf("Usage edgemesh_sampling <meshfilename.off> radius\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +88,7 @@ int main( int argc, char **argv )
|
||||||
tri::TrivialSampler<MyMesh> ps(sampleVec);
|
tri::TrivialSampler<MyMesh> ps(sampleVec);
|
||||||
tri::SurfaceSampling<MyMesh>::EdgeMeshUniform(e,ps,m.bbox.Diag()/90.0f);
|
tri::SurfaceSampling<MyMesh>::EdgeMeshUniform(e,ps,m.bbox.Diag()/90.0f);
|
||||||
MyMesh sampleMesh;
|
MyMesh sampleMesh;
|
||||||
tri::Build(sampleMesh,sampleVec);
|
tri::BuildMeshFromCoordVector(sampleMesh,sampleVec);
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(sampleMesh,"sampleMesh.ply");
|
tri::io::ExporterPLY<MyMesh>::Save(sampleMesh,"sampleMesh.ply");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,17 +28,14 @@
|
||||||
#include <vcg/complex/algorithms/update/bounding.h>
|
#include <vcg/complex/algorithms/update/bounding.h>
|
||||||
#include <vcg/complex/algorithms/update/normal.h>
|
#include <vcg/complex/algorithms/update/normal.h>
|
||||||
|
|
||||||
/*include the algorithms for mesh fixing */
|
|
||||||
#include <vcg/complex/algorithms/clean.h>
|
#include <vcg/complex/algorithms/clean.h>
|
||||||
|
#include <vcg/complex/algorithms/create/platonic.h>
|
||||||
|
|
||||||
#include <wrap/io_trimesh/import.h>
|
#include <wrap/io_trimesh/import.h>
|
||||||
#include <wrap/io_trimesh/export_ply.h>
|
#include <wrap/io_trimesh/export_ply.h>
|
||||||
|
|
||||||
/* include the support for polygon meshes (function to convert from/to trimesh)*/
|
/* include the support for polygon meshes (function to convert from/to trimesh)*/
|
||||||
#include <vcg/complex/algorithms/polygon_support.h>
|
//#include <vcg/complex/algorithms/polygon_support.h>
|
||||||
|
|
||||||
/* include the support for polygon meshes (the component for the face )*/
|
|
||||||
#include <vcg/simplex/face/component_polygon.h>
|
|
||||||
|
|
||||||
/* include the support for half edges */
|
/* include the support for half edges */
|
||||||
#include <vcg/complex/algorithms/update/halfedge_indexed.h>
|
#include <vcg/complex/algorithms/update/halfedge_indexed.h>
|
||||||
|
@ -48,179 +45,173 @@ using namespace vcg;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// forward declarations
|
// forward declarations
|
||||||
class CFace;
|
class TFace;
|
||||||
class CVertex;
|
class TVertex;
|
||||||
class CHEdge;
|
|
||||||
class CEdge;
|
|
||||||
class MyPolyVertex;
|
|
||||||
|
|
||||||
struct CUsedTypes: public vcg::UsedTypes< vcg::Use<CVertex>::AsVertexType, vcg::Use<CFace>::AsFaceType >{};
|
struct TUsedTypes: public vcg::UsedTypes< vcg::Use<TVertex>::AsVertexType, vcg::Use<TFace>::AsFaceType >{};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Definition of a mesh of triangles
|
/* Definition of a mesh of triangles
|
||||||
*/
|
*/
|
||||||
class CVertex : public Vertex< CUsedTypes,
|
class TVertex : public Vertex< TUsedTypes,
|
||||||
vertex::BitFlags,
|
vertex::BitFlags,
|
||||||
vertex::Coord3f,
|
vertex::Coord3f,
|
||||||
vertex::Normal3f,
|
vertex::Normal3f,
|
||||||
vertex::Mark >{};
|
vertex::Mark >{};
|
||||||
|
|
||||||
class CFace : public Face< CUsedTypes,
|
class TFace : public Face< TUsedTypes,
|
||||||
face::VertexRef, // three pointers to vertices
|
face::VertexRef, // three pointers to vertices
|
||||||
face::Normal3f, // normal
|
face::Normal3f, // normal
|
||||||
face::BitFlags, // flags
|
face::BitFlags, // flags
|
||||||
face::FFAdj // three pointers to adjacent faces
|
face::FFAdj // three pointers to adjacent faces
|
||||||
> {};
|
> {};
|
||||||
|
|
||||||
/* the mesh is a container of vertices and a container of faces */
|
/* the mesh is a container of vertices and a container of faces */
|
||||||
class CMesh : public vcg::tri::TriMesh< vector<CVertex>, vector<CFace> > {};
|
class TMesh : public vcg::tri::TriMesh< vector<TVertex>, vector<TFace> > {};
|
||||||
|
|
||||||
|
|
||||||
/* Definition of a mesh of polygons that also supports half-edges
|
/* Definition of a mesh of polygons that also supports half-edges
|
||||||
*/
|
*/
|
||||||
class MyPolyFace;
|
class PFace;
|
||||||
class MyPolyVertex;
|
class PVertex;
|
||||||
struct PolyUsedTypes: public vcg::UsedTypes<vcg::Use<MyPolyVertex> ::AsVertexType,
|
class PHEdge;
|
||||||
vcg::Use<CEdge> ::AsEdgeType,
|
class PEdge;
|
||||||
vcg::Use<CHEdge> ::AsHEdgeType,
|
|
||||||
vcg::Use<MyPolyFace> ::AsFaceType
|
struct PUsedTypes: public vcg::UsedTypes<vcg::Use<PVertex> ::AsVertexType,
|
||||||
>{};
|
vcg::Use<PEdge> ::AsEdgeType,
|
||||||
|
vcg::Use<PHEdge>::AsHEdgeType,
|
||||||
|
vcg::Use<PFace> ::AsFaceType
|
||||||
|
>{};
|
||||||
|
|
||||||
//class DummyEdge: public vcg::Edge<PolyUsedTypes>{};
|
//class DummyEdge: public vcg::Edge<PolyUsedTypes>{};
|
||||||
class MyPolyVertex:public vcg::Vertex< PolyUsedTypes,
|
class PVertex:public vcg::Vertex< PUsedTypes,
|
||||||
vcg::vertex::Coord3f,
|
vcg::vertex::Coord3f,
|
||||||
vcg::vertex::Normal3f,
|
vcg::vertex::Normal3f,
|
||||||
vcg::vertex::Mark,
|
vcg::vertex::Mark,
|
||||||
vcg::vertex::BitFlags,
|
vcg::vertex::BitFlags,
|
||||||
vcg::vertex::VHAdj>{} ;
|
vcg::vertex::VHAdj>{} ;
|
||||||
|
|
||||||
class CEdge : public Edge<PolyUsedTypes>{};
|
class PEdge : public Edge<PUsedTypes>{};
|
||||||
class CHEdge : public HEdge< PolyUsedTypes, hedge::BitFlags,
|
class PHEdge : public HEdge< PUsedTypes, hedge::BitFlags,
|
||||||
//hedge::HFAdj, // pointer to the face
|
//hedge::HFAdj, // pointer to the face
|
||||||
//hedge::HOppAdj, // pointer to the opposite edge
|
//hedge::HOppAdj, // pointer to the opposite edge
|
||||||
//hedge::HVAdj, // pointer to the vertex
|
//hedge::HVAdj, // pointer to the vertex
|
||||||
//hedge::HNextAdj, // pointer to the next halfedge
|
//hedge::HNextAdj, // pointer to the next halfedge
|
||||||
hedge::HEdgeData // the previous 4 components (just more handy, you can comment this and uncomment the previous four lines)
|
hedge::HEdgeData // the previous 4 components (just more handy, you can comment this and uncomment the previous four lines)
|
||||||
//,hedge::HPrevAdj // pointer to the previous halfedge
|
//,hedge::HPrevAdj // pointer to the previous halfedge
|
||||||
>{};
|
>{};
|
||||||
|
|
||||||
class MyPolyFace:public vcg::Face<
|
class PFace:public vcg::Face<
|
||||||
PolyUsedTypes
|
PUsedTypes
|
||||||
,vcg::face::PolyInfo // this is necessary if you use component in vcg/simplex/face/component_polygon.h
|
,vcg::face::PolyInfo // this is necessary if you use component in vcg/simplex/face/component_polygon.h
|
||||||
// It says "this class is a polygon and the memory for its components (e.g. pointer to its vertices
|
// It says "this class is a polygon and the memory for its components (e.g. pointer to its vertices
|
||||||
// will be allocated dynamically")
|
// will be allocated dynamically")
|
||||||
,vcg::face::PFVAdj // Pointer to the vertices (just like FVAdj )
|
,vcg::face::PFVAdj // Pointer to the vertices (just like FVAdj )
|
||||||
,vcg::face::PFVAdj
|
,vcg::face::PFVAdj
|
||||||
,vcg::face::PFFAdj // Pointer to edge-adjacent face (just like FFAdj )
|
,vcg::face::PFFAdj // Pointer to edge-adjacent face (just like FFAdj )
|
||||||
,vcg::face::PFHAdj // Pointer its half -edges ( you may need this if you use half edges)
|
,vcg::face::PFHAdj // Pointer its half -edges ( you may need this if you use half edges)
|
||||||
,vcg::face::BitFlags // bit flags
|
,vcg::face::BitFlags // bit flags
|
||||||
,vcg::face::Normal3f // normal
|
,vcg::face::Normal3f // normal
|
||||||
> {};
|
> {};
|
||||||
|
|
||||||
class MyPolyMesh: public
|
class PMesh: public
|
||||||
vcg::tri::TriMesh<
|
vcg::tri::TriMesh<
|
||||||
std::vector<MyPolyVertex>, // the vector of vertices
|
std::vector<PVertex>, // the vector of vertices
|
||||||
std::vector<MyPolyFace >, // the vector of faces
|
std::vector<PFace >, // the vector of faces
|
||||||
std::vector<CHEdge> , // the vector of edges
|
std::vector<PHEdge> , // the vector of edges
|
||||||
std::vector<CEdge> // the vector of edges
|
std::vector<PEdge> // the vector of edges
|
||||||
>{};
|
>{};
|
||||||
|
|
||||||
MyPolyMesh pm;
|
PMesh pm;
|
||||||
|
TMesh tm0;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
int loadmask;
|
||||||
// Globals: the mesh, the OpenGL wrapper to draw the mesh and the trackball.
|
|
||||||
CMesh mesh,mesh1;
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
|
|
||||||
int loadmask;
|
|
||||||
|
|
||||||
vcg::tri::io::PlyInfo pi;
|
|
||||||
|
|
||||||
// pm.hedge.reserve(100000);
|
|
||||||
if(true){
|
if(true){
|
||||||
/*
|
/*
|
||||||
first way:
|
first way:
|
||||||
1) read a polygon mesh that will be automatically converted in a triangle mesh tagging
|
1) read a polygon mesh that will be automatically converted in a triangle mesh tagging
|
||||||
the internal edges (i.e. the edges that have been added for triangulating the polygons)
|
the internal edges (i.e. the edges that have been added for triangulating the polygons)
|
||||||
2) make some cleaning
|
2) make some cleaning
|
||||||
3) import the tagged triangle mesh in a polygon mesh
|
3) import the tagged triangle mesh in a polygon mesh
|
||||||
*/
|
*/
|
||||||
// vcg::tri::io::ImporterOBJ<CMesh>::Open(mesh,argv[1],loadmask);
|
// vcg::tri::io::ImporterOBJ<CMesh>::Open(mesh,argv[1],loadmask);
|
||||||
vcg::tri::io::ImporterOFF<CMesh>::Open(mesh,argv[1],loadmask);
|
// vcg::tri::io::ImporterOFF<TMesh>::Open(tm0,argv[1],loadmask);
|
||||||
|
vcg::tri::Hexahedron(tm0);
|
||||||
|
vcg::tri::Clean<TMesh>::RemoveUnreferencedVertex(tm0);
|
||||||
|
vcg::tri::Clean<TMesh>::RemoveZeroAreaFace(tm0);
|
||||||
|
vcg::tri::UpdateTopology<TMesh>::FaceFace(tm0);
|
||||||
|
vcg::tri::Clean<TMesh>::RemoveNonManifoldFace(tm0);
|
||||||
|
vcg::tri::UpdateTopology<TMesh>::FaceFace(tm0);
|
||||||
|
assert(vcg::tri::Clean<TMesh>::CountNonManifoldEdgeFF(tm0)==0);
|
||||||
|
assert(vcg::tri::Clean<TMesh>::CountNonManifoldVertexFF(tm0)==0);
|
||||||
|
|
||||||
vcg::tri::Clean<CMesh>::RemoveUnreferencedVertex(mesh);
|
// create a polygon meshe from a trimesh with tagged faces
|
||||||
vcg::tri::Clean<CMesh>::RemoveZeroAreaFace(mesh);
|
vcg::tri::PolygonSupport<TMesh,PMesh>::ImportFromTriMesh(pm,tm0);
|
||||||
vcg::tri::UpdateTopology<CMesh>::FaceFace(mesh);
|
|
||||||
vcg::tri::Clean<CMesh>::RemoveNonManifoldFace(mesh);
|
|
||||||
vcg::tri::UpdateTopology<CMesh>::FaceFace(mesh);
|
|
||||||
assert(vcg::tri::Clean<CMesh>::CountNonManifoldEdgeFF(mesh)==0);
|
|
||||||
assert(vcg::tri::Clean<CMesh>::CountNonManifoldVertexFF(mesh)==0);
|
|
||||||
|
|
||||||
// create a polygon meshe from a trimesh with tagged faces
|
|
||||||
vcg::tri::PolygonSupport<CMesh,MyPolyMesh>::ImportFromTriMesh(pm,mesh);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* second way:
|
/* second way:
|
||||||
Load into a polygon mesh straight away.
|
Load into a polygon mesh straight away.
|
||||||
*/
|
*/
|
||||||
vcg::tri::io::ImporterOBJ<MyPolyMesh>::Open(pm,argv[1],loadmask);
|
vcg::tri::io::ImporterOBJ<PMesh>::Open(pm,argv[1],loadmask);
|
||||||
vcg::tri::UpdateTopology<MyPolyMesh>::FaceFace(pm);
|
vcg::tri::UpdateTopology<PMesh>::FaceFace(pm);
|
||||||
vcg::tri::Clean<MyPolyMesh>::RemoveNonManifoldFace(pm);
|
vcg::tri::Clean<PMesh>::RemoveNonManifoldFace(pm);
|
||||||
vcg::tri::UpdateTopology<MyPolyMesh>::FaceFace(pm);
|
vcg::tri::UpdateTopology<PMesh>::FaceFace(pm);
|
||||||
assert(vcg::tri::Clean<MyPolyMesh>::CountNonManifoldEdgeFF(pm));
|
assert(vcg::tri::Clean<PMesh>::CountNonManifoldEdgeFF(pm));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// compute the half edges because I'm a half-edge programmer
|
// compute the half edges because I'm a half-edge programmer
|
||||||
vcg::tri::UpdateHalfEdges<MyPolyMesh>::FromIndexed(pm);
|
vcg::tri::UpdateHalfEdges<PMesh>::FromIndexed(pm);
|
||||||
|
|
||||||
// .... my half edge based code ......
|
// .... my half edge based code ......
|
||||||
|
|
||||||
// check for consistency
|
// check for consistency
|
||||||
assert(vcg::tri::UpdateHalfEdges<MyPolyMesh>::CheckConsistency(pm));
|
assert(vcg::tri::UpdateHalfEdges<PMesh>::CheckConsistency(pm));
|
||||||
|
|
||||||
int size = pm.face.size();
|
int size = pm.face.size();
|
||||||
|
|
||||||
// add a face to each face with more than 3 vertices ( just one pass)
|
// add a face to each face with more than 3 vertices ( just one pass)
|
||||||
|
|
||||||
for(int i = 0; i < size; ++i)
|
|
||||||
if(!(pm.face[i].IsD()))
|
|
||||||
if(pm.face[i].VN()>3){
|
|
||||||
MyPolyMesh::HEdgePointer ef = pm.face[i].FHp();
|
|
||||||
MyPolyMesh::HEdgePointer ef1 = ef -> HNp();
|
|
||||||
ef1 = ef1->HNp();
|
|
||||||
vcg::tri::UpdateHalfEdges<MyPolyMesh>::AddHEdge(pm, ef, ef1 );
|
|
||||||
}
|
|
||||||
assert(vcg::tri::UpdateHalfEdges<MyPolyMesh>::CheckConsistency(pm));
|
|
||||||
size = pm.face.size();
|
|
||||||
|
|
||||||
// remove an edge for each face
|
for(int i = 0; i < size; ++i)
|
||||||
|
if(!(pm.face[i].IsD()))
|
||||||
for(int i = 0; i < size; ++i)
|
if(pm.face[i].VN()>3){
|
||||||
if(!(pm.face[i].IsD() ))
|
PMesh::HEdgePointer ef = pm.face[i].FHp();
|
||||||
{
|
PMesh::HEdgePointer ef1 = ef -> HNp();
|
||||||
MyPolyMesh::HEdgePointer ef = pm.face[i].FHp();
|
ef1 = ef1->HNp();
|
||||||
if( ef->HOp()->HFp() !=NULL){
|
vcg::tri::UpdateHalfEdges<PMesh>::AddHEdge(pm, ef, ef1 );
|
||||||
vcg::tri::UpdateHalfEdges<MyPolyMesh>::RemoveHEdge(pm,ef);
|
}
|
||||||
}
|
assert(vcg::tri::UpdateHalfEdges<PMesh>::CheckConsistency(pm));
|
||||||
}
|
size = pm.face.size();
|
||||||
|
|
||||||
// check for consistency
|
// remove an edge for each face
|
||||||
assert(vcg::tri::UpdateHalfEdges<MyPolyMesh>::CheckConsistency(pm));
|
|
||||||
|
|
||||||
// recompute indexed data structure from the half edge data structure
|
for(int i = 0; i < size; ++i)
|
||||||
vcg::tri::UpdateIndexed<MyPolyMesh>::FromHalfEdges(pm );
|
if(!(pm.face[i].IsD() ))
|
||||||
|
{
|
||||||
// create a triangle mesh from a polygon mesh
|
PMesh::HEdgePointer ef = pm.face[i].FHp();
|
||||||
vcg::tri::PolygonSupport<CMesh,MyPolyMesh>::ImportFromPolyMesh(mesh1,pm);
|
if( ef->HOp()->HFp() !=NULL){
|
||||||
|
vcg::tri::UpdateHalfEdges<PMesh>::RemoveHEdge(pm,ef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// write out the triangle mesh
|
// check for consistency
|
||||||
vcg::tri::io::ExporterPLY<CMesh>::Save(mesh1,"converted_out.ply",true,pi);
|
assert(vcg::tri::UpdateHalfEdges<PMesh>::CheckConsistency(pm));
|
||||||
|
|
||||||
|
// recompute indexed data structure from the half edge data structure
|
||||||
|
// vcg::tri::UpdateIndexed<PMesh>::FromHalfEdges(pm );
|
||||||
|
|
||||||
|
// create a triangle mesh from a polygon mesh
|
||||||
|
TMesh tm1;
|
||||||
|
vcg::tri::PolygonSupport<TMesh,PMesh>::ImportFromPolyMesh(tm1,pm);
|
||||||
|
|
||||||
|
vcg::tri::io::PlyInfo pi;
|
||||||
|
vcg::tri::io::ExporterPLY<TMesh>::Save(tm1,"converted_tri.ply",false,pi);
|
||||||
|
vcg::tri::io::ExporterPLY<PMesh>::Save(pm,"converted_poly.ply",false,pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class MyFace;
|
||||||
class MyVertex;
|
class MyVertex;
|
||||||
|
|
||||||
struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
||||||
Use<MyFace> ::AsFaceType>{};
|
Use<MyFace> ::AsFaceType>{};
|
||||||
|
|
||||||
class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags, vertex::Mark>{};
|
class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags, vertex::Mark>{};
|
||||||
class MyFace : public Face < MyUsedTypes, face::VertexRef, face::Normal3f, face::BitFlags > {};
|
class MyFace : public Face < MyUsedTypes, face::VertexRef, face::Normal3f, face::BitFlags > {};
|
||||||
|
@ -53,51 +53,49 @@ bool callback(int percent, const char *str) {
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if(argc<3)
|
if(argc<3)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"\n trimesh_ball_pivoting ("__DATE__")\n"
|
|
||||||
" Visual Computing Group I.S.T.I. C.N.R.\n"
|
|
||||||
"Usage: trimesh_ball_pivoting filein.ply fileout.ply [opt]\n"
|
"Usage: trimesh_ball_pivoting filein.ply fileout.ply [opt]\n"
|
||||||
"options: \n"
|
"options: \n"
|
||||||
"-r <val> radius of the rolling ball\n"
|
"-r <val> radius of the rolling ball\n"
|
||||||
"-c <val> clustering radius (as fraction of radius) default: 0.05\n"
|
"-c <val> clustering radius (as fraction of radius) default: 0.05\n"
|
||||||
);
|
);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float radius = 0.0f;
|
float radius = 0.0f;
|
||||||
float clustering = 0.05;
|
float clustering = 0.05;
|
||||||
int i = 3;
|
int i = 3;
|
||||||
while(i<argc)
|
while(i<argc)
|
||||||
{
|
{
|
||||||
if(argv[i][0]!='-')
|
if(argv[i][0]!='-')
|
||||||
{printf("Error unable to parse option '%s'\n",argv[i]); exit(0);}
|
{printf("Error unable to parse option '%s'\n",argv[i]); exit(0);}
|
||||||
switch(argv[i][1])
|
switch(argv[i][1])
|
||||||
{
|
{
|
||||||
case 'r' : radius = atof(argv[++i]); printf("Using %f sphere radius\n",radius); break;
|
case 'r' : radius = atof(argv[++i]); printf("Using %f sphere radius\n",radius); break;
|
||||||
case 'c' : clustering = atof(argv[++i]); printf("Using %f clustering radius\n",clustering); break;
|
case 'c' : clustering = atof(argv[++i]); printf("Using %f clustering radius\n",clustering); break;
|
||||||
|
|
||||||
default : {printf("Error unable to parse option '%s'\n",argv[i]); exit(0);}
|
|
||||||
}
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
if(radius == 0)
|
|
||||||
printf("Autodetecting ball radius...\n");
|
|
||||||
|
|
||||||
MyMesh m;
|
|
||||||
|
|
||||||
if(vcg::tri::io::ImporterPLY<MyMesh>::Open(m,argv[1])!=0)
|
default : {printf("Error unable to parse option '%s'\n",argv[i]); exit(0);}
|
||||||
{
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
if(radius == 0)
|
||||||
|
printf("Autodetecting ball radius...\n");
|
||||||
|
|
||||||
|
MyMesh m;
|
||||||
|
|
||||||
|
if(vcg::tri::io::ImporterPLY<MyMesh>::Open(m,argv[1])!=0)
|
||||||
|
{
|
||||||
printf("Error reading file %s\n",argv[1]);
|
printf("Error reading file %s\n",argv[1]);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
vcg::tri::UpdateBounding<MyMesh>::Box(m);
|
vcg::tri::UpdateBounding<MyMesh>::Box(m);
|
||||||
vcg::tri::UpdateNormal<MyMesh>::PerFace(m);
|
vcg::tri::UpdateNormal<MyMesh>::PerFace(m);
|
||||||
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());
|
printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());
|
||||||
|
|
||||||
int t0=clock();
|
int t0=clock();
|
||||||
// Initialization
|
// Initialization
|
||||||
tri::BallPivoting<MyMesh> pivot(m, radius, clustering);
|
tri::BallPivoting<MyMesh> pivot(m, radius, clustering);
|
||||||
printf("Ball radius: %f\nClustering points withing %f radii\n", pivot.radius, clustering);
|
printf("Ball radius: %f\nClustering points withing %f radii\n", pivot.radius, clustering);
|
||||||
|
|
||||||
int t1=clock();
|
int t1=clock();
|
||||||
|
@ -108,7 +106,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
printf("Output mesh vn:%i fn:%i\n",m.VN(),m.FN());
|
printf("Output mesh vn:%i fn:%i\n",m.VN(),m.FN());
|
||||||
printf("Created in :%i msec (%i+%i)\n",t2-t0,t1-t0,t2-t1);
|
printf("Created in :%i msec (%i+%i)\n",t2-t0,t1-t0,t2-t1);
|
||||||
|
|
||||||
vcg::tri::io::PlyInfo pi;
|
vcg::tri::io::PlyInfo pi;
|
||||||
vcg::tri::io::ExporterPLY<MyMesh>::Save(m,argv[2],pi.mask);
|
vcg::tri::io::ExporterPLY<MyMesh>::Save(m,argv[2],pi.mask);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -26,9 +26,9 @@ class MyVertex : public vcg::Vertex< MyUsedTypes,vcg::vertex::VFAdj,vcg::vertex
|
||||||
class MyEdge : public vcg::Edge< MyUsedTypes> {};
|
class MyEdge : public vcg::Edge< MyUsedTypes> {};
|
||||||
|
|
||||||
class MyFace : public vcg::Face< MyUsedTypes,
|
class MyFace : public vcg::Face< MyUsedTypes,
|
||||||
vcg::face::VFAdj,
|
vcg::face::VFAdj,
|
||||||
vcg::face::VertexRef,
|
vcg::face::VertexRef,
|
||||||
vcg::face::BitFlags > {};
|
vcg::face::BitFlags > {};
|
||||||
|
|
||||||
// the main mesh class
|
// the main mesh class
|
||||||
class MyMesh : public vcg::tri::TriMesh<std::vector<MyVertex>, std::vector<MyFace> > {};
|
class MyMesh : public vcg::tri::TriMesh<std::vector<MyVertex>, std::vector<MyFace> > {};
|
||||||
|
@ -39,8 +39,8 @@ class OcfFace;
|
||||||
|
|
||||||
// Declaration of the semantic of the used types
|
// Declaration of the semantic of the used types
|
||||||
class OcfUsedTypes: public vcg::UsedTypes < vcg::Use<OcfVertex>::AsVertexType,
|
class OcfUsedTypes: public vcg::UsedTypes < vcg::Use<OcfVertex>::AsVertexType,
|
||||||
vcg::Use<OcfEdge >::AsEdgeType,
|
vcg::Use<OcfEdge >::AsEdgeType,
|
||||||
vcg::Use<OcfFace >::AsFaceType >{};
|
vcg::Use<OcfFace >::AsFaceType >{};
|
||||||
|
|
||||||
|
|
||||||
// The Main Vertex Class
|
// The Main Vertex Class
|
||||||
|
@ -61,26 +61,18 @@ class OcfEdge : public vcg::Edge<OcfUsedTypes>
|
||||||
// Each face needs 32 byte, on 32bit arch. and 48 byte on 64bit arch.
|
// Each face needs 32 byte, on 32bit arch. and 48 byte on 64bit arch.
|
||||||
class OcfFace : public vcg::Face< OcfUsedTypes,vcg::face::InfoOcf,vcg::face::VertexRef,vcg::face::BitFlags,vcg::face::VFAdjOcf> {};
|
class OcfFace : public vcg::Face< OcfUsedTypes,vcg::face::InfoOcf,vcg::face::VertexRef,vcg::face::BitFlags,vcg::face::VFAdjOcf> {};
|
||||||
|
|
||||||
class OcfMesh : public vcg::tri::TriMesh< vcg::vertex::vector_ocf<OcfVertex>, vcg::face::vector_ocf<OcfFace> >
|
class OcfMesh : public vcg::tri::TriMesh< vcg::vertex::vector_ocf<OcfVertex>, vcg::face::vector_ocf<OcfFace> >
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
void Usage()
|
void Usage()
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"---------------------------------\n"
|
"\nUsage: "\
|
||||||
" TriMeshCopy V.1.0 \n"
|
"trimeshcopy fileIn -(n|o) [fileOut]\n"\
|
||||||
" http://vcg.isti.cnr.it\n"
|
"trimeshcopy test vcg::MeshCopy efficiency.\nIt imports a fileIn file into a user defined mesh and test how long vcg::MeshCopy needs to copy the imported mesh in a second one.The copy time is expressed in milliseconds.\nIf the -n flag is used a non-optional attributes mesh will be tested, defining -o, instead, the target mesh will be an ocf one.\nA fileOut file can be passed to the tool in order to check if the mesh was successfully copied.\nThe file will be exported in PLY file format.\n"
|
||||||
" http://vcg.sourceforge.net\n"
|
);
|
||||||
" release date: "__DATE__"\n"
|
exit(-1);
|
||||||
"---------------------------------\n\n"
|
|
||||||
"TriMeshCopy 1.0 \n"__DATE__"\n"
|
|
||||||
"Copyright 2003-2012 Visual Computing Lab I.S.T.I. C.N.R.\n"
|
|
||||||
"\nUsage: "\
|
|
||||||
"trimeshcopy fileIn -(n|o) [fileOut]\n"\
|
|
||||||
"trimeshcopy test vcg::MeshCopy efficiency.\nIt imports a fileIn file into a user defined mesh and test how long vcg::MeshCopy needs to copy the imported mesh in a second one.The copy time is expressed in milliseconds.\nIf the -n flag is used a non-optional attributes mesh will be tested, defining -o, instead, the target mesh will be an ocf one.\nA fileOut file can be passed to the tool in order to check if the mesh was successfully copied.\nThe file will be exported in PLY file format.\n"
|
|
||||||
);
|
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MeshType>
|
template <class MeshType>
|
||||||
|
@ -117,7 +109,7 @@ bool UnitTest_Append(const char *filename1, const char *filename2)
|
||||||
|
|
||||||
int main(int /*argc*/ ,char**argv)
|
int main(int /*argc*/ ,char**argv)
|
||||||
{
|
{
|
||||||
UnitTest_Append<MyMesh>(argv[1],"out.ply");
|
UnitTest_Append<MyMesh>(argv[1],"out.ply");
|
||||||
UnitTest_Append<OcfMesh>(argv[1],"out.ply");
|
UnitTest_Append<OcfMesh>(argv[1],"out.ply");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,12 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include<vcg/complex/complex.h>
|
#include<vcg/complex/complex.h>
|
||||||
|
|
||||||
#include<wrap/io_trimesh/import_off.h>
|
#include<wrap/io_trimesh/import_ply.h>
|
||||||
|
#include<wrap/io_trimesh/export_ply.h>
|
||||||
|
|
||||||
|
#include<vcg/complex/algorithms/point_sampling.h>
|
||||||
#include<vcg/complex/algorithms/geodesic.h>
|
#include<vcg/complex/algorithms/geodesic.h>
|
||||||
|
#include<vcg/complex/algorithms/update/color.h>
|
||||||
|
|
||||||
using namespace vcg;
|
using namespace vcg;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -36,8 +39,8 @@ struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
||||||
Use<MyEdge> ::AsEdgeType,
|
Use<MyEdge> ::AsEdgeType,
|
||||||
Use<MyFace> ::AsFaceType>{};
|
Use<MyFace> ::AsFaceType>{};
|
||||||
|
|
||||||
class MyVertex : public Vertex<MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{};
|
class MyVertex : public Vertex<MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::Mark, vertex::VFAdj, vertex::Color4b, vertex::Qualityf, vertex::BitFlags >{};
|
||||||
class MyFace : public Face< MyUsedTypes, face::FFAdj, face::VertexRef, face::BitFlags > {};
|
class MyFace : public Face< MyUsedTypes, face::VFAdj, face::VertexRef, face::Normal3f, face::BitFlags > {};
|
||||||
class MyEdge : public Edge<MyUsedTypes>{};
|
class MyEdge : public Edge<MyUsedTypes>{};
|
||||||
class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector<MyEdge> > {};
|
class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector<MyEdge> > {};
|
||||||
|
|
||||||
|
@ -45,20 +48,47 @@ int main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
if(argc<2)
|
if(argc<2)
|
||||||
{
|
{
|
||||||
printf("Usage trimesh_base <meshfilename.obj>\n");
|
printf("Usage trimesh_geodesic <meshfilename.obj>\n");
|
||||||
return -1;
|
// return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MyMesh m;
|
MyMesh m;
|
||||||
|
|
||||||
if(tri::io::ImporterOFF<MyMesh>::Open(m,argv[1])!=0)
|
// if(tri::io::ImporterPLY<MyMesh>::Open(m,"../../meshes/disk_irregular_1k.ply")!=0)
|
||||||
|
if(tri::io::ImporterPLY<MyMesh>::Open(m,"../../meshes/disk_irregular_650k.ply")!=0)
|
||||||
{
|
{
|
||||||
printf("Error reading file %s\n",argv[1]);
|
printf("Error reading file %s\n",argv[1]);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
vector<Point3f> pointVec;
|
|
||||||
float radius;
|
Point3f c=m.bbox.Center();
|
||||||
tri::PoissonSampling<MyMesh>(m,pointVec,1000,radius);
|
MyVertex*closest=&*m.vert.begin();
|
||||||
|
float minDist = Distance(closest->P(),c);
|
||||||
|
for(MyMesh::VertexIterator vi=m.vert.begin();vi!=m.vert.end(); ++vi)
|
||||||
|
{
|
||||||
|
if(Distance(vi->P(),c)<minDist)
|
||||||
|
{
|
||||||
|
minDist = Distance(vi->P(),c);
|
||||||
|
closest = &*vi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vector<MyVertex*> seedVec;
|
||||||
|
seedVec.push_back(closest);
|
||||||
|
tri::EuclideanDistance<MyMesh> ed;
|
||||||
|
tri::Clean<MyMesh>::RemoveUnreferencedVertex(m);
|
||||||
|
tri::Allocator<MyMesh>::CompactEveryVector(m);
|
||||||
|
tri::UpdateTopology<MyMesh>::VertexFace(m);
|
||||||
|
tri::Geodesic<MyMesh>::Compute(m,seedVec,ed);
|
||||||
|
pair<float,float> minmax = tri::Stat<MyMesh>::ComputePerVertexQualityMinMax(m);
|
||||||
|
tri::UpdateColor<MyMesh>::PerVertexQualityRamp(m);
|
||||||
|
printf("min %f max %f\n",minmax.first,minmax.second);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(m,"base.ply",tri::io::Mask::IOM_VERTCOLOR | tri::io::Mask::IOM_VERTQUALITY);
|
||||||
|
int t0=clock();
|
||||||
|
tri::Geodesic<MyMesh>::PerVertexDijsktraCompute(m,seedVec,ed);
|
||||||
|
int t1=clock();
|
||||||
|
printf("Geodesic dijkstra %6.3f\n",float(t1-t0)/CLOCKS_PER_SEC);
|
||||||
|
tri::UpdateColor<MyMesh>::PerVertexQualityRamp(m);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(m,"base_d.ply",tri::io::Mask::IOM_VERTCOLOR | tri::io::Mask::IOM_VERTQUALITY);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
include(../common.pri)
|
include(../common.pri)
|
||||||
TARGET = trimesh_geodesic
|
TARGET = trimesh_geodesic
|
||||||
SOURCES += trimesh_geodesic.cpp
|
SOURCES += trimesh_geodesic.cpp ../../../wrap/ply/plylib.cpp
|
||||||
|
|
|
@ -73,13 +73,13 @@ bool NormalTest(typename face::Pos<typename MESH::FaceType> pos)
|
||||||
{
|
{
|
||||||
//giro intorno al vertice e controllo le normali
|
//giro intorno al vertice e controllo le normali
|
||||||
typename MESH::ScalarType thr = 0.0f;
|
typename MESH::ScalarType thr = 0.0f;
|
||||||
typename MESH::CoordType NdP = vcg::Normal<typename MESH::FaceType>(*pos.f);
|
typename MESH::CoordType NdP = vcg::TriangleNormal<typename MESH::FaceType>(*pos.f);
|
||||||
typename MESH::CoordType tmp, oop, soglia = typename MESH::CoordType(thr,thr,thr);
|
typename MESH::CoordType tmp, oop, soglia = typename MESH::CoordType(thr,thr,thr);
|
||||||
face::Pos<typename MESH::FaceType> aux=pos;
|
face::Pos<typename MESH::FaceType> aux=pos;
|
||||||
do{
|
do{
|
||||||
aux.FlipF();
|
aux.FlipF();
|
||||||
aux.FlipE();
|
aux.FlipE();
|
||||||
oop = Abs(tmp - ::vcg::Normal<typename MESH::FaceType>(*pos.f));
|
oop = Abs(tmp - ::vcg::TriangleNormal<typename MESH::FaceType>(*pos.f));
|
||||||
if(oop < soglia )return false;
|
if(oop < soglia )return false;
|
||||||
}while(aux != pos && !aux.IsBorder());
|
}while(aux != pos && !aux.IsBorder());
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ int main(int argc,char ** argv){
|
||||||
if(argc<5)
|
if(argc<5)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"\n HoleFilling ("__DATE__")\n"
|
"\n HoleFilling (" __DATE__ ")\n"
|
||||||
"Visual Computing Group I.S.T.I. C.N.R.\n"
|
"Visual Computing Group I.S.T.I. C.N.R.\n"
|
||||||
"Usage: trimesh_hole #algorithm #size filein.ply fileout.ply \n"
|
"Usage: trimesh_hole #algorithm #size filein.ply fileout.ply \n"
|
||||||
"#algorithm: \n"
|
"#algorithm: \n"
|
||||||
|
|
|
@ -40,7 +40,7 @@ class MyFace;
|
||||||
class MyVertex;
|
class MyVertex;
|
||||||
|
|
||||||
struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
||||||
Use<MyFace> ::AsFaceType>{};
|
Use<MyFace> ::AsFaceType>{};
|
||||||
|
|
||||||
class MyVertex : public Vertex <MyUsedTypes, vertex::Coord3f, vertex::BitFlags >{};
|
class MyVertex : public Vertex <MyUsedTypes, vertex::Coord3f, vertex::BitFlags >{};
|
||||||
class MyFace : public Face < MyUsedTypes, face::VertexRef, face::BitFlags > {};
|
class MyFace : public Face < MyUsedTypes, face::VertexRef, face::BitFlags > {};
|
||||||
|
@ -51,31 +51,29 @@ class MyMesh : public vcg::tri::TriMesh< vector<MyVertex>, vector<MyFace> > {
|
||||||
int main(int argc,char **argv )
|
int main(int argc,char **argv )
|
||||||
{
|
{
|
||||||
if(argc<2)
|
if(argc<2)
|
||||||
{
|
{
|
||||||
printf( "\n trimesh_join ("__DATE__")\n"
|
printf( "Usage: trimesh_join [opt] filename.ply [filename.ply | *] \n"
|
||||||
"Visual Computing Group I.S.T.I. C.N.R.\n"
|
|
||||||
"Usage: trimesh_join [opt] filename.ply [filename.ply | *] \n"
|
|
||||||
"where opt can be:\n"
|
"where opt can be:\n"
|
||||||
" -b xmin ymin zmin xmax ymax zmax : \n"
|
" -b xmin ymin zmin xmax ymax zmax : \n"
|
||||||
" Returns only mesh composed by faces inside specified bbox\n"
|
" Returns only mesh composed by faces inside specified bbox\n"
|
||||||
" -t Just scan all the input files computing the total bbox\n"
|
" -t Just scan all the input files computing the total bbox\n"
|
||||||
);
|
);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MyMesh ml,mr;
|
MyMesh ml,mr;
|
||||||
Box3f ClipBB,TotBB;
|
Box3f ClipBB,TotBB;
|
||||||
bool ClipFlag=false,MergeFlag=true;
|
bool ClipFlag=false,MergeFlag=true;
|
||||||
int i=1;
|
int i=1;
|
||||||
// Parsing option loop
|
// Parsing option loop
|
||||||
while(argv[i][0]=='-')
|
while(argv[i][0]=='-')
|
||||||
{
|
{
|
||||||
switch(argv[i][1])
|
switch(argv[i][1])
|
||||||
{
|
{
|
||||||
case 'b': {
|
case 'b': {
|
||||||
if(argc<i+7) {
|
if(argc<i+7) {
|
||||||
printf("Error in parsing bbox option");
|
printf("Error in parsing bbox option");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
ClipBB.min=Point3f::Construct(atof(argv[i+1]),atof(argv[i+2]),atof(argv[i+3]));
|
ClipBB.min=Point3f::Construct(atof(argv[i+1]),atof(argv[i+2]),atof(argv[i+3]));
|
||||||
ClipBB.max=Point3f::Construct(atof(argv[i+4]),atof(argv[i+5]),atof(argv[i+6]));
|
ClipBB.max=Point3f::Construct(atof(argv[i+4]),atof(argv[i+5]),atof(argv[i+6]));
|
||||||
|
@ -90,36 +88,36 @@ int main(int argc,char **argv )
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
while(i<argc)
|
while(i<argc)
|
||||||
{
|
{
|
||||||
if(vcg::tri::io::ImporterPLY<MyMesh>::Open(mr,argv[i])!=0)
|
if(vcg::tri::io::ImporterPLY<MyMesh>::Open(mr,argv[i])!=0)
|
||||||
{
|
{
|
||||||
printf("Error reading file %s\n",argv[1]);
|
printf("Error reading file %s\n",argv[1]);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
printf("Input mesh %3i vn:%9i fn:%9i\n",i, mr.VN(), mr.FN());
|
printf("Input mesh %3i vn:%9i fn:%9i\n",i, mr.VN(), mr.FN());
|
||||||
if(ClipFlag)
|
if(ClipFlag)
|
||||||
{
|
{
|
||||||
tri::GenericVertexInterpolator<MyMesh> interp(mr);
|
tri::GenericVertexInterpolator<MyMesh> interp(mr);
|
||||||
tri::TriMeshClipper<MyMesh>::Box(ClipBB,interp,mr);
|
tri::TriMeshClipper<MyMesh>::Box(ClipBB,interp,mr);
|
||||||
printf(" clipped to vn:%9i fn:%9i\n", mr.VN(), mr.FN());
|
printf(" clipped to vn:%9i fn:%9i\n", mr.VN(), mr.FN());
|
||||||
}
|
}
|
||||||
tri::UpdateBounding<MyMesh>::Box(mr);
|
tri::UpdateBounding<MyMesh>::Box(mr);
|
||||||
TotBB.Add(mr.bbox);
|
TotBB.Add(mr.bbox);
|
||||||
|
|
||||||
if(MergeFlag) tri::Append<MyMesh,MyMesh>::Mesh(ml,mr); // append mesh mr to ml
|
if(MergeFlag) tri::Append<MyMesh,MyMesh>::Mesh(ml,mr); // append mesh mr to ml
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Output mesh vn:%i fn:%i\n",ml.VN(),ml.FN());
|
printf("Output mesh vn:%i fn:%i\n",ml.VN(),ml.FN());
|
||||||
|
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(ml,"joined.ply");
|
tri::io::ExporterPLY<MyMesh>::Save(ml,"joined.ply");
|
||||||
int dv=tri::Clean<MyMesh>::RemoveDuplicateVertex(ml);
|
int dv=tri::Clean<MyMesh>::RemoveDuplicateVertex(ml);
|
||||||
printf("Removed %i duplicated vertices\n",dv);
|
printf("Removed %i duplicated vertices\n",dv);
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(ml,"joined_unif.ply");
|
tri::io::ExporterPLY<MyMesh>::Save(ml,"joined_unif.ply");
|
||||||
printf("Final BBox of mesh :\n (%7.4f %7.4f %7.4f) - (%7.4f %7.4f %7.4f)\n",
|
printf("Final BBox of mesh :\n (%7.4f %7.4f %7.4f) - (%7.4f %7.4f %7.4f)\n",
|
||||||
TotBB.min[0],TotBB.min[1],TotBB.min[2],
|
TotBB.min[0],TotBB.min[1],TotBB.min[2],
|
||||||
TotBB.max[0],TotBB.max[1],TotBB.max[2]);
|
TotBB.max[0],TotBB.max[1],TotBB.max[2]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
/*! \file trimesh_kdtree.cpp
|
/*! \file trimesh_kdtree.cpp
|
||||||
\ingroup code_sample
|
\ingroup code_sample
|
||||||
|
|
||||||
\brief An example about using the kdtree and meshes
|
\brief An example about using a kdtree to spatially index the vertexes of a mesh
|
||||||
|
|
||||||
KdTree are one of the Spatial indexing data structure available.
|
KdTree are one of the Spatial indexing data structures available.
|
||||||
They are tailored for storing point-based structures and performing k-neighbours queries.
|
They are tailored for storing point-based structures and performing k-neighbours queries.
|
||||||
In this simple example we simply compute the average distance of a vertex from its neighbours.
|
In this simple example we simply compute the average distance of a vertex from its neighbours.
|
||||||
\ref spatial_indexing for more Details
|
\ref spatial_indexing for more Details
|
||||||
|
@ -69,13 +69,13 @@ int main( int argc, char **argv )
|
||||||
|
|
||||||
KdTree<float> tree(ww);
|
KdTree<float> tree(ww);
|
||||||
KdTree<float>::PriorityQueue queue;
|
KdTree<float>::PriorityQueue queue;
|
||||||
|
|
||||||
for (int j = 0; j < m.VN(); j++) {
|
for (int j = 0; j < m.VN(); j++) {
|
||||||
tree.doQueryK(m.vert[j].cP(), 3, queue);
|
tree.doQueryK(m.vert[j].cP(), 3, queue);
|
||||||
int neighbours = queue.getNofElements();
|
int neighbours = queue.getNofElements();
|
||||||
float avgDist=0;
|
float avgDist=0;
|
||||||
for (int i = 0; i < neighbours; i++) {
|
for (int i = 0; i < neighbours; i++) {
|
||||||
int neightId = queue.getIndex(i);
|
int neightId = queue.getIndex(i);
|
||||||
avgDist += Distance(m.vert[j].cP(),m.vert[neightId].cP());
|
avgDist += Distance(m.vert[j].cP(),m.vert[neightId].cP());
|
||||||
}
|
}
|
||||||
m.vert[j].Q() = avgDist/=neighbours;
|
m.vert[j].Q() = avgDist/=neighbours;
|
||||||
|
|
|
@ -40,7 +40,7 @@ int main(int argc, char **argv)
|
||||||
if(argc<4)
|
if(argc<4)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"\n PlyRefine ("__DATE__")\n"
|
"\n PlyRefine (" __DATE__ ")\n"
|
||||||
" Visual Computing Group I.S.T.I. C.N.R.\n"
|
" Visual Computing Group I.S.T.I. C.N.R.\n"
|
||||||
"Usage: PlyRefine filein.ply fileout.[ply|off|obj|...] ref_step [opt] \n"
|
"Usage: PlyRefine filein.ply fileout.[ply|off|obj|...] ref_step [opt] \n"
|
||||||
"Commands: \n"
|
"Commands: \n"
|
||||||
|
|
|
@ -61,17 +61,18 @@ int main( int argc, char **argv )
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::SamplingRandomGenerator().initialize(time(0));
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::SamplingRandomGenerator().initialize(time(0));
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Basic Sample,
|
// Basic Sample of a mesh surface
|
||||||
// Build a point cloud with points with a plain poisson disk distribution
|
// Build a point cloud with points with a plain poisson disk distribution
|
||||||
|
|
||||||
int t0=clock();
|
int t0=clock();
|
||||||
vector<Point3f> pointVec;
|
vector<Point3f> pointVec;
|
||||||
float rad;
|
float rad=0;
|
||||||
if(argc>2) rad=atof(argv[2]);
|
if(argc>2) rad=atof(argv[2]);
|
||||||
int sampleNum=rad?0:1000;
|
int sampleNum=rad?0:1000;
|
||||||
tri::PoissonSampling<MyMesh>(m,pointVec,sampleNum,rad);
|
tri::PoissonSampling<MyMesh>(m,pointVec,sampleNum,rad);
|
||||||
int t1=clock();
|
int t1=clock();
|
||||||
MyMesh BasicPoissonMesh;
|
MyMesh BasicPoissonMesh;
|
||||||
tri::Build(BasicPoissonMesh,pointVec);
|
tri::BuildMeshFromCoordVector(BasicPoissonMesh,pointVec);
|
||||||
|
|
||||||
tri::io::ExporterOFF<MyMesh>::Save(BasicPoissonMesh,"BasicPoissonMesh.off");
|
tri::io::ExporterOFF<MyMesh>::Save(BasicPoissonMesh,"BasicPoissonMesh.off");
|
||||||
printf("Computed a basic poisson disk distribution of %i vertices radius is %6.3f in %5.2f sec\n",BasicPoissonMesh.VN(),rad,float(t1-t0)/CLOCKS_PER_SEC);
|
printf("Computed a basic poisson disk distribution of %i vertices radius is %6.3f in %5.2f sec\n",BasicPoissonMesh.VN(),rad,float(t1-t0)/CLOCKS_PER_SEC);
|
||||||
|
@ -90,32 +91,32 @@ int main( int argc, char **argv )
|
||||||
tri::UpdateNormal<MyMesh>::PerFace(m);
|
tri::UpdateNormal<MyMesh>::PerFace(m);
|
||||||
tri::UpdateFlags<MyMesh>::FaceFauxCrease(m,math::ToRad(40.0f));
|
tri::UpdateFlags<MyMesh>::FaceFauxCrease(m,math::ToRad(40.0f));
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::EdgeMontecarlo(m,mps,10000,false);
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::EdgeMontecarlo(m,mps,10000,false);
|
||||||
tri::Build(MontecarloEdgeMesh,sampleVec);
|
tri::BuildMeshFromCoordVector(MontecarloEdgeMesh,sampleVec);
|
||||||
tri::io::ExporterOFF<MyMesh>::Save(MontecarloEdgeMesh,"MontecarloEdgeMesh.off");
|
tri::io::ExporterOFF<MyMesh>::Save(MontecarloEdgeMesh,"MontecarloEdgeMesh.off");
|
||||||
|
|
||||||
sampleVec.clear();
|
sampleVec.clear();
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::VertexCrease(m, mps);
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::VertexCrease(m, mps);
|
||||||
tri::Build(PoissonEdgeMesh,sampleVec);
|
tri::BuildMeshFromCoordVector(PoissonEdgeMesh,sampleVec);
|
||||||
tri::io::ExporterOFF<MyMesh>::Save(PoissonEdgeMesh,"CreaseMesh.off");
|
tri::io::ExporterOFF<MyMesh>::Save(PoissonEdgeMesh,"VertexCreaseMesh.off");
|
||||||
|
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskParam pp;
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskParam pp;
|
||||||
pp.preGenMesh = &PoissonEdgeMesh;
|
pp.preGenMesh = &PoissonEdgeMesh;
|
||||||
pp.preGenFlag=true;
|
pp.preGenFlag=true;
|
||||||
sampleVec.clear();
|
sampleVec.clear();
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, MontecarloEdgeMesh, rad, pp);
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, MontecarloEdgeMesh, rad, pp);
|
||||||
tri::Build(PoissonEdgeMesh,sampleVec);
|
tri::BuildMeshFromCoordVector(PoissonEdgeMesh,sampleVec);
|
||||||
tri::io::ExporterOFF<MyMesh>::Save(PoissonEdgeMesh,"PoissonEdgeMesh.off");
|
tri::io::ExporterOFF<MyMesh>::Save(PoissonEdgeMesh,"PoissonEdgeMesh.off");
|
||||||
|
|
||||||
sampleVec.clear();
|
sampleVec.clear();
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::Montecarlo(m,mps,50000);
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::Montecarlo(m,mps,50000);
|
||||||
tri::Build(MontecarloSurfaceMesh,sampleVec);
|
tri::BuildMeshFromCoordVector(MontecarloSurfaceMesh,sampleVec);
|
||||||
tri::io::ExporterOFF<MyMesh>::Save(MontecarloSurfaceMesh,"MontecarloSurfaceMesh.off");
|
tri::io::ExporterOFF<MyMesh>::Save(MontecarloSurfaceMesh,"MontecarloSurfaceMesh.off");
|
||||||
|
|
||||||
pp.preGenMesh = &PoissonEdgeMesh;
|
pp.preGenMesh = &PoissonEdgeMesh;
|
||||||
pp.preGenFlag=true;
|
pp.preGenFlag=true;
|
||||||
sampleVec.clear();
|
sampleVec.clear();
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, MontecarloSurfaceMesh, rad, pp);
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, MontecarloSurfaceMesh, rad, pp);
|
||||||
tri::Build(PoissonMesh,sampleVec);
|
tri::BuildMeshFromCoordVector(PoissonMesh,sampleVec);
|
||||||
tri::io::ExporterOFF<MyMesh>::Save(PoissonMesh,"PoissonMesh.off");
|
tri::io::ExporterOFF<MyMesh>::Save(PoissonMesh,"PoissonMesh.off");
|
||||||
printf("Computed a feature aware poisson disk distribution of %i vertices radius is %6.3f\n",PoissonMesh.VN(),rad);
|
printf("Computed a feature aware poisson disk distribution of %i vertices radius is %6.3f\n",PoissonMesh.VN(),rad);
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ int main(int ,char ** )
|
||||||
std::vector<std::pair<int,MyMesh::FacePointer> > fpVec;
|
std::vector<std::pair<int,MyMesh::FacePointer> > fpVec;
|
||||||
tri::UpdateTopology<MyMesh>::FaceFace(tm);
|
tri::UpdateTopology<MyMesh>::FaceFace(tm);
|
||||||
tri::Clean<MyMesh>::ConnectedComponents(tm,fpVec);
|
tri::Clean<MyMesh>::ConnectedComponents(tm,fpVec);
|
||||||
printf("Mesh has %i texture components\n",fpVec.size());
|
printf("Mesh has %lu texture components\n",fpVec.size());
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(tm,"out.ply");
|
tri::io::ExporterPLY<MyMesh>::Save(tm,"out.ply");
|
||||||
std::vector< std::vector<Point2f> > outline2Vec;
|
std::vector< std::vector<Point2f> > outline2Vec;
|
||||||
|
|
||||||
|
@ -99,13 +99,13 @@ int main(int ,char ** )
|
||||||
outline2Vec.push_back(compOutline2Vec[largestInd]);
|
outline2Vec.push_back(compOutline2Vec[largestInd]);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Mesh has %i texture components\n",outline2Vec.size());
|
printf("Mesh has %lu texture components\n",outline2Vec.size());
|
||||||
|
|
||||||
Outline2Dumper::Param pp;
|
Outline2Dumper::Param pp;
|
||||||
Similarity2f sim;
|
Similarity2f sim;
|
||||||
sim.sca=1024.0f;
|
sim.sca=1024.0f;
|
||||||
std::vector<Similarity2f> trVec(outline2Vec.size(),sim);
|
std::vector<Similarity2f> trVec(outline2Vec.size(),sim);
|
||||||
printf("Mesh has %i texture components\n",outline2Vec.size());
|
printf("Mesh has %lu texture components\n",outline2Vec.size());
|
||||||
Outline2Dumper::dumpOutline2VecPNG("PrePack.png",outline2Vec,trVec,pp);
|
Outline2Dumper::dumpOutline2VecPNG("PrePack.png",outline2Vec,trVec,pp);
|
||||||
|
|
||||||
const Point2i containerSize(1024,1024);
|
const Point2i containerSize(1024,1024);
|
||||||
|
|
|
@ -39,7 +39,7 @@ struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
||||||
Use<MyFace> ::AsFaceType>{};
|
Use<MyFace> ::AsFaceType>{};
|
||||||
|
|
||||||
class MyVertex : public Vertex<MyUsedTypes, vertex::InfoOcf, vertex::Coord3f, vertex::Normal3f, vertex::TexCoord2f, vertex::VFAdj , vertex::Qualityf, vertex::Color4b, vertex::BitFlags >{};
|
class MyVertex : public Vertex<MyUsedTypes, vertex::InfoOcf, vertex::Coord3f, vertex::Normal3f, vertex::TexCoord2f, vertex::VFAdj , vertex::Qualityf, vertex::Color4b, vertex::BitFlags >{};
|
||||||
class MyFace : public Face< MyUsedTypes, face::InfoOcf, face::VertexRef, face::BitFlags, face::FFAdjOcf ,face::VFAdj , face::WedgeTexCoord2f> {};
|
class MyFace : public Face< MyUsedTypes, face::InfoOcf, face::VertexRef, face::CurvatureDirf, face::BitFlags, face::FFAdjOcf ,face::VFAdj , face::WedgeTexCoord2f> {};
|
||||||
class MyEdge : public Edge< MyUsedTypes>{};
|
class MyEdge : public Edge< MyUsedTypes>{};
|
||||||
class MyMesh : public tri::TriMesh< vertex::vector_ocf<MyVertex>, face::vector_ocf<MyFace> , vector<MyEdge> > {};
|
class MyMesh : public tri::TriMesh< vertex::vector_ocf<MyVertex>, face::vector_ocf<MyFace> , vector<MyEdge> > {};
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,9 @@ int main( int argc, char **argv )
|
||||||
printf("Usage trimesh_voronoiclustering mesh region_num iterNum\n");
|
printf("Usage trimesh_voronoiclustering mesh region_num iterNum\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int seed = atoi(argv[2]);
|
int seedNum = atoi(argv[2]);
|
||||||
int iterNum = atoi(argv[3]);
|
int iterNum = atoi(argv[3]);
|
||||||
printf("Reading %s and sampling %i \n",argv[1],seed);
|
printf("Reading %s and sampling %i \n",argv[1],seedNum);
|
||||||
int ret= tri::io::ImporterPLY<MyMesh>::Open(baseMesh,argv[1]);
|
int ret= tri::io::ImporterPLY<MyMesh>::Open(baseMesh,argv[1]);
|
||||||
if(ret!=0)
|
if(ret!=0)
|
||||||
{
|
{
|
||||||
|
@ -66,15 +66,14 @@ int main( int argc, char **argv )
|
||||||
|
|
||||||
int randSeed=time(0);
|
int randSeed=time(0);
|
||||||
tri::UpdateTopology<MyMesh>::VertexFace(baseMesh);
|
tri::UpdateTopology<MyMesh>::VertexFace(baseMesh);
|
||||||
std::vector<MyVertex *> seedVec;
|
tri::TrivialPointerSampler<MyMesh> cs;
|
||||||
tri::ClusteringSampler<MyMesh> cs(seedVec);
|
tri::SurfaceSampling<MyMesh, tri::TrivialPointerSampler<MyMesh> >::SamplingRandomGenerator().initialize(randSeed);
|
||||||
tri::SurfaceSampling<MyMesh, vcg::tri::ClusteringSampler<MyMesh> >::SamplingRandomGenerator().initialize(randSeed);
|
tri::SurfaceSampling<MyMesh, tri::TrivialPointerSampler<MyMesh> >::VertexUniform(baseMesh,cs,seedNum);
|
||||||
tri::SurfaceSampling<MyMesh, vcg::tri::ClusteringSampler<MyMesh> >::VertexUniform(baseMesh,cs,seed);
|
|
||||||
tri::VoronoiProcessingParameter vpp;
|
tri::VoronoiProcessingParameter vpp;
|
||||||
tri::EuclideanDistance<MyMesh> df;
|
tri::EuclideanDistance<MyMesh> df;
|
||||||
tri::VoronoiProcessing<MyMesh>::VoronoiRelaxing(baseMesh, seedVec, iterNum, df, vpp);
|
tri::VoronoiProcessing<MyMesh>::VoronoiRelaxing(baseMesh, cs.sampleVec, iterNum, df, vpp);
|
||||||
tri::VoronoiProcessing<MyMesh>::TopologicalVertexColoring(baseMesh, seedVec);
|
tri::VoronoiProcessing<MyMesh>::TopologicalVertexColoring(baseMesh, cs.sampleVec);
|
||||||
tri::VoronoiProcessing<MyMesh>::ConvertDelaunayTriangulationToMesh(baseMesh,clusteredMesh,seedVec);
|
tri::VoronoiProcessing<MyMesh>::ConvertDelaunayTriangulationToMesh(baseMesh,clusteredMesh,cs.sampleVec);
|
||||||
|
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(baseMesh,"base.ply",tri::io::Mask::IOM_VERTCOLOR );
|
tri::io::ExporterPLY<MyMesh>::Save(baseMesh,"base.ply",tri::io::Mask::IOM_VERTCOLOR );
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(clusteredMesh,"clustered.ply");
|
tri::io::ExporterPLY<MyMesh>::Save(clusteredMesh,"clustered.ply");
|
||||||
|
|
|
@ -70,7 +70,8 @@ int main( int argc, char **argv )
|
||||||
int sampleNum = atoi(argv[2]);
|
int sampleNum = atoi(argv[2]);
|
||||||
int iterNum = atoi(argv[3]);
|
int iterNum = atoi(argv[3]);
|
||||||
|
|
||||||
bool fixCornerFlag=false;
|
bool fixCornerFlag=true;
|
||||||
|
bool uniformEdgeSamplingFlag = true;
|
||||||
|
|
||||||
printf("Reading %s and sampling %i points with %i iteration\n",argv[1],sampleNum,iterNum);
|
printf("Reading %s and sampling %i points with %i iteration\n",argv[1],sampleNum,iterNum);
|
||||||
int ret= tri::io::ImporterPLY<MyMesh>::Open(baseMesh,argv[1]);
|
int ret= tri::io::ImporterPLY<MyMesh>::Open(baseMesh,argv[1]);
|
||||||
|
@ -91,34 +92,42 @@ int main( int argc, char **argv )
|
||||||
tri::VoronoiProcessing<MyMesh>::PreprocessForVoronoi(baseMesh,radius,vpp);
|
tri::VoronoiProcessing<MyMesh>::PreprocessForVoronoi(baseMesh,radius,vpp);
|
||||||
|
|
||||||
tri::UpdateFlags<MyMesh>::FaceBorderFromVF(baseMesh);
|
tri::UpdateFlags<MyMesh>::FaceBorderFromVF(baseMesh);
|
||||||
tri::UpdateFlags<MyMesh>::VertexBorderFromFace(baseMesh);
|
tri::UpdateFlags<MyMesh>::VertexBorderFromFaceBorder(baseMesh);
|
||||||
|
|
||||||
|
|
||||||
// -- Build a sampling with just corners (Poisson filtered)
|
// -- Build a sampling with just corners (Poisson filtered)
|
||||||
MyMesh poissonCornerMesh;
|
MyMesh poissonCornerMesh;
|
||||||
std::vector<Point3f> sampleVec;
|
std::vector<Point3f> sampleVec;
|
||||||
tri::TrivialSampler<MyMesh> mps(sampleVec);
|
tri::TrivialSampler<MyMesh> mps(sampleVec);
|
||||||
if(fixCornerFlag)
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::VertexBorderCorner(baseMesh,mps,math::ToRad(150.f));
|
||||||
|
tri::BuildMeshFromCoordVector(poissonCornerMesh,sampleVec);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(poissonCornerMesh,"cornerMesh.ply");
|
||||||
|
sampleVec.clear();
|
||||||
|
MyMesh borderMesh,poissonBorderMesh;
|
||||||
|
|
||||||
|
|
||||||
|
if(uniformEdgeSamplingFlag)
|
||||||
{
|
{
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::VertexBorderCorner(baseMesh,mps,math::ToRad(150.f));
|
|
||||||
tri::Build(poissonCornerMesh,sampleVec);
|
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(poissonCornerMesh,"cornerMesh.ply");
|
|
||||||
sampleVec.clear();
|
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, poissonCornerMesh, radius, pp);
|
|
||||||
tri::Build(poissonCornerMesh,sampleVec);
|
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(poissonCornerMesh,"poissonCornerMesh.ply");
|
|
||||||
// Now save the corner as Fixed Seeds for later...
|
|
||||||
std::vector<MyVertex *> fixedSeedVec;
|
|
||||||
tri::VoronoiProcessing<MyMesh>::SeedToVertexConversion(baseMesh,sampleVec,fixedSeedVec);
|
|
||||||
tri::VoronoiProcessing<MyMesh, tri::EuclideanDistance<MyMesh> >::FixVertexVector(baseMesh,fixedSeedVec);
|
|
||||||
vpp.preserveFixedSeed=true;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(fixCornerFlag)
|
||||||
|
{
|
||||||
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, poissonCornerMesh, radius, pp);
|
||||||
|
tri::BuildMeshFromCoordVector(poissonCornerMesh,sampleVec);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(poissonCornerMesh,"poissonCornerMesh.ply");
|
||||||
|
// Now save the corner as Fixed Seeds for later...
|
||||||
|
std::vector<MyVertex *> fixedSeedVec;
|
||||||
|
tri::VoronoiProcessing<MyMesh>::SeedToVertexConversion(baseMesh,sampleVec,fixedSeedVec);
|
||||||
|
tri::VoronoiProcessing<MyMesh, tri::EuclideanDistance<MyMesh> >::FixVertexVector(baseMesh,fixedSeedVec);
|
||||||
|
vpp.preserveFixedSeed=true;
|
||||||
|
}
|
||||||
|
|
||||||
// -- Build a sampling with points on the border
|
// -- Build a sampling with points on the border
|
||||||
MyMesh borderMesh,poissonBorderMesh;
|
|
||||||
sampleVec.clear();
|
sampleVec.clear();
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::VertexBorder(baseMesh,mps);
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::VertexBorder(baseMesh,mps);
|
||||||
tri::Build(borderMesh,sampleVec);
|
tri::BuildMeshFromCoordVector(borderMesh,sampleVec);
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(borderMesh,"borderMesh.ply");
|
tri::io::ExporterPLY<MyMesh>::Save(borderMesh,"borderMesh.ply");
|
||||||
|
|
||||||
// -- and then prune the border sampling with poisson strategy using the precomputed corner vertexes.
|
// -- and then prune the border sampling with poisson strategy using the precomputed corner vertexes.
|
||||||
|
@ -126,14 +135,16 @@ int main( int argc, char **argv )
|
||||||
pp.preGenFlag=true;
|
pp.preGenFlag=true;
|
||||||
sampleVec.clear();
|
sampleVec.clear();
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, borderMesh, radius*0.8f, pp);
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, borderMesh, radius*0.8f, pp);
|
||||||
tri::Build(poissonBorderMesh,sampleVec);
|
tri::BuildMeshFromCoordVector(poissonBorderMesh,sampleVec);
|
||||||
|
}
|
||||||
|
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(poissonBorderMesh,"PoissonEdgeMesh.ply");
|
tri::io::ExporterPLY<MyMesh>::Save(poissonBorderMesh,"PoissonEdgeMesh.ply");
|
||||||
|
|
||||||
// -- Build the montercarlo sampling of the surface
|
// -- Build the montercarlo sampling of the surface
|
||||||
MyMesh MontecarloSurfaceMesh;
|
MyMesh MontecarloSurfaceMesh;
|
||||||
sampleVec.clear();
|
sampleVec.clear();
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::Montecarlo(baseMesh,mps,50000);
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::Montecarlo(baseMesh,mps,50000);
|
||||||
tri::Build(MontecarloSurfaceMesh,sampleVec);
|
tri::BuildMeshFromCoordVector(MontecarloSurfaceMesh,sampleVec);
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(MontecarloSurfaceMesh,"MontecarloSurfaceMesh.ply");
|
tri::io::ExporterPLY<MyMesh>::Save(MontecarloSurfaceMesh,"MontecarloSurfaceMesh.ply");
|
||||||
|
|
||||||
// -- Prune the montecarlo sampling with poisson strategy using the precomputed vertexes on the border.
|
// -- Prune the montecarlo sampling with poisson strategy using the precomputed vertexes on the border.
|
||||||
|
@ -141,7 +152,7 @@ int main( int argc, char **argv )
|
||||||
sampleVec.clear();
|
sampleVec.clear();
|
||||||
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, MontecarloSurfaceMesh, radius, pp);
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::PoissonDiskPruning(mps, MontecarloSurfaceMesh, radius, pp);
|
||||||
MyMesh PoissonMesh;
|
MyMesh PoissonMesh;
|
||||||
tri::Build(PoissonMesh,sampleVec);
|
tri::BuildMeshFromCoordVector(PoissonMesh,sampleVec);
|
||||||
tri::io::ExporterPLY<MyMesh>::Save(PoissonMesh,"PoissonMesh.ply");
|
tri::io::ExporterPLY<MyMesh>::Save(PoissonMesh,"PoissonMesh.ply");
|
||||||
|
|
||||||
std::vector<MyVertex *> seedVec;
|
std::vector<MyVertex *> seedVec;
|
||||||
|
|
Loading…
Reference in New Issue