From 8e4a9f2011dee93252f95a9a77701f5ca6b677a5 Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 6 Dec 2006 00:14:33 +0000 Subject: [PATCH] Added flipping optimization, it compiles but does not work well... --- apps/sample/trimesh_hole/trimesh_hole.cpp | 25 +++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/apps/sample/trimesh_hole/trimesh_hole.cpp b/apps/sample/trimesh_hole/trimesh_hole.cpp index 0f828cb4..25e4ad60 100644 --- a/apps/sample/trimesh_hole/trimesh_hole.cpp +++ b/apps/sample/trimesh_hole/trimesh_hole.cpp @@ -5,6 +5,9 @@ #include #include #include +#include +#include + // topology computation #include @@ -29,12 +32,21 @@ class MyEdge; // dummy prototype never used class MyFace; class MyVertex; -class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vert::Coord3f, vert::BitFlags, vert::Normal3f >{}; +class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vert::Coord3f, vert::BitFlags, vert::Normal3f, vert::Mark >{}; class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,face::FFAdj, face::Mark, face::BitFlags, face::Normal3f > {}; class MyMesh : public tri::TriMesh< vector, vector >{}; + +class MyTriEdgeFlip: public vcg::tri::TriEdgeFlip< MyMesh, MyTriEdgeFlip > { + public: + typedef vcg::tri::TriEdgeFlip< MyMesh, MyTriEdgeFlip > TEF; + //typedef MyMesh::VertexType::PosType PosType; + inline MyTriEdgeFlip( const TEF::PosType &p, int i) :TEF(p,i){} +}; + + bool callback(int percent, const char *str) { cout << "str: " << str << " " << percent << "%\r"; return true; @@ -76,7 +88,7 @@ int main(int argc,char ** argv){ //update the face-face topology tri::UpdateTopology::FaceFace(m); - tri::UpdateNormals::PerVertex(m); + tri::UpdateNormals::PerVertexPerFace(m); tri::UpdateFlags::FaceBorderFromFF(m); assert(tri::Clean::IsFFAdjacencyConsistent(m)); @@ -91,6 +103,15 @@ int main(int argc,char ** argv){ printf("\nCompleted. Saving....\n"); assert(tri::Clean::IsFFAdjacencyConsistent(m)); tri::io::ExporterPLY::Save(m,argv[4],false); + printf("\nCompleted. flipping....\n"); + + /* Does not Work!!! (but it compiles :) ) */ + vcg::LocalOptimization FlippingSession(m); + FlippingSession.SetTargetOperations(100); + FlippingSession.Init(); + FlippingSession.DoOptimization(); + tri::io::ExporterPLY::Save(m,"out2.ply",false); + return 0; }