*** empty log message ***

This commit is contained in:
Federico Ponchio 2007-06-11 15:26:30 +00:00
parent 75c0f42d92
commit acc11c1df4
2 changed files with 39 additions and 25 deletions

View File

@ -9,6 +9,8 @@
namespace vcg { namespace vcg {
namespace tri { namespace tri {
extern FILE *fp;
class FrontEdge { class FrontEdge {
public: public:
@ -50,11 +52,8 @@ template <class MESH> class AdvancingFront {
MESH &mesh; //this structure will be filled by the algorithm MESH &mesh; //this structure will be filled by the algorithm
AdvancingFront(MESH &_mesh): mesh(_mesh) { AdvancingFront(MESH &_mesh): mesh(_mesh) {
// UpdateFlags<MESH>::VertexClear(mesh);
UpdateFlags<MESH>::Clear(mesh);
// UpdateTopology<MESH>::VertexFace(mesh);
//UpdateTopology<MESH>::TestVertexFace(mesh); //odd i would like to return a false not an assert...
// UpdateFlags<MESH>::FaceBorderFromVF(mesh);
UpdateFlags<MESH>::FaceBorderFromNone(mesh); UpdateFlags<MESH>::FaceBorderFromNone(mesh);
UpdateFlags<MESH>::VertexBorderFromFace(mesh); UpdateFlags<MESH>::VertexBorderFromFace(mesh);
@ -69,8 +68,10 @@ template <class MESH> class AdvancingFront {
void BuildMesh(CallBackPos call = NULL, int interval = 512) { void BuildMesh(CallBackPos call = NULL, int interval = 512) {
while(1) { while(1) {
if(call) call(0, "Advancing front"); if(call) call(0, "Advancing front");
for(int i = 0; i < interval; i++) for(int i = 0; i < interval; i++) {
if(!AddFace()) return; if(!front.size() && !SeedFace()) return;
AddFace();
}
} }
} }
@ -82,9 +83,9 @@ protected:
bool CheckFrontEdge(int v0, int v1) { bool CheckFrontEdge(int v0, int v1) {
int tot = 0; int tot = 0;
//HACK to speed up things until i can use a seach structure //HACK to speed up things until i can use a seach structure
int i = mesh.face.size() - 4*(front.size()); // int i = mesh.face.size() - 4*(front.size());
if(front.size() < 100) i = mesh.face.size() - 100; // if(front.size() < 100) i = mesh.face.size() - 100;
// i = 0; i = 0;
if(i < 0) i = 0; if(i < 0) i = 0;
for(; i < (int)mesh.face.size(); i++) { for(; i < (int)mesh.face.size(); i++) {
FaceType &f = mesh.face[i]; FaceType &f = mesh.face[i];
@ -176,9 +177,7 @@ protected:
public: public:
bool AddFace() { bool AddFace() {
if(!front.size()) { if(!front.size()) return false;
return SeedFace();
}
std::list<FrontEdge>::iterator ei = front.begin(); std::list<FrontEdge>::iterator ei = front.begin();
FrontEdge &current = *ei; FrontEdge &current = *ei;
@ -192,20 +191,20 @@ public:
int v2 = Place(current, touch); int v2 = Place(current, touch);
if(v2 == -1) { if(v2 == -1) {
KillEdge(ei); KillEdge(ei);
return true; return false;
} }
assert(v2 != v0 && v2 != v1); assert(v2 != v0 && v2 != v1);
if(touch != front.end()) { if(touch != front.end()) {
//check for orientation and manifoldness //check for orientation and manifoldness
//if(!CheckEdge(v0, v2) || !CheckEdge(v2, v1)) {
//touch == current.previous? //touch == current.previous?
if(v2 == previous.v0) { if(v2 == previous.v0) {
if(!CheckEdge(v2, v1)) { if(!CheckEdge(v2, v1)) {
fprintf(fp, "killing\n");
KillEdge(ei); KillEdge(ei);
return 0; return false;
} }
/*touching previous FrontEdge (we reuse previous) /*touching previous FrontEdge (we reuse previous)
next next
@ -231,8 +230,9 @@ public:
//touch == (*current.next).next //touch == (*current.next).next
} else if(v2 == next.v1) { } else if(v2 == next.v1) {
if(!CheckEdge(v0, v2)) { if(!CheckEdge(v0, v2)) {
fprintf(fp, "killing\n");
KillEdge(ei); KillEdge(ei);
return 0; return false;
} }
/*touching next FrontEdge (we reuse next) /*touching next FrontEdge (we reuse next)
previous previous
@ -256,7 +256,7 @@ public:
} else { } else {
if(!CheckEdge(v0, v2) || !CheckEdge(v2, v1)) { if(!CheckEdge(v0, v2) || !CheckEdge(v2, v1)) {
KillEdge(ei); KillEdge(ei);
return 0; return false;
} }
//touching some loop: split (or merge it is local does not matter. //touching some loop: split (or merge it is local does not matter.
//like this //like this
@ -276,7 +276,7 @@ public:
//this would be a really bad join //this would be a really bad join
if(v1 == (*right).v0 || v0 == (*left).v1) { if(v1 == (*right).v0 || v0 == (*left).v1) {
KillEdge(ei); KillEdge(ei);
return 0; return false;
} }
nb[v2]++; nb[v2]++;
@ -300,8 +300,8 @@ public:
} else { } else {
assert(CheckEdge(v0, v2)); // assert(CheckEdge(v0, v2));
assert(CheckEdge(v2, v1)); // assert(CheckEdge(v2, v1));
/* adding a new vertex /* adding a new vertex
v2 v2
@ -328,7 +328,7 @@ public:
} }
AddFace(v0, v2, v1); AddFace(v0, v2, v1);
return 1; return false;
} }
protected: protected:

View File

@ -14,6 +14,8 @@
*/ */
namespace vcg { namespace vcg {
namespace tri { namespace tri {
FILE *fp;
template <class MESH> class BallPivoting: public AdvancingFront<MESH> { template <class MESH> class BallPivoting: public AdvancingFront<MESH> {
public: public:
@ -53,6 +55,10 @@ template <class MESH> class BallPivoting: public AdvancingFront<MESH> {
radius = sqrt((this->mesh.bbox.Diag()*this->mesh.bbox.Diag())/this->mesh.vn); radius = sqrt((this->mesh.bbox.Diag()*this->mesh.bbox.Diag())/this->mesh.vn);
else else
radius *= this->mesh.bbox.Diag()/100; radius *= this->mesh.bbox.Diag()/100;
fp = fopen("prova.txt", "wb+");
fprintf(fp, "radius %lf\n", radius);
min_edge *= radius; min_edge *= radius;
max_edge *= radius; max_edge *= radius;
@ -67,7 +73,11 @@ template <class MESH> class BallPivoting: public AdvancingFront<MESH> {
std::vector<ScalarType> dists; std::vector<ScalarType> dists;
usedBit = VertexType::NewBitFlag(); usedBit = VertexType::NewBitFlag();
for(int i = 0; i < (int)this->mesh.vert.size(); i++)
this->mesh.vert[i].ClearUserBit(usedBit);
UpdateFlags<MESH>::VertexClearV(this->mesh);
for(int i = 0; i < (int)this->mesh.face.size(); i++) { for(int i = 0; i < (int)this->mesh.face.size(); i++) {
FaceType &f = this->mesh.face[i]; FaceType &f = this->mesh.face[i];
if(f.IsD()) continue; if(f.IsD()) continue;
@ -87,7 +97,7 @@ template <class MESH> class BallPivoting: public AdvancingFront<MESH> {
VertexType::DeleteBitFlag(usedBit); VertexType::DeleteBitFlag(usedBit);
} }
bool Seed(int &v0, int &v1, int &v2) { bool Seed(int &v0, int &v1, int &v2) {
bool use_normals = false; bool use_normals = false;
//get a sphere of neighbours //get a sphere of neighbours
std::vector<VertexType *> targets; std::vector<VertexType *> targets;
@ -195,6 +205,7 @@ template <class MESH> class BallPivoting: public AdvancingFront<MESH> {
//select a new vertex, mark as Visited and mark as usedBit all neighbours (less than min_edge) //select a new vertex, mark as Visited and mark as usedBit all neighbours (less than min_edge)
int Place(FrontEdge &edge, std::list<FrontEdge>::iterator &touch) { int Place(FrontEdge &edge, std::list<FrontEdge>::iterator &touch) {
fprintf(fp, "place front.size() %d\n", this->front.size());
Point3x v0 = this->mesh.vert[edge.v0].P(); Point3x v0 = this->mesh.vert[edge.v0].P();
Point3x v1 = this->mesh.vert[edge.v1].P(); Point3x v1 = this->mesh.vert[edge.v1].P();
Point3x v2 = this->mesh.vert[edge.v2].P(); Point3x v2 = this->mesh.vert[edge.v2].P();
@ -301,6 +312,9 @@ template <class MESH> class BallPivoting: public AdvancingFront<MESH> {
if(normal * newnormal < max_angle || this->nb[id] >= 2) { if(normal * newnormal < max_angle || this->nb[id] >= 2) {
return -1; return -1;
} }
fprintf(fp, "isB: %d\n", candidate->IsB());
//test if id is in some border (to return touch //test if id is in some border (to return touch
for(list<FrontEdge>::iterator k = this->front.begin(); k != this->front.end(); k++) for(list<FrontEdge>::iterator k = this->front.begin(); k != this->front.end(); k++)
if((*k).v0 == id) touch = k; if((*k).v0 == id) touch = k;
@ -308,7 +322,7 @@ template <class MESH> class BallPivoting: public AdvancingFront<MESH> {
if((*k).v0 == id) touch = k; if((*k).v0 == id) touch = k;
//mark vertices close to candidate //mark vertices close to candidate
Mark(candidate); Mark(candidate);
return id; return id;
} }