Making Position/Direction structs more friendly for array-based signatures.

This commit is contained in:
shriwise 2018-08-11 08:30:12 -05:00 committed by pshriwise
parent 2e4809c8d5
commit baa92194ef
3 changed files with 5 additions and 13 deletions

View file

@ -57,9 +57,7 @@ struct Position {
}
// Data members
double x = 0.;
double y = 0.;
double z = 0.;
union{ double xyz[3]; struct{ double x,y,z; }; };
};
// Binary operators

View file

@ -599,12 +599,10 @@ CADCell::CADCell() : Cell{} {};
std::pair<double, int32_t> CADCell::distance(Position p, Direction u, int32_t on_surface) const {
double xyz[3] = {p.x, p.y, p.z};
double uvw[3] = {u.x, u.y, u.z};
moab::EntityHandle vol = dagmc_ptr->entity_by_id(3, id);
moab::EntityHandle hit_surf;
double dist;
dagmc_ptr->ray_fire(vol, xyz, uvw, hit_surf, dist);
dagmc_ptr->ray_fire(vol, p.xyz, u.xyz, hit_surf, dist);
int surf_idx = dagmc_ptr->index_by_handle(hit_surf);
@ -615,12 +613,10 @@ std::pair<double, int32_t> CADCell::distance(Position p, Direction u, int32_t on
bool CADCell::contains(Position p, Direction u, int32_t on_surface) const {
double xyz[3] = {p.x, p.y, p.z};
double uvw[3] = {u.x, u.y, u.z};
moab::EntityHandle vol = dagmc_ptr->entity_by_id(3, id);
int result = 0;
dagmc_ptr->point_in_volume(vol, xyz, result, uvw);
dagmc_ptr->point_in_volume(vol, p.xyz, result, u.xyz);
return bool(result);
}

View file

@ -262,11 +262,9 @@ double CADSurface::distance(Position p, Direction u, bool coincident) const {
Direction CADSurface::normal(Position p) const {
double xyz[3] = {p.x, p.y, p.z};
double uvw[3];
Direction u;
moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id);
dagmc_ptr->get_angle(surf, xyz, uvw);
Direction u = {uvw};
dagmc_ptr->get_angle(surf, p.xyz, u.xyz);
return u;
}