XDG Interface

namespace xdg
class XDG

Public Functions

XDG() = default
inline XDG(
std::shared_ptr<MeshManager> mesh_manager,
RTLibrary ray_tracing_lib = RTLibrary::EMBREE,
)
void prepare_raytracer()
void prepare_volume_for_raytracing(MeshID volume)
MeshID find_volume(const Position &point, const Direction &direction) const
MeshID find_element(const Position &point) const
MeshID find_element(MeshID volume, const Position &point) const
bool point_in_volume(
MeshID volume,
const Position point,
const Direction *direction = nullptr,
const std::vector<MeshID> *exclude_primitives = nullptr,
) const
std::pair<double, MeshID> ray_fire(
MeshID volume,
const Position &origin,
const Direction &direction,
const double dist_limit = INFTY,
HitOrientation orientation = HitOrientation::EXITING,
std::vector<MeshID> *const exclude_primitives = nullptr,
) const
void closest(
MeshID volume,
const Position &origin,
double &dist,
MeshID &triangle,
) const
void closest(MeshID volume, const Position &origin, double &dist) const
bool occluded(
MeshID volume,
const Position &origin,
const Direction &direction,
double &dist,
) const
Direction surface_normal(
MeshID surface,
Position point,
const std::vector<MeshID> *exclude_primitives = nullptr,
) const
double measure_volume(MeshID volume) const
double measure_surface_area(MeshID surface) const
double measure_volume_area(MeshID surface) const
inline void set_mesh_manager_interface(
std::shared_ptr<MeshManager> mesh_manager,
)
inline void set_ray_tracing_interface(
std::shared_ptr<RayTracer> ray_tracing_interface,
)
inline const std::shared_ptr<RayTracer> &ray_tracing_interface() const
inline const std::shared_ptr<MeshManager> &mesh_manager() const

Public Static Functions

static std::shared_ptr<XDG> create(
MeshLibrary mesh_lib = MeshLibrary::MOAB,
RTLibrary ray_tracing_lib = RTLibrary::EMBREE,
)

Private Functions

double _triangle_volume_contribution(const PrimitiveRef &triangle) const
double _triangle_area_contribution(const PrimitiveRef &triangle) const

Private Members

std::shared_ptr<RayTracer> ray_tracing_interface_ = {nullptr}
std::shared_ptr<MeshManager> mesh_manager_ = {nullptr}
std::unordered_map<MeshID, TreeID> volume_to_surface_tree_map_
std::unordered_map<MeshID, TreeID> surface_to_tree_map_
std::unordered_map<MeshID, TreeID> volume_to_point_location_tree_map_
std::unordered_map<MeshID, RTCGeometry> surface_to_geometry_map_
TreeID global_scene_
namespace xdg
class MeshManager

Subclassed by xdg::LibMeshManager, xdg::MOABMeshManager

Public Functions

virtual ~MeshManager() = default
virtual void load_file(const std::string &filepath) = 0
virtual void init() = 0
virtual int num_volumes() const = 0
virtual int num_surfaces() const = 0
virtual int num_ents_of_dimension(int dim) const = 0
virtual int num_volume_elements(MeshID volume) const = 0
virtual int num_volume_faces(MeshID volume) const = 0
virtual int num_surface_faces(MeshID surface) const = 0
virtual std::vector<MeshID> get_volume_elements(MeshID volume) const = 0
std::vector<MeshID> get_volume_faces(MeshID volume) const
virtual std::vector<MeshID> get_surface_faces(MeshID surface) const = 0
virtual std::vector<Vertex> element_vertices(MeshID element) const = 0
virtual std::array<Vertex, 3> face_vertices(MeshID element) const = 0
virtual std::vector<Vertex> get_surface_vertices(MeshID surface) const = 0
virtual std::pair<std::vector<Vertex>, std::vector<int>> get_surface_mesh(
MeshID surface,
) const = 0
virtual SurfaceElementType get_surface_element_type(MeshID element) const = 0
BoundingBox element_bounding_box(MeshID element) const
BoundingBox face_bounding_box(MeshID element) const
BoundingBox surface_bounding_box(MeshID surface) const
BoundingBox volume_bounding_box(MeshID volume) const
BoundingBox global_bounding_box() const
Direction face_normal(MeshID element) const
std::pair<MeshID, MeshID> get_parent_volumes(MeshID surface) const
virtual std::vector<MeshID> get_volume_surfaces(MeshID volume) const = 0
virtual std::pair<MeshID, MeshID> surface_senses(MeshID surface) const = 0
virtual Sense surface_sense(MeshID surface, MeshID volume) const = 0
virtual MeshID create_volume() = 0
virtual void add_surface_to_volume(
MeshID volume,
MeshID surface,
Sense sense,
bool overwrite = false,
) = 0
MeshID next_volume(MeshID current_volume, MeshID surface) const
MeshID next_volume_id() const
MeshID next_surface_id() const
MeshID create_implicit_complement()
virtual void parse_metadata() = 0
bool volume_has_property(MeshID volume, PropertyType type) const
bool surface_has_property(MeshID surface, PropertyType type) const
Property get_volume_property(MeshID volume, PropertyType type) const
Property get_surface_property(MeshID surface, PropertyType type) const
inline const std::vector<MeshID> &volumes() const
inline std::vector<MeshID> &volumes()
inline const std::vector<MeshID> &surfaces() const
inline std::vector<MeshID> &surfaces()
inline MeshID implicit_complement() const
virtual MeshLibrary mesh_library() const = 0

Protected Attributes

std::map<std::pair<MeshID, PropertyType>, Property> volume_metadata_
std::map<std::pair<MeshID, PropertyType>, Property> surface_metadata_
std::vector<MeshID> volumes_
std::vector<MeshID> surfaces_
MeshID implicit_complement_ = {ID_NONE}
namespace xdg
class RayTracer

Subclassed by xdg::EmbreeRayTracer

Public Functions

virtual ~RayTracer()
virtual void init() = 0
virtual std::pair<TreeID, TreeID> register_volume(
const std::shared_ptr<MeshManager> &mesh_manager,
MeshID volume,
) = 0

Registers a volume with the ray tracer.

This method associates a volume, represented by a MeshID, with the ray tracer using the provided MeshManager. It returns a pair of TreeIDs that can be used for further operations involving the registered volume.

Parameters:
  • mesh_manager -- A shared pointer to the MeshManager responsible for managing the volume's mesh data.

  • volume -- The MeshID representing the volume to be registered.

Returns:

A pair of TreeIDs, where the first TreeID corresponds to the surface ray tracing tree and the second TreeID corresponds to the volume element point location tree (if applicable).

virtual TreeID create_surface_tree(
const std::shared_ptr<MeshManager> &mesh_manager,
MeshID volume,
) = 0

Creates a surface tree for a given volume.

This method creates a ray tracing tree specifically for the surfaces of a given volume. The tree can be used for ray-surface intersection queries.

Parameters:
  • mesh_manager -- A shared pointer to the MeshManager responsible for managing the volume's mesh data.

  • volume -- The MeshID representing the volume whose surfaces will be used to create the tree.

Returns:

A TreeID that can be used to reference this surface tree in subsequent ray tracing operations.

virtual TreeID create_element_tree(
const std::shared_ptr<MeshManager> &mesh_manager,
MeshID volume,
) = 0

Creates an element tree for a given volume.

This method creates a ray tracing tree specifically for the volumetric elements of a given volume. The tree can be used for point-in-element queries.

Parameters:
  • mesh_manager -- A shared pointer to the MeshManager responsible for managing the volume's mesh data.

  • volume -- The MeshID representing the volume whose elements will be used to create the tree.

Returns:

A TreeID that can be used to reference this element tree in subsequent point containment operations.

virtual void create_global_surface_tree() = 0

Builds a global tree for all surfaces registered with the ray tracer.

virtual void create_global_element_tree() = 0

Builds a global tree for all elements registered with the ray tracer.

virtual bool point_in_volume(
TreeID tree,
const Position &point,
const Direction *direction = nullptr,
const std::vector<MeshID> *exclude_primitives = nullptr,
) const = 0
virtual std::pair<double, MeshID> ray_fire(
TreeID tree,
const Position &origin,
const Direction &direction,
const double dist_limit = INFTY,
HitOrientation orientation = HitOrientation::EXITING,
std::vector<MeshID> *const exclude_primitives = nullptr,
) = 0
virtual MeshID find_element(const Position &point) const = 0

Finds the element containing a given point using the global element tree.

This method searches for the element that contains the specified point using the global element tree. It is a convenience wrapper around the tree-specific find_element method.

Parameters:

point -- The Position to search for

Returns:

The MeshID of the containing element, or ID_NONE if no element contains the point

virtual MeshID find_element(TreeID tree, const Position &point) const = 0

Finds the element containing a given point using a specific tree.

This method searches for the element that contains the specified point using the provided tree. It is a more specific version of the global find_element method.

virtual void closest(
TreeID tree,
const Position &origin,
double &dist,
MeshID &triangle,
) = 0
virtual void closest(TreeID tree, const Position &origin, double &dist) = 0
virtual bool occluded(
TreeID tree,
const Position &origin,
const Direction &direction,
double &dist,
) const = 0
inline int num_registered_trees() const
inline int num_registered_surface_trees() const
inline int num_registered_element_trees() const

Protected Functions

const double bounding_box_bump(
const std::shared_ptr<MeshManager> mesh_manager,
MeshID volume_id,
)
SurfaceTreeID next_surface_tree_id()
ElementTreeID next_element_tree_id()

Protected Attributes

SurfaceTreeID global_surface_tree_ = {TREE_NONE}
ElementTreeID global_element_tree_ = {TREE_NONE}
std::map<MeshID, SurfaceTreeID> surface_to_tree_map_
std::map<MeshID, ElementTreeID> point_location_tree_map_
std::vector<SurfaceTreeID> surface_trees_
std::vector<ElementTreeID> element_trees_
SurfaceTreeID next_surface_tree_id_ = {0}
ElementTreeID next_element_tree_id_ = {0}
double numerical_precision_ = {1e-3}
namespace xdg
struct RTCDPointQuery : public RTCPointQuery
#include <ray.h>

Structure extending Embree's RTCPointQuery to include double precision values

Public Functions

inline RTCDPointQuery()
inline void set_radius(double rad)

Set both the single and double precision versions of the query radius.

inline void set_point(const double xyz[3])

Set both the single and double precision versions of the query location.

inline void set_point(const Position &xyz)

Public Members

unsigned int primID = RTC_INVALID_GEOMETRY_ID
unsigned int geomID = RTC_INVALID_GEOMETRY_ID
double dblx
double dbly
double dblz
const PrimitiveRef *primitive_ref = {nullptr}

Pointer to the primitive reference for this hit.

double dradius

Double precision version of the query distance.

struct RTCDualHit : public RTCHit
#include <ray.h>

Structure extending Embree's RayHit to include a double precision version of the primitive normal

Public Functions

inline RTCDualHit()

Public Members

const PrimitiveRef *primitive_ref = {nullptr}

Pointer to the primitive reference for this hit.

MeshID surface = {ID_NONE}

ID of the surface this hit belongs to.

Vec3da dNg

Double precision version of the primitive normal.

struct RTCDualRay : public RTCRay
#include <ray.h>

Stucture that is an extension of Embree's RTCRay with double precision versions of the origin, direction and intersection distance.

Subclassed by xdg::RTCElementDualRay, xdg::RTCSurfaceDualRay

Public Functions

inline RTCDualRay()
inline void set_org(double o[3])

Set both the single and double precision versions of the ray origin.

inline void set_org(const double o[3])

Set both the single and double precision versions of the ray origin.

inline void set_org(const Vec3da &o)

Set both the single and double precision versions of the ray origin.

inline void set_dir(double o[3])

Set both the single and double precision versions of the ray direction.

inline void set_dir(const double o[3])

Set both the single and double precision versions of the ray direction.

inline void set_dir(const Vec3da &o)

Set both the single and double precision versions of the ray direction.

inline void set_tfar(double d)

Set both the single and double precision versions of the ray max distance.

inline void set_tnear(double d)

Set both the single and double precision versions of the ray near distance.

Public Members

Vec3da dorg
Vec3da ddir

double precision versions of the origin and ray direction

double dtfar

double precision version of the ray far distance

struct RTCDualRayHit
#include <ray.h>

Stucture combining the ray and ray-hit structures to be passed to Embree queries

Public Functions

inline double dot_prod()

Compute the dot product of the ray direction and current hit normal.

Public Members

struct RTCSurfaceDualRay ray
struct RTCDualHit hit
struct RTCElementDualRay : public xdg::RTCDualRay

Public Functions

inline RTCElementDualRay()

Public Members

MeshID element

ID of the element this ray is associated with.

struct RTCSurfaceDualRay : public xdg::RTCDualRay

Public Members

RayFireType rf_type = {RayFireType::VOLUME}

Enum indicating the type of query this ray is used for.

HitOrientation orientation = {HitOrientation::EXITING}

Enum indicating what hits to accept based on orientation.

const std::vector<MeshID> *exclude_primitives = {nullptr}
TreeID volume_tree = {ID_NONE}

< Set of primitives to exclude from the query