diff --git a/vcg/complex/algorithms/create/advancing_front.h b/vcg/complex/algorithms/create/advancing_front.h index cfbda931..7c627921 100644 --- a/vcg/complex/algorithms/create/advancing_front.h +++ b/vcg/complex/algorithms/create/advancing_front.h @@ -342,12 +342,7 @@ public: protected: void AddFace(int v0, int v1, int v2) { - assert(v0 < (int)mesh.vert.size() && v1 < (int)mesh.vert.size() && v2 < (int)mesh.vert.size()); - FaceIterator fi = vcg::tri::Allocator::AddFaces(mesh,1); - fi->ClearFlags(); - fi->V(0) = &mesh.vert[v0]; - fi->V(1) = &mesh.vert[v1]; - fi->V(2) = &mesh.vert[v2]; + FaceIterator fi = vcg::tri::Allocator::AddFace(mesh,v0,v1,v2); ComputeNormalizedNormal(*fi); if(tri::HasVFAdjacency(mesh)) { @@ -520,24 +515,24 @@ template class AdvancingTest: public AdvancingFront { { if((this->mesh.vert[i].P() - point).Norm() < 0.1) { - vn = i; - //find the border - assert(this->mesh.vert[i].IsB()); - for(std::list::iterator k = this->front.begin(); k != this->front.end(); k++) - if((*k).v0 == i) - { - touch.first = AdvancingFront::FRONT; - touch.second = k; - } + vn = i; + //find the border + assert(this->mesh.vert[i].IsB()); + for(std::list::iterator k = this->front.begin(); k != this->front.end(); k++) + if((*k).v0 == i) + { + touch.first = AdvancingFront::FRONT; + touch.second = k; + } - for(std::list::iterator k = this->deads.begin(); k != this->deads.end(); k++) - if((*k).v0 == i) - if((*k).v0 == i) - { - touch.first = AdvancingFront::FRONT; - touch.second = k; - } - break; + for(std::list::iterator k = this->deads.begin(); k != this->deads.end(); k++) + if((*k).v0 == i) + if((*k).v0 == i) + { + touch.first = AdvancingFront::FRONT; + touch.second = k; + } + break; } } if(vn == this->mesh.vert.size()) { diff --git a/vcg/complex/algorithms/create/ball_pivoting.h b/vcg/complex/algorithms/create/ball_pivoting.h index fd721aae..600d39db 100644 --- a/vcg/complex/algorithms/create/ball_pivoting.h +++ b/vcg/complex/algorithms/create/ball_pivoting.h @@ -59,7 +59,7 @@ template class BallPivoting: public AdvancingFront { VertexConstDataWrapper ww(this->mesh); tree = new KdTree(ww); - tree->setMaxNofNeighbors(16); +// tree->setMaxNofNeighbors(16); usedBit = VertexType::NewBitFlag(); UpdateFlags::VertexClear(this->mesh,usedBit); @@ -88,11 +88,12 @@ template class BallPivoting: public AdvancingFront { seed.SetUserBit(usedBit); - tree->doQueryK(seed.P()); - int nn = tree->getNofFoundNeighbors(); + typename KdTree::PriorityQueue pq; + tree->doQueryK(seed.P(),16,pq); + int nn = pq.getNofElements(); for(int i=0;imesh.vert[tree->getNeighborId(i)]; + VertexType *vp = &this->mesh.vert[pq.getIndex(i)]; if(Distance(seed.P(),vp->cP()) > 2*radius) continue; targets.push_back(vp); } @@ -223,8 +224,9 @@ template class BallPivoting: public AdvancingFront { ScalarType r = sqrt(radius*radius - axis_len/4); - tree->doQueryK(middle); - int nn = tree->getNofFoundNeighbors(); + typename KdTree::PriorityQueue pq; + tree->doQueryK(middle,16,pq); + int nn = pq.getNofElements(); if(nn==0) return -1; VertexType *candidate = NULL; @@ -233,7 +235,7 @@ template class BallPivoting: public AdvancingFront { // Loop over all the nearest vertexes and choose the best one according the ball pivoting strategy. // for (int i = 0; i < nn; i++) { - int vInd = tree->getNeighborId(i); + int vInd = pq.getIndex(i); VertexType *v = &this->mesh.vert[vInd]; if(Distance(middle,v->cP()) > r + radius) continue; @@ -391,10 +393,11 @@ template class BallPivoting: public AdvancingFront { } void Mark(VertexType *v) { - tree->doQueryK(v->cP()); - int n = tree->getNofFoundNeighbors(); + typename KdTree::PriorityQueue pq; + tree->doQueryK(v->cP(),16,pq); + int n = pq.getNofElements(); for (int i = 0; i < n; i++) { - VertexType *vp = &this->mesh.vert[tree->getNeighborId(i)]; + VertexType *vp = &this->mesh.vert[pq.getIndex(i)]; if(Distance(v->cP(),vp->cP())SetUserBit(usedBit); }