44 using PointType = MeshType::VertexType::CoordType;
45 using ScalarType = PointType::ScalarType;
46 using ConstIterator = std::ranges::iterator_t<CoordView>;
50 enableIfPerVertexNormalOptional(mMesh);
51 enableIfPerVertexQualityOptional(mMesh);
53 mMesh.name() =
"Sampling";
57 const MeshType& samples()
const {
return mMesh; }
59 const PointType& sample(
uint i)
const {
return mMesh.vertex(
i).coord(); }
61 std::size_t size()
const {
return mMesh.vertexNumber(); }
63 void clear() { mMesh.clear(); }
67 if (
n > mMesh.vertexNumber()) {
68 uint k =
n - mMesh.vertexNumber();
73 void reserve(
uint n) { mMesh.reserveVertices(
n); }
75 void add(
const PointType&
p) { mMesh.addVertex(
p); }
77 void set(
uint i,
const PointType&
p) { mMesh.vertex(
i).coord() =
p; }
79 template<VertexConcept VertexType>
80 void add(
const VertexType& v)
82 uint vi = mMesh.addVertex(v.coord());
83 mMesh.vertex(
vi).importFrom(v,
false);
85 setBirthElement(
vi,
"birthVertex", v.index());
88 template<VertexConcept VertexType>
89 void set(
uint i,
const VertexType& v)
91 mMesh.vertex(
i).coord() = v.coord();
92 mMesh.vertex(
i).importFrom(v,
false);
94 setBirthElement(
i,
"birthVertex", v.index());
97 template<EdgeConcept EdgeType>
98 void add(
const EdgeType& e,
double u,
bool copyQuality =
true)
100 uint vi = mMesh.addVertex(
101 (e.vertex(0).coord() * (1 - u)) + (e.vertex(1).coord() * u));
106 if (isPerVertexQualityAvailable(mMesh) &&
107 comp::isQualityAvailableOn(e)) {
108 mMesh.vertex(
vi).quality() = e.quality();
113 setBirthElement(
vi,
"birthEdge", e.index());
116 template<EdgeConcept EdgeType>
119 mMesh.vertex(
i).coord() =
120 (e.vertex(0).coord() * (1 - u)) + (e.vertex(1).coord() * u);
125 if (isPerVertexQualityAvailable(mMesh) &&
126 comp::isQualityAvailableOn(e)) {
127 mMesh.vertex(
i).quality() = e.quality();
132 setBirthElement(
i,
"birthEdge", e.index());
135 template<FaceConcept FaceType>
144 setBirthElement(
vi,
"birthFace", f.index());
147 template<FaceConcept FaceType>
157 setBirthElement(
i,
"birthFace", f.index());
160 template<FaceConcept FaceType>
163 const std::vector<ScalarType>&
barCoords,
170 for (
uint i = 0;
i < f.vertexNumber();
i++)
176 setBirthElement(
vi,
"birthFace", f.index());
179 template<FaceConcept FaceType>
183 const std::vector<ScalarType>&
barCoords,
190 for (
uint i = 0;
i < f.vertexNumber();
i++)
193 mMesh.vertex(
i).coord() =
p;
196 setBirthElement(
i,
"birthFace", f.index());
199 template<FaceConcept FaceType>
206 static_assert(FaceType::NV == 3 || FaceType::NV == -1);
207 if constexpr (FaceType::NV == -1) {
208 assert(f.vertexNumber() == 3);
216 setBirthElement(
vi,
"birthFace", f.index());
219 template<FaceConcept FaceType>
227 static_assert(FaceType::NV == 3 || FaceType::NV == -1);
228 if constexpr (FaceType::NV == -1) {
229 assert(f.vertexNumber() == 3);
234 mMesh.vertex(
i).coord() =
p;
237 setBirthElement(
i,
"birthFace", f.index());
240 ConstIterator begin()
const
242 return std::ranges::begin(mMesh.vertices() | views::coords);
245 ConstIterator end()
const
247 return std::ranges::end(mMesh.vertices() | views::coords);
251 template<FaceConcept FaceType>
261 if (isPerVertexNormalAvailable(mMesh) &&
262 comp::isNormalAvailableOn(f)) {
263 mMesh.vertex(
vi).normal() = f.normal();
271 if (isPerVertexQualityAvailable(mMesh) &&
272 comp::isQualityAvailableOn(f)) {
273 mMesh.vertex(
vi).quality() = f.quality();
279 void setBirthElement(
uint vi,
const std::string& key,
uint value)
282 if (!mMesh.hasPerVertexCustomComponent(key)) {
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