25 using T =
typename V::ValueType;
46 for (
int i = 0; i < V::elements; ++i )
66 for (
int i = 0; i < V::elements; ++i )
74 for (
int i = 0; i < V::elements; ++i )
76 if ( pt[i] <
min[i] )
min[i] = pt[i];
77 if ( pt[i] >
max[i] )
max[i] = pt[i];
84 for (
int i = 0; i < V::elements; ++i )
94 for (
int i = 0; i < V::elements; ++i )
95 if (
min[i] > pt[i] || pt[i] >
max[i] )
105 for (
int i = 0; i < V::elements; ++i )
106 res[i] = std::clamp( pt[i],
min[i],
max[i] );
113 for (
int i = 0; i < V::elements; ++i )
125 for (
int i = 0; i < V::elements; ++i )
127 res.
min[i] = std::max(
min[i], b.
min[i] );
128 res.
max[i] = std::min(
max[i], b.
max[i] );
140 for (
int i = 0; i < V::elements; ++i )
141 if ( ibox.min[i] > ibox.max[i] )
142 distSq +=
sqr( ibox.min[i] - ibox.max[i] );
152 for (
int i = 0; i < V::elements; ++i )
154 if ( pt[i] <
min[i] )
155 res +=
sqr( pt[i] -
min[i] );
157 if ( pt[i] >
max[i] )
158 res +=
sqr( pt[i] -
max[i] );
168 for (
int i = 0; i < V::elements; ++i )
170 res.
min[i] = std::nextafter(
min[i], std::numeric_limits<T>::lowest() );
171 res.
max[i] = std::nextafter(
max[i], std::numeric_limits<T>::max() );
179 {
return !( *
this == a ); }
232 return box.
max.x - box.
min.x;
239 return box.
max.y - box.
min.y;
246 return box.
max.z - box.
min.z;
auto width(const Box< V > &box)
returns size along x axis
Definition MRMesh/MRBox.h:230
std::array< Vector3< T >, 8 > getCorners(const Box< Vector3< T > > &box)
returns all corners of given box
Definition MRMesh/MRBox.h:183
auto height(const Box< V > &box)
returns size along y axis
Definition MRMesh/MRBox.h:237
auto depth(const Box< V > &box)
returns size along z axis
Definition MRMesh/MRBox.h:244
Box< V > transformed(const Box< V > &box, const AffineXf< V > &xf)
find the tightest box enclosing this one after transformation
Definition MRMesh/MRBox.h:212
Definition MRCameraOrientationPlugin.h:7
constexpr T sqr(T x) noexcept
Definition MRMesh/MRMeshFwd.h:613
Box
Definition MRMesh/MRMeshFwd.h:297
constexpr NoInit noInit
Definition MRMesh/MRMeshFwd.h:57
MRMESH_CLASS Vector3
Definition MRMesh/MRMeshFwd.h:136
Definition MRMesh/MRAffineXf.h:14
Box given by its min- and max- corners.
Definition MRMesh/MRBox.h:23
Box(const V &min, const V &max)
Definition MRMesh/MRBox.h:36
void include(const V &pt)
minimally increases the box to include given point
Definition MRMesh/MRBox.h:72
V getBoxClosestPointTo(const V &pt) const
returns closest point in the box to given point
Definition MRMesh/MRBox.h:101
T getDistanceSq(const Box &b) const
Definition MRMesh/MRBox.h:136
T diagonal() const
computes length from min to max
Definition MRMesh/MRBox.h:59
void include(const Box &b)
minimally increases the box to include another box
Definition MRMesh/MRBox.h:82
V max
Definition MRMesh/MRBox.h:27
Box insignificantlyExpanded() const
expands min and max to their closest representable value
Definition MRMesh/MRBox.h:164
V center() const
computes center of the box
Definition MRMesh/MRBox.h:53
T getDistanceSq(const V &pt) const
Definition MRMesh/MRBox.h:148
V size() const
computes size of the box in all dimensions
Definition MRMesh/MRBox.h:56
bool intersects(const Box &b) const
checks whether this box intersects or touches given box
Definition MRMesh/MRBox.h:111
T volume() const
computes the volume of this box
Definition MRMesh/MRBox.h:62
static Box fromMinAndSize(const V &min, const V &size)
Definition MRMesh/MRBox.h:41
Box()
create invalid box by default
Definition MRMesh/MRBox.h:34
const V & operator[](int e) const
min/max access by 0/1 index
Definition MRMesh/MRBox.h:30
bool operator!=(const Box &a) const
Definition MRMesh/MRBox.h:178
V min
Definition MRMesh/MRBox.h:27
Box intersection(const Box &b) const
computes intersection between this and other box
Definition MRMesh/MRBox.h:122
bool contains(const V &pt) const
checks whether given point is inside (including the surface) of the box
Definition MRMesh/MRBox.h:92
Box & intersect(const Box &b)
Definition MRMesh/MRBox.h:132
Box(const Box< U > &a)
Definition MRMesh/MRBox.h:39
Box(NoInit)
Definition MRMesh/MRBox.h:35
bool valid() const
true if the box contains at least one point
Definition MRMesh/MRBox.h:44
bool operator==(const Box &a) const
Definition MRMesh/MRBox.h:176
typename V::ValueType T
Definition MRMesh/MRBox.h:25
Definition MRMesh/MRMeshFwd.h:56
Definition MRVector2.h:18
T x
Definition MRVector2.h:24
Definition MRMesh/MRVector3.h:19
T x
Definition MRMesh/MRVector3.h:25