Skip to content

Commit

Permalink
modified PerVertexDijsktraCompute to return parent and source for eac…
Browse files Browse the repository at this point in the history
…h node
  • Loading branch information
nicopietroni committed Sep 14, 2015
1 parent 3627a7c commit e612b0b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions vcg/complex/algorithms/geodesic.h
Expand Up @@ -582,18 +582,21 @@ It is just a simple wrapper of the basic Compute()
static void PerVertexDijsktraCompute(MeshType &m, const std::vector<VertexPointer> &seedVec,
DistanceFunctor &distFunc,
ScalarType maxDistanceThr = std::numeric_limits<ScalarType>::max(),
std::vector<VertexPointer> *InInterval=NULL,bool avoid_selected=false,
std::vector<VertexPointer> *InInterval=NULL,
typename MeshType::template PerVertexAttributeHandle<VertexPointer> * sourceHandle= NULL,
typename MeshType::template PerVertexAttributeHandle<VertexPointer> * parentHandle=NULL,
bool avoid_selected=false,
VertexPointer target=NULL)
{
tri::RequireVFAdjacency(m);
tri::RequirePerVertexMark(m);
tri::RequirePerVertexQuality(m);

typename MeshType::template PerVertexAttributeHandle<VertexPointer> sourceHandle
= tri::Allocator<MeshType>::template GetPerVertexAttribute<VertexPointer>(m, sourcesAttributeName());
// typename MeshType::template PerVertexAttributeHandle<VertexPointer> sourceHandle
// = tri::Allocator<MeshType>::template GetPerVertexAttribute<VertexPointer>(m, sourcesAttributeName());

typename MeshType::template PerVertexAttributeHandle<VertexPointer> parentHandle
= tri::Allocator<MeshType>::template GetPerVertexAttribute<VertexPointer> (m, parentsAttributeName());
// typename MeshType::template PerVertexAttributeHandle<VertexPointer> parentHandle
// = tri::Allocator<MeshType>::template GetPerVertexAttribute<VertexPointer> (m, parentsAttributeName());

std::vector<DIJKDist> Heap;
tri::UnMarkAll(m);
Expand All @@ -603,8 +606,10 @@ It is just a simple wrapper of the basic Compute()
assert(!tri::IsMarked(m,seedVec[i]));
tri::Mark(m,seedVec[i]);
seedVec[i]->Q()=0;
sourceHandle[seedVec[i]]=seedVec[i];
parentHandle[seedVec[i]]=seedVec[i];
if (sourceHandle!=NULL)
(*sourceHandle)[seedVec[i]]=seedVec[i];
if (parentHandle!=NULL)
(*parentHandle)[seedVec[i]]=seedVec[i];
Heap.push_back(DIJKDist(seedVec[i]));
if (InInterval!=NULL) InInterval->push_back(seedVec[i]);
}
Expand All @@ -631,8 +636,10 @@ It is just a simple wrapper of the basic Compute()
Heap.push_back(DIJKDist(nextV));
push_heap(Heap.begin(),Heap.end());
if (InInterval!=NULL) InInterval->push_back(nextV);
sourceHandle[nextV] = sourceHandle[curr];
parentHandle[nextV] = curr;
if (sourceHandle!=NULL)
(*sourceHandle)[nextV] = (*sourceHandle)[curr];
if (parentHandle!=NULL)
(*parentHandle)[nextV] = curr;
// printf("Heapsize %i nextDist = %f curr vert %i next vert %i \n",Heap.size(), nextDist, tri::Index(m,curr), tri::Index(m,nextV));
}
}
Expand Down

0 comments on commit e612b0b

Please sign in to comment.