preCICE v3.1.1
Loading...
Searching...
No Matches
BoundingBox.hpp
Go to the documentation of this file.
1#pragma once
2#include <Eigen/Core>
3#include <fmt/ostream.h>
4#include <iosfwd>
5#include <vector>
6#include "logging/Logger.hpp"
7#include "mesh/Vertex.hpp"
8
9namespace precice {
10namespace logging {
11class Logger;
12} // namespace logging
13
14namespace mesh {
15class Vertex;
16
19
20public:
21 /***
22 *
23 * @brief Constructor
24 *
25 * @param[in] dimension Dimension of the bounding box
26 *
27 */
28 explicit BoundingBox(int dimension);
29
30 /***
31 *
32 * @brief Constructor.
33 *
34 * @param[in] bounds Min-max values of the bounding box in each dimesion (x_min, x_max, y_min, y_max, z_min, z_max)
35 *
36 */
37 explicit BoundingBox(std::vector<double> bounds);
38
45 explicit BoundingBox(Eigen::VectorXd boundMin, Eigen::VectorXd boundMax);
46
48 BoundingBox(const BoundingBox &) = default;
49 BoundingBox(BoundingBox &&) = default;
50 BoundingBox &operator=(const BoundingBox &bb) = default;
52
54 bool operator==(const BoundingBox &otherBB) const;
55
57 bool empty() const;
58
62 bool isDefault() const;
63
65 void expandBy(const BoundingBox &otherBB);
66
68 void expandBy(const Vertex &vertices);
69
72 void expandBy(double value);
73
75 void scaleBy(double safetyFactor);
76
78 bool contains(const Vertex &vertex) const;
79
81 bool overlapping(const BoundingBox &otherBB) const;
82
89 Eigen::VectorXd center() const;
90
92 Eigen::VectorXd minCorner() const;
93
95 Eigen::VectorXd maxCorner() const;
96
98 double getEdgeLength(int axis) const;
99
101 double longestEdgeLength() const;
102
104 double getArea(std::vector<bool> deadAxis);
105
107 const std::vector<double> dataVector() const;
108
110 int getDimension() const;
111
113 void print(std::ostream &out) const;
114
115private:
117
120
124 Eigen::VectorXd _boundMin;
125
129 Eigen::VectorXd _boundMax;
130};
131
133
134} // namespace mesh
135} // namespace precice
136
137template <>
138struct fmt::formatter<precice::mesh::BoundingBox> : ostream_formatter {
139};
std::ostream & out
This class provides a lightweight logger.
Definition Logger.hpp:16
An axis-aligned bounding box around a (partition of a) mesh.
BoundingBox & operator=(const BoundingBox &bb)=default
bool contains(const Vertex &vertex) const
Checks if vertex in contained in _bb.
Eigen::VectorXd maxCorner() const
the max corner of the bounding box
void print(std::ostream &out) const
Print bounds of bounding box, output operator overload.
Eigen::VectorXd minCorner() const
the min corner of the bounding box
BoundingBox(BoundingBox &&)=default
bool empty() const
Check if every dimension's length is equal to zero.
double longestEdgeLength() const
returns the maximum length of the bounding box in any dimension
static logging::Logger _log
double getArea(std::vector< bool > deadAxis)
Calculate the area of bounding box.
void expandBy(const BoundingBox &otherBB)
Expand bounding box using another bounding box.
BoundingBox(const BoundingBox &)=default
Special Members.
const std::vector< double > dataVector() const
Return data as std::vector.
bool overlapping(const BoundingBox &otherBB) const
Checks whether two bounding boxes are overlapping.
bool operator==(const BoundingBox &otherBB) const
Comparison Operator.
int getDimension() const
Getter dimension of the bounding box.
int _dimensions
Number of dimensions (2 or 3)
void scaleBy(double safetyFactor)
Increase the size of bounding box by safety margin.
Eigen::VectorXd center() const
Returns the Center Of Gravity of the mesh.
BoundingBox & operator=(BoundingBox &&bb)=default
double getEdgeLength(int axis) const
returns the edge length of a specific axis
Vertex of a mesh.
Definition Vertex.hpp:16
std::ostream & operator<<(std::ostream &os, const BoundingBox &bb)
Main namespace of the precice library.