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

Represents a sphere in 3D space centered at the origin. More...

#include <Sphere.h>

Inherits SFCGAL::PrimitiveImpl< Derived, Base >.

Public Member Functions

 Sphere (const Kernel::FT &radius=1.0, unsigned int num_subdivisions=2)
 Constructs a Sphere object. More...
 
 Sphere (const Sphere &other)=default
 Copy constructor. More...
 
 ~Sphere () override=default
 Destructor. 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...
 
void setRadius (const Kernel::FT &radius)
 Sets the radius of the sphere. More...
 
void setNumSubdivisions (unsigned int num)
 Sets the number of subdivisions. More...
 
auto radius () const -> const Kernel::FT &
 Gets the radius of the sphere. More...
 
auto numSubdivisions () const -> unsigned int
 Gets the number of subdivisions. More...
 
auto generatePolyhedron () const -> CGAL::Polyhedron_3< Kernel >
 Generates a polyhedron representation of the sphere. More...
 
auto generatePoints () const -> std::vector< Kernel::Point_3 >
 Generates a point cloud representation of the sphere. More...
 
auto generatePolyhedralSurface () const -> PolyhedralSurface override
 Generates a surface mesh representation of the sphere. 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 sphere area. 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 sphere in 3D space centered at the origin.

This class provides methods to generate a polyhedron and a point cloud representation of a sphere. It uses SFCGAL's Kernel for exact computations.

Constructor & Destructor Documentation

SFCGAL::Sphere::Sphere ( const Kernel::FT &  radius = 1.0,
unsigned int  num_subdivisions = 2 
)

Constructs a Sphere object.

Parameters
radiusThe radius of the sphere
num_subdivisionsThe number of icosahedron subdivisions (0=12 vertices, 1=42, 2=162, etc.)
SFCGAL::Sphere::Sphere ( const Sphere &  other)
default

Copy constructor.

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

Destructor.

Member Function Documentation

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

Returns the sphere area.

Parameters
withDiscretizationComputes area with discretization (true) or as perfect primitive (false). Defaults to false.
Returns
The sphere area
Note
only perfect primitive version is available
auto SFCGAL::Sphere::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::Sphere::generatePoints ( ) const -> std::vector<Kernel::Point_3>

Generates a point cloud representation of the sphere.

Returns
A vector of Point_3 objects representing points on the sphere's surface
auto SFCGAL::Sphere::generatePolyhedralSurface ( ) const -> PolyhedralSurface
override

Generates a surface mesh representation of the sphere.

Returns
A SFCGAL::PolyhedralSurface object representing the sphere
auto SFCGAL::Sphere::generatePolyhedron ( ) const -> CGAL::Polyhedron_3<Kernel>

Generates a polyhedron representation of the sphere.

Returns
A CGAL::Polyhedron_3 object representing the sphere
void SFCGAL::Sphere::invalidateCache ( )
overrideprotected

Invalidates the cached geometries.

auto SFCGAL::Sphere::numSubdivisions ( ) const -> unsigned int
inline

Gets the number of subdivisions.

Returns
The number of subdivisions
auto SFCGAL::Sphere::primitiveType ( ) const -> std::string
override

returns the primitive type

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

returns a code corresponding to the type

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

Gets the radius of the sphere.

Returns
The radius
void SFCGAL::Sphere::setNumSubdivisions ( unsigned int  num)
inline

Sets the number of subdivisions.

Parameters
numThe new number of subdivisions
void SFCGAL::Sphere::setRadius ( const Kernel::FT &  radius)
inline

Sets the radius of the sphere.

Parameters
radiusThe new radius
void SFCGAL::Sphere::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.