34 std::vector<PointT> mSamples;
37 using PointType = PointT;
38 using ScalarType = PointT::ScalarType;
39 using ConstIterator = std::vector<PointT>::const_iterator;
43 const std::vector<PointT>& samples()
const {
return mSamples; }
45 const PointT& sample(
uint i)
const {
return mSamples[
i]; }
47 std::size_t size()
const {
return mSamples.size(); }
49 void clear() { mSamples.clear(); }
51 void reserve(
uint n) { mSamples.reserve(
n); }
53 void resize(
uint n) { mSamples.resize(
n); }
55 void add(
const PointT&
p) { mSamples.push_back(
p); }
57 void set(
uint i,
const PointT&
p) { mSamples[
i] =
p; }
59 template<VertexConcept VertexType>
60 void add(
const VertexType& v)
62 mSamples.push_back(v.position());
65 template<VertexConcept VertexType>
66 void set(
uint i,
const VertexType& v)
68 mSamples[
i] = v.position();
71 template<EdgeConcept EdgeType>
72 void add(
const EdgeType& e,
double u = 0.5)
75 (e.vertex(0).position() * (1 - u)) + (e.vertex(1).position() * u));
78 template<EdgeConcept EdgeType>
79 void set(
uint i,
const EdgeType& e,
double u = 0.5)
82 (e.vertex(0).position() * (1 - u)) + (e.vertex(1).position() * u);
85 template<FaceConcept FaceType>
86 void add(
const FaceType& f)
91 template<FaceConcept FaceType>
92 void set(
uint i,
const FaceType& f)
97 template<FaceConcept FaceType>
98 void add(
const FaceType& f,
const std::vector<ScalarType>&
barCoords)
103 for (
uint i = 0;
i < f.vertexNumber();
i++)
106 mSamples.push_back(
p);
109 template<FaceConcept FaceType>
113 const std::vector<ScalarType>&
barCoords)
118 for (
uint i = 0;
i < f.vertexNumber();
i++)
124 template<FaceConcept FaceType>
125 void add(
const FaceType& f,
const PointT&
barCoords)
127 static_assert(FaceType::NV == 3 || FaceType::NV == -1);
128 if constexpr (FaceType::NV == -1) {
129 assert(f.vertexNumber() == 3);
134 mSamples.push_back(
p);
137 template<FaceConcept FaceType>
140 static_assert(FaceType::NV == 3 || FaceType::NV == -1);
141 if constexpr (FaceType::NV == -1) {
142 assert(f.vertexNumber() == 3);
150 ConstIterator begin()
const {
return mSamples.begin(); }
152 ConstIterator end()
const {
return mSamples.end(); }
FaceType::VertexType::PositionType 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:81