|
SFCGAL 2.3.0
|
Abstract base class for primitive object (Cube, Cylinder, Cone, etc.). More...
#include <Primitive.h>
Public Member Functions | |
| Primitive ()=default | |
| Default constructor. | |
| virtual | ~Primitive ()=default |
| Destructor. | |
| auto | clone () const -> std::unique_ptr< Primitive > |
| Get a deep copy of the primitive. | |
| virtual auto | primitiveType () const -> std::string=0 |
| returns the primitive type | |
| virtual auto | primitiveTypeId () const -> PrimitiveType=0 |
| virtual auto | generatePolyhedralSurface () const -> PolyhedralSurface=0 |
| Generates a surface mesh representation of the primitive. | |
| void | setParameter (const std::string &name, const PrimitiveParameter ¶meter) |
| Sets the value of a primitive parameter. | |
| auto | parameter (const std::string &name) const -> PrimitiveParameter |
Retrieves the value of a primitive parameter based ont its name. | |
| auto | parameters () const -> std::unordered_map< std::string, PrimitiveParameter > |
| Retrieves the list of parameters. | |
| void | setTransformation (const Kernel::Aff_transformation_3 &transform) |
| Sets the primitive affine transformation. | |
| auto | transformation () const -> Kernel::Aff_transformation_3 |
| Retrieves the primitive affine transformation. | |
| void | translate (const Kernel::Vector_3 &vector) |
| Translates the primitive by the given vector. | |
| void | rotate (const Kernel::FT &angle, const Kernel::Vector_3 &axis, const Kernel::Point_3 ¢er=Kernel::Point_3(0, 0, 0)) |
| Rotates the primitive around a specified axis and center point by a given angle. | |
| void | scale (const Kernel::Vector_3 &factors, const Kernel::Point_3 ¢er=Kernel::Point_3(0, 0, 0)) |
| Scales the primitive by the given factor. | |
| auto | volume (bool withDiscretization=false) const -> double |
| Returns the primitive volume. | |
| virtual auto | baseVolume (bool withDiscretization=false) const -> double=0 |
| Returns the sphere volume without scaling. | |
| virtual auto | area3D (bool withDiscretization=false) const -> double=0 |
| Returns the primitive area. | |
| auto | almostEqual (const Primitive &other, double epsilon) const -> bool |
| Equality operator. | |
| virtual auto | toString () const -> std::string |
| Returns string representation of this object. | |
Protected Member Functions | |
| virtual void | invalidateCache () |
| Invalidates the cached geometries. | |
| virtual void | validateParameters (std::unordered_map< std::string, PrimitiveParameter > const &tempParameters) const =0 |
| Verifies that all parameters are valid. | |
| virtual void | validateAndSetParameter (const std::string &name, const PrimitiveParameter ¶meter) |
| Checks that the new value is valid and sets it. | |
| auto | scaleFactor (int columnIdx) const -> double |
| Returns the scale factor for a given column of the affine transform matrix. | |
Protected Attributes | |
| std::unordered_map< std::string, PrimitiveParameter > | m_parameters |
| Holds parameter value according to their name. | |
| std::optional< PolyhedralSurface > | m_polyhedral_surface |
| Cached PolyhedralSurface to avoid regeneration each time we call generatePolyhedralSurface(). | |
| Kernel::Aff_transformation_3 | m_transform = CGAL::IDENTITY |
| Holds primitive affine transformation. | |
Friends | |
| auto | operator<< (std::ostream &out, const Primitive &prim) -> std::ostream & |
| overloaded operator<< | |
Abstract base class for primitive object (Cube, Cylinder, Cone, etc.).
This class provides generic parameter functions to set, get, list member fields. All parameters needed by inherited classes must be declared in the constructor:
|
default |
Default constructor.
|
virtualdefault |
Destructor.
|
nodiscard |
Equality operator.
| other | other geometry to compare to |
| epsilon | allowed tolerance |
|
nodiscardpure virtual |
Returns the primitive area.
| withDiscretization | Computes volume with discretization (true) or as perfect primitive (false). Defaults to false. |
|
pure virtual |
Returns the sphere volume without scaling.
| withDiscretization | Computes volume with discretization (true) or as perfect primitive (false). Defaults to false. |
|
inlinenodiscard |
Get a deep copy of the primitive.
|
pure virtual |
Generates a surface mesh representation of the primitive.
|
protectedvirtual |
Invalidates the cached geometries.
|
nodiscard |
Retrieves the value of a primitive parameter based ont its name.
| name | The name of the parameter to retrieve. |
name must exist. | SFCGAL::Exception | if the parameter does not exist or if the provided variant type is not compatible with the parameter. |
|
nodiscard |
Retrieves the list of parameters.
|
nodiscardpure virtual |
returns the primitive type
|
nodiscardpure virtual |
| void SFCGAL::Primitive::rotate | ( | const Kernel::FT & | angle, |
| const Kernel::Vector_3 & | axis, | ||
| const Kernel::Point_3 & | center = Kernel::Point_3(0, 0, 0) ) |
Rotates the primitive around a specified axis and center point by a given angle.
| angle | Rotation angle in radians |
| axis | The rotation axis. |
| center | The rotation center |
| void SFCGAL::Primitive::scale | ( | const Kernel::Vector_3 & | factors, |
| const Kernel::Point_3 & | center = Kernel::Point_3(0, 0, 0) ) |
Scales the primitive by the given factor.
| factors | The scale factors. |
| center | The scale center. |
|
protected |
Returns the scale factor for a given column of the affine transform matrix.
| columnIdx | Column index of the transform matrix (0 = X, 1 = Y, 2 = Z). |
| void SFCGAL::Primitive::setParameter | ( | const std::string & | name, |
| const PrimitiveParameter & | parameter ) |
Sets the value of a primitive parameter.
Assigns a new value to the parameter identified by name.
| name | The name of the parameter to set. |
| parameter | The new parameter value as a ::PrimitiveParameter. |
name must exist and accept the provided variant type. | SFCGAL::Exception | if the parameter does not exist or if the provided variant type is not compatible with the parameter. |
| void SFCGAL::Primitive::setTransformation | ( | const Kernel::Aff_transformation_3 & | transform | ) |
Sets the primitive affine transformation.
| transform | The new affine transformation |
|
nodiscardvirtual |
Returns string representation of this object.
Can be overriden by sub-classes.
|
nodiscard |
Retrieves the primitive affine transformation.
| void SFCGAL::Primitive::translate | ( | const Kernel::Vector_3 & | vector | ) |
Translates the primitive by the given vector.
| vector | The translation vector. |
|
protectedvirtual |
Checks that the new value is valid and sets it.
This also invalidates the cache. Unlike setParameter, this does not check that name exists and that it accepts the provided variant type. This assumes that name exists and the variant type is compatible with the parameter
| name | parameter name to check |
| parameter | value |
| SFCGAL::Exception | if the parameter is not valid |
|
protectedpure virtual |
Verifies that all parameters are valid.
For instance, it raises an error if a radius is negative.
| tempParameters | a temp map of parameter with new values |
| SFCGAL::Exception | if one of the parameters if not valid provided variant type is not compatible with the parameter. |
|
nodiscard |
Returns the primitive volume.
| withDiscretization | Computes area with discretization (true) or as perfect primitive (false). Defaults to false. |
|
friend |
overloaded operator<<
| out | stream to fill |
| prim | primitive to print via Primitive::toString() |
|
protected |
Holds parameter value according to their name.
|
mutableprotected |
Cached PolyhedralSurface to avoid regeneration each time we call generatePolyhedralSurface().
|
protected |
Holds primitive affine transformation.