From a0cf6bac3c5f70bb89b68f02ee09b928173b247f Mon Sep 17 00:00:00 2001 From: Hans-Christian Ebke Date: Wed, 29 Jan 2014 15:05:09 +0000 Subject: [PATCH] OpenMesh: Added convenience method for face centroid computation. git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@989 fdac6126-5c0c-442c-9429-916003d36597 --- src/OpenMesh/Core/Mesh/PolyMeshT.cc | 6 ++++-- src/OpenMesh/Core/Mesh/PolyMeshT.hh | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.cc b/src/OpenMesh/Core/Mesh/PolyMeshT.cc index d6092139..72cb7d78 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.cc +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.cc @@ -164,10 +164,11 @@ calc_face_normal(const Point& _p0, //----------------------------------------------------------------------------- template -void +typename PolyMeshT::Point PolyMeshT:: -calc_face_centroid(FaceHandle _fh, Point& _pt) const +calc_face_centroid(FaceHandle _fh) const { + Point _pt; _pt.vectorize(0); Scalar valence = 0.0; for (ConstFaceVertexIter cfv_it = this->cfv_iter(_fh); cfv_it.is_valid(); ++cfv_it, valence += 1.0) @@ -175,6 +176,7 @@ calc_face_centroid(FaceHandle _fh, Point& _pt) const _pt += this->point(*cfv_it); } _pt /= valence; + return _pt; } //----------------------------------------------------------------------------- diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.hh b/src/OpenMesh/Core/Mesh/PolyMeshT.hh index 0f6d1f02..d053d91d 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.hh +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.hh @@ -232,7 +232,12 @@ public: Normal calc_face_normal(const Point& _p0, const Point& _p1, const Point& _p2) const; /// calculates the average of the vertices defining _fh - void calc_face_centroid(FaceHandle _fh, Point& _pt) const; + void calc_face_centroid(FaceHandle _fh, Point& _pt) const { + _pt = calc_face_centroid(_fh); + } + + /// Computes and returns the average of the vertices defining _gh + Point calc_face_centroid(FaceHandle _fh) const; /// Update normal for halfedge _heh void update_normal(HalfedgeHandle _heh, const double _feature_angle = 0.8)