SFCGAL  2.3.0
Public Types | Public Member Functions | List of all members
SFCGAL::TriangulatedSurface Class Reference

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

#include <TriangulatedSurface.h>

Inherits SFCGAL::GeometryImpl< Derived, Base >.

Public Types

using iterator = DereferenceIterator< std::vector< std::unique_ptr< Triangle >>::iterator >
 Iterator type for triangulated surface patches. More...
 
using const_iterator = DereferenceIterator< std::vector< std::unique_ptr< Triangle >>::const_iterator >
 Const iterator type for triangulated surface patches. More...
 

Public Member Functions

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

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 type for triangulated surface patches.

Iterator type for triangulated surface patches.

Constructor & Destructor Documentation

SFCGAL::TriangulatedSurface::TriangulatedSurface ( )
default

Empty TriangulatedSurface constructor.

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

Constructor with a vector of triangles.

Parameters
triangleVector of triangles to initialize the surface
SFCGAL::TriangulatedSurface::TriangulatedSurface ( const TriangulatedSurface &  other)

Copy constructor.

Parameters
otherThe triangulated surface to copy from
SFCGAL::TriangulatedSurface::~TriangulatedSurface ( )
overridedefault

destructor

Member Function Documentation

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

Accept a geometry visitor.

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

Accept a const geometry visitor.

Parameters
visitorConst visitor to accept
void SFCGAL::TriangulatedSurface::addPatch ( const Triangle &  patch)
inline

Adds a patch to the TriangulatedSurface.

Parameters
patchThe Triangle object representing the new patch to add.
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
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.
void SFCGAL::TriangulatedSurface::addPatches ( const TriangulatedSurface &  other)

add patches from an other TriangulatedSurface

Parameters
otherThe triangulated surface to add patches from
void SFCGAL::TriangulatedSurface::addTriangle ( const Triangle &  triangle)
inline

add a Triangle to the TriangulatedSurface

Parameters
triangleThe triangle to add
Deprecated:
see addPatch()
void SFCGAL::TriangulatedSurface::addTriangle ( Triangle *  triangle)
inline

add a Triangle to the TriangulatedSurface

Parameters
trianglePointer to the triangle to add
Deprecated:
see addPatch()
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()
void SFCGAL::TriangulatedSurface::addTriangles ( const TriangulatedSurface &  other)

add triangles from an other TriangulatedSurface

Parameters
otherThe triangulated surface to copy triangles from
Deprecated:
see addPatches()
auto SFCGAL::TriangulatedSurface::begin ( ) -> iterator
inline

Get iterator to beginning of patches.

Returns
Iterator to first patch
auto SFCGAL::TriangulatedSurface::begin ( ) const -> const_iterator
inline

Get const iterator to beginning of patches.

Returns
Const iterator to first patch
auto SFCGAL::TriangulatedSurface::coordinateDimension ( ) const -> int
override

Get the coordinate dimension.

Returns
Number of coordinates per point
auto SFCGAL::TriangulatedSurface::dimension ( ) const -> int
override

Get the dimension of the surface.

Returns
2 (surfaces are 2-dimensional)
auto SFCGAL::TriangulatedSurface::dropM ( ) -> bool
override

Drop M coordinate from all points.

Returns
true if M was dropped, false otherwise
auto SFCGAL::TriangulatedSurface::dropZ ( ) -> bool
override

Drop Z coordinate from all points.

Returns
true if Z was dropped, false otherwise
auto SFCGAL::TriangulatedSurface::end ( ) -> iterator
inline

Get iterator to end of patches.

Returns
Iterator to past-the-end
auto SFCGAL::TriangulatedSurface::end ( ) const -> const_iterator
inline

Get const iterator to end of patches.

Returns
Const iterator to past-the-end
auto SFCGAL::TriangulatedSurface::geometryType ( ) const -> std::string
override

Get the geometry type as string.

Returns
"TriangulatedSurface"
auto SFCGAL::TriangulatedSurface::geometryTypeId ( ) const -> GeometryType
override

Get the geometry type identifier.

Returns
TYPE_TRIANGULATEDSURFACE
auto SFCGAL::TriangulatedSurface::is3D ( ) const -> bool
override

Check if the surface has 3D coordinates.

Returns
true if 3D, false otherwise
auto SFCGAL::TriangulatedSurface::isEmpty ( ) const -> bool
override

Check if the surface is empty.

Returns
true if empty, false otherwise
auto SFCGAL::TriangulatedSurface::isMeasured ( ) const -> bool
override

Check if the surface has measured coordinates.

Returns
true if measured, false otherwise
auto SFCGAL::TriangulatedSurface::numEdges ( ) const -> size_t

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
auto SFCGAL::TriangulatedSurface::numPatches ( ) const -> size_t
inline

[SFA/OGC]Returns the number of patches

Returns
Number of triangular patches
auto SFCGAL::TriangulatedSurface::numTriangles ( ) const -> size_t
inline

[SFA/OGC]Returns the number of triangles

Returns
Number of triangles in the surface
Deprecated:
see numPatches()
auto SFCGAL::TriangulatedSurface::operator= ( TriangulatedSurface  other) -> TriangulatedSurface &

assign operator

Parameters
otherThe triangulated surface to assign from
Returns
Reference to this triangulated surface
auto SFCGAL::TriangulatedSurface::patchN ( size_t const &  index) const -> const Triangle &

[SFA/OGC]Returns the n-th patch

Parameters
indexThe index of the patch to get
Returns
Const reference to the nth triangle patch
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
void SFCGAL::TriangulatedSurface::reserve ( const size_t &  count)

Reserve space for triangles.

Parameters
countNumber of triangles to reserve space for
template<class Archive >
void SFCGAL::TriangulatedSurface::serialize ( Archive &  ar,
const unsigned  int 
)
inline

Serializer.

Parameters
arArchive for serialization
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
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
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.
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
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
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.
auto SFCGAL::TriangulatedSurface::swapXY ( ) -> void
override

Swap X and Y coordinates of all points.

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.
auto SFCGAL::TriangulatedSurface::toSurfaceMesh ( ) const -> Surface_mesh_3

Convert TriangulatedSurface to CGAL::Surface_mesh.

Returns
CGAL Surface_mesh representation of the triangulated surface
auto SFCGAL::TriangulatedSurface::triangleN ( size_t const &  index) const -> const Triangle &
inline

[SFA/OGC]Returns the n-th triangle

Parameters
indexThe triangle index
Returns
Const reference to the nth triangle
Deprecated:
see patchN()
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()