13#include "libmesh/point.h"
40 const std::vector<Point> & centroids,
43 const int leaf_max_size = 10,
44 const FileName & obb_file_name =
"",
45 const FileName & ray_file_name =
"",
133 const Point & ray_end,
163 std::optional<SurfaceGeometry::SurfaceSide>
175 const Point & ray_end,
176 const bool use_primary_direction =
true)
const;
183 template <
typename CrossingTest>
185 const Point & ray_end,
186 const bool use_primary_direction,
187 CrossingTest is_crossing)
const;
194 const Point & ray_end,
195 const bool use_primary_direction)
const;
203 rayStartOutsideAABB(
const Point & point,
const Point & unit_direction,
const bool inverted)
const;
211 const Point & ray_direction,
212 const unsigned int obb_axis,
213 const bool inverted =
false)
const;
218 const Point & plane_point,
219 const Point & plane_normal)
const;
Ray-casting point-in-solid engine over a closed surface mesh represented as a collection of SurfaceEl...
std::vector< Point > _projected_centroids
Projected centroids of the elements in the boundary mesh.
int countFilteredCrossings(const Point &ray_start, const Point &ray_end, const bool use_primary_direction, CrossingTest is_crossing) const
Shared traversal for the 2D and 3D crossing counts: walk the candidate elements (KD-tree candidates f...
std::unique_ptr< KDTree > _kd_tree
The KDTree is constructed using the projected centroids of the elements in the boundary mesh.
Point _max_variance_vector
max variance vector
int countCrossings2D(const Point &ray_start, const Point &ray_end, const bool use_primary_direction) const
2D crossing count using a half-open side-based crossing rule: an edge is counted when its two endpoin...
Point rayStartOutsideAABB(const Point &point, const Point &unit_direction, const bool inverted) const
Ray start strictly outside the global AABB along unit_direction, for any direction.
Point projectPointOntoPlane(const Point &point_to_project, const Point &plane_point, const Point &plane_normal) const
Orthogonally project point_to_project onto the plane defined by plane_point and unit normal plane_nor...
Point _ray_direction
Ray shooting direction.
bool isOutsideRayBBox(const Point &orig, const Point &dir, const Ball &ball) const
Check if element center is outside ray bounding box.
bool rayIntersectGeometry(const Point &ray_start, const Point &ray_end, const SurfaceElement *elem) const
Ray-element intersection (e.g., ray-line for 2D, ray-triangle for 3D)
FileName _obb_file_name
The file name for the OBB.
Point _second_variance_vector
second max variance vector
Point _plane_origin
The origin of the plane used to ensure that every projected point is correctly aligned and lies on th...
Point _centroid_nodal_points
The centroid of the boundary elements' node points (prepare inside this class).
bool isOutsideBoundingRegion(const Point &orig, const Point &dir, const Ball &ball) const
Check if element center is outside ray bounding circle/sphere.
int countCrossings(const Point &ray_start, const Point &ray_end, const bool use_primary_direction=true) const
Count how many times the segment from ray_start to ray_end crosses the surface.
SurfaceGeometry::SurfaceSide sideness(const Point &p) const
Main function: Determine if a point is inside the geometry.
Real _max_projected_diag_length
The maximum diagonal length of the projected bounding box from the boundary elements.
const Point & rayDirection() const
The resolved ray direction actually used for shooting: the (normalized) user direction for a user-sel...
std::vector< unsigned int > collectCandidateElementIDs(const Point &query_point) const
Use the kd-tree to collect candidate element IDs to check intersections.
bool isOnSurface(const Point &p) const
True if p lies on the surface (within _eps_on_surface), i.e.
Point _min_variance_vector
min variance vector (only used for 3D)
BoundingBox computeGlobalBoundingBox()
Compute the global bounding box of all boundary elements.
Real _eps_on_surface
Epsilon value for checking if a point is on the surface of the geometry.
int _dim
The dimension of the embedding mesh.
const std::vector< std::unique_ptr< SurfaceElement > > & _bd_elements
pass into the constructor for the surface elements
OrientedBoundingBox _obb_bounds
The oriented bounding box (OBB).
FileName _ray_file_name
The file name for the ray.
Point rayStartOutsideOBB(const Point &point, const Point &ray_direction, const unsigned int obb_axis, const bool inverted=false) const
Computes the starting point of an OBB-based ray (auto/PCA policy) for a given query point.
int _leaf_max_size
Configures KDTree leaf node size for performance tuning.
const std::vector< Point > & _centroids
pass into the constructor for the surface element centroids
bool _build_obb
When the ray direction is auto-selected (PCA) we build an Oriented Bounding Box (OBB); a user-selecte...
std::size_t _num_elements
The number of elements in the boundary mesh.
bool isOutsideBoundingBox(const Point &query_point) const
Check if point is outside global bounding box.
std::optional< SurfaceGeometry::SurfaceSide > sidenessFromRayPair(const Point &p, const std::array< Point, 2 > &ray_starts) const
Determine sideness from a pair of opposite rays.
void buildObbKdtreeAndMaxProjectedDiagonal(const Real expand_box_length)
Constructs an oriented bounding box (OBB) using the results of PCA and the KD-tree.
void initializeRayDirection()
Finalizes the ray direction and the matching bounding box.
const libMesh::Parallel::Communicator * _comm
Communicator used only for writing the debug OBB/ray mesh files.
BoundingBox _bounds
The bounding box AABB.
bool _auto_ray_direction
Whether the ray direction is auto-selected via PCA (true) or user-selected (false).
Ball primitive: a circle in 2D or a sphere in 3D.
Oriented bounding box in 2 D or 3 D.
Base class for a single surface (boundary) element of a closed surface mesh.
SurfaceSide
The side of a closed surface where a query point is located.
static constexpr Real TOLERANCE
Ray-direction intent for AdaptiveRayContainmentCheck: an explicit mode plus the direction to use when...