23#ifndef VCL_ALGORITHMS_MESH_STAT_BARYCENTER_H
24#define VCL_ALGORITHMS_MESH_STAT_BARYCENTER_H
26#include <vclib/concepts/mesh.h>
27#include <vclib/mesh/requirements.h>
42template<MeshConcept MeshType>
43typename MeshType::VertexType::CoordType barycenter(
const MeshType& m)
45 using VertexType = MeshType::VertexType;
46 using CoordType = VertexType::CoordType;
50 for (
const VertexType& v : m.
vertices()) {
54 return bar / m.vertexNumber();
72template<MeshConcept MeshType>
73typename MeshType::VertexType::CoordType scalarWeightedBarycenter(
76 requirePerVertexQuality(m);
78 using VertexType = MeshType::VertexType;
79 using CoordType = VertexType::CoordType;
80 using QualityType = VertexType::QualityType;
83 QualityType weightedSum = 0;
85 for (
const VertexType& v : m.
vertices()) {
86 bar += v.coord() * v.quality();
87 weightedSum += v.quality();
90 return bar / weightedSum;
108template<FaceMeshConcept MeshType>
109typename MeshType::VertexType::CoordType shellBarycenter(
const MeshType& m)
111 using VertexType = MeshType::VertexType;
112 using FaceType = MeshType::FaceType;
113 using CoordType = VertexType::CoordType;
114 using ScalarType = CoordType::ScalarType;
118 ScalarType areaSum = 0;
120 for (
const FaceType& f : m.
faces()) {
126 return bar / areaSum;
FaceType::VertexType::CoordType faceBarycenter(const FaceType &f)
Computes the barycenter of a face. Works both for triangle and polygonal faces, and it is optimized i...
Definition geometry.h:77
auto faceArea(const FaceType &f)
Computes the area of a face. Works both for triangle and polygonal faces, and it is optimized in case...
Definition geometry.h:101
constexpr detail::FacesView faces
A view that allows to iterate overt the Face elements of an object.
Definition face.h:52
constexpr detail::VerticesView vertices
A view that allows to iterate over the Vertex elements of an object.
Definition vertex.h:60