From da2a99b475708d823398a8b00e6e63e3ca79fd14 Mon Sep 17 00:00:00 2001 From: shriwise Date: Fri, 17 Aug 2018 14:52:25 -0500 Subject: [PATCH] Implementing a couple more methods for CAD surfaces. --- include/openmc/surface.h | 8 ++++++++ src/surface.cpp | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/openmc/surface.h b/include/openmc/surface.h index 7f1feb4b9..858cb4846 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -45,6 +45,14 @@ extern std::map surface_map; struct BoundingBox { + + BoundingBox(double x_min, double x_max, + double y_min, double y_max, + double z_min, double z_max) : + xmin(x_min), xmax(x_max), + ymin(y_min), ymax(y_max), + zmin(z_min), zmax(z_max) {} + double xmin; double xmax; double ymin; diff --git a/src/surface.cpp b/src/surface.cpp index 174a24deb..aee21287e 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -257,19 +257,27 @@ double CADSurface::evaluate(Position r) const } double CADSurface::distance(Position p, Direction u, bool coincident) const { - return 0.0; + moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id); + moab::EntityHandle hit_surf; + double dist; + dagmc_ptr->ray_fire(surf, p.xyz, u.xyz, hit_surf, dist, NULL, 0, 0); + if (dist < 0.0) dist = INFTY; + return dist; } Direction CADSurface::normal(Position p) const { - Direction u; moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id); dagmc_ptr->get_angle(surf, p.xyz, u.xyz); return u; - } -BoundingBox CADSurface::bounding_box() const { return BoundingBox(); } +BoundingBox CADSurface::bounding_box() const { + moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id); + double min[3], max[3]; + dagmc_ptr->getobb(surf, min, max); + return BoundingBox(min[0], max[0], min[1], max[1], min[2], max[2]); +} #endif //============================================================================== // PeriodicSurface implementation