23#ifndef VCL_ALGORITHMS_MESH_SHUFFLE_H
24#define VCL_ALGORITHMS_MESH_SHUFFLE_H
26#include <vclib/mesh.h>
38template<
typename M,
typename V>
39std::vector<V*> genericFASVPV(M m, std::optional<uint> seed = std::nullopt)
42 vec.reserve(m.vertexNumber());
59template<
typename M,
typename F>
60std::vector<F*> genericFASFPV(M m, std::optional<uint> seed = std::nullopt)
63 vec.reserve(m.faceNumber());
65 for (F& f : m.
faces()) {
76template<MeshConcept MeshType>
77std::vector<typename MeshType::VertexType*> fillAndShuffleVertexPointerVector(
79 std::optional<uint> seed = std::nullopt)
81 using VertexType = MeshType::VertexType;
83 return detail::genericFASVPV<MeshType&, VertexType>(m, seed);
86template<MeshConcept MeshType>
87std::vector<const typename MeshType::VertexType*>
88fillAndShuffleVertexPointerVector(
90 std::optional<uint> seed = std::nullopt)
92 using VertexType = MeshType::VertexType;
93 return detail::genericFASVPV<const MeshType&, const VertexType>(
97template<MeshConcept MeshType>
98std::vector<uint> fillAndShuffleVertexIndexVector(
100 std::optional<uint> seed = std::nullopt)
102 using VertexType = MeshType::VertexType;
104 std::vector<uint> vec;
105 vec.reserve(m.vertexNumber());
107 for (
const VertexType& v : m.
vertices()) {
108 vec.push_back(m.index(v));
116template<FaceMeshConcept MeshType>
117std::vector<typename MeshType::FaceType*> fillAndShuffleFacePointerVector(
119 std::optional<uint> seed = std::nullopt)
121 using FaceType = MeshType::FaceType;
123 return detail::genericFASFPV<MeshType&, FaceType>(m, seed);
126template<FaceMeshConcept MeshType>
127std::vector<const typename MeshType::FaceType*> fillAndShuffleFacePointerVector(
129 std::optional<uint> seed = std::nullopt)
131 using FaceType = MeshType::FaceType;
133 return detail::genericFASFPV<const MeshType&, const FaceType>(
137template<FaceMeshConcept MeshType>
138std::vector<uint> fillAndShuffleFaceIndexVector(
140 std::optional<uint> seed = std::nullopt)
142 using FaceType = MeshType::FaceType;
144 std::vector<uint> vec;
145 vec.reserve(m.faceNumber());
147 for (
const FaceType& f : m.
faces()) {
148 vec.push_back(m.index(f));
void shuffle(R &&range, std::optional< uint > seed=std::nullopt)
Shuffle the elements of a range.
Definition random.h:70
constexpr detail::FacesView faces
A view that allows to iterate overt the Face elements of an object.
Definition face.h:84
constexpr detail::VerticesView vertices
A view that allows to iterate over the Vertex elements of an object.
Definition vertex.h:92