From 3179316c829b3e34ae8ca08ce16c05a6a762c532 Mon Sep 17 00:00:00 2001 From: Janis Born Date: Wed, 11 Jan 2017 17:27:11 +0100 Subject: [PATCH] add calc_edge_midpoint methods for meshes --- src/OpenMesh/Core/Mesh/PolyMeshT.hh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/OpenMesh/Core/Mesh/PolyMeshT.hh b/src/OpenMesh/Core/Mesh/PolyMeshT.hh index d514fedc..bccabcd6 100644 --- a/src/OpenMesh/Core/Mesh/PolyMeshT.hh +++ b/src/OpenMesh/Core/Mesh/PolyMeshT.hh @@ -409,6 +409,22 @@ public: return edge_vec.sqrnorm(); } + /** Calculates the midpoint of the halfedge _heh, defined by the positions of + the two incident vertices */ + Point calc_edge_midpoint(HalfedgeHandle _heh) const + { + auto vh0 = this->from_vertex_handle(_heh); + auto vh1 = this->to_vertex_handle(_heh); + return 0.5 * (this->point(vh0) + this->point(vh1)); + } + + /** Calculates the midpoint of the edge _eh, defined by the positions of the + two incident vertices */ + Point calc_edge_midpoint(EdgeHandle _eh) const + { + return calc_edge_midpoint(this->halfedge_handle(_eh, 0)); + } + /** defines a consistent representation of a sector geometry: the halfedge _in_heh defines the sector orientation the vertex pointed by _in_heh defines the sector center