From e612b0b2f8639e9b0fae3f0117d3d771637175a3 Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Mon, 14 Sep 2015 12:05:44 +0000 Subject: [PATCH] modified PerVertexDijsktraCompute to return parent and source for each node --- vcg/complex/algorithms/geodesic.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/vcg/complex/algorithms/geodesic.h b/vcg/complex/algorithms/geodesic.h index 419221d2..90aa69ca 100644 --- a/vcg/complex/algorithms/geodesic.h +++ b/vcg/complex/algorithms/geodesic.h @@ -582,18 +582,21 @@ It is just a simple wrapper of the basic Compute() static void PerVertexDijsktraCompute(MeshType &m, const std::vector &seedVec, DistanceFunctor &distFunc, ScalarType maxDistanceThr = std::numeric_limits::max(), - std::vector *InInterval=NULL,bool avoid_selected=false, + std::vector *InInterval=NULL, + typename MeshType::template PerVertexAttributeHandle * sourceHandle= NULL, + typename MeshType::template PerVertexAttributeHandle * parentHandle=NULL, + bool avoid_selected=false, VertexPointer target=NULL) { tri::RequireVFAdjacency(m); tri::RequirePerVertexMark(m); tri::RequirePerVertexQuality(m); - typename MeshType::template PerVertexAttributeHandle sourceHandle - = tri::Allocator::template GetPerVertexAttribute(m, sourcesAttributeName()); +// typename MeshType::template PerVertexAttributeHandle sourceHandle +// = tri::Allocator::template GetPerVertexAttribute(m, sourcesAttributeName()); - typename MeshType::template PerVertexAttributeHandle parentHandle - = tri::Allocator::template GetPerVertexAttribute (m, parentsAttributeName()); +// typename MeshType::template PerVertexAttributeHandle parentHandle +// = tri::Allocator::template GetPerVertexAttribute (m, parentsAttributeName()); std::vector Heap; tri::UnMarkAll(m); @@ -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]); } @@ -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)); } }