OpenMesh: Added convenience method for face centroid computation.

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@989 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Hans-Christian Ebke
2014-01-29 15:05:09 +00:00
parent 6465c08ec7
commit a0cf6bac3c
2 changed files with 10 additions and 3 deletions

View File

@@ -164,10 +164,11 @@ calc_face_normal(const Point& _p0,
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <class Kernel> template <class Kernel>
void typename PolyMeshT<Kernel>::Point
PolyMeshT<Kernel>:: PolyMeshT<Kernel>::
calc_face_centroid(FaceHandle _fh, Point& _pt) const calc_face_centroid(FaceHandle _fh) const
{ {
Point _pt;
_pt.vectorize(0); _pt.vectorize(0);
Scalar valence = 0.0; Scalar valence = 0.0;
for (ConstFaceVertexIter cfv_it = this->cfv_iter(_fh); cfv_it.is_valid(); ++cfv_it, valence += 1.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 += this->point(*cfv_it);
} }
_pt /= valence; _pt /= valence;
return _pt;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -232,7 +232,12 @@ public:
Normal calc_face_normal(const Point& _p0, const Point& _p1, Normal calc_face_normal(const Point& _p0, const Point& _p1,
const Point& _p2) const; const Point& _p2) const;
/// calculates the average of the vertices defining _fh /// 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 /// Update normal for halfedge _heh
void update_normal(HalfedgeHandle _heh, const double _feature_angle = 0.8) void update_normal(HalfedgeHandle _heh, const double _feature_angle = 0.8)