31 if (a0 == b0 || a0 == b1) {
34 if (a1 == b0 || a1 == b1) {
51template <std::
size_t n>
71template <std::
size_t n>
74 static_assert(n > 1,
"You already know the answer.");
80 for (std::size_t i = 1; i < n - 1; ++i) {
82 for (std::size_t j = i; j < n; ++j) {
83 if (edges[i - 1]->connectedTo(*edges[j])) {
84 std::swap(edges[i], edges[j]);
94 if (!edges[n - 1]->connectedTo(*edges[n - 2]) ||
95 !edges[n - 1]->connectedTo(*edges[0])) {
101 for (std::size_t i = 0; i < n - 1; ++i) {
110template <std::
size_t n>
113 static_assert(n > 0,
"Cannot handle nothing.");
114 std::array<Vertex *, n> vptrs;
115 std::transform(vertexIDs.begin(), vertexIDs.end(), vptrs.begin(),
116 [&
mesh](
int id) { return &(mesh.vertex(id)); });
121template <std::
size_t n>
124 std::array<Eigen::VectorXd, n> coords;
125 std::transform(vertexIDs.begin(), vertexIDs.end(), coords.begin(),
126 [&
mesh](
int id) { return mesh.vertex(id).getCoords(); });
131template <std::
size_t n>
132std::array<Eigen::VectorXd, n>
coordsFor(
const std::array<Vertex *, n> &vertexPtrs)
134 std::array<Eigen::VectorXd, n> coords;
135 std::transform(vertexPtrs.begin(), vertexPtrs.end(), coords.begin(),
136 [](
Vertex *v) { return v->getCoords(); });
146template <
typename Container>
149 if (
const auto invalidIter = std::find_if(container.begin(), container.end(), [&
mesh](
VertexID id) { return !mesh.isValidVertexID(id); });
150 invalidIter != container.end()) {
151 return {std::distance(container.begin(), invalidIter)};
std::shared_ptr< Mesh > PtrMesh
An axis-aligned bounding box around a (partition of a) mesh.
Linear edge of a mesh, defined by two Vertex objects.
Vertex & vertex(int i)
Returns the edge's vertex with index 0 or 1.
Container and creator for meshes.
Eigen::VectorXd getCoords() const
Returns the coordinates of the vertex.
contains data mapping from points to meshes.
provides Mesh, Data and primitives.
Eigen::VectorXd integrateSurface(const PtrMesh &mesh, const Eigen::VectorXd &input)
Given the data and the mesh, this function returns the surface integral. Assumes no overlap exists fo...
Eigen::VectorXd integrateVolume(const PtrMesh &mesh, const Eigen::VectorXd &input)
Given the data and the mesh, this function returns the volume integral. Assumes no overlap exists for...
std::array< Eigen::VectorXd, n > coordsFor(const Mesh &mesh, const std::array< int, n > &vertexIDs)
Given a mesh and an array of vertexIDS, this function returns an array of coordinates of the vertices...
std::shared_ptr< Mesh > PtrMesh
Vertex * sharedVertex(Edge &a, Edge &b)
std::optional< std::size_t > locateInvalidVertexID(const Mesh &mesh, const Container &container)
std::array< Vertex *, n > vertexPtrsFor(Mesh &mesh, const std::array< int, n > &vertexIDs)
Given a mesh and an array of vertexIDS, this function returns an array of pointers to vertices.
std::size_t countVerticesInBoundingBox(mesh::PtrMesh mesh, const mesh::BoundingBox &bb)
Given a Mesh and a bounding box, counts all vertices within the bounding box.
double edgeLength(const Edge &e)
Chain< n > asChain(std::array< mesh::Edge *, n > edges)
std::array< Edge *, n > edges
undefined if not connected
bool connected
true if the chain is connected or closed and thus valid
std::array< Vertex *, n > vertices
undefined if not connected