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>(m, seed);
96template<MeshConcept MeshType>
97std::vector<uint> fillAndShuffleVertexIndexVector(
99 std::optional<uint> seed = std::nullopt)
101 using VertexType = MeshType::VertexType;
103 std::vector<uint> vec;
104 vec.reserve(m.vertexNumber());
106 for (
const VertexType& v : m.
vertices()) {
107 vec.push_back(m.index(v));
115template<FaceMeshConcept MeshType>
116std::vector<typename MeshType::FaceType*> fillAndShuffleFacePointerVector(
118 std::optional<uint> seed = std::nullopt)
120 using FaceType = MeshType::FaceType;
122 return detail::genericFASFPV<MeshType&, FaceType>(m, seed);
125template<FaceMeshConcept MeshType>
126std::vector<const typename MeshType::FaceType*> fillAndShuffleFacePointerVector(
128 std::optional<uint> seed = std::nullopt)
130 using FaceType = MeshType::FaceType;
132 return detail::genericFASFPV<const MeshType&, const FaceType>(m, seed);
135template<FaceMeshConcept MeshType>
136std::vector<uint> fillAndShuffleFaceIndexVector(
138 std::optional<uint> seed = std::nullopt)
140 using FaceType = MeshType::FaceType;
142 std::vector<uint> vec;
143 vec.reserve(m.faceNumber());
145 for (
const FaceType& f : m.
faces()) {
146 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:71
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