mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 05:05:30 -04:00
Moving bounding box back into surface.
This commit is contained in:
parent
80d35e2bb8
commit
df997644b6
3 changed files with 66 additions and 78 deletions
|
|
@ -1,76 +0,0 @@
|
|||
#ifndef OPENMC_BOUNDING_BOX_H
|
||||
#define OPENMC_BOUNDING_BOX_H
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/position.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
//! Coordinates for an axis-aligned cuboid bounds a geometric object.
|
||||
//==============================================================================
|
||||
|
||||
struct BoundingBox
|
||||
{
|
||||
double xmin = -INFTY;
|
||||
double xmax = INFTY;
|
||||
double ymin = -INFTY;
|
||||
double ymax = INFTY;
|
||||
double zmin = -INFTY;
|
||||
double zmax = INFTY;
|
||||
|
||||
|
||||
inline BoundingBox operator &(const BoundingBox& other) {
|
||||
BoundingBox result = *this;
|
||||
return result &= other;
|
||||
}
|
||||
|
||||
inline BoundingBox operator |(const BoundingBox& other) {
|
||||
BoundingBox result = *this;
|
||||
return result |= other;
|
||||
}
|
||||
|
||||
// intersect operator
|
||||
inline BoundingBox& operator &=(const BoundingBox& other) {
|
||||
xmin = std::max(xmin, other.xmin);
|
||||
xmax = std::min(xmax, other.xmax);
|
||||
ymin = std::max(ymin, other.ymin);
|
||||
ymax = std::min(ymax, other.ymax);
|
||||
zmin = std::max(zmin, other.zmin);
|
||||
zmax = std::min(zmax, other.zmax);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// union operator
|
||||
inline BoundingBox& operator |=(const BoundingBox& other) {
|
||||
xmin = std::min(xmin, other.xmin);
|
||||
xmax = std::max(xmax, other.xmax);
|
||||
ymin = std::min(ymin, other.ymin);
|
||||
ymax = std::max(ymax, other.ymax);
|
||||
zmin = std::min(zmin, other.zmin);
|
||||
zmax = std::max(zmax, other.zmax);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ensure bounding box contains a point
|
||||
inline void update(const Position& r) {
|
||||
xmin = std::min(xmin, r.x);
|
||||
xmax = std::max(xmax, r.x);
|
||||
ymin = std::min(ymin, r.y);
|
||||
ymax = std::max(ymax, r.y);
|
||||
zmin = std::min(zmin, r.z);
|
||||
zmax = std::max(zmax, r.z);
|
||||
}
|
||||
|
||||
// check if a point is in the box
|
||||
inline bool contains(const Position& r) const {
|
||||
if (r.x < xmin || r.x > xmax) { return false; }
|
||||
if (r.y < ymin || r.y > ymax) { return false; }
|
||||
if (r.z < zmin || r.z > zmax) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_BOUNDING_BOX_H
|
||||
|
|
@ -12,7 +12,6 @@
|
|||
#include "pugixml.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/bounding_box.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/position.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include "pugixml.hpp"
|
||||
|
||||
#include "openmc/boundary_condition.h"
|
||||
#include "openmc/bounding_box.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/position.h"
|
||||
|
|
@ -30,6 +29,72 @@ namespace model {
|
|||
extern std::vector<std::unique_ptr<Surface>> surfaces;
|
||||
} // namespace model
|
||||
|
||||
//==============================================================================
|
||||
//! Coordinates for an axis-aligned cuboid bounding a geometric object.
|
||||
//==============================================================================
|
||||
|
||||
struct BoundingBox
|
||||
{
|
||||
double xmin = -INFTY;
|
||||
double xmax = INFTY;
|
||||
double ymin = -INFTY;
|
||||
double ymax = INFTY;
|
||||
double zmin = -INFTY;
|
||||
double zmax = INFTY;
|
||||
|
||||
|
||||
inline BoundingBox operator &(const BoundingBox& other) {
|
||||
BoundingBox result = *this;
|
||||
return result &= other;
|
||||
}
|
||||
|
||||
inline BoundingBox operator |(const BoundingBox& other) {
|
||||
BoundingBox result = *this;
|
||||
return result |= other;
|
||||
}
|
||||
|
||||
// intersect operator
|
||||
inline BoundingBox& operator &=(const BoundingBox& other) {
|
||||
xmin = std::max(xmin, other.xmin);
|
||||
xmax = std::min(xmax, other.xmax);
|
||||
ymin = std::max(ymin, other.ymin);
|
||||
ymax = std::min(ymax, other.ymax);
|
||||
zmin = std::max(zmin, other.zmin);
|
||||
zmax = std::min(zmax, other.zmax);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// union operator
|
||||
inline BoundingBox& operator |=(const BoundingBox& other) {
|
||||
xmin = std::min(xmin, other.xmin);
|
||||
xmax = std::max(xmax, other.xmax);
|
||||
ymin = std::min(ymin, other.ymin);
|
||||
ymax = std::max(ymax, other.ymax);
|
||||
zmin = std::min(zmin, other.zmin);
|
||||
zmax = std::max(zmax, other.zmax);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ensure bounding box contains a point
|
||||
inline void update(const Position& r) {
|
||||
xmin = std::min(xmin, r.x);
|
||||
xmax = std::max(xmax, r.x);
|
||||
ymin = std::min(ymin, r.y);
|
||||
ymax = std::max(ymax, r.y);
|
||||
zmin = std::min(zmin, r.z);
|
||||
zmax = std::max(zmax, r.z);
|
||||
}
|
||||
|
||||
// check if a point is in the box
|
||||
inline bool contains(const Position& r) const {
|
||||
if (r.x < xmin || r.x > xmax) { return false; }
|
||||
if (r.y < ymin || r.y > ymax) { return false; }
|
||||
if (r.z < zmin || r.z > zmax) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
//! A geometry primitive used to define regions of 3D space.
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue