Developer Documentation
EntityPosition.hh
1#pragma once
2
3#include <ACG/Math/VectorT.hh>
4#include <OpenVolumeMesh/Core/Entities.hh>
5#include <OpenVolumeMesh/Core/GeometryKernel.hh>
6
7template<class MeshT>
9{
10public:
11 EntityPosition(MeshT &mesh) : mesh_(mesh) {}
13 {
14 return mesh_.vertex(vh);
15 }
17 {
18 auto edge = mesh_.edge(eh);
19 return 0.5 * (mesh_.vertex(edge.from_vertex()) + mesh_.vertex(edge.to_vertex()));
20 }
22 {
23 auto edge = mesh_.halfedge(heh);
24 return (1./3.) * (2 * mesh_.vertex(edge.from_vertex()) + mesh_.vertex(edge.to_vertex()));
25 }
27 {
28 int count = 0;
29 ACG::Vec3d sum{0.,0.,0.};
30 for (auto vh: mesh_.cell_vertices(ch)) {
31 sum += mesh_.vertex(vh);
32 ++count;
33 }
34 return sum / count;
35 }
36
38 {
39 return (*this)(mesh_.halfface_handle(fh, 0));
40 }
41
43 {
44 // TODO: maybe offset this slightly from the face barycenter?
45 int count = 0;
46 ACG::Vec3d sum{0.,0.,0.};
47 for (auto vh: mesh_.halfface_vertices(hfh)) {
48 sum += mesh_.vertex(vh);
49 ++count;
50 }
51 return sum / count;
52 }
53private:
54 MeshT &mesh_;
55};
56
const VecT & vertex(VertexHandle _vh) const
Get point _vh's coordinates.
static HalfFaceHandle halfface_handle(FaceHandle _h, const unsigned char _subIdx)
Conversion function.
Edge halfedge(HalfEdgeHandle _halfEdgeHandle) const
Get edge that corresponds to halfedge with handle _halfEdgeHandle.
const Edge & edge(EdgeHandle _edgeHandle) const
Get edge with handle _edgeHandle.