36 , maxBound(maxBound) {
50 maxBound =
max(maxBound, v);
51 minBound =
min(minBound, v);
59 maxBound =
max(maxBound, other.maxBound);
60 minBound =
min(minBound, other.minBound);
67 for (
int i = 0; i < 3; ++i) {
68 if (v[i] < minBound[i] || v[i] > maxBound[i]) {
108 return maxBound - minBound;
114 return 0.5_f * (minBound + maxBound);
120 return s[
X] * s[
Y] * s[
Z];
125 return minBound == other.minBound && maxBound == other.maxBound;
130 return minBound != other.minBound || maxBound != other.maxBound;
135 return Box(minBound + offset, maxBound + offset);
147 SPH_ASSERT(x >= minBound[dim] && x <= maxBound[dim]);
148 Box b1 = *
this, b2 = *
this;
149 b1.maxBound[dim] = x;
150 b2.minBound[dim] = x;
157 is.minBound =
max(minBound, other.minBound);
158 is.maxBound =
min(maxBound, other.maxBound);
167 template <
typename TFunctor>
170 for (
Float x = minBound[
X]; x <= maxBound[
X]; x += step[
X]) {
171 for (
Float y = minBound[
Y]; y <= maxBound[
Y]; y += step[
Y]) {
172 for (
Float z = minBound[
Z]; z <= maxBound[
Z]; z += step[
Z]) {
181 template <
typename TFunctor>
184 Size i = 0, j = 0, k = 0;
185 for (
Float z = minBound[
Z]; z <= maxBound[
Z]; z += step[
Z], k++) {
188 for (
Float y = minBound[
Y]; y <= maxBound[
Y]; y += step[
Y], j++) {
190 for (
Float x = minBound[
X]; x <= maxBound[
X]; x += step[
X], i++) {
210 bool isValid()
const {
211 return minElement(maxBound - minBound) >= 0._f;
INLINE Float minElement(const AntisymmetricTensor &t)
Returns the minimal element of the tensor.
Generic dynamically allocated resizable storage.
#define SPH_ASSERT(x,...)
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Vectorized computations with integral numbers.
constexpr INLINE T max(const T &f1, const T &f2)
constexpr INLINE T clamp(const T &f, const T &f1, const T &f2)
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Basic vector algebra. Computations are accelerated using SIMD.
BasicVector< Float > Vector
Helper object defining three-dimensional interval (box).
INLINE Box translate(const Vector &offset) const
Returns a box with specified offset.
friend std::ostream & operator<<(std::ostream &stream, const Box &box)
Prints the bounds of the box into the stream.
INLINE void extend(const Vector &v)
Enlarges the box to contain the vector.
INLINE const Vector & lower() const
Returns lower bounds of the box.
INLINE Box()=default
Constructs empty box with negative dimensions.
INLINE const Vector & upper() const
Returns upper bounds of the box.
INLINE Vector center() const
Returns the center of the box.
INLINE bool contains(const Vector &v) const
Checks if the vector lies inside the box.
INLINE Vector size() const
Returns box dimensions.
INLINE Vector & lower()
Returns lower bounds of the box.
void iterateWithIndices(const Vector &step, TFunctor &&functor) const
Execute functor for all possible values of vector (with constant stepping), passing auxiliary indices...
INLINE Box intersect(const Box &other) const
Computes the intersection of this box with another one.
INLINE Float volume() const
Returns the volume of the box.
INLINE Box(const Vector &minBound, const Vector &maxBound)
Constructs a box given its 'corners'.
INLINE Pair< Box > split(const Size dim, const Float x) const
Splits the box along given coordinate.
INLINE Vector clamp(const Vector &v) const
Clamps all components of the vector to fit within the box.
static Box EMPTY()
Syntactic sugar, returns a default-constructed (empty) box.
INLINE Vector & upper()
Returns upper bounds of the box.
void iterate(const Vector &step, TFunctor &&functor) const
Execute functor for all possible values of vector (with constant stepping)
INLINE bool operator!=(const Box &other) const
Checks for inequality of boxes.
INLINE void extend(const Box &other)
Enlarges the box to contain another box.
INLINE bool operator==(const Box &other) const
Compares two boxes, return true if box lower and upper bounds are equal.
Helper object for storing three (possibly four) int or bool values.
Array with fixed number of allocated elements.