Defines a 2D bounding box. More...

## Public Member Functions

ModelData_Box2d ()
Constructor. Creates a box with infinite boundaries.

ModelData_Box2d (const ModelData_Point2dd &theCorner1, const ModelData_Point2dd &theCorner2)
Constructor. More...

ModelData_Box2d (const Bnd_Box2d &theBox)
Constructor.

const ModelData_Point2dMinCorner () const

ModelData_Point2dMinCorner ()

const ModelData_Point2dMaxCorner () const

ModelData_Point2dMaxCorner ()

ModelData_Point2d Center () const
Returns a center point. Returns a middle of the diagonal between MinCorner() and MaxCorner().

Adjusts the box corners so that it contains thePoint. More...

Adjusts the box corners so that it contains theBox.

void Clear ()
Resets the box. More...

void SetXRange (double theMin, double theMax)
Sets the range of box along X axis to the specified values.

void SetYRange (double theMin, double theMax)
Sets the range of box along Y axis to the specified values.

void SetRange (size_t theIdx, double theMin, double theMax)
Sets one range of the box to the specified values. More...

double Range (size_t theIdx) const
Returns the length of range along specified axis.

double XRange () const
Returns the length of range along X axis.

double YRange () const
Returns the length of range along Y axis.

void Enlarge (double theX, double theY)
Enlarge the box dimensions by specified values. More...

void Enlarge (double theSize)
Enlarge the box dimensions by specified value. More...

ModelData_Box2d Enlarged (double theX, double theY) const
Return the box with dimensions enlarged by specified values. More...

ModelData_Box2d Enlarged (double theSize) const
Return the box with dimensions enlarged by specified value. More...

bool IsIn (const ModelData_Point2d &thePoint) const
Returns true if the point lies inside the box.

bool Intersects (const ModelData_Box2d &theOther) const
Returns the other box has at least one common point with this box.

bool IsInfinite () const
Returns true if at least one coordinate is infinite. More...

void Multiply (double theValue)
Scales box by scalar value. More...

ModelData_Box2d Multiplied (double theValue) const
Returns the box scaled by scalar value.

void Transform (const ModelData_Transformation2d &theTransformation)
Transforms the box. More...

ModelData_Box2d Transformed (const ModelData_Transformation2d &theTransformation) const
Returns the transformed box.

operator Bnd_Box2d () const
Casts to a Bnd_Box object.

## Detailed Description

Defines a 2D bounding box.

The box is defined via two corners - MinCorner() and MaxCorner() - containing minimum and maximum coordinates respectively.

ModelData_Box.

## ◆ ModelData_Box2d()

 cadex::ModelData_Box2d::ModelData_Box2d ( const ModelData_Point2dd & theCorner1, const ModelData_Point2dd & theCorner2 )

Constructor.

Creates a box with specified corners.

## Member Function Documentation

Adjusts the box corners so that it contains thePoint.

Takes into account only finite coordinates of thePoint (those whose absolute value is less than $$10^{100}$$).

## ◆ Clear()

Resets the box.

Assigns infinite values to the coordinates, so that IsInfinite() returns true.

## ◆ Enlarge() [1/2]

 void cadex::ModelData_Box2d::Enlarge ( double theSize )
inline

Enlarge the box dimensions by specified value.

Each box extent is shifted by $$\frac{1}{2}\cdot\mathrm{theSize}$$ to the negative and positive side along respective axis.

## ◆ Enlarge() [2/2]

 void cadex::ModelData_Box2d::Enlarge ( double theX, double theY )
inline

Enlarge the box dimensions by specified values.

Each box extent is shifted by $$\frac{1}{2}$$ of the specified shift value to the negative and positive side along respective axis.

## ◆ Enlarged() [1/2]

 ModelData_Box2d cadex::ModelData_Box2d::Enlarged ( double theSize ) const
inline

Return the box with dimensions enlarged by specified value.

Each box extent of the result is shifted by $$\frac{1}{2}\cdot\mathrm{theSize}$$ to the negative and positive side along respective axis compared to the original.

## ◆ Enlarged() [2/2]

 ModelData_Box2d cadex::ModelData_Box2d::Enlarged ( double theX, double theY ) const
inline

Return the box with dimensions enlarged by specified values.

Each box extent of the result is shifted by $$\frac{1}{2}$$ of the specified shift value to the negative and positive side along respective axis compared to the original.

## ◆ IsInfinite()

Returns true if at least one coordinate is infinite.

"Infinite" means that coordinate's absolute value is greater than $$10^{100}$$.

Clear()

## ◆ MaxCorner() [1/2]

inline

Returns the MaxCorner property.

## ◆ MaxCorner() [2/2]

 const ModelData_Point2d& cadex::ModelData_Box2d::MaxCorner ( ) const
inline

Returns the MaxCorner property.

## ◆ MinCorner() [1/2]

inline

Returns the MinCorner property.

## ◆ MinCorner() [2/2]

 const ModelData_Point2d& cadex::ModelData_Box2d::MinCorner ( ) const
inline

Returns the MinCorner property.

## ◆ Multiply()

 void cadex::ModelData_Box2d::Multiply ( double theValue )

Scales box by scalar value.

Performs the scaling transformation of all the points of the box in the form:

$P'=\mathrm{theValue}\; P$

where $$P$$ and $$P'$$ are the box points before and after transformation respectively and $$\mathrm{theValue}$$ is the scale factor.

## ◆ SetRange()

 void cadex::ModelData_Box2d::SetRange ( size_t theIdx, double theMin, double theMax )
inline

Sets one range of the box to the specified values.

Range axis Index
X 0
Y 1

## ◆ Transform()

 void cadex::ModelData_Box2d::Transform ( const ModelData_Transformation2d & theTransformation )

Transforms the box.

If the transformation does not contain anything besides perhaps a translation, the box dimensions are kept as is and its position is recalcuated accordingly.

If rotation or scale are present, all box corners are transformed and a new axis-aligned box containing them is built. If the box was infinite in one of the directions, the new box will also be infinite in the directions that are results of applying the transformation to the original directions. The new box most likely has larger dimensions than the original.

For more accurate results, it's recommended instead to transform the arguments the box was built from and only then calculate the box.