mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-17 18:14:38 +00:00
- In Dijkstra algorithm I have not to compute the arches connecting vertices already visited. It leads to inconsistent priority_queue.
This commit is contained in:
parent
12965d5b03
commit
02b92791a4
@ -95,7 +95,8 @@ public:
|
||||
this->distFromCenter = distFromCenter;
|
||||
}
|
||||
|
||||
bool operator() (const _MyVertexType* lhs, const _MyVertexType* rhs) const {
|
||||
bool operator() (const _MyVertexType* lhs, const _MyVertexType* rhs) const
|
||||
{
|
||||
return (*distFromCenter)[*lhs] > (*distFromCenter)[*rhs];
|
||||
}
|
||||
};
|
||||
@ -151,21 +152,27 @@ void ComponentFinder<_MyMeshType, _MyVertexType>::Dijkstra(_MyMeshType& m, _MyVe
|
||||
element = prQueue.top();
|
||||
prQueue.pop();
|
||||
|
||||
for (it = neighboursVect[element]->begin(); it != neighboursVect[element]->end(); it++) {
|
||||
distance = vcg::Distance((*it)->P(), element->P());
|
||||
for (it = neighboursVect[element]->begin(); it != neighboursVect[element]->end(); it++)
|
||||
{
|
||||
//I have not to compute the arches connecting vertices already visited.
|
||||
if (!(*it)->IsV())
|
||||
{
|
||||
distance = vcg::Distance((*it)->P(), element->P());
|
||||
|
||||
// we take into account only the arcs with a distance less or equal to maxHopDist
|
||||
if (distance <= maxHopDist) {
|
||||
if (distFromCenter[*element] + distance < distFromCenter[*it])
|
||||
distFromCenter[*it] = distFromCenter[*element] + distance;
|
||||
// we take into account only the arcs with a distance less or equal to maxHopDist
|
||||
if (distance <= maxHopDist)
|
||||
{
|
||||
if ((distFromCenter[*element] + distance) < distFromCenter[*it])
|
||||
distFromCenter[*it] = distFromCenter[*element] + distance;
|
||||
|
||||
if (!(*it)->IsV()) {
|
||||
prQueue.push(*it);
|
||||
(*it)->SetV();
|
||||
}
|
||||
}
|
||||
// all the other are the notReachable arcs
|
||||
else if (distance > maxHopDist) notReachableVect.push_back(element);
|
||||
if (!(*it)->IsV()) {
|
||||
prQueue.push(*it);
|
||||
(*it)->SetV();
|
||||
}
|
||||
}
|
||||
// all the other are the notReachable arcs
|
||||
else if (distance > maxHopDist) notReachableVect.push_back(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user