Cleaned up a bit the geodesic interfaces. Removed useless parameters to avoid ambiguity. Could require updating the existing code using it

This commit is contained in:
Paolo Cignoni 2011-04-22 11:09:30 +00:00
parent e87fe74584
commit e878e7ae88
1 changed files with 30 additions and 51 deletions

View File

@ -155,7 +155,8 @@ namespace vcg{
} }
/* /*
starting from the seeds, it assign a distance value to each vertex. The distance of a vertex is its This is the low level version of the geodesic computation framework.
Starting from the seeds, it assign a distance value to each vertex. The distance of a vertex is its
approximated geodesic distance to the closest seeds. approximated geodesic distance to the closest seeds.
This is function is not meant to be called (although is not prevented). Instead, it is invoked by This is function is not meant to be called (although is not prevented). Instead, it is invoked by
wrapping function. wrapping function.
@ -163,10 +164,9 @@ namespace vcg{
static VertexPointer Visit( static VertexPointer Visit(
MeshType & m, MeshType & m,
std::vector<VertDist> & seedVec, std::vector<VertDist> & seedVec,
ScalarType & max_distance, bool farthestOnBorder = false,
bool farthestOnBorder = false,
ScalarType distance_threshold = std::numeric_limits<ScalarType>::max(), ScalarType distance_threshold = std::numeric_limits<ScalarType>::max(),
typename MeshType::template PerVertexAttributeHandle<VertexPointer> * sources = NULL, typename MeshType::template PerVertexAttributeHandle<VertexPointer> * vertSource = NULL,
std::vector<VertexPointer> *InInterval=NULL) std::vector<VertexPointer> *InInterval=NULL)
{ {
bool isLeaf; bool isLeaf;
@ -194,7 +194,7 @@ namespace vcg{
ScalarType curr_d,d_curr = 0.0,d_heap; ScalarType curr_d,d_curr = 0.0,d_heap;
VertexPointer curr_s = NULL; VertexPointer curr_s = NULL;
max_distance=0.0; ScalarType max_distance=0.0;
typename std::vector<VertDist >:: iterator iv; typename std::vector<VertDist >:: iterator iv;
while(!frontier.empty() && max_distance < distance_threshold) while(!frontier.empty() && max_distance < distance_threshold)
@ -205,8 +205,8 @@ namespace vcg{
InInterval->push_back(curr); InInterval->push_back(curr);
curr_s = TD[curr].source; curr_s = TD[curr].source;
if(sources!=NULL) if(vertSource!=NULL)
(*sources)[curr] = curr_s; (*vertSource)[curr] = curr_s;
d_heap = (frontier.back()).d; d_heap = (frontier.back()).d;
frontier.pop_back(); frontier.pop_back();
@ -283,31 +283,33 @@ namespace vcg{
public: public:
/* /*
Given a mesh and a vector of pointers to vertices (sources), assigns the approximated geodesic Given a mesh and a vector of pointers to seed vertices, this function assigns the approximated geodesic
distance from the cloasest source to all the mesh vertices and returns the vertices within the distance from the closest source to all the mesh vertices within the
specified interval specified interval and returns the found vertices writing on their Quality field the distance.
Note: update the field Q() of the vertices Optionally for each vertex it can store, in a passed attribute, its corresponding seed vertex.
To allocate such an attribute:
typename MeshType::template PerVertexAttributeHandle<VertexPointer> sources;
sources = tri::Allocator<CMeshO>::AddPerVertexAttribute<VertexPointer> (m,"sources");
*/ */
static bool FarthestVertex( MeshType & m, static bool FarthestVertex( MeshType & m,
std::vector<VertexPointer> & fro, std::vector<VertexPointer> & seedVec,
VertexPointer & farthest, VertexPointer & farthest_vert,
ScalarType & distance, ScalarType distance_thr = std::numeric_limits<ScalarType>::max(),
ScalarType distance_thr = std::numeric_limits<ScalarType>::max(), typename MeshType::template PerVertexAttributeHandle<VertexPointer> * sourceSeed = NULL,
typename MeshType::template PerVertexAttributeHandle<VertexPointer> * sources = NULL,
std::vector<VertexPointer> *InInterval=NULL) std::vector<VertexPointer> *InInterval=NULL)
{ {
typename std::vector<VertexPointer>::iterator fi; typename std::vector<VertexPointer>::iterator fi;
std::vector<VertDist>fr; std::vector<VertDist> vdSeedVec;
if(fro.empty()) return false; if(seedVec.empty()) return false;
for( fi = seedVec.begin(); fi != seedVec.end() ; ++fi)
for( fi = fro.begin(); fi != fro.end() ; ++fi)
{ {
fr.push_back(VertDist(*fi,0.0)); vdSeedVec.push_back(VertDist(*fi,0.0));
/* if (InInterval==NULL)continue; /* if (InInterval==NULL)continue;
InInterval.push_back();*/ InInterval.push_back();*/
} }
farthest = Visit(m,fr,distance,false,distance_thr,sources,InInterval); farthest_vert = Visit(m, vdSeedVec, false, distance_thr, sourceSeed, InInterval);
return true; return true;
} }
/* /*
@ -315,38 +317,16 @@ namespace vcg{
distance from the vertex-source to all the mesh vertices and returns the pointer to the farthest distance from the vertex-source to all the mesh vertices and returns the pointer to the farthest
Note: update the field Q() of the vertices Note: update the field Q() of the vertices
*/ */
static void FarthestVertex( MeshType & m, static bool FarthestVertex( MeshType & m,
VertexPointer seed, VertexPointer seed,
VertexPointer & farthest,
ScalarType & distance,
ScalarType distance_thr = std::numeric_limits<ScalarType>::max()) ScalarType distance_thr = std::numeric_limits<ScalarType>::max())
{ {
std::vector<VertexPointer> seedVec; std::vector<VertexPointer> seedVec;
seedVec.push_back( seed ); seedVec.push_back( seed );
VertexPointer v0; VertexPointer v0;
FarthestVertex(m,seedVec,v0,distance,distance_thr); return FarthestVertex(m,seedVec,v0,distance_thr);
farthest = v0;
} }
/*
Given a mesh and a pointers to a vertex-source (source), assigns the approximated geodesic
distance from the vertex-source to all the mesh vertices and returns the vertices within the
specified interval
Note: update the field Q() of the vertices
*/
static void FarthestVertex( MeshType & m,
VertexPointer seed,
VertexPointer & farthest,
ScalarType & distance,
ScalarType distance_thr,
std::vector<VertexPointer> *InInterval=NULL)
{
std::vector<VertexPointer> seedVec;
seedVec.push_back( seed );
VertexPointer v0;
FarthestVertex(m,seedVec,v0,distance,distance_thr,NULL,InInterval);
farthest = v0;
}
/* /*
Same as FarthestPoint but the returned pointer is to a border vertex Same as FarthestPoint but the returned pointer is to a border vertex
@ -387,8 +367,7 @@ namespace vcg{
Note: update the field Q() of the vertices Note: update the field Q() of the vertices
*/ */
static bool DistanceFromBorder( MeshType & m, static bool DistanceFromBorder( MeshType & m,
ScalarType & distance, typename MeshType::template PerVertexAttributeHandle<VertexPointer> * sources = NULL
typename MeshType::template PerVertexAttributeHandle<VertexPointer> * sources = NULL
){ ){
std::vector<VertexPointer> fro; std::vector<VertexPointer> fro;
VertexIterator vi; VertexIterator vi;
@ -400,10 +379,10 @@ namespace vcg{
tri::UpdateQuality<MeshType>::VertexConstant(m,0); tri::UpdateQuality<MeshType>::VertexConstant(m,0);
return FarthestVertex(m,fro,farthest,distance,std::numeric_limits<ScalarType>::max(),sources); return FarthestVertex(m,fro,farthest,std::numeric_limits<ScalarType>::max(),sources);
} }
}; };
};// end namespace tri };// end namespace tri
};// end namespace vcg };// end namespace vcg
#endif #endif