Tool for querying different aspects of geometric topology sets in MOAB. More...
#include <GeomQueryTool.hpp>
Classes | |
class | RayHistory |
Public Member Functions | |
GeomQueryTool (Interface *impl, bool find_geoments=false, EntityHandle modelRootSet=0, bool p_rootSets_vector=true, bool restore_rootSets=true, bool trace_counting=false, double overlap_thickness=0., double numerical_precision=0.001) | |
GeomQueryTool (GeomTopoTool *geomtopotool, bool trace_counting=false, double overlap_thickness=0., double numerical_precision=0.001) | |
~GeomQueryTool () | |
ErrorCode | initialize () |
ErrorCode | ray_fire (const EntityHandle volume, const double ray_start[3], const double ray_dir[3], EntityHandle &next_surf, double &next_surf_dist, RayHistory *history=NULL, double dist_limit=0, int ray_orientation=1, OrientedBoxTreeTool::TrvStats *stats=NULL) |
find the next surface crossing from a given point in a given direction More... | |
ErrorCode | point_in_volume (const EntityHandle volume, const double xyz[3], int &result, const double *uvw=NULL, const RayHistory *history=NULL) |
Test if a point is inside or outside a volume. More... | |
ErrorCode | point_in_volume_slow (const EntityHandle volume, const double xyz[3], int &result) |
Robust test if a point is inside or outside a volume using unit sphere area method. More... | |
ErrorCode | find_volume (const double xyz[3], EntityHandle &volume, const double *dir=NULL) |
Find volume for a given location. More... | |
ErrorCode | find_volume_slow (const double xyz[3], EntityHandle &volume, const double *dir=NULL) |
Find volume for a given location using loop. (slow) More... | |
ErrorCode | point_in_box (const EntityHandle volume, const double point[3], int &inside) |
Test if a point is inside or outsize a volume's axis-aligned bounding box. More... | |
ErrorCode | test_volume_boundary (const EntityHandle volume, const EntityHandle surface, const double xyz[3], const double uvw[3], int &result, const RayHistory *history=NULL) |
Given a ray starting at a surface of a volume, check whether the ray enters or exits the volume. More... | |
ErrorCode | closest_to_location (EntityHandle volume, const double point[3], double &result, EntityHandle *closest_surface=0) |
Find the distance to the point on the boundary of the volume closest to the test point. More... | |
ErrorCode | measure_volume (EntityHandle volume, double &result) |
ErrorCode | measure_area (EntityHandle surface, double &result) |
ErrorCode | get_normal (EntityHandle surf, const double xyz[3], double angle[3], const RayHistory *history=NULL) |
void | set_overlap_thickness (double new_overlap_thickness) |
State object used in calls to ray_fire() More... | |
void | set_numerical_precision (double new_precision) |
void | set_verbosity (bool value) |
bool | get_verbosity () const |
double | get_numerical_precision () |
double | get_overlap_thickness () |
GeomTopoTool * | gttool () |
Interface * | moab_instance () |
Private Member Functions | |
ErrorCode | boundary_case (EntityHandle volume, int &result, double u, double v, double w, EntityHandle facet, EntityHandle surface) |
determine the point membership when the point is effectively on the boundary More... | |
ErrorCode | poly_solid_angle (EntityHandle face, const CartVect &point, double &area) |
Private Attributes | |
GeomTopoTool * | geomTopoTool |
bool | verbose |
bool | owns_gtt |
Interface * | MBI |
OrientedBoxTreeTool * | obbTreeTool |
bool | counting |
long long int | n_pt_in_vol_calls |
long long int | n_ray_fire_calls |
double | overlapThickness |
double | numericalPrecision |
Tag | senseTag |
Tool for querying different aspects of geometric topology sets in MOAB.
Given the conventions established in GeomTopoTool for representing geometric topology through a hierarchy of meshsets, this tool provides a set of methods to query different geometric aspects of those geometric topology sets including:
A feature of these queries is that there is some support for overlapping geometries.
Definition at line 45 of file GeomQueryTool.hpp.
moab::GeomQueryTool::GeomQueryTool | ( | Interface * | impl, |
bool | find_geoments = false , |
||
EntityHandle | modelRootSet = 0 , |
||
bool | p_rootSets_vector = true , |
||
bool | restore_rootSets = true , |
||
bool | trace_counting = false , |
||
double | overlap_thickness = 0. , |
||
double | numerical_precision = 0.001 |
||
) |
Definition at line 624 of file GeomQueryTool.cpp.
References counting, geomTopoTool, moab::GeomTopoTool::get_moab_instance(), moab::GeomTopoTool::get_sense_tag(), MBI, n_pt_in_vol_calls, n_ray_fire_calls, numericalPrecision, moab::GeomTopoTool::obb_tree(), obbTreeTool, overlapThickness, and senseTag.
moab::GeomQueryTool::GeomQueryTool | ( | GeomTopoTool * | geomtopotool, |
bool | trace_counting = false , |
||
double | overlap_thickness = 0. , |
||
double | numerical_precision = 0.001 |
||
) |
Definition at line 650 of file GeomQueryTool.cpp.
References counting, geomTopoTool, moab::GeomTopoTool::get_moab_instance(), moab::GeomTopoTool::get_sense_tag(), MBI, n_pt_in_vol_calls, n_ray_fire_calls, numericalPrecision, moab::GeomTopoTool::obb_tree(), obbTreeTool, overlapThickness, and senseTag.
moab::GeomQueryTool::~GeomQueryTool | ( | ) |
Definition at line 673 of file GeomQueryTool.cpp.
References geomTopoTool, and owns_gtt.
|
private |
determine the point membership when the point is effectively on the boundary
Called by point_in_volume when the point is with tolerance of the boundary. Compares the ray direction with the surface normal to determine a volume membership.
Definition at line 1488 of file GeomQueryTool.cpp.
References ErrorCode, geomTopoTool, moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::GeomTopoTool::get_sense(), MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, and MBI.
Referenced by point_in_volume(), and test_volume_boundary().
ErrorCode moab::GeomQueryTool::closest_to_location | ( | EntityHandle | volume, |
const double | point[3], | ||
double & | result, | ||
EntityHandle * | closest_surface = 0 |
||
) |
Find the distance to the point on the boundary of the volume closest to the test point.
volume | Volume to query |
point | Coordinates of test point |
result | Set to the minimum distance from point to a surface in volume |
Definition at line 1313 of file GeomQueryTool.cpp.
References moab::CartVect::array(), moab::OrientedBoxTreeTool::closest_to_location(), ErrorCode, geomTopoTool, moab::GeomTopoTool::get_root(), length(), MB_CHK_SET_ERR, MB_SUCCESS, and moab::GeomTopoTool::obb_tree().
ErrorCode moab::GeomQueryTool::find_volume | ( | const double | xyz[3], |
EntityHandle & | volume, | ||
const double * | dir = NULL |
||
) |
Find volume for a given location.
Determines which volume contains the point if possible. If no volume is found, a null EntityHandle is returned along with a MB_ENTITY_NOT_FOUND ErrorCode.
xyz | The location to test |
volume | Set to volume handle containing the location if found |
dir | Optional direction to use for underlying ray fire query. Used to ensure consistent results when a ray direction is known. If NULL or {0,0,0} is given, a random direction will be used. |
Definition at line 1178 of file GeomQueryTool.cpp.
References moab::CartVect::array(), ErrorCode, find_volume_slow(), geomTopoTool, moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::GeomTopoTool::get_implicit_complement(), moab::GeomTopoTool::get_one_vol_root(), moab::GeomTopoTool::get_surface_senses(), MB_CHK_SET_ERR, MB_ENTITY_NOT_FOUND, MB_SUCCESS, MBI, moab::CartVect::normalize(), numericalPrecision, moab::GeomTopoTool::obb_tree(), point_in_box(), and moab::OrientedBoxTreeTool::ray_intersect_sets().
ErrorCode moab::GeomQueryTool::find_volume_slow | ( | const double | xyz[3], |
EntityHandle & | volume, | ||
const double * | dir = NULL |
||
) |
Find volume for a given location using loop. (slow)
Loops over all volumes in the model, checking for point containment
xyz | The location to test |
volume | Set to volume handle containing the location if found |
dir | Optional direction to use for underlying ray fire query. Used to ensure consistent results when a ray direction is known. If NULL or {0,0,0} is given, a random direction will be used. |
Definition at line 1290 of file GeomQueryTool.cpp.
References moab::Range::begin(), moab::Range::end(), ErrorCode, geomTopoTool, moab::GeomTopoTool::get_gsets_by_dimension(), MB_CHK_SET_ERR, MB_ENTITY_NOT_FOUND, MB_SUCCESS, and point_in_volume().
Referenced by find_volume().
ErrorCode moab::GeomQueryTool::get_normal | ( | EntityHandle | surf, |
const double | xyz[3], | ||
double | angle[3], | ||
const RayHistory * | history = NULL |
||
) |
Get the normal to a given surface at the point on the surface closest to a given point
This method first identifies which facet contains this point and then calculates the unit outward normal of that facet. The facet of the provided volume that is nearest the provided point is used for this calculation. The search for that facet can be circumvented by providing a RayHistory, in which case the last facet of the history will be used.
surf | Surface on which to get normal |
xyz | Point on surf |
angle | Set to coordinates of surface normal nearest xyz |
history | Optional ray history from a previous call to ray_fire(). If present and non-empty, return the normal of the most recently intersected facet, ignoring xyz. |
Definition at line 1436 of file GeomQueryTool.cpp.
References moab::angle(), moab::OrientedBoxTreeTool::closest_to_location(), ErrorCode, geomTopoTool, moab::CartVect::get(), moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::GeomTopoTool::get_root(), MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, MBI, moab::CartVect::normalize(), numericalPrecision, moab::GeomTopoTool::obb_tree(), and moab::GeomQueryTool::RayHistory::prev_facets.
|
inline |
Definition at line 376 of file GeomQueryTool.hpp.
References numericalPrecision.
|
inline |
Definition at line 381 of file GeomQueryTool.hpp.
References overlapThickness.
|
inline |
Definition at line 371 of file GeomQueryTool.hpp.
References verbose.
|
inline |
Definition at line 386 of file GeomQueryTool.hpp.
References geomTopoTool.
ErrorCode moab::GeomQueryTool::initialize | ( | ) |
Definition at line 681 of file GeomQueryTool.cpp.
References moab::GeomTopoTool::construct_obb_trees(), ErrorCode, moab::GeomTopoTool::find_geomsets(), geomTopoTool, MB_CHK_SET_ERR, MB_SUCCESS, and moab::GeomTopoTool::setup_implicit_complement().
ErrorCode moab::GeomQueryTool::measure_area | ( | EntityHandle | surface, |
double & | result | ||
) |
Calculate sum of area of triangles
Definition at line 1399 of file GeomQueryTool.cpp.
References moab::Range::all_of_type(), moab::Range::begin(), moab::Range::clear(), moab::Range::end(), ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::Interface::get_entities_by_dimension(), moab::Interface::get_entities_by_type(), moab::CartVect::length(), MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, MBI, and MBTRI.
ErrorCode moab::GeomQueryTool::measure_volume | ( | EntityHandle | volume, |
double & | result | ||
) |
Calculate the volume contained in a 'volume'
Definition at line 1336 of file GeomQueryTool.cpp.
References moab::Range::all_of_type(), moab::Range::begin(), moab::Range::clear(), moab::Range::end(), ErrorCode, geomTopoTool, moab::Interface::get_child_meshsets(), moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::Interface::get_entities_by_dimension(), moab::Interface::get_entities_by_type(), moab::GeomTopoTool::get_surface_senses(), moab::GeomTopoTool::is_implicit_complement(), MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, MBI, and MBTRI.
|
inline |
ErrorCode moab::GeomQueryTool::point_in_box | ( | const EntityHandle | volume, |
const double | point[3], | ||
int & | inside | ||
) |
Test if a point is inside or outsize a volume's axis-aligned bounding box.
For the volume pointed to and the point wished to be tested, returns whether the point is inside or outside the bounding box of the volume. inside = 0, not inside, inside = 1, inside.
This is used as a fast way to determine whether a point is inside or outside of a volume before performing a point_in_volume test which involves firing a ray.
volume | The volume to test |
point | The location to test for bounding box containment |
inside | set to 0 if point is outside the box, 1 if inside |
Definition at line 1077 of file GeomQueryTool.cpp.
References ErrorCode, geomTopoTool, moab::GeomTopoTool::get_bounding_coords(), and MB_CHK_SET_ERR.
Referenced by find_volume(), and point_in_volume().
ErrorCode moab::GeomQueryTool::point_in_volume | ( | const EntityHandle | volume, |
const double | xyz[3], | ||
int & | result, | ||
const double * | uvw = NULL , |
||
const RayHistory * | history = NULL |
||
) |
Test if a point is inside or outside a volume.
This method finds the point on the boundary of the volume that is nearest the test point (x,y,z). If that point is "close" to a surface, a boundary test is performed based on the normal of the surface at that point and the optional ray direction (u,v,w).
volume | The volume to test |
xyz | The location to test for volume containment |
result | Set to 0 if xyz it outside volume, 1 if inside, and -1 if on boundary. |
Optional | direction to use for underlying ray fire query. Used to ensure consistent results when a ray direction is known. If NULL or {0,0,0} is given, a random direction will be used. |
history | Optional RayHistory object to pass to underlying ray fire query. The history is not modified by this call. |
Definition at line 915 of file GeomQueryTool.cpp.
References boundary_case(), counting, ErrorCode, geomTopoTool, moab::GeomTopoTool::get_root(), moab::GeomTopoTool::is_implicit_complement(), MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, n_pt_in_vol_calls, numericalPrecision, moab::GeomTopoTool::obb_tree(), overlapThickness, point_in_box(), moab::GeomQueryTool::RayHistory::prev_facets, moab::OrientedBoxTreeTool::ray_intersect_sets(), senseTag, and moab::sum().
Referenced by moab::GeomTopoTool::A_is_in_B(), find_volume_slow(), and ray_fire().
ErrorCode moab::GeomQueryTool::point_in_volume_slow | ( | const EntityHandle | volume, |
const double | xyz[3], | ||
int & | result | ||
) |
Robust test if a point is inside or outside a volume using unit sphere area method.
This test may be more robust that the standard point_in_volume, but is much slower. It does not detect 'on boundary' situations as point_in_volume does.
volume | The volume to test |
xyz | The location to test for volume containment |
result | Set to 0 if xyz it outside volume, 1 if inside. |
Definition at line 1141 of file GeomQueryTool.cpp.
References moab::Range::begin(), moab::Range::clear(), moab::Range::end(), ErrorCode, geomTopoTool, moab::Interface::get_child_meshsets(), moab::Interface::get_entities_by_dimension(), moab::GeomTopoTool::get_surface_senses(), MB_CHK_SET_ERR, MB_SUCCESS, MBI, poly_solid_angle(), and moab::sum().
|
private |
get the solid angle projected by a facet on a unit sphere around a point
Definition at line 1560 of file GeomQueryTool.cpp.
References moab::CartVect::array(), ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::CartVect::length(), MB_CHK_SET_ERR, MB_SUCCESS, and MBI.
Referenced by point_in_volume_slow().
ErrorCode moab::GeomQueryTool::ray_fire | ( | const EntityHandle | volume, |
const double | ray_start[3], | ||
const double | ray_dir[3], | ||
EntityHandle & | next_surf, | ||
double & | next_surf_dist, | ||
RayHistory * | history = NULL , |
||
double | dist_limit = 0 , |
||
int | ray_orientation = 1 , |
||
OrientedBoxTreeTool::TrvStats * | stats = NULL |
||
) |
find the next surface crossing from a given point in a given direction
This is the primary method to enable ray tracing through a geometry. Given a volume and a ray, it determines the distance to the nearest intersection with a bounding surface of that volume and returns that distance and the EntityHandle indicating on which surface that intersection occurs. The caller can compute the location of the intersection by adding the distance to the ray.
When a series of calls to this function are made along the same ray (e.g. for the purpose of tracking a ray through several volumes), the optional history argument should be given. The history prevents previously intersected facets from being intersected again. A single history should be used as long as a ray is proceeding forward without changing direction. This situation is sometimes referred to as "streaming."
If a ray changes direction at an intersection site, the caller should call reset_to_last_intersection() on the history object before the next ray fire.
volume | The volume at which to fire the ray |
ray_start | An array of x,y,z coordinates from which to start the ray. |
ray_dir | An array of x,y,z coordinates indicating the direction of the ray. Must be of unit length. |
next_surf | Output parameter indicating the next surface intersected by the ray. If no intersection is found, will be set to 0. |
next_surf_dist | Output parameter indicating distance to next_surf. If next_surf is 0, this value is undefined and should not be used. |
history | Optional RayHistory object. If provided, the facets in the history are assumed to not intersect with the given ray. The facet intersected by this query will also be added to the history. |
dist_limit | Optional distance limit. If provided and > 0, no intersections at a distance further than this value will be returned. |
ray_orientation | Optional ray orientation. If provided determines intersections along the normal provided, e.g. if -1 allows intersections back along the the ray direction, Default is 1, i.e. exit intersections |
stats | Optional TrvStats object used to measure performance of underlying OBB ray-firing query. See OrientedBoxTreeTool.hpp for details. |
Definition at line 738 of file GeomQueryTool.cpp.
References counting, ErrorCode, geomTopoTool, moab::Interface::get_parent_meshsets(), moab::GeomTopoTool::get_root(), MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, MBI, n_pt_in_vol_calls, n_ray_fire_calls, numericalPrecision, moab::GeomTopoTool::obb_tree(), overlapThickness, point_in_volume(), moab::GeomQueryTool::RayHistory::prev_facets, moab::OrientedBoxTreeTool::ray_intersect_sets(), and senseTag.
void moab::GeomQueryTool::set_numerical_precision | ( | double | new_precision | ) |
Attempt to set a new numerical precision , first checking for sanity Use of this function is discouraged.
Definition at line 1627 of file GeomQueryTool.cpp.
References numericalPrecision, and verbose.
void moab::GeomQueryTool::set_overlap_thickness | ( | double | new_overlap_thickness | ) |
State object used in calls to ray_fire()
Storage for the "history" of a ray. This represents the surface facets that the ray is known to have crossed, which cannot be crossed again as long as the ray does not change direction. It is intended to be used with a series of consecutive calls to ray_fire(), in which a ray passes over potentially many surfaces. Attempt to set a new overlap thickness tolerance, first checking for sanity
Definition at line 1613 of file GeomQueryTool.cpp.
References overlapThickness, and verbose.
|
inline |
Definition at line 366 of file GeomQueryTool.hpp.
References verbose.
ErrorCode moab::GeomQueryTool::test_volume_boundary | ( | const EntityHandle | volume, |
const EntityHandle | surface, | ||
const double | xyz[3], | ||
const double | uvw[3], | ||
int & | result, | ||
const RayHistory * | history = NULL |
||
) |
Given a ray starting at a surface of a volume, check whether the ray enters or exits the volume.
This function is most useful for rays that change directions at a surface crossing. It can be used to check whether a direction change redirects the ray back into the originating volume.
volume | The volume to test |
surface | A surface on volume |
xyz | A point location on surface |
uvw | A (unit) direction vector |
result | Set to 1 if ray is entering volume, or 0 if it is leaving |
history | Optional ray history object from a previous call to ray_fire. If present and non-empty, the history is used to look up the surface facet at which the ray begins. Absent a history, the facet nearest to xyz will be looked up. The history should always be provided if available, as it avoids the computational expense of a nearest-facet query. |
Definition at line 1103 of file GeomQueryTool.cpp.
References moab::CartVect::array(), boundary_case(), moab::OrientedBoxTreeTool::closest_to_location(), ErrorCode, geomTopoTool, moab::GeomTopoTool::get_root(), MB_CHK_SET_ERR, MB_SUCCESS, moab::GeomTopoTool::obb_tree(), and moab::GeomQueryTool::RayHistory::prev_facets.
|
private |
Definition at line 402 of file GeomQueryTool.hpp.
Referenced by GeomQueryTool(), point_in_volume(), and ray_fire().
|
private |
Definition at line 397 of file GeomQueryTool.hpp.
Referenced by boundary_case(), closest_to_location(), find_volume(), find_volume_slow(), GeomQueryTool(), get_normal(), gttool(), initialize(), measure_volume(), point_in_box(), point_in_volume(), point_in_volume_slow(), ray_fire(), test_volume_boundary(), and ~GeomQueryTool().
|
private |
Definition at line 400 of file GeomQueryTool.hpp.
Referenced by boundary_case(), find_volume(), GeomQueryTool(), get_normal(), measure_area(), measure_volume(), moab_instance(), point_in_volume_slow(), poly_solid_angle(), and ray_fire().
|
private |
Definition at line 403 of file GeomQueryTool.hpp.
Referenced by GeomQueryTool(), point_in_volume(), and ray_fire().
|
private |
Definition at line 404 of file GeomQueryTool.hpp.
Referenced by GeomQueryTool(), and ray_fire().
|
private |
Definition at line 405 of file GeomQueryTool.hpp.
Referenced by find_volume(), GeomQueryTool(), get_normal(), get_numerical_precision(), point_in_volume(), ray_fire(), and set_numerical_precision().
|
private |
Definition at line 401 of file GeomQueryTool.hpp.
Referenced by GeomQueryTool().
|
private |
Definition at line 405 of file GeomQueryTool.hpp.
Referenced by GeomQueryTool(), get_overlap_thickness(), point_in_volume(), ray_fire(), and set_overlap_thickness().
|
private |
Definition at line 399 of file GeomQueryTool.hpp.
Referenced by ~GeomQueryTool().
|
private |
Definition at line 406 of file GeomQueryTool.hpp.
Referenced by GeomQueryTool(), point_in_volume(), and ray_fire().
|
private |
Definition at line 398 of file GeomQueryTool.hpp.
Referenced by get_verbosity(), set_numerical_precision(), set_overlap_thickness(), and set_verbosity().