-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
volume_mesh_topology.h
49 lines (40 loc) · 1.45 KB
/
volume_mesh_topology.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <array>
#include <vector>
#include "drake/geometry/proximity/sorted_triplet.h"
#include "drake/geometry/proximity/volume_mesh.h"
namespace drake {
namespace geometry {
namespace internal {
/* %VolumeMeshTopology represents the topology of a tetrahedral volume mesh.
*/
class VolumeMeshTopology {
public:
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(VolumeMeshTopology);
template <typename T>
explicit VolumeMeshTopology(const VolumeMesh<T>& mesh);
~VolumeMeshTopology();
/*
Returns the index of `i`-th neighbor of tet `e` (i.e. the tet across from
vertex `i`). If tet `e` does not have a neighbor across from `i` (i.e. face
`i` is a boundary face), returns -1.
@param e The index of the element.
@param i The index of the neighbor
@pre `e ∈ [0, mesh().num_elements())`.
@pre `i ∈ [0, 3]`.
*/
int neighbor(int e, int i) const {
DRAKE_DEMAND(0 <= e && e < ssize(tetrahedra_neighbors_));
DRAKE_DEMAND(0 <= i && i < 4);
return tetrahedra_neighbors_[e][i];
}
private:
// Stores the index of the neighboring tetrahedra of the element at index i.
// The index stored at index j is the neighbor across for vertex j, or in
// other terms the tet that shares face {0, 1, 2, 3} / {i}. -1 is used to
// represent the absence of a neighbor on a face (i.e. a boundary face).
std::vector<std::array<int, 4>> tetrahedra_neighbors_;
};
} // namespace internal
} // namespace geometry
} // namespace drake