Abstract base class for primitive object (Cube, Cylinder, Cone, etc.)
More...
#include <Primitive.h>
Inherited by SFCGAL::PrimitiveImpl< Box, Primitive >, SFCGAL::PrimitiveImpl< Cone, Primitive >, SFCGAL::PrimitiveImpl< Cube, Primitive >, SFCGAL::PrimitiveImpl< Cylinder, Primitive >, SFCGAL::PrimitiveImpl< Sphere, Primitive >, and SFCGAL::PrimitiveImpl< Torus, Primitive >.
|
| | Primitive ()=default |
| | Default constructor. More...
|
| |
| virtual | ~Primitive ()=default |
| | Destructor. More...
|
| |
| auto | clone () const -> std::unique_ptr< Primitive > |
| | Get a deep copy of the primitive. More...
|
| |
| virtual auto | primitiveType () const -> std::string=0 |
| | returns the primitive type More...
|
| |
| virtual auto | primitiveTypeId () const -> PrimitiveType=0 |
| |
| virtual auto | generatePolyhedralSurface () const -> PolyhedralSurface=0 |
| | Generates a surface mesh representation of the primitive. More...
|
| |
| void | setParameter (const std::string &name, const PrimitiveParameter ¶meter) |
| | Sets the value of a primitive parameter. More...
|
| |
| auto | parameter (const std::string &name) const -> PrimitiveParameter |
| | Retrieves the value of a primitive parameter based ont its name. More...
|
| |
| auto | parameters () const -> std::unordered_map< std::string, PrimitiveParameter > |
| | Retrieves the list of parameters. More...
|
| |
| void | setTransformation (const Kernel::Aff_transformation_3 &transform) |
| | Sets the primitive affine transformation. More...
|
| |
| auto | transformation () const -> Kernel::Aff_transformation_3 |
| | Retrieves the primitive affine transformation. More...
|
| |
| void | translate (const Kernel::Vector_3 &vector) |
| | Translates the primitive by the given vector. More...
|
| |
| 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. More...
|
| |
| 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. More...
|
| |
| auto | volume (bool withDiscretization=false) const -> double |
| | Returns the primitive volume. More...
|
| |
| virtual auto | baseVolume (bool withDiscretization=false) const -> double=0 |
| | Returns the sphere volume without scaling. More...
|
| |
| virtual auto | area3D (bool withDiscretization=false) const -> double=0 |
| | Returns the primitive area. More...
|
| |
| auto | almostEqual (const Primitive &other, double epsilon) const -> bool |
| | Equality operator. More...
|
| |
| virtual auto | toString () const -> std::string |
| | Returns string representation of this object. More...
|
| |
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:
SubClass::SubClass(const Kernel::FT &radius, const Kernel::FT &height,
unsigned int num)
{
}
| SFCGAL::Primitive::Primitive |
( |
| ) |
|
|
default |
| virtual SFCGAL::Primitive::~Primitive |
( |
| ) |
|
|
virtualdefault |
| auto SFCGAL::Primitive::almostEqual |
( |
const Primitive & |
other, |
|
|
double |
epsilon |
|
) |
| const -> bool |
Equality operator.
- Parameters
-
| other | other geometry to compare to |
| epsilon | allowed tolerance |
- Returns
- true when this is almost equal
| virtual auto SFCGAL::Primitive::area3D |
( |
bool |
withDiscretization = false | ) |
const -> double |
|
pure virtual |
Returns the primitive area.
- Parameters
-
| withDiscretization | Computes volume with discretization (true) or as perfect primitive (false). Defaults to false. |
- Returns
- The primitive volume
| virtual auto SFCGAL::Primitive::baseVolume |
( |
bool |
withDiscretization = false | ) |
const -> double |
|
pure virtual |
Returns the sphere volume without scaling.
- Parameters
-
| withDiscretization | Computes volume with discretization (true) or as perfect primitive (false). Defaults to false. |
- Returns
- The sphere volume
| auto SFCGAL::Primitive::clone |
( |
| ) |
const -> std::unique_ptr<Primitive>
|
|
inline |
Get a deep copy of the primitive.
- Returns
- a deep copy of the primitive as a unique_ptr
| virtual auto SFCGAL::Primitive::generatePolyhedralSurface |
( |
| ) |
const -> PolyhedralSurface |
|
pure virtual |
Generates a surface mesh representation of the primitive.
- Returns
- A PolyhedralSurface object representing the torus
| void SFCGAL::Primitive::invalidateCache |
( |
| ) |
|
|
protectedvirtual |
Invalidates the cached geometries.
Retrieves the value of a primitive parameter based ont its name.
- Parameters
-
| name | The name of the parameter to retrieve. |
- Returns
- The parameter value as a PrimitiveParameter variant.
- Precondition
- The parameter identified by
name must exist.
- Exceptions
-
| SFCGAL::Exception | if the parameter does not exist or if the provided variant type is not compatible with the parameter. |
| auto SFCGAL::Primitive::parameters |
( |
| ) |
const -> std::unordered_map<std::string, PrimitiveParameter> |
Retrieves the list of parameters.
- Returns
- the key/value parameter map
| virtual auto SFCGAL::Primitive::primitiveType |
( |
| ) |
const -> std::string |
|
pure virtual |
returns the primitive type
- Warning
- use CamelCase (Cylinder, not CYLINDER)
- Returns
- the primitive type as string
| virtual auto SFCGAL::Primitive::primitiveTypeId |
( |
| ) |
const -> PrimitiveType |
|
pure virtual |
- Returns
- a code corresponding to the type
| 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.
- Parameters
-
| 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.
- Parameters
-
| factors | The scale factors. |
| center | The scale center. |
| auto SFCGAL::Primitive::scaleFactor |
( |
int |
columnIdx | ) |
const -> double |
|
protected |
Returns the scale factor for a given column of the affine transform matrix.
- Parameters
-
| columnIdx | Column index of the transform matrix (0 = X, 1 = Y, 2 = Z). |
- Returns
- The scale factor along the corresponding axis.
| 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.
- Parameters
-
| name | The name of the parameter to set. |
| parameter | The new parameter value as a PrimitiveParameter. |
- Precondition
- The parameter identified by
name must exist and accept the provided variant type.
- Exceptions
-
| 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.
- Parameters
-
| transform | The new affine transformation |
| auto SFCGAL::Primitive::toString |
( |
| ) |
const -> std::string |
|
virtual |
Returns string representation of this object.
Can be overriden by sub-classes.
- Returns
- string representation of this object
| auto SFCGAL::Primitive::transformation |
( |
| ) |
const -> Kernel::Aff_transformation_3 |
Retrieves the primitive affine transformation.
- Returns
- the primitive affine transformation
| void SFCGAL::Primitive::translate |
( |
const Kernel::Vector_3 & |
vector | ) |
|
Translates the primitive by the given vector.
- Parameters
-
| vector | The translation vector. |
| void SFCGAL::Primitive::validateAndSetParameter |
( |
const std::string & |
name, |
|
|
const PrimitiveParameter & |
parameter |
|
) |
| |
|
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
- Parameters
-
| name | parameter name to check |
| parameter | value |
- Exceptions
-
| virtual void SFCGAL::Primitive::validateParameters |
( |
std::unordered_map< std::string, PrimitiveParameter > const & |
tempParameters | ) |
const |
|
protectedpure virtual |
Verifies that all parameters are valid.
For instance, it raises an error if a radius is negative.
- Parameters
-
| tempParameters | a temp map of parameter with new values |
- Exceptions
-
| SFCGAL::Exception | if one of the parameters if not valid provided variant type is not compatible with the parameter. |
| auto SFCGAL::Primitive::volume |
( |
bool |
withDiscretization = false | ) |
const -> double |
Returns the primitive volume.
- Parameters
-
| withDiscretization | Computes area with discretization (true) or as perfect primitive (false). Defaults to false. |
- Returns
- The cone volume
| auto operator<< |
( |
std::ostream & |
out, |
|
|
const Primitive & |
prim |
|
) |
| -> std::ostream &
|
|
friend |
overloaded operator<<
- Parameters
-
- Returns
- filled stream
Holds parameter value according to their name.
| Kernel::Aff_transformation_3 SFCGAL::Primitive::m_transform = CGAL::IDENTITY |
|
protected |
Holds primitive affine transformation.