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

Represents a cube in 3D space, which is a box where all 3 sides are of equal size. More...

#include <Cube.h>

Inherits SFCGAL::PrimitiveImpl< Derived, Base >.

Public Member Functions

 Cube (const Kernel::FT &size=1.0)
 Constructs a Cube object in the first octant (+, +, +) centered at origin (0, 0, 0). More...
 
 Cube (const Cube &other)=default
 Copy constructor. More...
 
auto primitiveType () const -> std::string override
 returns the primitive type More...
 
auto primitiveTypeId () const -> PrimitiveType override
 
 ~Cube () override=default
 Destructor. More...
 
void setSize (const Kernel::FT &size)
 Sets the size of the cube. More...
 
auto size () const -> const Kernel::FT &
 Gets the size of the cube. More...
 
auto generatePolyhedralSurface () const -> PolyhedralSurface override
 Generates a surface mesh representation of the cube. 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...
 
auto toString () const -> std::string override
 Returns string representation of this object. More...
 

Protected Member Functions

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

Detailed Description

Represents a cube in 3D space, which is a box where all 3 sides are of equal size.

This class provides methods to generate a polyhedral surface representation of a cube. It uses SFCGAL's Kernel for exact computations.

Constructor & Destructor Documentation

SFCGAL::Cube::Cube ( const Kernel::FT &  size = 1.0)

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

Parameters
sizeThe cube size
SFCGAL::Cube::Cube ( const Cube &  other)
default

Copy constructor.

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

Destructor.

Member Function Documentation

auto SFCGAL::Cube::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::Cube::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::Cube::generatePolyhedralSurface ( ) const -> PolyhedralSurface
override

Generates a surface mesh representation of the cube.

Returns
A CGAL::Surface_mesh object representing the cube
void SFCGAL::Cube::invalidateCache ( )
overrideprotected

Invalidates the cached geometries.

auto SFCGAL::Cube::primitiveType ( ) const -> std::string
override

returns the primitive type

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

Returns
a code corresponding to the type
void SFCGAL::Cube::setSize ( const Kernel::FT &  size)

Sets the size of the cube.

Parameters
sizeThe new size
auto SFCGAL::Cube::size ( ) const -> const Kernel::FT &

Gets the size of the cube.

Returns
The size
auto SFCGAL::Cube::toString ( ) const -> std::string
override

Returns string representation of this object.

Can be overriden by sub-classes.

Returns
string representation of this object
void SFCGAL::Cube::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.