File indexing completed on 2025-01-19 09:23:34
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/Polyhedron.hpp"
0013
0014 #include <numeric>
0015 #include <utility>
0016 #include <vector>
0017
0018 namespace Acts::detail {
0019
0020
0021 struct FacesHelper {
0022 using FaceVector = std::vector<Polyhedron::FaceType>;
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 static std::pair<FaceVector, FaceVector> convexFaceMesh(
0033 const std::vector<Vector3>& vertices, bool centerLast = false) {
0034 FaceVector faces;
0035 FaceVector triangularMesh;
0036
0037 unsigned int offset = centerLast ? 1 : 0;
0038 std::vector<std::size_t> face(vertices.size() - offset);
0039 std::iota(face.begin(), face.end(), 0);
0040 faces.push_back(face);
0041
0042 unsigned int anker = centerLast ? vertices.size() - 1 : 0;
0043 for (unsigned int it = 2 - offset; it < vertices.size() - offset; ++it) {
0044 triangularMesh.push_back({anker, it - 1, it});
0045 }
0046
0047 if (centerLast) {
0048 triangularMesh.push_back({anker, vertices.size() - 2, 0});
0049 }
0050 return {faces, triangularMesh};
0051 }
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 static std::pair<FaceVector, FaceVector> cylindricalFaceMesh(
0065 const std::vector<Vector3>& vertices, bool fullTwoPi = true) {
0066 FaceVector faces;
0067 FaceVector triangularMesh;
0068 std::size_t nqfaces = static_cast<std::size_t>(0.5 * vertices.size());
0069 std::size_t reduce = (!fullTwoPi) ? 1 : 0;
0070 for (std::size_t iface = 0; iface < nqfaces - reduce; ++iface) {
0071 std::size_t p2 = (iface + 1 == nqfaces) ? 0 : iface + 1;
0072 std::vector<std::size_t> face = {iface, p2, p2 + nqfaces,
0073 nqfaces + iface};
0074 faces.push_back(face);
0075 std::vector<std::size_t> triA = {iface, p2, p2 + nqfaces};
0076 triangularMesh.push_back(triA);
0077 std::vector<std::size_t> triB = {p2 + nqfaces, nqfaces + iface, iface};
0078 triangularMesh.push_back(triB);
0079 }
0080 return {faces, triangularMesh};
0081 }
0082 };
0083
0084 }