SFCGAL  2.3.0
Public Member Functions | Protected Member Functions | List of all members
SFCGAL::Box Class Reference

Represents a box in 3D space. More...

#include <Box.h>

Inherits SFCGAL::PrimitiveImpl< Derived, Base >.

Public Member Functions

 Box (const Kernel::FT &x_extent=1.0, const Kernel::FT &y_extent=1.0, const Kernel::FT &z_extent=1.0)
 Constructs a Box object in the first octant (+, +, +) centered at origin (0, 0, 0). More...
 
 Box (const Box &other)=default
 Copy constructor. More...
 
auto primitiveType () const -> std::string override
 returns the primitive type More...
 
auto primitiveTypeId () const -> PrimitiveType override
 
 ~Box () override=default
 Destructor. More...
 
void setXExtent (const Kernel::FT &x_extent)
 Sets the x_extent of the box. More...
 
void setYExtent (const Kernel::FT &y_extent)
 Sets the y_extent of the box. More...
 
void setZExtent (const Kernel::FT &z_extent)
 Sets the z_extent of the box. More...
 
auto xExtent () const -> const Kernel::FT &
 Gets the x_extent of the box. More...
 
auto yExtent () const -> const Kernel::FT &
 Gets the y_extent of the box. More...
 
auto zExtent () const -> const Kernel::FT &
 Gets the z_extent of the box. More...
 
auto generatePolyhedralSurface () const -> PolyhedralSurface override
 Generates a surface mesh representation of the box. More...
 
auto baseVolume (bool withDiscretization=false) const -> double override
 Returns the sphere volume without scaling. More...
 
auto area3D (bool withDiscretization=false) const -> double override
 Returns the primitive area. More...
 

Protected Member Functions

void validateParameters (std::unordered_map< std::string, PrimitiveParameter > const &tempParameters) const override
 Verifies that all parameters are valid. More...
 

Detailed Description

Represents a box in 3D space.

This class provides methods to generate a polyhedral surface representation of a box (rectangular prism). It uses SFCGAL's Kernel for exact computations.

Constructor & Destructor Documentation

SFCGAL::Box::Box ( const Kernel::FT &  x_extent = 1.0,
const Kernel::FT &  y_extent = 1.0,
const Kernel::FT &  z_extent = 1.0 
)

Constructs a Box object in the first octant (+, +, +) centered at origin (0, 0, 0).

Parameters
x_extentThe box length in x direction
y_extentThe box length in y direction
z_extentThe box length in z direction
SFCGAL::Box::Box ( const Box &  other)
default

Copy constructor.

Parameters
othercopy from
SFCGAL::Box::~Box ( )
overridedefault

Destructor.

Member Function Documentation

auto SFCGAL::Box::area3D ( bool  withDiscretization = false) const -> double
override

Returns the primitive area.

Parameters
withDiscretizationComputes volume with discretization (true) or as perfect primitive (false). Defaults to false.
Returns
The primitive volume
Note
only perfect primitive version is available
auto SFCGAL::Box::baseVolume ( bool  withDiscretization = false) const -> double
override

Returns the sphere volume without scaling.

Parameters
withDiscretizationComputes volume with discretization (true) or as perfect primitive (false). Defaults to false.
Returns
The sphere volume
Note
only perfect primitive version is available
auto SFCGAL::Box::generatePolyhedralSurface ( ) const -> PolyhedralSurface
override

Generates a surface mesh representation of the box.

Returns
A CGAL::Surface_mesh object representing the box
auto SFCGAL::Box::primitiveType ( ) const -> std::string
override

returns the primitive type

Warning
use CamelCase (Cylinder, not CYLINDER)
Returns
the primitive type as string
auto SFCGAL::Box::primitiveTypeId ( ) const -> PrimitiveType
override

Returns
a code corresponding to the type
void SFCGAL::Box::setXExtent ( const Kernel::FT &  x_extent)

Sets the x_extent of the box.

Parameters
x_extentThe new x_extent
void SFCGAL::Box::setYExtent ( const Kernel::FT &  y_extent)

Sets the y_extent of the box.

Parameters
y_extentThe new y_extent
void SFCGAL::Box::setZExtent ( const Kernel::FT &  z_extent)

Sets the z_extent of the box.

Parameters
z_extentThe new z_extent
void SFCGAL::Box::validateParameters ( std::unordered_map< std::string, PrimitiveParameter > const &  tempParameters) const
overrideprotected

Verifies that all parameters are valid.

For instance, it raises an error if an extent is negative.

Parameters
tempParametersa temp map of parameter with new values
Exceptions
SFCGAL::Exceptionif one of the parameters if not valid provided variant type is not compatible with the parameter.
auto SFCGAL::Box::xExtent ( ) const -> const Kernel::FT &

Gets the x_extent of the box.

Returns
The x_extent
auto SFCGAL::Box::yExtent ( ) const -> const Kernel::FT &

Gets the y_extent of the box.

Returns
The y_extent
auto SFCGAL::Box::zExtent ( ) const -> const Kernel::FT &

Gets the z_extent of the box.

Returns
The z_extent