23#ifndef VCL_ALGORITHMS_MESH_SORT_H
24#define VCL_ALGORITHMS_MESH_SORT_H
28#include <vclib/space/complex.h>
34template<FaceMeshConcept MeshType>
35std::vector<MeshEdgeUtil<MeshType>> fillAndSortMeshEdgeUtilVector(
37 bool includeFauxEdges =
true)
39 using FaceType = MeshType::FaceType;
41 std::vector<MeshEdgeUtil<MeshType>> vec;
44 for (
const FaceType& f : m.
faces())
45 n_edges += f.vertexNumber();
49 for (FaceType& f : m.
faces()) {
50 for (uint j = 0; j < f.vertexNumber(); ++j) {
51 if (includeFauxEdges || !f.edgeFaux(j)) {
52 vec.emplace_back(f, j);
58 std::sort(std::execution::par_unseq, vec.begin(), vec.end());
63template<FaceMeshConcept MeshType>
64std::vector<ConstMeshEdgeUtil<MeshType>> fillAndSortMeshEdgeUtilVector(
66 bool includeFauxEdges =
true)
68 using FaceType = MeshType::FaceType;
70 std::vector<ConstMeshEdgeUtil<MeshType>> vec;
73 for (
const FaceType& f : m.
faces())
74 n_edges += f.vertexNumber();
78 for (
const FaceType& f : m.
faces()) {
79 for (uint j = 0; j < f.vertexNumber(); ++j) {
80 if (includeFauxEdges || !f.edgeFaux(j)) {
81 vec.emplace_back(f, j);
87 std::sort(std::execution::par_unseq, vec.begin(), vec.end());
115template<u
int ELEM_ID, MeshConcept MeshType>
116std::vector<uint> sortElemIndicesByFunction(
117 const MeshType& mesh,
118 const std::function<
bool(
119 const typename MeshType::template ElementType<ELEM_ID>&,
120 const typename MeshType::template ElementType<ELEM_ID>&)>& func,
121 bool getIndicesAsIfContainerCompact =
false)
123 using ElemType =
typename MeshType::template ElementType<ELEM_ID>;
125 auto compactIndices = detail::elemCompactIndices<ELEM_ID>(
126 mesh, getIndicesAsIfContainerCompact);
128 std::vector<uint> indices;
131 indices.resize(mesh.template number<ELEM_ID>());
132 std::iota(indices.begin(), indices.end(), 0u);
134 std::sort(indices.begin(), indices.end(), [&](uint a, uint b) {
136 mesh.template element<ELEM_ID>(a),
137 mesh.template element<ELEM_ID>(b));
140 if (!compactIndices.empty()) {
141 for (
auto& idx : indices) {
142 idx = compactIndices[idx];
170template<MeshConcept MeshType>
171std::vector<uint> sortVertexIndicesByFunction(
172 const MeshType& mesh,
173 const std::function<
bool(
174 const typename MeshType::VertexType&,
175 const typename MeshType::VertexType&)>& func,
176 bool getIndicesAsIfContainerCompact =
false)
178 return sortElemIndicesByFunction<ElemId::VERTEX>(
179 mesh, func, getIndicesAsIfContainerCompact);
203template<FaceMeshConcept MeshType>
204std::vector<uint> sortFaceIndicesByFunction(
205 const MeshType& mesh,
206 const std::function<
bool(
207 const typename MeshType::FaceType&,
208 const typename MeshType::FaceType&)>& func,
209 bool getIndicesAsIfContainerCompact =
false)
211 return sortElemIndicesByFunction<ElemId::FACE>(
212 mesh, func, getIndicesAsIfContainerCompact);
236template<EdgeMeshConcept MeshType>
237std::vector<uint> sortEdgeIndicesByFunction(
238 const MeshType& mesh,
239 const std::function<
bool(
240 const typename MeshType::EdgeType&,
241 const typename MeshType::EdgeType&)>& func,
242 bool getIndicesAsIfContainerCompact =
false)
244 return sortElemIndicesByFunction<ElemId::EDGE>(
245 mesh, func, getIndicesAsIfContainerCompact);
constexpr detail::FacesView faces
A view that allows to iterate overt the Face elements of an object.
Definition face.h:84