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

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

#include <Cylinder.h>

Inherits SFCGAL::PrimitiveImpl< Derived, Base >.

Public Member Functions

 Cylinder (const Kernel::FT &radius=1.0, const Kernel::FT &height=1.0, unsigned int num_radial=32)
 Constructs a Cylinder object. More...
 
 Cylinder (const Cylinder &other)=default
 Copy constructor. More...
 
auto primitiveType () const -> std::string override
 returns the primitive type More...
 
auto primitiveTypeId () const -> PrimitiveType override
 returns a code corresponding to the type More...
 
 ~Cylinder () override=default
 Destructor. More...
 
void setRadius (const Kernel::FT &radius)
 Sets the radius of the cylinder. More...
 
void setHeight (const Kernel::FT &height)
 Sets the height of the cylinder. More...
 
void setNumRadial (unsigned int num)
 Sets the number of radial divisions. More...
 
auto radius () const -> const Kernel::FT &
 Gets the radius of the cylinder. More...
 
auto height () const -> const Kernel::FT &
 Gets the height of the cylinder. More...
 
auto numRadial () const -> unsigned int
 Gets the number of radial divisions. More...
 
auto generatePolyhedron () const -> Polyhedron_3
 Generates a polyhedron representation of the cylinder. More...
 
auto generateSurfaceMesh () const -> Surface_mesh_3
 Generates a surface mesh representation of the cylinder. More...
 
auto generatePolyhedralSurface () const -> PolyhedralSurface override
 Generates a surface mesh representation of the cylinder. More...
 
auto baseVolume (bool withDiscretization=false) const -> double override
 Returns the primitive 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...
 
void invalidateCache () override
 Invalidates the cached polyhedron and surface mesh. More...
 

Detailed Description

Represents a cylinder in 3D space.

The cylinder is aligned along the Z axis with its base centered at the origin and its top cap located at z = height.

This class provides methods to generate a polyhedron and a surface mesh representation of a cylinder. It uses SFCGAL's Kernel for exact computations.

Constructor & Destructor Documentation

SFCGAL::Cylinder::Cylinder ( const Kernel::FT &  radius = 1.0,
const Kernel::FT &  height = 1.0,
unsigned int  num_radial = 32 
)

Constructs a Cylinder object.

Parameters
radiusThe radius of the cylinder
heightThe height of the cylinder
num_radialThe number of radial divisions
SFCGAL::Cylinder::Cylinder ( const Cylinder &  other)
default

Copy constructor.

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

Destructor.

Member Function Documentation

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

Returns the primitive area.

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

Returns the primitive volume without scaling.

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

Generates a surface mesh representation of the cylinder.

Returns
A SFCGAL::PolyhedralSurface object representing the cylinder
auto SFCGAL::Cylinder::generatePolyhedron ( ) const -> Polyhedron_3

Generates a polyhedron representation of the cylinder.

Returns
A CGAL::Polyhedron_3 object representing the cylinder
auto SFCGAL::Cylinder::generateSurfaceMesh ( ) const -> Surface_mesh_3

Generates a surface mesh representation of the cylinder.

Returns
A CGAL::Surface_mesh object representing the cylinder
auto SFCGAL::Cylinder::height ( ) const -> const Kernel::FT &
inline

Gets the height of the cylinder.

Returns
The height
void SFCGAL::Cylinder::invalidateCache ( )
overrideprotected

Invalidates the cached polyhedron and surface mesh.

auto SFCGAL::Cylinder::numRadial ( ) const -> unsigned int
inline

Gets the number of radial divisions.

Returns
The number of radial divisions
auto SFCGAL::Cylinder::primitiveType ( ) const -> std::string
override

returns the primitive type

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

returns a code corresponding to the type

Returns
a code corresponding to the type
auto SFCGAL::Cylinder::radius ( ) const -> const Kernel::FT &
inline

Gets the radius of the cylinder.

Returns
The radius
void SFCGAL::Cylinder::setHeight ( const Kernel::FT &  height)

Sets the height of the cylinder.

Parameters
heightThe new height
void SFCGAL::Cylinder::setNumRadial ( unsigned int  num)

Sets the number of radial divisions.

Parameters
numThe new number of radial divisions
void SFCGAL::Cylinder::setRadius ( const Kernel::FT &  radius)

Sets the radius of the cylinder.

Parameters
radiusThe new radius
void SFCGAL::Cylinder::validateParameters ( std::unordered_map< std::string, PrimitiveParameter > const &  tempParameters) const
overrideprotected

Verifies that all parameters are valid.

For instance, it raises an error if a radius 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.