Visual Computing Library  devel
Loading...
Searching...
No Matches
vertex_sampler.h
1#ifndef VCL_SPACE_COMPLEX_SAMPLER_VERTEX_SAMPLER_H
2#define VCL_SPACE_COMPLEX_SAMPLER_VERTEX_SAMPLER_H
3
4#include <vclib/mesh.h>
5
6namespace vcl {
7
8template<VertexConcept Vertex, bool CNST = true>
10{
11 using VertexType = std::conditional_t<CNST, const Vertex, Vertex>;
12
13 std::vector<VertexType*> mSamples;
14
15public:
16 using PointType = VertexType::PositionType;
17
18 VertexSampler() {}
19
20 const std::vector<VertexType*> samples() const { return mSamples; }
21
22 const typename VertexType::PositionType& sample(uint i) const
23 {
24 return mSamples[i]->position();
25 }
26
27 std::size_t size() const { return mSamples.size(); }
28
29 void clear() { mSamples.clear(); }
30
31 void reserve(uint n) { mSamples.reserve(n); }
32
33 void resize(uint n) { mSamples.resize(n); }
34
35 void add(VertexType& v) { mSamples.push_back(&v); }
36
37 void set(uint i, VertexType& v) { mSamples[i] = &v; }
38
39 auto begin() const { return std::begin(mSamples | views::positions); }
40
41 auto end() const { return std::end(mSamples | views::positions); }
42};
43
44template<VertexConcept VertexType>
46
47} // namespace vcl
48
49#endif // VCL_SPACE_COMPLEX_SAMPLER_VERTEX_SAMPLER_H
A class representing a box in N-dimensional space.
Definition box.h:46
Definition vertex_sampler.h:10