Utility for querying point containment against a closed triangulated surface mesh. More...
#include <TriangleManifold.h>
Public Member Functions | |
| TriangleManifold (MeshBase &mesh, const Real surface_tolerance) | |
| Build a manifold classifier from a prepared surface mesh. | |
| bool | contains (const Point &point) const |
| SurfaceGeometry::SurfaceSide | sideness (const Point &point) const |
| Classify a query point relative to the manifold surface. | |
| const libMesh::BoundingBox & | boundingBox () const |
| std::size_t | numTriangles () const |
Private Types | |
| enum class | RayIntersection { Miss , Hit , Ambiguous } |
| Result of intersecting the positive x-direction ray with a triangle. More... | |
Private Member Functions | |
| void | finalize () |
| Complete post-parse validation and acceleration-structure setup. | |
| void | buildCandidateGrid () |
| Build the yz-plane lookup grid used to accelerate +x ray queries. | |
| bool | pointInsideBoundingBox (const Point &point) const |
| Cheap global bounding-box rejection for containment queries. | |
| bool | pointOnSurface (const Point &point) const |
| Detect whether a query point lies on or extremely near the manifold surface. | |
| RayIntersection | rayIntersectsTriangle (const Point &point, const libMesh::Elem &tri) const |
| Intersect a positive x-direction ray with a single triangle. | |
| bool | containsBySolidAngle (const Point &point) const |
| Robust fallback containment query based on accumulated solid angle. | |
| SurfaceGeometry::SurfaceSide | classifyByParity (const Point &point) const |
| Resolve INSIDE vs OUTSIDE via the fixed +x ray parity test (with solid-angle fallback for ambiguous grazing hits). | |
| std::vector< dof_id_type > | rayCandidates (const Point &point) const |
| Get the subset of triangles whose yz extents may intersect the query ray. | |
Private Attributes | |
| std::size_t | _num_y_cells = 1 |
| Number of yz-grid bins in the y direction. | |
| std::size_t | _num_z_cells = 1 |
| Number of yz-grid bins in the z direction. | |
| Real | _y_min = 0.0 |
| Minimum global y coordinate used to map query points into yz-grid bins. | |
| Real | _z_min = 0.0 |
| Minimum global z coordinate used to map query points into yz-grid bins. | |
| Real | _y_cell_size = 1.0 |
| Width of one yz-grid cell in the y direction. | |
| Real | _z_cell_size = 1.0 |
| Width of one yz-grid cell in the z direction. | |
| std::unordered_map< std::uint64_t, std::vector< dof_id_type > > | _ray_grid |
| Lookup from packed yz-grid cell index to triangles that could intersect the +x query ray. | |
| MeshBase & | _mesh |
| const Real | _surface_tolerance |
| Absolute tolerance used throughout validation and geometric classification. | |
| const libMesh::BoundingBox | _bounding_box |
| Global bounding box of the transformed manifold. | |
| const std::unique_ptr< libMesh::PointLocatorBase > | _point_locator |
| Pre-built point locator for fast proximity-to-surface detection. | |
Utility for querying point containment against a closed triangulated surface mesh.
The class takes ownership of a reference to a prepared 2D surface mesh, validates that it forms a closed 2-manifold (every triangle has exactly three neighbors, all elements are Tri3, and the mesh is consistently oriented), builds a lightweight yz-plane acceleration grid, and exposes contains() for point-in-solid queries.
Containment is resolved in three stages:
surface_tolerance of the mesh surface are treated as inside).The referenced mesh must outlive this object. Any geometric transforms (scale, rotation, translation) should be applied to the mesh before constructing a TriangleManifold.
Definition at line 45 of file TriangleManifold.h.
|
strongprivate |
Result of intersecting the positive x-direction ray with a triangle.
Ambiguous is returned when the hit is too close to an edge, vertex, or the ray origin. In that case we abandon parity counting and fall back to the more expensive but robust solid-angle test.
| Enumerator | |
|---|---|
| Miss | |
| Hit | |
| Ambiguous | |
Definition at line 93 of file TriangleManifold.h.
| TriangleManifold::TriangleManifold | ( | MeshBase & | mesh, |
| const Real | surface_tolerance | ||
| ) |
Build a manifold classifier from a prepared surface mesh.
| mesh | Serialized 2D surface mesh that defines the closed manifold. Must outlive this object. Any desired transforms should already be applied to the mesh. |
| surface_tolerance | Absolute tolerance used for manifold validation and near-surface classification. Choose this relative to the mesh length scale and expected coordinate noise from the export pipeline. |
Definition at line 57 of file TriangleManifold.C.
|
inline |
Definition at line 78 of file TriangleManifold.h.
Referenced by buildCandidateGrid(), pointInsideBoundingBox(), and rayCandidates().
|
private |
Build the yz-plane lookup grid used to accelerate +x ray queries.
Definition at line 146 of file TriangleManifold.C.
Referenced by finalize().
|
private |
Resolve INSIDE vs OUTSIDE via the fixed +x ray parity test (with solid-angle fallback for ambiguous grazing hits).
Assumes the point is neither outside the bounding box nor on the surface; those cases are handled by sideness().
Definition at line 95 of file TriangleManifold.C.
Referenced by sideness().
| bool TriangleManifold::contains | ( | const Point & | point | ) | const |
Definition at line 74 of file TriangleManifold.C.
Referenced by ManifoldSubdomainGenerator::generate().
|
private |
Robust fallback containment query based on accumulated solid angle.
Definition at line 259 of file TriangleManifold.C.
Referenced by classifyByParity().
|
private |
Complete post-parse validation and acceleration-structure setup.
Definition at line 128 of file TriangleManifold.C.
Referenced by TriangleManifold().
|
inline |
Definition at line 83 of file TriangleManifold.h.
Referenced by buildCandidateGrid().
|
private |
Cheap global bounding-box rejection for containment queries.
Definition at line 192 of file TriangleManifold.C.
Referenced by sideness().
|
private |
Detect whether a query point lies on or extremely near the manifold surface.
Definition at line 204 of file TriangleManifold.C.
Referenced by sideness().
|
private |
Get the subset of triangles whose yz extents may intersect the query ray.
Definition at line 272 of file TriangleManifold.C.
Referenced by classifyByParity().
|
private |
Intersect a positive x-direction ray with a single triangle.
Definition at line 210 of file TriangleManifold.C.
Referenced by classifyByParity().
| SurfaceGeometry::SurfaceSide TriangleManifold::sideness | ( | const Point & | point | ) | const |
Classify a query point relative to the manifold surface.
On-surface points (within surface_tolerance of the surface) are reported as SurfaceGeometry::SurfaceSide::ON; this is checked before parity counting. Otherwise the fixed +x ray parity test (with solid-angle fallback) resolves INSIDE vs OUTSIDE.
Definition at line 81 of file TriangleManifold.C.
Referenced by contains().
|
private |
Global bounding box of the transformed manifold.
Definition at line 153 of file TriangleManifold.h.
Referenced by boundingBox().
|
private |
Definition at line 147 of file TriangleManifold.h.
Referenced by buildCandidateGrid(), classifyByParity(), containsBySolidAngle(), finalize(), and numTriangles().
|
private |
Number of yz-grid bins in the y direction.
Definition at line 127 of file TriangleManifold.h.
Referenced by buildCandidateGrid(), and rayCandidates().
|
private |
Number of yz-grid bins in the z direction.
Definition at line 130 of file TriangleManifold.h.
Referenced by buildCandidateGrid(), and rayCandidates().
|
private |
Pre-built point locator for fast proximity-to-surface detection.
Definition at line 156 of file TriangleManifold.h.
Referenced by pointOnSurface(), and TriangleManifold().
|
private |
Lookup from packed yz-grid cell index to triangles that could intersect the +x query ray.
Definition at line 145 of file TriangleManifold.h.
Referenced by buildCandidateGrid(), and rayCandidates().
|
private |
Absolute tolerance used throughout validation and geometric classification.
Definition at line 150 of file TriangleManifold.h.
Referenced by buildCandidateGrid(), classifyByParity(), pointInsideBoundingBox(), rayCandidates(), rayIntersectsTriangle(), and TriangleManifold().
|
private |
Width of one yz-grid cell in the y direction.
Definition at line 139 of file TriangleManifold.h.
Referenced by buildCandidateGrid(), and rayCandidates().
|
private |
Minimum global y coordinate used to map query points into yz-grid bins.
Definition at line 133 of file TriangleManifold.h.
Referenced by buildCandidateGrid(), and rayCandidates().
|
private |
Width of one yz-grid cell in the z direction.
Definition at line 142 of file TriangleManifold.h.
Referenced by buildCandidateGrid(), and rayCandidates().
|
private |
Minimum global z coordinate used to map query points into yz-grid bins.
Definition at line 136 of file TriangleManifold.h.
Referenced by buildCandidateGrid(), and rayCandidates().