*** 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

@ -10,6 +10,8 @@
namespace vcg {
namespace tri {
extern FILE *fp;
class FrontEdge {
public:
int v0, v1, v2; //v0, v1 represent the FrontEdge, v2 the other vertex
@ -50,11 +52,8 @@ template <class MESH> class AdvancingFront {
MESH &mesh; //this structure will be filled by the algorithm
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>::VertexBorderFromFace(mesh);
@ -69,8 +68,10 @@ template <class MESH> 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<FrontEdge>::iterator ei = front.begin();
FrontEdge &current = *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:

View File

@ -15,6 +15,8 @@
namespace vcg {
namespace tri {
FILE *fp;
template <class MESH> class BallPivoting: public AdvancingFront<MESH> {
public:
typedef typename MESH::VertexType VertexType;
@ -54,6 +56,10 @@ template <class MESH> class BallPivoting: public AdvancingFront<MESH> {
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,6 +73,10 @@ template <class MESH> class BallPivoting: public AdvancingFront<MESH> {
std::vector<ScalarType> dists;
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++) {
FaceType &f = this->mesh.face[i];
@ -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)
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 v1 = this->mesh.vert[edge.v1].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) {
return -1;
}
fprintf(fp, "isB: %d\n", candidate->IsB());
//test if id is in some border (to return touch
for(list<FrontEdge>::iterator k = this->front.begin(); k != this->front.end(); k++)
if((*k).v0 == id) touch = k;