From acc11c1df408f83ee0b9844ea12e61f160d0a9e1 Mon Sep 17 00:00:00 2001 From: ponchio Date: Mon, 11 Jun 2007 15:26:30 +0000 Subject: [PATCH] *** empty log message *** --- vcg/complex/trimesh/create/advancing_front.h | 44 ++++++++++---------- vcg/complex/trimesh/create/ball_pivoting.h | 20 +++++++-- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/vcg/complex/trimesh/create/advancing_front.h b/vcg/complex/trimesh/create/advancing_front.h index d19daf01..ba4ceab7 100644 --- a/vcg/complex/trimesh/create/advancing_front.h +++ b/vcg/complex/trimesh/create/advancing_front.h @@ -9,6 +9,8 @@ namespace vcg { namespace tri { + +extern FILE *fp; class FrontEdge { public: @@ -50,11 +52,8 @@ template class AdvancingFront { MESH &mesh; //this structure will be filled by the algorithm AdvancingFront(MESH &_mesh): mesh(_mesh) { -// UpdateFlags::VertexClear(mesh); - UpdateFlags::Clear(mesh); -// UpdateTopology::VertexFace(mesh); - //UpdateTopology::TestVertexFace(mesh); //odd i would like to return a false not an assert... -// UpdateFlags::FaceBorderFromVF(mesh); + + UpdateFlags::FaceBorderFromNone(mesh); UpdateFlags::VertexBorderFromFace(mesh); @@ -69,8 +68,10 @@ template class AdvancingFront { void BuildMesh(CallBackPos call = NULL, int interval = 512) { while(1) { if(call) call(0, "Advancing front"); - for(int i = 0; i < interval; i++) - if(!AddFace()) return; + for(int i = 0; i < interval; i++) { + if(!front.size() && !SeedFace()) return; + AddFace(); + } } } @@ -82,9 +83,9 @@ protected: bool CheckFrontEdge(int v0, int v1) { int tot = 0; //HACK to speed up things until i can use a seach structure - int i = mesh.face.size() - 4*(front.size()); - if(front.size() < 100) i = mesh.face.size() - 100; - // i = 0; +// int i = mesh.face.size() - 4*(front.size()); +// if(front.size() < 100) i = mesh.face.size() - 100; + i = 0; if(i < 0) i = 0; for(; i < (int)mesh.face.size(); i++) { FaceType &f = mesh.face[i]; @@ -176,9 +177,7 @@ protected: public: bool AddFace() { - if(!front.size()) { - return SeedFace(); - } + if(!front.size()) return false; std::list::iterator ei = front.begin(); FrontEdge ¤t = *ei; @@ -192,20 +191,20 @@ public: int v2 = Place(current, touch); if(v2 == -1) { KillEdge(ei); - return true; + return false; } assert(v2 != v0 && v2 != v1); if(touch != front.end()) { //check for orientation and manifoldness - //if(!CheckEdge(v0, v2) || !CheckEdge(v2, v1)) { //touch == current.previous? if(v2 == previous.v0) { if(!CheckEdge(v2, v1)) { + fprintf(fp, "killing\n"); KillEdge(ei); - return 0; + return false; } /*touching previous FrontEdge (we reuse previous) next @@ -231,8 +230,9 @@ public: //touch == (*current.next).next } else if(v2 == next.v1) { if(!CheckEdge(v0, v2)) { + fprintf(fp, "killing\n"); KillEdge(ei); - return 0; + return false; } /*touching next FrontEdge (we reuse next) previous @@ -256,7 +256,7 @@ public: } else { if(!CheckEdge(v0, v2) || !CheckEdge(v2, v1)) { KillEdge(ei); - return 0; + return false; } //touching some loop: split (or merge it is local does not matter. //like this @@ -276,7 +276,7 @@ public: //this would be a really bad join if(v1 == (*right).v0 || v0 == (*left).v1) { KillEdge(ei); - return 0; + return false; } nb[v2]++; @@ -300,8 +300,8 @@ public: } else { - assert(CheckEdge(v0, v2)); - assert(CheckEdge(v2, v1)); +// assert(CheckEdge(v0, v2)); +// assert(CheckEdge(v2, v1)); /* adding a new vertex v2 @@ -328,7 +328,7 @@ public: } AddFace(v0, v2, v1); - return 1; + return false; } protected: diff --git a/vcg/complex/trimesh/create/ball_pivoting.h b/vcg/complex/trimesh/create/ball_pivoting.h index bd5cf442..01e81bf4 100644 --- a/vcg/complex/trimesh/create/ball_pivoting.h +++ b/vcg/complex/trimesh/create/ball_pivoting.h @@ -14,6 +14,8 @@ */ namespace vcg { namespace tri { + +FILE *fp; template class BallPivoting: public AdvancingFront { public: @@ -53,6 +55,10 @@ template class BallPivoting: public AdvancingFront { radius = sqrt((this->mesh.bbox.Diag()*this->mesh.bbox.Diag())/this->mesh.vn); else radius *= this->mesh.bbox.Diag()/100; + + fp = fopen("prova.txt", "wb+"); + fprintf(fp, "radius %lf\n", radius); + min_edge *= radius; max_edge *= radius; @@ -67,7 +73,11 @@ template class BallPivoting: public AdvancingFront { std::vector dists; usedBit = VertexType::NewBitFlag(); - + for(int i = 0; i < (int)this->mesh.vert.size(); i++) + this->mesh.vert[i].ClearUserBit(usedBit); + + UpdateFlags::VertexClearV(this->mesh); + for(int i = 0; i < (int)this->mesh.face.size(); i++) { FaceType &f = this->mesh.face[i]; if(f.IsD()) continue; @@ -87,7 +97,7 @@ template class BallPivoting: public AdvancingFront { VertexType::DeleteBitFlag(usedBit); } - bool Seed(int &v0, int &v1, int &v2) { + bool Seed(int &v0, int &v1, int &v2) { bool use_normals = false; //get a sphere of neighbours std::vector targets; @@ -195,6 +205,7 @@ template class BallPivoting: public AdvancingFront { //select a new vertex, mark as Visited and mark as usedBit all neighbours (less than min_edge) int Place(FrontEdge &edge, std::list::iterator &touch) { + fprintf(fp, "place front.size() %d\n", this->front.size()); Point3x v0 = this->mesh.vert[edge.v0].P(); Point3x v1 = this->mesh.vert[edge.v1].P(); Point3x v2 = this->mesh.vert[edge.v2].P(); @@ -301,6 +312,9 @@ template class BallPivoting: public AdvancingFront { if(normal * newnormal < max_angle || this->nb[id] >= 2) { return -1; } + + fprintf(fp, "isB: %d\n", candidate->IsB()); + //test if id is in some border (to return touch for(list::iterator k = this->front.begin(); k != this->front.end(); k++) if((*k).v0 == id) touch = k; @@ -308,7 +322,7 @@ template class BallPivoting: public AdvancingFront { if((*k).v0 == id) touch = k; //mark vertices close to candidate - Mark(candidate); + Mark(candidate); return id; }