SFCGAL 2.3.0
SFCGAL::TriangulatedSurface Class Reference

A TriangulatedSurface in SFA modeled as a Triangle soup. More...

#include <TriangulatedSurface.h>

Public Types

using iterator
 Iterator type for triangulated surface patches.
using const_iterator
 Const iterator type for triangulated surface patches.

Public Member Functions

 TriangulatedSurface ()
 Empty TriangulatedSurface constructor.
 TriangulatedSurface (const std::vector< Triangle > &triangle)
 Constructor with a vector of triangles.
 TriangulatedSurface (const TriangulatedSurface &other)
 Copy constructor.
auto operator= (TriangulatedSurface other) -> TriangulatedSurface &
 assign operator
 ~TriangulatedSurface () override
 destructor
auto geometryType () const -> std::string override
 Get the geometry type as string.
auto geometryTypeId () const -> GeometryType override
 Get the geometry type identifier.
auto dimension () const -> int override
 Get the dimension of the surface.
auto coordinateDimension () const -> int override
 Get the coordinate dimension.
auto isEmpty () const -> bool override
 Check if the surface is empty.
auto is3D () const -> bool override
 Check if the surface has 3D coordinates.
auto isMeasured () const -> bool override
 Check if the surface has measured coordinates.
auto dropZ () -> bool override
 Drop Z coordinate from all points.
auto dropM () -> bool override
 Drop M coordinate from all points.
auto swapXY () -> void override
 Swap X and Y coordinates of all points.
auto numPatches () const -> size_t
 [SFA/OGC]Returns the number of patches
auto patchN (size_t const &index) const -> const Triangle &
 [SFA/OGC]Returns the n-th patch
auto patchN (size_t const &index) -> Triangle &
 [SFA/OGC]Returns the n-th patch
void addPatch (const Triangle &patch)
 Adds a patch to the TriangulatedSurface.
void addPatch (Triangle *patch)
 Adds a patch to the TriangulatedSurface.
void addPatch (std::unique_ptr< Triangle > patch)
 Adds a patch to the TriangulatedSurface.
void addPatches (const TriangulatedSurface &other)
 add patches from an other TriangulatedSurface
auto numTriangles () const -> size_t
 [SFA/OGC]Returns the number of triangles
auto triangleN (size_t const &index) const -> const Triangle &
 [SFA/OGC]Returns the n-th triangle
auto triangleN (size_t const &index) -> Triangle &
 [SFA/OGC]Returns the n-th triangle
void addTriangle (const Triangle &triangle)
 add a Triangle to the TriangulatedSurface
void addTriangle (Triangle *triangle)
 add a Triangle to the TriangulatedSurface
void addTriangle (std::unique_ptr< Triangle > triangle)
 add a Triangle to the TriangulatedSurface
void addTriangles (const TriangulatedSurface &other)
 add triangles from an other TriangulatedSurface
void setPatchN (const Geometry &geometry, size_t const &idx)
 Sets the n-th Geometry, starting at zero It needs to be a triangle.
void setPatchN (Geometry *geometry, size_t const &idx)
 Sets the n-th Geometry, starting at zero It needs to be a triangle.
void setPatchN (std::unique_ptr< Geometry > geometry, size_t const &idx)
 Sets the n-th patch in the TriangulatedSurface.
void setPatchN (const Triangle &triangle, size_t const &idx)
 Sets the n-th Patch, starting at zero.
void setPatchN (Triangle *triangle, size_t const &idx)
 Sets the n-th Patch, starting at zero The ownership of the polygon is taken.
void setPatchN (std::unique_ptr< Triangle > triangle, size_t const &idx)
 Sets the n-th patch in the TriangulatedSurface.
void reserve (const size_t &count)
 Reserve space for triangles.
auto begin () -> iterator
 Get iterator to beginning of patches.
auto begin () const -> const_iterator
 Get const iterator to beginning of patches.
auto end () -> iterator
 Get iterator to end of patches.
auto end () const -> const_iterator
 Get const iterator to end of patches.
void accept (GeometryVisitor &visitor) override
 Accept a geometry visitor.
void accept (ConstGeometryVisitor &visitor) const override
 Accept a const geometry visitor.
template<typename Polyhedron>
auto toPolyhedron_3 () const -> std::unique_ptr< Polyhedron >
 Converts the current TriangulatedSurface into a CGAL::Polyhedron_3.
auto toSurfaceMesh () const -> Surface_mesh_3
 Convert TriangulatedSurface to CGAL::Surface_mesh.
auto numEdges () const -> size_t
 Returns the number of edges in the geometry.
template<class Archive>
void serialize (Archive &ar, const unsigned int)
 Serializer.

Detailed Description

A TriangulatedSurface in SFA modeled as a Triangle soup.

Todo
do better than a "triangle soup" or add topological view?

Member Typedef Documentation

◆ const_iterator

Initial value:
std::vector<std::unique_ptr<Triangle>>::const_iterator>
Iterator adapter that dereferences unique_ptr elements automatically.
Definition DereferenceIterator.h:22
DereferenceIterator< std::vector< std::unique_ptr< Geometry > >::const_iterator > const_iterator
Const iterator type for geometry collection.
Definition GeometryCollection.h:30

Const iterator type for triangulated surface patches.

◆ iterator

Initial value:
DereferenceIterator< std::vector< std::unique_ptr< Geometry > >::iterator > iterator
Iterator type for geometry collection.
Definition GeometryCollection.h:27

Iterator type for triangulated surface patches.

Constructor & Destructor Documentation

◆ TriangulatedSurface() [1/3]

SFCGAL::TriangulatedSurface::TriangulatedSurface ( )
default

Empty TriangulatedSurface constructor.

◆ TriangulatedSurface() [2/3]

SFCGAL::TriangulatedSurface::TriangulatedSurface ( const std::vector< Triangle > & triangle)

Constructor with a vector of triangles.

Parameters
triangleVector of triangles to initialize the surface

◆ TriangulatedSurface() [3/3]

SFCGAL::TriangulatedSurface::TriangulatedSurface ( const TriangulatedSurface & other)

Copy constructor.

Parameters
otherThe triangulated surface to copy from

◆ ~TriangulatedSurface()

SFCGAL::TriangulatedSurface::~TriangulatedSurface ( )
overridedefault

destructor

Member Function Documentation

◆ accept() [1/2]

void SFCGAL::TriangulatedSurface::accept ( ConstGeometryVisitor & visitor) const
override

Accept a const geometry visitor.

Parameters
visitorConst visitor to accept

◆ accept() [2/2]

void SFCGAL::TriangulatedSurface::accept ( GeometryVisitor & visitor)
override

Accept a geometry visitor.

Parameters
visitorVisitor to accept

◆ addPatch() [1/3]

void SFCGAL::TriangulatedSurface::addPatch ( const Triangle & patch)
inline

Adds a patch to the TriangulatedSurface.

Parameters
patchThe Triangle object representing the new patch to add.

◆ addPatch() [2/3]

void SFCGAL::TriangulatedSurface::addPatch ( std::unique_ptr< Triangle > patch)
inline

Adds a patch to the TriangulatedSurface.

Parameters
patchA unique pointer to the Triangle object representing the new patch to add. Ownership of this patch is moved into the TriangulatedSurface.

◆ addPatch() [3/3]

void SFCGAL::TriangulatedSurface::addPatch ( Triangle * patch)
inline

Adds a patch to the TriangulatedSurface.

Parameters
patchA raw pointer to the Triangle object representing the new patch to add. Ownership of this patch is transferred to the TriangulatedSurface.
Deprecated
The unique_ptr version should be used instead

◆ addPatches()

void SFCGAL::TriangulatedSurface::addPatches ( const TriangulatedSurface & other)

add patches from an other TriangulatedSurface

Parameters
otherThe triangulated surface to add patches from

◆ addTriangle() [1/3]

void SFCGAL::TriangulatedSurface::addTriangle ( const Triangle & triangle)
inline

add a Triangle to the TriangulatedSurface

Parameters
triangleThe triangle to add
Deprecated
see addPatch()

◆ addTriangle() [2/3]

void SFCGAL::TriangulatedSurface::addTriangle ( std::unique_ptr< Triangle > triangle)
inline

add a Triangle to the TriangulatedSurface

Parameters
triangleUnique pointer to the triangle to add
Deprecated
see addPatch()

◆ addTriangle() [3/3]

void SFCGAL::TriangulatedSurface::addTriangle ( Triangle * triangle)
inline

add a Triangle to the TriangulatedSurface

Parameters
trianglePointer to the triangle to add
Deprecated
see addPatch()

◆ addTriangles()

void SFCGAL::TriangulatedSurface::addTriangles ( const TriangulatedSurface & other)

add triangles from an other TriangulatedSurface

Parameters
otherThe triangulated surface to copy triangles from
Deprecated
see addPatches()

◆ begin() [1/2]

auto SFCGAL::TriangulatedSurface::begin ( ) -> iterator
inline

Get iterator to beginning of patches.

Returns
Iterator to first patch

◆ begin() [2/2]

auto SFCGAL::TriangulatedSurface::begin ( ) const -> const_iterator
inlinenodiscard

Get const iterator to beginning of patches.

Returns
Const iterator to first patch

◆ coordinateDimension()

auto SFCGAL::TriangulatedSurface::coordinateDimension ( ) const -> int
nodiscardoverride

Get the coordinate dimension.

Returns
Number of coordinates per point

◆ dimension()

auto SFCGAL::TriangulatedSurface::dimension ( ) const -> int
nodiscardoverride

Get the dimension of the surface.

Returns
2 (surfaces are 2-dimensional)

◆ dropM()

auto SFCGAL::TriangulatedSurface::dropM ( ) -> bool
override

Drop M coordinate from all points.

Returns
true if M was dropped, false otherwise

◆ dropZ()

auto SFCGAL::TriangulatedSurface::dropZ ( ) -> bool
override

Drop Z coordinate from all points.

Returns
true if Z was dropped, false otherwise

◆ end() [1/2]

auto SFCGAL::TriangulatedSurface::end ( ) -> iterator
inline

Get iterator to end of patches.

Returns
Iterator to past-the-end

◆ end() [2/2]

auto SFCGAL::TriangulatedSurface::end ( ) const -> const_iterator
inlinenodiscard

Get const iterator to end of patches.

Returns
Const iterator to past-the-end

◆ geometryType()

auto SFCGAL::TriangulatedSurface::geometryType ( ) const -> std::string
nodiscardoverride

Get the geometry type as string.

Returns
"TriangulatedSurface"

◆ geometryTypeId()

auto SFCGAL::TriangulatedSurface::geometryTypeId ( ) const -> GeometryType
nodiscardoverride

Get the geometry type identifier.

Returns
TYPE_TRIANGULATEDSURFACE

◆ is3D()

auto SFCGAL::TriangulatedSurface::is3D ( ) const -> bool
nodiscardoverride

Check if the surface has 3D coordinates.

Returns
true if 3D, false otherwise

◆ isEmpty()

auto SFCGAL::TriangulatedSurface::isEmpty ( ) const -> bool
nodiscardoverride

Check if the surface is empty.

Returns
true if empty, false otherwise

◆ isMeasured()

auto SFCGAL::TriangulatedSurface::isMeasured ( ) const -> bool
nodiscardoverride

Check if the surface has measured coordinates.

Returns
true if measured, false otherwise

◆ numEdges()

auto SFCGAL::TriangulatedSurface::numEdges ( ) const -> size_t
nodiscard

Returns the number of edges in the geometry.

Convert the geometry to a CGAL::Surface_mesh and use the mesh number_of_edges accessor. As the conversion to a Surface mesh may be costly, it is advised not to call this method into a for-loop.

Returns
Number of edges in the geometry

◆ numPatches()

auto SFCGAL::TriangulatedSurface::numPatches ( ) const -> size_t
inlinenodiscard

[SFA/OGC]Returns the number of patches

Returns
Number of triangular patches

◆ numTriangles()

auto SFCGAL::TriangulatedSurface::numTriangles ( ) const -> size_t
inlinenodiscard

[SFA/OGC]Returns the number of triangles

Returns
Number of triangles in the surface
Deprecated
see numPatches()

◆ operator=()

auto SFCGAL::TriangulatedSurface::operator= ( TriangulatedSurface other) -> TriangulatedSurface &

assign operator

Parameters
otherThe triangulated surface to assign from
Returns
Reference to this triangulated surface

◆ patchN() [1/2]

auto SFCGAL::TriangulatedSurface::patchN ( size_t const & index) -> Triangle &

[SFA/OGC]Returns the n-th patch

Parameters
indexThe index of the patch to get
Returns
Reference to the nth triangle patch

◆ patchN() [2/2]

auto SFCGAL::TriangulatedSurface::patchN ( size_t const & index) const -> const Triangle &
nodiscard

[SFA/OGC]Returns the n-th patch

Parameters
indexThe index of the patch to get
Returns
Const reference to the nth triangle patch

◆ reserve()

void SFCGAL::TriangulatedSurface::reserve ( const size_t & count)

Reserve space for triangles.

Parameters
countNumber of triangles to reserve space for

◆ serialize()

template<class Archive>
void SFCGAL::TriangulatedSurface::serialize ( Archive & ar,
const unsigned int  )
inline

Serializer.

Parameters
arArchive for serialization

◆ setPatchN() [1/6]

void SFCGAL::TriangulatedSurface::setPatchN ( const Geometry & geometry,
size_t const & idx )

Sets the n-th Geometry, starting at zero It needs to be a triangle.

Parameters
geometryThe geometry to set (must be a triangle)
idxThe index of the patch to set

◆ setPatchN() [2/6]

void SFCGAL::TriangulatedSurface::setPatchN ( const Triangle & triangle,
size_t const & idx )

Sets the n-th Patch, starting at zero.

Parameters
triangleThe triangle to set
idxThe index of the patch to set

◆ setPatchN() [3/6]

void SFCGAL::TriangulatedSurface::setPatchN ( Geometry * geometry,
size_t const & idx )

Sets the n-th Geometry, starting at zero It needs to be a triangle.

The ownership of the polygon is taken. The caller is not responsible anymore of its deallocation.

Parameters
geometryPointer to the geometry to set (must be a triangle)
idxThe index of the patch to set

◆ setPatchN() [4/6]

void SFCGAL::TriangulatedSurface::setPatchN ( std::unique_ptr< Geometry > geometry,
size_t const & idx )

Sets the n-th patch in the TriangulatedSurface.

Replaces the patch at the specified index with the provided one. Only Triangle geometries are allowed. Indexing starts at zero.

Parameters
geometryA unique pointer to the Geometry object to set. Ownership is transferred to this class.
idxThe zero-based index of the patch to replace.

◆ setPatchN() [5/6]

void SFCGAL::TriangulatedSurface::setPatchN ( std::unique_ptr< Triangle > triangle,
size_t const & idx )

Sets the n-th patch in the TriangulatedSurface.

Replaces the patch at the specified index with the provided one. Indexing starts at zero.

Parameters
triangleA unique pointer to the Triangle object to set. Ownership is transferred to this class.
idxThe zero-based index of the patch to replace.

◆ setPatchN() [6/6]

void SFCGAL::TriangulatedSurface::setPatchN ( Triangle * triangle,
size_t const & idx )

Sets the n-th Patch, starting at zero The ownership of the polygon is taken.

The caller is not responsible anymore of its deallocation.

Parameters
trianglePointer to the triangle to set
idxThe index of the patch to set
Deprecated
The unique_ptr version should be used instead

◆ swapXY()

auto SFCGAL::TriangulatedSurface::swapXY ( ) -> void
override

Swap X and Y coordinates of all points.

◆ toPolyhedron_3()

template<typename Polyhedron>
auto SFCGAL::TriangulatedSurface::toPolyhedron_3 ( ) const -> std::unique_ptr< Polyhedron >

Converts the current TriangulatedSurface into a CGAL::Polyhedron_3.

This function creates a new Polyhedron instance that represents the geometry of the TriangulatedSurface.

Template Parameters
PolyhedronThe CGAL Polyhedron_3 type.
Returns
std::unique_ptr<Polyhedron> A unique pointer to the newly created Polyhedron.

◆ toSurfaceMesh()

auto SFCGAL::TriangulatedSurface::toSurfaceMesh ( ) const -> Surface_mesh_3
nodiscard

Convert TriangulatedSurface to CGAL::Surface_mesh.

Returns
CGAL Surface_mesh representation of the triangulated surface

◆ triangleN() [1/2]

auto SFCGAL::TriangulatedSurface::triangleN ( size_t const & index) -> Triangle &
inline

[SFA/OGC]Returns the n-th triangle

Parameters
indexThe triangle index
Returns
Reference to the nth triangle
Deprecated
see patchN()

◆ triangleN() [2/2]

auto SFCGAL::TriangulatedSurface::triangleN ( size_t const & index) const -> const Triangle &
inlinenodiscard

[SFA/OGC]Returns the n-th triangle

Parameters
indexThe triangle index
Returns
Const reference to the nth triangle
Deprecated
see patchN()