From b3e9a9e105fb828927b60d6e70dbfbb4d1a28c2f Mon Sep 17 00:00:00 2001 From: cignoni Date: Tue, 26 May 2009 22:31:58 +0000 Subject: [PATCH] Changed a few geodesic function from void to bool to return possible failures (like for exmple asking for border distance on a mesh without border) --- vcg/complex/trimesh/geodesic.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/vcg/complex/trimesh/geodesic.h b/vcg/complex/trimesh/geodesic.h index 022d57a2..b94804ba 100644 --- a/vcg/complex/trimesh/geodesic.h +++ b/vcg/complex/trimesh/geodesic.h @@ -35,10 +35,11 @@ #include +#include #include #include #include -#include +#include #include #include #include @@ -297,7 +298,7 @@ public: distance from the cloasest source to all the mesh vertices and returns the pointer to the farthest. Note: update the field Q() of the vertices */ - static void FarthestVertex( MeshType & m, + static bool FarthestVertex( MeshType & m, std::vector & fro, VertexPointer & farthest, ScalarType & distance, @@ -305,10 +306,12 @@ public: typename std::vector::iterator fi; std::vectorfr; - + 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,sources); + return true; } /* Given a mesh and a pointers to a vertex-source (source), assigns the approximated geodesic @@ -364,7 +367,7 @@ public: Assigns to each vertex of the mesh its distance to the closest vertex on the border Note: update the field Q() of the vertices */ - static void DistanceFromBorder( MeshType & m, + static bool DistanceFromBorder( MeshType & m, ScalarType & distance, typename MeshType::template PerVertexAttributeHandle * sources = NULL ){ @@ -374,7 +377,11 @@ public: for(vi = m.vert.begin(); vi != m.vert.end(); ++vi) if( (*vi).IsB()) fro.push_back(&(*vi)); - FarthestVertex(m,fro,farthest,distance,sources); + if(fro.empty()) return false; + + tri::UpdateQuality::VertexConstant(m,0); + + return FarthestVertex(m,fro,farthest,distance,sources); } };