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

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

#include <Torus.h>

Inherits SFCGAL::PrimitiveImpl< Derived, Base >.

Public Member Functions

 Torus (const Kernel::FT &main_radius=10.0, const Kernel::FT &tube_radius=2.0, unsigned int main_num_radial=32, unsigned int tube_num_radial=16)
 Constructs a Torus object centered on the origin and lying in the XY plane. More...
 
 Torus (const Torus &other)=default
 Copy constructor. More...
 
auto primitiveType () const -> std::string override
 returns the primitive type More...
 
auto primitiveTypeId () const -> PrimitiveType override
 
 ~Torus () override=default
 Destructor. More...
 
void setMainRadius (const Kernel::FT &main_radius)
 Sets the main radius of the torus. More...
 
void setTubeRadius (const Kernel::FT &tube_radius)
 Sets the tube radius of the torus. More...
 
void setMainNumRadial (const unsigned int &main_num_radial)
 Sets the main number of radial divisions. More...
 
void setTubeNumRadial (const unsigned int &tube_num_radial)
 Sets the number of radial divisions for the tube. More...
 
auto mainRadius () const -> const Kernel::FT &
 Gets the main radius of the torus. More...
 
auto tubeRadius () const -> const Kernel::FT &
 Gets the tube radius of the torus. More...
 
auto mainNumRadial () const -> unsigned int
 Gets the number of main radial divisions. More...
 
auto tubeNumRadial () const -> unsigned int
 Gets the number of radial divisions for the tube. More...
 
auto generatePolyhedralSurface () const -> PolyhedralSurface override
 Generates a surface mesh representation of the torus. 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 torus in 3D space.

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

Constructor & Destructor Documentation

SFCGAL::Torus::Torus ( const Kernel::FT &  main_radius = 10.0,
const Kernel::FT &  tube_radius = 2.0,
unsigned int  main_num_radial = 32,
unsigned int  tube_num_radial = 16 
)

Constructs a Torus object centered on the origin and lying in the XY plane.

Parameters
main_radiusthe main radius of the torus
tube_radiusthe tube radius of the torus
main_num_radialThe number of main radial divisions
tube_num_radialThe number of tube radial divisions
SFCGAL::Torus::Torus ( const Torus &  other)
default

Copy constructor.

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

Destructor.

Member Function Documentation

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

Generates a surface mesh representation of the torus.

Returns
A CGAL::Surface_mesh object representing the torus
auto SFCGAL::Torus::mainNumRadial ( ) const -> unsigned int

Gets the number of main radial divisions.

Returns
The number of main radial divisions
auto SFCGAL::Torus::mainRadius ( ) const -> const Kernel::FT &

Gets the main radius of the torus.

Returns
The main radius
auto SFCGAL::Torus::primitiveType ( ) const -> std::string
override

returns the primitive type

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

Returns
a code corresponding to the type
void SFCGAL::Torus::setMainNumRadial ( const unsigned int &  main_num_radial)

Sets the main number of radial divisions.

Parameters
main_num_radialThe new number of main radial
void SFCGAL::Torus::setMainRadius ( const Kernel::FT &  main_radius)

Sets the main radius of the torus.

Parameters
main_radiusThe new main radius
void SFCGAL::Torus::setTubeNumRadial ( const unsigned int &  tube_num_radial)

Sets the number of radial divisions for the tube.

Parameters
tube_num_radialThe new number of tube radial divisions
void SFCGAL::Torus::setTubeRadius ( const Kernel::FT &  tube_radius)

Sets the tube radius of the torus.

Parameters
tube_radiusThe new tube radius
auto SFCGAL::Torus::tubeNumRadial ( ) const -> unsigned int

Gets the number of radial divisions for the tube.

Returns
The number of tube radial divisions
auto SFCGAL::Torus::tubeRadius ( ) const -> const Kernel::FT &

Gets the tube radius of the torus.

Returns
The tube radius
void SFCGAL::Torus::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.