updated to the recent changes (no more edge meshes and changes in the optimiz framework)
This commit is contained in:
parent
d019261682
commit
ed9e9df701
|
@ -49,7 +49,7 @@ class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace > >{};
|
||||||
class MyDelaunayFlip: public vcg::tri::TriEdgeFlip< MyMesh, MyDelaunayFlip > {
|
class MyDelaunayFlip: public vcg::tri::TriEdgeFlip< MyMesh, MyDelaunayFlip > {
|
||||||
public:
|
public:
|
||||||
typedef vcg::tri::TriEdgeFlip< MyMesh, MyDelaunayFlip > TEF;
|
typedef vcg::tri::TriEdgeFlip< MyMesh, MyDelaunayFlip > TEF;
|
||||||
inline MyDelaunayFlip( const TEF::PosType &p, int i) :TEF(p,i){}
|
inline MyDelaunayFlip( const TEF::PosType &p, int i,BaseParameterClass *pp) :TEF(p,i,pp){}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool callback(int percent, const char *str) {
|
bool callback(int percent, const char *str) {
|
||||||
|
@ -96,7 +96,7 @@ int main(int argc,char ** argv){
|
||||||
int holeSize = atoi(argv[2]);
|
int holeSize = atoi(argv[2]);
|
||||||
if(algorithm < 0 && algorithm > 4)
|
if(algorithm < 0 && algorithm > 4)
|
||||||
{
|
{
|
||||||
printf("Error in algorithm's selection\n",algorithm);
|
printf("Error in algorithm's selection %i\n",algorithm);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +128,7 @@ int main(int argc,char ** argv){
|
||||||
}
|
}
|
||||||
AVG=sumA/numA;
|
AVG=sumA/numA;
|
||||||
|
|
||||||
|
//tri::Hole<MyMesh> holeFiller;
|
||||||
switch(algorithm)
|
switch(algorithm)
|
||||||
{
|
{
|
||||||
case 1: tri::Hole<MyMesh>::EarCuttingFill<tri::TrivialEar<MyMesh> >(m,holeSize,false); break;
|
case 1: tri::Hole<MyMesh>::EarCuttingFill<tri::TrivialEar<MyMesh> >(m,holeSize,false); break;
|
||||||
|
@ -177,7 +178,8 @@ int main(int argc,char ** argv){
|
||||||
f->V(2)->ClearW();
|
f->V(2)->ClearW();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vcg::LocalOptimization<MyMesh> Fs(m);
|
BaseParameterClass pp;
|
||||||
|
vcg::LocalOptimization<MyMesh> Fs(m,&pp);
|
||||||
Fs.SetTargetMetric(0.0f);
|
Fs.SetTargetMetric(0.0f);
|
||||||
Fs.Init<MyDelaunayFlip >();
|
Fs.Init<MyDelaunayFlip >();
|
||||||
Fs.DoOptimization();
|
Fs.DoOptimization();
|
||||||
|
@ -204,7 +206,7 @@ int main(int argc,char ** argv){
|
||||||
}
|
}
|
||||||
|
|
||||||
//info print
|
//info print
|
||||||
printf("\r Raffino [%d] - > %d",i,vf.size());
|
printf("\r Refining [%d] - > %d",i,int(vf.size()));
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
FPP.clear();
|
FPP.clear();
|
||||||
|
@ -238,14 +240,15 @@ int main(int argc,char ** argv){
|
||||||
added.push_back( &(*f2) );
|
added.push_back( &(*f2) );
|
||||||
}
|
}
|
||||||
|
|
||||||
vcg::LocalOptimization<MyMesh> FlippingSession(m);
|
BaseParameterClass pp;
|
||||||
|
vcg::LocalOptimization<MyMesh> FlippingSession(m,&pp);
|
||||||
FlippingSession.SetTargetMetric(0.0f);
|
FlippingSession.SetTargetMetric(0.0f);
|
||||||
FlippingSession.Init<MyDelaunayFlip >();
|
FlippingSession.Init<MyDelaunayFlip >();
|
||||||
FlippingSession.DoOptimization();
|
FlippingSession.DoOptimization();
|
||||||
|
|
||||||
}while(!vf.empty());
|
}while(!vf.empty());
|
||||||
|
|
||||||
vcg::LocalOptimization<MyMesh> Fiss(m);
|
vcg::LocalOptimization<MyMesh> Fiss(m,&pp);
|
||||||
Fiss.SetTargetMetric(0.0f);
|
Fiss.SetTargetMetric(0.0f);
|
||||||
Fiss.Init<MyDelaunayFlip >();
|
Fiss.Init<MyDelaunayFlip >();
|
||||||
Fiss.DoOptimization();
|
Fiss.DoOptimization();
|
||||||
|
|
|
@ -16,9 +16,9 @@ using namespace std;
|
||||||
#include <vcg/complex/algorithms/intersection.h>
|
#include <vcg/complex/algorithms/intersection.h>
|
||||||
#include <vcg/space/index/grid_static_ptr.h>
|
#include <vcg/space/index/grid_static_ptr.h>
|
||||||
//#include <vcg/simplex/edge/with/ae.h>
|
//#include <vcg/simplex/edge/with/ae.h>
|
||||||
#include <vcg/complex/edgemesh/base.h>
|
//#include <vcg/complex/edgemesh/base.h>
|
||||||
#include <vcg/complex/edgemesh/allocate.h>
|
//#include <vcg/complex/edgemesh/allocate.h>
|
||||||
#include <vcg/complex/edgemesh/update/bounding.h>
|
//#include <vcg/complex/edgemesh/update/bounding.h>
|
||||||
|
|
||||||
// VCG File Format Importer/Exporter
|
// VCG File Format Importer/Exporter
|
||||||
#include <wrap/io_trimesh/import.h>
|
#include <wrap/io_trimesh/import.h>
|
||||||
|
@ -44,7 +44,7 @@ class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::BitFlags,
|
||||||
class MyEdge : public Edge< MyUsedTypes, edge::VertexRef, edge::EVAdj> {};
|
class MyEdge : public Edge< MyUsedTypes, edge::VertexRef, edge::EVAdj> {};
|
||||||
class MyFace : public Face <MyUsedTypes, face::VertexRef,face::FFAdj, face::BitFlags, face::Normal3f> {};
|
class MyFace : public Face <MyUsedTypes, face::VertexRef,face::FFAdj, face::BitFlags, face::Normal3f> {};
|
||||||
|
|
||||||
class MyEdgeMesh: public vcg::edg::EdgeMesh< vector<MyVertex>, vector<MyEdge> > {};
|
class MyEdgeMesh: public tri::TriMesh< vector<MyVertex>, vector<MyEdge> > {};
|
||||||
class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace > >{};
|
class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace > >{};
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,23 +96,16 @@ int main(int argc,char ** argv)
|
||||||
|
|
||||||
vcg::Plane3<MyMesh::ScalarType> plane(distance, direction);
|
vcg::Plane3<MyMesh::ScalarType> plane(distance, direction);
|
||||||
|
|
||||||
double avg_length; // average length of the edges
|
|
||||||
MyEdgeMesh edge_mesh; // returned EdgeMesh (i.e. the cross-section)
|
MyEdgeMesh edge_mesh; // returned EdgeMesh (i.e. the cross-section)
|
||||||
|
|
||||||
// Create a static grid (for fast indexing) and fill it
|
vcg::IntersectionPlaneMesh<MyMesh, MyEdgeMesh, MyMesh::ScalarType>(m, plane, edge_mesh);
|
||||||
TriMeshGrid static_grid;
|
|
||||||
static_grid.Set(m.face.begin(), m.face.end());
|
|
||||||
std::vector<TriMeshGrid::Cell *> intersected_cells;
|
|
||||||
|
|
||||||
vcg::Intersection<MyMesh, MyEdgeMesh, MyMesh::ScalarType, TriMeshGrid>(plane,
|
|
||||||
edge_mesh, avg_length, &static_grid, intersected_cells);
|
|
||||||
|
|
||||||
// Compute bounding box
|
// Compute bounding box
|
||||||
vcg::edg::UpdateBounding<MyEdgeMesh>::Box(edge_mesh);
|
vcg::tri::UpdateBounding<MyEdgeMesh>::Box(edge_mesh);
|
||||||
|
|
||||||
// export the cross-section
|
// export the cross-section
|
||||||
edg::io::SVGProperties pro;
|
tri::io::SVGProperties pro;
|
||||||
if (edg::io::ExporterSVG<MyEdgeMesh>::Save(edge_mesh, "out.svg",pro))
|
if (tri::io::ExporterSVG<MyEdgeMesh>::Save(edge_mesh, "out.svg",pro))
|
||||||
printf(" The cross-intersection has been successfully saved (OUT.SVG).\n");
|
printf(" The cross-intersection has been successfully saved (OUT.SVG).\n");
|
||||||
else
|
else
|
||||||
printf(" The cross-intersection cannot be saved.\n");
|
printf(" The cross-intersection cannot be saved.\n");
|
||||||
|
|
Loading…
Reference in New Issue