src/utilities/geometry/BoundingBox.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #ifndef UTILITIES_GEOMETRY_BOUNDINGBOX_HPP | ||
| 7 | #define UTILITIES_GEOMETRY_BOUNDINGBOX_HPP | ||
| 8 | |||
| 9 | #include "../UtilitiesAPI.hpp" | ||
| 10 | #include "../core/Logger.hpp" | ||
| 11 | |||
| 12 | #include <boost/optional.hpp> | ||
| 13 | |||
| 14 | #include <vector> | ||
| 15 | |||
| 16 | namespace openstudio { | ||
| 17 | |||
| 18 | // forward declaration | ||
| 19 | class Point3d; | ||
| 20 | |||
| 21 | /** BoundingBox is an axis aligned cuboid that can check for intersections with another BoundingBox. | ||
| 22 | * BoundingBox intersections require that both boxes are specified in the same coordinate system. | ||
| 23 | */ | ||
| 24 | class UTILITIES_API BoundingBox | ||
| 25 | { | ||
| 26 | public: | ||
| 27 | /// default constructor creates empty BoundingBox, will not intersect with anything | ||
| 28 | 80683 | BoundingBox() = default; | |
| 29 | |||
| 30 | /// add another BoundingBox | ||
| 31 | void add(const BoundingBox& other); | ||
| 32 | |||
| 33 | /// add a point to the BoundingBox | ||
| 34 | void addPoint(const Point3d& point); | ||
| 35 | |||
| 36 | /// add points to the BoundingBox | ||
| 37 | void addPoints(const std::vector<Point3d>& points); | ||
| 38 | |||
| 39 | /// test for intersection. Default tolerance is 1cm | ||
| 40 | bool intersects(const BoundingBox& other, double tol = 0.01) const; | ||
| 41 | |||
| 42 | bool isEmpty() const; | ||
| 43 | |||
| 44 | boost::optional<double> minX() const; | ||
| 45 | boost::optional<double> minY() const; | ||
| 46 | boost::optional<double> minZ() const; | ||
| 47 | |||
| 48 | boost::optional<double> maxX() const; | ||
| 49 | boost::optional<double> maxY() const; | ||
| 50 | boost::optional<double> maxZ() const; | ||
| 51 | |||
| 52 | std::vector<Point3d> corners() const; | ||
| 53 | |||
| 54 | private: | ||
| 55 | REGISTER_LOGGER("utilities.BoundingBox"); | ||
| 56 | |||
| 57 | boost::optional<double> m_minX; | ||
| 58 | boost::optional<double> m_minY; | ||
| 59 | boost::optional<double> m_minZ; | ||
| 60 | |||
| 61 | boost::optional<double> m_maxX; | ||
| 62 | boost::optional<double> m_maxY; | ||
| 63 | boost::optional<double> m_maxZ; | ||
| 64 | }; | ||
| 65 | |||
| 66 | // optional BoundingBox | ||
| 67 | using OptionalBoundingBox = boost::optional<BoundingBox>; | ||
| 68 | |||
| 69 | // vector of BoundingBox | ||
| 70 | using BoundingBoxVector = std::vector<BoundingBox>; | ||
| 71 | |||
| 72 | } // namespace openstudio | ||
| 73 | |||
| 74 | #endif //UTILITIES_GEOMETRY_BOUNDINGBOX_HPP | ||
| 75 |