[sample refactoring] added various samples
This commit is contained in:
parent
ad146d8c0f
commit
bf0f5db991
|
@ -0,0 +1,64 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2004-2009 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
#include<vcg/complex/complex.h>
|
||||||
|
#include<vcg/complex/algorithms/create/platonic.h>
|
||||||
|
|
||||||
|
#include<wrap/io_trimesh/import_ply.h>
|
||||||
|
#include<wrap/io_trimesh/export_ply.h>
|
||||||
|
#include<vcg/complex/algorithms/create/platonic.h>
|
||||||
|
#include<vcg/complex/algorithms/smooth_field.h>
|
||||||
|
|
||||||
|
using namespace vcg;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class MyEdge;
|
||||||
|
class MyFace;
|
||||||
|
class MyVertex;
|
||||||
|
struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
||||||
|
Use<MyEdge> ::AsEdgeType,
|
||||||
|
Use<MyFace> ::AsFaceType>{};
|
||||||
|
|
||||||
|
class MyVertex : public Vertex<MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::VFAdj, vertex::Qualityf, vertex::Color4b, vertex::BitFlags, vertex::CurvatureDirf >{};
|
||||||
|
class MyFace : public Face< MyUsedTypes, face::VertexRef, face::Normal3f, face::BitFlags, face::FFAdj, face::VFAdj, face::CurvatureDirf, face::Qualityf, face::Color4b> {};
|
||||||
|
class MyEdge : public Edge< MyUsedTypes>{};
|
||||||
|
class MyMesh : public tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , vector<MyEdge> > {};
|
||||||
|
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
MyMesh m;
|
||||||
|
tri::Hexahedron(m);
|
||||||
|
tri::UpdateTopology<MyMesh>::FaceFace(m);
|
||||||
|
tri::UpdateFlags<MyMesh>::FaceBorderFromFF(m);
|
||||||
|
for(int i=0;i<3;++i)
|
||||||
|
tri::Refine<MyMesh, tri::MidPoint<MyMesh> >(m,tri::MidPoint<MyMesh>(&m));
|
||||||
|
|
||||||
|
tri::UpdateNormal<MyMesh>::PerVertexNormalized(m);
|
||||||
|
tri::Smooth<MyMesh>::VertexCoordLaplacian(m,3);
|
||||||
|
tri::FieldSmoother<MyMesh>::InitByCurvature(m);
|
||||||
|
tri::FieldSmoother<MyMesh>::SmoothParam par;
|
||||||
|
|
||||||
|
tri::FieldSmoother<MyMesh>::SmoothDirections(m,par);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(m,"Full.ply",tri::io::Mask::IOM_VERTCOLOR|tri::io::Mask::IOM_WEDGTEXCOORD );
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
include(../common.pri)
|
||||||
|
TARGET = trimesh_field_smoothing
|
||||||
|
SOURCES += trimesh_field_smoothing.cpp ../../../wrap/ply/plylib.cpp
|
|
@ -0,0 +1,77 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2004-2012 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
#include<vcg/complex/complex.h>
|
||||||
|
|
||||||
|
#include<wrap/io_trimesh/import_off.h>
|
||||||
|
#include<wrap/io_trimesh/export_off.h>
|
||||||
|
|
||||||
|
#include<vcg/complex/algorithms/point_sampling.h>
|
||||||
|
#include<vcg/complex/algorithms/create/platonic.h>
|
||||||
|
|
||||||
|
using namespace vcg;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class MyEdge;
|
||||||
|
class MyFace;
|
||||||
|
class MyVertex;
|
||||||
|
struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
||||||
|
Use<MyEdge> ::AsEdgeType,
|
||||||
|
Use<MyFace> ::AsFaceType>{};
|
||||||
|
|
||||||
|
class MyVertex : public Vertex<MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{};
|
||||||
|
class MyFace : public Face< MyUsedTypes, face::FFAdj, face::Normal3f, face::VertexRef, face::BitFlags > {};
|
||||||
|
class MyEdge : public Edge<MyUsedTypes>{};
|
||||||
|
class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector<MyEdge> > {};
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
if(argc<2)
|
||||||
|
{
|
||||||
|
printf("Usage trimesh_base <meshfilename.obj> radius\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
MyMesh m;
|
||||||
|
|
||||||
|
if(tri::io::ImporterOFF<MyMesh>::Open(m,argv[1])!=0)
|
||||||
|
{
|
||||||
|
printf("Error reading file %s\n",argv[1]);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::SamplingRandomGenerator().initialize(time(0));
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// Advanced Sample
|
||||||
|
// Make a feature dependent Poisson Disk sampling
|
||||||
|
MyMesh MontecarloSurfaceMesh;
|
||||||
|
|
||||||
|
std::vector<Point3f> sampleVec;
|
||||||
|
tri::TrivialSampler<MyMesh> mps(sampleVec);
|
||||||
|
int t0=clock();
|
||||||
|
tri::SurfaceSampling<MyMesh,tri::TrivialSampler<MyMesh> >::Montecarlo(m,mps,10000000);
|
||||||
|
int t1=clock();
|
||||||
|
|
||||||
|
printf("Computed a montecarlo distribution of %i vertices radius is %6.3f\n",sampleVec.size(),float(t1-t0)/float(CLOCKS_PER_SEC));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
include(../common.pri)
|
||||||
|
TARGET = trimesh_montecarlosampling
|
||||||
|
SOURCES += trimesh_montecarlosampling.cpp
|
|
@ -0,0 +1,66 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2004-2012 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
/*! \file trimesh_normal.cpp
|
||||||
|
\ingroup code_sample
|
||||||
|
|
||||||
|
\brief An example of all the methods for computing normals over a mesh.
|
||||||
|
|
||||||
|
*/
|
||||||
|
#include<vcg/complex/complex.h>
|
||||||
|
|
||||||
|
#include<wrap/io_trimesh/import_ply.h>
|
||||||
|
|
||||||
|
#include<vcg/complex/algorithms/clean.h>
|
||||||
|
#include<vcg/complex/algorithms/update/bounding.h>
|
||||||
|
|
||||||
|
using namespace vcg;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class MyEdge;
|
||||||
|
class MyFace;
|
||||||
|
class MyVertex;
|
||||||
|
struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
||||||
|
Use<MyEdge> ::AsEdgeType,
|
||||||
|
Use<MyFace> ::AsFaceType>{};
|
||||||
|
|
||||||
|
class MyVertex : public Vertex<MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{};
|
||||||
|
class MyFace : public Face< MyUsedTypes, face::Mark, face::VertexRef, face::Normal3f, face::BitFlags > {};
|
||||||
|
class MyEdge : public Edge<MyUsedTypes>{};
|
||||||
|
class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector<MyEdge> > {};
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
MyMesh m;
|
||||||
|
|
||||||
|
if(tri::io::ImporterPLY<MyMesh>::Open(m,"../../meshes/SelfIntersection2.ply")!=0)
|
||||||
|
{
|
||||||
|
printf("Error reading file %s\n",argv[1]);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
std::vector<MyFace *> retVec;
|
||||||
|
tri::UpdateNormal<MyMesh>::PerVertexNormalizedPerFaceNormalized(m);
|
||||||
|
tri::UpdateBounding<MyMesh>::Box(m);
|
||||||
|
tri::Clean<MyMesh>::SelfIntersections(m, retVec);
|
||||||
|
printf("Mesh has %i selfintersecting faces\n",retVec.size());
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
include(../common.pri)
|
||||||
|
TARGET = trimesh_selfintersection
|
||||||
|
SOURCES += trimesh_selfintersection.cpp ../../../wrap/ply/plylib.cpp
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2004-2012 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include<vcg/complex/complex.h>
|
||||||
|
#include<wrap/io_trimesh/import.h>
|
||||||
|
#include<wrap/io_trimesh/export.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include<vcg/complex/algorithms/curve_on_manifold.h>
|
||||||
|
#include<vcg/complex/algorithms/crease_cut.h>
|
||||||
|
|
||||||
|
using namespace vcg;
|
||||||
|
|
||||||
|
class MyEdge;
|
||||||
|
class MyFace;
|
||||||
|
class MyVertex;
|
||||||
|
struct MyUsedTypes : public UsedTypes<Use<MyVertex>::AsVertexType, Use<MyEdge>::AsEdgeType, Use<MyFace>::AsFaceType>{};
|
||||||
|
|
||||||
|
class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::Qualityf, vertex::Color4b, vertex::VEAdj, vertex::VFAdj,vertex::BitFlags >{};
|
||||||
|
class MyEdge : public Edge< MyUsedTypes, edge::VertexRef, edge::VEAdj, edge::EEAdj, edge::BitFlags> {};
|
||||||
|
class MyFace : public Face < MyUsedTypes, face::VertexRef, face::Normal3f, face::VFAdj, face::FFAdj, face::Mark, face::Color4b, face::BitFlags > {};
|
||||||
|
class MyMesh : public tri::TriMesh< std::vector<MyVertex>, std::vector<MyEdge>, std::vector<MyFace> >{};
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc,char ** argv )
|
||||||
|
{
|
||||||
|
MyMesh base,basecopy, poly;
|
||||||
|
int ret0 = tri::io::Importer<MyMesh>::Open(base,argv[1]);
|
||||||
|
tri::UpdateBounding<MyMesh>::Box(base);
|
||||||
|
tri::Append<MyMesh,MyMesh>::MeshCopy(basecopy,base);
|
||||||
|
printf( "Mesh %s has %i vert and %i faces\n", argv[1], basecopy.VN(), basecopy.FN() );
|
||||||
|
if(ret0 != 0 )
|
||||||
|
{
|
||||||
|
printf("Failed Loading\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
tri::CoM<MyMesh> cc(base);
|
||||||
|
cc.Init();
|
||||||
|
cc.BuildVisitTree(poly);
|
||||||
|
tri::UpdateBounding<MyMesh>::Box(poly);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(poly,"tree.ply",tri::io::Mask::IOM_EDGEINDEX);
|
||||||
|
while(cc.OptimizeTree(poly));
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(poly,"tree1.ply",tri::io::Mask::IOM_EDGEINDEX);
|
||||||
|
|
||||||
|
cc.MarkFauxEdgeWithPolyLine(basecopy,poly);
|
||||||
|
tri::UpdateTopology<MyMesh>::FaceFace(basecopy);
|
||||||
|
tri::CutMeshAlongNonFauxEdges<MyMesh>(basecopy);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(basecopy,"basecut.ply");
|
||||||
|
cc.par.surfDistThr = base.bbox.Diag()/100.0;
|
||||||
|
cc.par.maxSimpEdgeLen = base.bbox.Diag()/60.0;
|
||||||
|
cc.SmoothProject(poly,5,0.8, 0.2);
|
||||||
|
Distribution<float> dist;
|
||||||
|
cc.EvaluateHausdorffDistance(poly, dist );
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(poly,"poly_adapted.ply",tri::io::Mask::IOM_EDGEINDEX+tri::io::Mask::IOM_VERTCOLOR+tri::io::Mask::IOM_VERTQUALITY);
|
||||||
|
cc.par.surfDistThr = base.bbox.Diag()/1000.0;
|
||||||
|
cc.par.maxSimpEdgeLen = base.bbox.Diag()/500.0;
|
||||||
|
cc.SmoothProject(poly,5,0.3, 0.7);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(poly,"poly_adapted2.ply",tri::io::Mask::IOM_EDGEINDEX+tri::io::Mask::IOM_VERTCOLOR+tri::io::Mask::IOM_VERTQUALITY);
|
||||||
|
cc.par.minRefEdgeLen = base.bbox.Diag()/200.0;
|
||||||
|
cc.Refine(poly,true);
|
||||||
|
cc.Refine(poly,true);
|
||||||
|
cc.SnapPolyline(poly);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(poly,"poly_adapted2_snap.ply",tri::io::Mask::IOM_EDGEINDEX+tri::io::Mask::IOM_VERTCOLOR+tri::io::Mask::IOM_VERTQUALITY);
|
||||||
|
cc.par.maxSimpEdgeLen = base.bbox.Diag()/200.0;
|
||||||
|
cc.SmoothProject(poly,10 ,0.8, 0.2);
|
||||||
|
cc.RefineBaseMesh(poly);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(poly,"poly_adapted2_snapSmooth.ply",tri::io::Mask::IOM_EDGEINDEX+tri::io::Mask::IOM_VERTCOLOR+tri::io::Mask::IOM_VERTQUALITY);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
include(../common.pri)
|
||||||
|
TARGET = trimesh_topological_cut
|
||||||
|
SOURCES += trimesh_topological_cut.cpp ../../../wrap/ply/plylib.cpp
|
|
@ -0,0 +1,122 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2004-2009 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include<vcg/complex/complex.h>
|
||||||
|
#include<vcg/complex/algorithms/create/platonic.h>
|
||||||
|
#include<wrap/io_trimesh/import_ply.h>
|
||||||
|
#include<wrap/io_trimesh/export_off.h>
|
||||||
|
#include<wrap/io_trimesh/export_ply.h>
|
||||||
|
#include<wrap/io_trimesh/export_dxf.h>
|
||||||
|
#include<vcg/complex/algorithms/point_sampling.h>
|
||||||
|
#include<vcg/complex/algorithms/voronoi_processing.h>
|
||||||
|
#include<vcg/complex/algorithms/voronoi_volume_sampling.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace vcg;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class MyEdge;
|
||||||
|
class MyFace;
|
||||||
|
class MyVertex;
|
||||||
|
struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
|
||||||
|
Use<MyEdge> ::AsEdgeType,
|
||||||
|
Use<MyFace> ::AsFaceType>{};
|
||||||
|
|
||||||
|
class MyVertex : public Vertex<MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::VFAdj, vertex::Qualityf, vertex::Color4b, vertex::BitFlags >{};
|
||||||
|
class MyFace : public Face< MyUsedTypes, face::VertexRef, face::Normal3f, face::BitFlags, face::Mark, face::VFAdj, face::FFAdj > {};
|
||||||
|
class MyEdge : public Edge< MyUsedTypes, edge::VertexRef, edge::BitFlags>{};
|
||||||
|
class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyEdge>, vector<MyFace> > {};
|
||||||
|
|
||||||
|
class EmEdge;
|
||||||
|
class EmFace;
|
||||||
|
class EmVertex;
|
||||||
|
struct EmUsedTypes : public UsedTypes< Use<EmVertex> ::AsVertexType,
|
||||||
|
Use<EmEdge> ::AsEdgeType,
|
||||||
|
Use<EmFace> ::AsFaceType>{};
|
||||||
|
|
||||||
|
class EmVertex : public Vertex<EmUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::VFAdj , vertex::Qualityf, vertex::Color4b, vertex::BitFlags >{};
|
||||||
|
class EmFace : public Face< EmUsedTypes, face::VertexRef, face::BitFlags, face::VFAdj > {};
|
||||||
|
class EmEdge : public Edge< EmUsedTypes, edge::VertexRef> {};
|
||||||
|
class EmMesh : public tri::TriMesh< vector<EmVertex>, vector<EmEdge>, vector<EmFace> > {};
|
||||||
|
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
MyMesh mSur; // the original surface
|
||||||
|
MyMesh mOff; // the offsetted surface
|
||||||
|
if(argc < 3 )
|
||||||
|
{
|
||||||
|
printf("Usage trimesh_voronoisampling origSurf offsetSurf radius \n"
|
||||||
|
"radius is expressed as a perc bbox diag (e.g. 0.1 -> 10 % of bbox diag) \n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tri::io::ImporterPLY<MyMesh>::Open(mSur,argv[1]);
|
||||||
|
tri::io::ImporterPLY<MyMesh>::Open(mOff,argv[2]);
|
||||||
|
tri::UpdateNormal<MyMesh>::PerVertexNormalizedPerFaceNormalized(mOff);
|
||||||
|
tri::UpdateNormal<MyMesh>::PerVertexNormalizedPerFaceNormalized(mSur);
|
||||||
|
|
||||||
|
std::vector<Point3f> sampleSurVec, sampleOffVec;
|
||||||
|
// MontecarloSampling(mSur, sampleSurVec,50000);
|
||||||
|
MontecarloSampling(mOff, sampleOffVec,50000);
|
||||||
|
sampleSurVec.insert( sampleSurVec.end(), sampleOffVec.begin(), sampleOffVec.end() );
|
||||||
|
|
||||||
|
|
||||||
|
printf("Read %i vn %i fn \n",mOff.vn, mOff.fn);
|
||||||
|
|
||||||
|
float poissonRadius = mOff.bbox.Diag()*atof(argv[3]);
|
||||||
|
// float poissonRadius = mOff.bbox.Diag()/10;
|
||||||
|
printf("Poisson Radius %f\n",poissonRadius);
|
||||||
|
|
||||||
|
float sampleSurfRadius=mOff.bbox.Diag()/100.0f;
|
||||||
|
int montecarloSampleNum = 100000;
|
||||||
|
|
||||||
|
MyMesh seedM;
|
||||||
|
VoronoiVolumeSampling<MyMesh> vvs(mOff, seedM);
|
||||||
|
printf("Sampling Surface at a radius %f ",sampleSurfRadius);
|
||||||
|
vvs.Init(sampleSurfRadius);
|
||||||
|
tri::BuildMeshFromCoordVector(vvs.seedDomainMesh, sampleSurVec);
|
||||||
|
printf("Sampled\n");
|
||||||
|
vvs.BuildVolumeSampling(montecarloSampleNum,0,poissonRadius);
|
||||||
|
|
||||||
|
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(vvs.seedDomainMesh,"seedDomainMesh.ply");
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(vvs.poissonSurfaceMesh,"poissonSurfaceMesh.ply");
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(vvs.montecarloVolumeMesh,"montecarloVolumeMesh.ply");
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(seedM,"seedMesh0.ply");
|
||||||
|
// vvs.restrictedRelaxationFlag=true;
|
||||||
|
// vvs.BarycentricRelaxVoronoiSamples(10);
|
||||||
|
vvs.QuadricRelaxVoronoiSamples(10);
|
||||||
|
|
||||||
|
tri::UpdateColor<MyMesh>::PerVertexQualityRamp(seedM);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(seedM,"seedMesh1.ply",tri::io::Mask::IOM_VERTCOLOR | tri::io::Mask::IOM_VERTQUALITY );
|
||||||
|
vvs.QuadricRelaxVoronoiSamples(10);
|
||||||
|
|
||||||
|
tri::UpdateColor<MyMesh>::PerVertexQualityRamp(seedM);
|
||||||
|
tri::io::ExporterPLY<MyMesh>::Save(seedM,"seedMesh2.ply",tri::io::Mask::IOM_VERTCOLOR | tri::io::Mask::IOM_VERTQUALITY );
|
||||||
|
printf("\n Saved %i points \n",seedM.vn);
|
||||||
|
// Second Pipeline
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
include(../common.pri)
|
||||||
|
TARGET = trimesh_volumesampling
|
||||||
|
SOURCES += trimesh_volumesampling.cpp ../../../wrap/ply/plylib.cpp
|
Loading…
Reference in New Issue