SFCGAL 2.3.0
SFCGAL::Cylinder Class Reference

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

#include <Cylinder.h>

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

Protected Member Functions

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

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

◆ Cylinder() [1/2]

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

◆ Cylinder() [2/2]

SFCGAL::Cylinder::Cylinder ( const Cylinder & other)
default

Copy constructor.

Parameters
othercopy from

◆ ~Cylinder()

SFCGAL::Cylinder::~Cylinder ( )
overridedefault

Destructor.

Member Function Documentation

◆ area3D()

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

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

◆ baseVolume()

auto SFCGAL::Cylinder::baseVolume ( bool withDiscretization = false) const -> double
nodiscardoverride

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

◆ generatePolyhedralSurface()

auto SFCGAL::Cylinder::generatePolyhedralSurface ( ) const -> PolyhedralSurface
override

Generates a surface mesh representation of the cylinder.

Returns
A SFCGAL::PolyhedralSurface object representing the cylinder

◆ generatePolyhedron()

auto SFCGAL::Cylinder::generatePolyhedron ( ) const -> Polyhedron_3

Generates a polyhedron representation of the cylinder.

Returns
A CGAL::Polyhedron_3 object representing the cylinder

◆ generateSurfaceMesh()

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

◆ height()

auto SFCGAL::Cylinder::height ( ) const -> const Kernel::FT &
inlinenodiscard

Gets the height of the cylinder.

Returns
The height

◆ invalidateCache()

void SFCGAL::Cylinder::invalidateCache ( )
overrideprotected

Invalidates the cached polyhedron and surface mesh.

◆ numRadial()

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

Gets the number of radial divisions.

Returns
The number of radial divisions

◆ primitiveType()

auto SFCGAL::Cylinder::primitiveType ( ) const -> std::string
nodiscardoverride

returns the primitive type

Warning
use CamelCase (Cylinder, not CYLINDER)
Returns
the primitive type as string

◆ primitiveTypeId()

auto SFCGAL::Cylinder::primitiveTypeId ( ) const -> PrimitiveType
nodiscardoverride

returns a code corresponding to the type

Returns
a code corresponding to the type

◆ radius()

auto SFCGAL::Cylinder::radius ( ) const -> const Kernel::FT &
inlinenodiscard

Gets the radius of the cylinder.

Returns
The radius

◆ setHeight()

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

Sets the height of the cylinder.

Parameters
heightThe new height

◆ setNumRadial()

void SFCGAL::Cylinder::setNumRadial ( unsigned int num)

Sets the number of radial divisions.

Parameters
numThe new number of radial divisions

◆ setRadius()

void SFCGAL::Cylinder::setRadius ( const Kernel::FT & radius)

Sets the radius of the cylinder.

Parameters
radiusThe new radius

◆ validateParameters()

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.