Adding a bounding box method to the universe class.

This commit is contained in:
Patrick Shriwise 2019-06-21 14:51:06 -05:00
parent 470e26c783
commit 08239a98d2
2 changed files with 22 additions and 2 deletions

View file

@ -65,6 +65,8 @@ public:
//! \param group_id An HDF5 group id. //! \param group_id An HDF5 group id.
void to_hdf5(hid_t group_id) const; void to_hdf5(hid_t group_id) const;
BoundingBox bounding_box() const;
std::unique_ptr<UniversePartitioner> partitioner_; std::unique_ptr<UniversePartitioner> partitioner_;
}; };

View file

@ -208,6 +208,19 @@ Universe::to_hdf5(hid_t universes_group) const
close_group(group); close_group(group);
} }
BoundingBox Universe::bounding_box() const {
BoundingBox bbox;
if (cells_.size() == 0) {
bbox = {-INFTY, INFTY, -INFTY, -INFTY, INFTY};
} else {
for (const auto& cell : cells_) {
auto& c = model::cells[cell];
bbox.update(c->bounding_box());
}
}
return bbox;
}
//============================================================================== //==============================================================================
// Cell implementation // Cell implementation
//============================================================================== //==============================================================================
@ -569,9 +582,14 @@ CSGCell::to_hdf5(hid_t cell_group) const
BoundingBox CSGCell::bounding_box() const { BoundingBox CSGCell::bounding_box() const {
BoundingBox bbox; BoundingBox bbox;
for (int32_t token : rpn_) { if (rpn_.size() == 0) {
bbox.update(model::surfaces[abs(token)-1]->bounding_box(token > 0)); bbox = {-INFTY, INFTY, -INFTY, INFTY, -INFTY, INFTY};
} else {
for (int32_t token : rpn_) {
bbox.update(model::surfaces[abs(token)-1]->bounding_box(token > 0));
}
} }
return bbox;
} }
//============================================================================== //==============================================================================