- added call of FarthestVertex with returning vertices within a specified interval

- added initial #define to avoid multiple inclusion
This commit is contained in:
Nico Pietroni 2011-04-19 09:40:04 +00:00
parent 95713e5723
commit c4cc235b52
1 changed files with 328 additions and 284 deletions

View File

@ -43,6 +43,9 @@ basic example: farthest vertex from a specified one
g.FarthestVertex(m,seed,far,d);
*/
#ifndef __VCGLIB_GEODESIC
#define __VCGLIB_GEODESIC
namespace vcg{
namespace tri{
@ -163,8 +166,8 @@ class Geo{
ScalarType & max_distance,
bool farthestOnBorder = false,
ScalarType distance_threshold = std::numeric_limits<ScalarType>::max(),
typename MeshType::template PerVertexAttributeHandle<VertexPointer> * sources = NULL
)
typename MeshType::template PerVertexAttributeHandle<VertexPointer> * sources = NULL,
std::vector<VertexPointer> *InInterval=NULL)
{
bool isLeaf;
std::vector<VertDist> frontier;
@ -198,6 +201,9 @@ class Geo{
{
pop_heap(frontier.begin(),frontier.end(),pred());
curr = (frontier.back()).v;
if (InInterval!=NULL)
InInterval->push_back(curr);
curr_s = TD[curr].source;
if(sources!=NULL)
(*sources)[curr] = curr_s;
@ -259,8 +265,17 @@ class Geo{
}// end while
// Copy found distance onto the Quality (\todo parametric!)
if (InInterval==NULL)
{
for(VertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi) if(!(*vi).IsD())
(*vi).Q() = TD[&(*vi)].d;
}
else
{
assert(InInterval->size()>0);
for(int i=0;i<InInterval->size();i++)
(*InInterval)[i]->Q() = TD[(*InInterval)[i]].d;
}
return farthest;
}
@ -269,7 +284,8 @@ class Geo{
public:
/*
Given a mesh and a vector of pointers to vertices (sources), assigns the approximated geodesic
distance from the cloasest source to all the mesh vertices and returns the pointer to the farthest.
distance from the cloasest source to all the mesh vertices and returns the vertices within the
specified interval
Note: update the field Q() of the vertices
*/
static bool FarthestVertex( MeshType & m,
@ -277,15 +293,21 @@ public:
VertexPointer & farthest,
ScalarType & distance,
ScalarType distance_thr = std::numeric_limits<ScalarType>::max(),
typename MeshType::template PerVertexAttributeHandle<VertexPointer> * sources = NULL){
typename MeshType::template PerVertexAttributeHandle<VertexPointer> * sources = NULL,
std::vector<VertexPointer> *InInterval=NULL)
{
typename std::vector<VertexPointer>::iterator fi;
std::vector<VertDist>fr;
if(fro.empty()) return false;
for( fi = fro.begin(); fi != fro.end() ; ++fi)
{
fr.push_back(VertDist(*fi,0.0));
farthest = Visit(m,fr,distance,false,distance_thr,sources);
/* if (InInterval==NULL)continue;
InInterval.push_back();*/
}
farthest = Visit(m,fr,distance,false,distance_thr,sources,InInterval);
return true;
}
/*
@ -297,7 +319,8 @@ public:
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;
seedVec.push_back( seed );
VertexPointer v0;
@ -305,6 +328,26 @@ public:
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
Note: update the field Q() of the vertices
@ -363,3 +406,4 @@ public:
};
};// end namespace tri
};// end namespace vcg
#endif