From a1a82331e34b335fcbdb1e7bc88997fd84412f42 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Fri, 6 Dec 2019 11:14:27 +0100 Subject: [PATCH] add calc_centroid methods for all elements returning calc_face_centroid, calc_edge_midpoint and point respectively --- src/OpenMesh/Core/Mesh/PolyMeshT.hh | 17 +++++++- src/OpenMesh/Core/Mesh/PolyMeshT_impl.hh | 50 ++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.hh b/src/OpenMesh/Core/Mesh/PolyMeshT.hh index 0ffb4691..e2bf2dac 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.hh +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.hh @@ -276,9 +276,24 @@ public: _pt = calc_face_centroid(_fh); } - /// Computes and returns the average of the vertices defining _gh + /// Computes and returns the average of the vertices defining _fh Point calc_face_centroid(FaceHandle _fh) const; + /// Computes and returns the average of the vertices defining _fh (same as calc_face_centroid) + Point calc_centroid(FaceHandle _fh) const; + + /// Computes and returns the average of the vertices defining _eh (same as calc_edge_midpoint) + Point calc_centroid(EdgeHandle _eh) const; + + /// Computes and returns the average of the vertices defining _heh (same as calc_edge_midpoint for edge of halfedge) + Point calc_centroid(HalfedgeHandle _heh) const; + + /// Returns the point of _vh + Point calc_centroid(VertexHandle _vh) const; + + /// Computes and returns the average of the vertices defining the mesh + Point calc_centroid(MeshHandle _mh) const; + /// Update normal for halfedge _heh void update_normal(HalfedgeHandle _heh, const double _feature_angle = 0.8) { this->set_normal(_heh, calc_halfedge_normal(_heh,_feature_angle)); } diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT_impl.hh b/src/OpenMesh/Core/Mesh/PolyMeshT_impl.hh index 11d885c2..ba7cfd85 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT_impl.hh +++ b/src/OpenMesh/Core/Mesh/PolyMeshT_impl.hh @@ -250,8 +250,58 @@ calc_face_centroid(FaceHandle _fh) const _pt /= valence; return _pt; } + //----------------------------------------------------------------------------- +template +typename PolyMeshT::Point +PolyMeshT:: +calc_centroid(FaceHandle _fh) const +{ + return calc_face_centroid(_fh); +} + +//----------------------------------------------------------------------------- + +template +typename PolyMeshT::Point +PolyMeshT:: +calc_centroid(EdgeHandle _eh) const +{ + return this->calc_edge_midpoint(_eh); +} + +//----------------------------------------------------------------------------- + +template +typename PolyMeshT::Point +PolyMeshT:: +calc_centroid(HalfedgeHandle _heh) const +{ + return this->calc_edge_midpoint(this->edge_handle(_heh)); +} + +//----------------------------------------------------------------------------- + +template +typename PolyMeshT::Point +PolyMeshT:: +calc_centroid(VertexHandle _vh) const +{ + return this->point(_vh); +} + +//----------------------------------------------------------------------------- + +template +typename PolyMeshT::Point +PolyMeshT:: +calc_centroid(MeshHandle /*_mh*/) const +{ + return this->vertices().avg(getPointsProperty(*this)); +} + +//----------------------------------------------------------------------------- template void