30 using Vb =
typename VTraits::template ChangeBaseType<bool>;
44 template <typename VV = V, typename std::enable_if_t<VectorTraits<VV>::supportNoInit,
int> = 0>
47 template <typename VV = V, typename std::enable_if_t<!VectorTraits<VV>::supportNoInit,
int> = 0>
107 for (
int i = 0; i <
elements; ++i )
117 for (
int i = 0; i <
elements; ++i )
127 for (
int i = 0; i <
elements; ++i )
138 for (
int i = 0; i <
elements; ++i )
146 for (
int i = 0; i <
elements; ++i )
158 for (
int i = 0; i <
elements; ++i )
173 for (
int i = 0; i <
elements; ++i )
185 for (
int i = 0; i <
elements; ++i )
200 return Box(
min - expansion,
max + expansion );
208 for (
int i = 0; i <
elements; ++i )
219 {
return !( *
this == a ); }
225 assert( box.valid() );
242 assert( box.valid() );
258 auto maxCorner = minCorner;
259 for (
auto & v : maxCorner )
263 dot( n, box.
corner( minCorner ) ),
264 dot( n, box.
corner( maxCorner ) )
290 return box.
max.x - box.
min.x;
297 return box.
max.y - box.
min.y;
304 return box.
max.z - box.
min.z;
308template<
size_t I,
typename V>
309constexpr const V&
get(
const Box<V>& box )
noexcept {
return box[int(
I )]; }
310template<
size_t I,
typename V>
311constexpr V&
get(
Box<V>& box )
noexcept {
return box[int(
I )]; }
320template<
size_t I,
typename V>
321struct tuple_element<
I,
MR::
Box<V>> {
using type = V; };
324struct tuple_size<
MR::
Box<V>> : integral_constant<size_t, 2> {};
auto width(const Box< V > &box)
returns size along x axis
Definition MRMesh/MRBox.h:288
constexpr const V & get(const Box< V > &box) noexcept
get<0> returns min, get<1> returns max
Definition MRMesh/MRBox.h:309
std::array< Vector3< T >, 8 > getCorners(const Box< Vector3< T > > &box)
returns all corners of given box
Definition MRMesh/MRBox.h:223
auto height(const Box< V > &box)
returns size along y axis
Definition MRMesh/MRBox.h:295
auto depth(const Box< V > &box)
returns size along z axis
Definition MRMesh/MRBox.h:302
Box< V > transformed(const Box< V > &box, const AffineXf< V > &xf)
find the tightest box enclosing this one after transformation
Definition MRMesh/MRBox.h:270
MinMax< typename Box< V >::T > getTouchPlanes(const Box< V > &box, const V &n)
Definition MRMesh/MRBox.h:255
constexpr T sqr(T x) noexcept
squared value
Definition MRMesh/MRMeshFwd.h:661
Box
Definition MRMesh/MRMeshFwd.h:331
constexpr NoInit noInit
Definition MRMesh/MRMeshFwd.h:90
I
Definition MRMesh/MRMeshFwd.h:121
MRMESH_CLASS Vector3
Definition MRMesh/MRMeshFwd.h:170
Definition MRMesh/MRAffineXf.h:14
Box given by its min- and max- corners.
Definition MRMesh/MRBox.h:25
Box(const V &min, const V &max)
Definition MRMesh/MRBox.h:41
typename VTraits::BaseType T
Definition MRMesh/MRBox.h:28
void include(const V &pt)
minimally increases the box to include given point
Definition MRMesh/MRBox.h:105
typename VTraits::template ChangeBaseType< bool > Vb
Definition MRMesh/MRBox.h:30
V getBoxClosestPointTo(const V &pt) const
returns closest point in the box to given point
Definition MRMesh/MRBox.h:134
T getDistanceSq(const Box &b) const
Definition MRMesh/MRBox.h:169
T diagonal() const
computes length from min to max
Definition MRMesh/MRBox.h:92
void include(const Box &b)
minimally increases the box to include another box
Definition MRMesh/MRBox.h:115
Box expanded(const V &expansion) const
decreases min and increased max on given value
Definition MRMesh/MRBox.h:197
V max
Definition MRMesh/MRBox.h:33
Box insignificantlyExpanded() const
decreases min and increases max to their closest representable value
Definition MRMesh/MRBox.h:204
V corner(const Vb &c) const
Definition MRMesh/MRBox.h:70
V center() const
computes center of the box
Definition MRMesh/MRBox.h:65
T getDistanceSq(const V &pt) const
Definition MRMesh/MRBox.h:181
V size() const
computes size of the box in all dimensions
Definition MRMesh/MRBox.h:89
static Vb getMinBoxCorner(const V &n)
Definition MRMesh/MRBox.h:80
bool intersects(const Box &b) const
checks whether this box intersects or touches given box
Definition MRMesh/MRBox.h:144
static constexpr int elements
Definition MRMesh/MRBox.h:29
T volume() const
computes the volume of this box
Definition MRMesh/MRBox.h:95
static Box fromMinAndSize(const V &min, const V &size)
Definition MRMesh/MRBox.h:53
Box()
create invalid box by default
Definition MRMesh/MRBox.h:40
const V & operator[](int e) const
min/max access by 0/1 index
Definition MRMesh/MRBox.h:36
bool operator!=(const Box &a) const
Definition MRMesh/MRBox.h:218
V min
Definition MRMesh/MRBox.h:33
Box intersection(const Box &b) const
computes intersection between this and other box
Definition MRMesh/MRBox.h:155
bool contains(const V &pt) const
checks whether given point is inside (including the surface) of the box
Definition MRMesh/MRBox.h:125
Box & intersect(const Box &b)
Definition MRMesh/MRBox.h:165
Box(const Box< U > &a)
Definition MRMesh/MRBox.h:51
bool valid() const
true if the box contains at least one point
Definition MRMesh/MRBox.h:56
Box(NoInit)
skip initialization of min/max
Definition MRMesh/MRBox.h:45
bool operator==(const Box &a) const
Definition MRMesh/MRBox.h:216
Definition MRMesh/MRMeshFwd.h:89
Definition MRVector2.h:25
T x
Definition MRVector2.h:31
Definition MRMesh/MRVector3.h:26
T x
Definition MRMesh/MRVector3.h:32
Definition MRMesh/MRVectorTraits.h:15
static constexpr int size
Definition MRMesh/MRVectorTraits.h:19
static constexpr auto && getElem(int i, U &&value)
Definition MRMesh/MRVectorTraits.h:29
T BaseType
Definition MRMesh/MRVectorTraits.h:18