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

A PolyhedralSurface in SFA modeled as a Polygon soup. More...

#include <PolyhedralSurface.h>

Inherits SFCGAL::GeometryImpl< Derived, Base >.

Public Types

using iterator = DereferenceIterator< std::vector< std::unique_ptr< Polygon >>::iterator >
 Iterator type for polyhedral surface patches. More...
 
using const_iterator = DereferenceIterator< std::vector< std::unique_ptr< Polygon >>::const_iterator >
 Const iterator type for polyhedral surface patches. More...
 
using value_type = Polygon
 Value type for container compatibility. More...
 
using reference = Polygon &
 Reference type for container compatibility. More...
 
using const_reference = const Polygon &
 Const reference type for container compatibility. More...
 

Public Member Functions

 PolyhedralSurface ()
 Empty PolyhedralSurface constructor. More...
 
 PolyhedralSurface (const std::vector< Polygon > &polygons)
 Constructor with a vector of polygons. More...
 
 PolyhedralSurface (const std::unique_ptr< Geometry > &geometry)
 Constructor with a Geometry. More...
 
template<typename Polyhedron >
 PolyhedralSurface (const Polyhedron &poly)
 Constructor from a Polyhedron (detail::MarkedPolyhedron or CGAL::Polyhedron_3) More...
 
 PolyhedralSurface (const Mesh &sm, bool simplifyTriangulation=true)
 Constructor from a CGAL::Surface_mesh. More...
 
 PolyhedralSurface (const InexactMesh &inexactMesh)
 Constructor from an inexact CGAL::Surface_mesh. More...
 
 PolyhedralSurface (const PolyhedralSurface &other)
 Copy constructor. More...
 
auto operator= (PolyhedralSurface other) -> PolyhedralSurface &
 assign operator More...
 
 ~PolyhedralSurface () 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 polyhedral surface. More...
 
auto coordinateDimension () const -> int override
 Get the coordinate dimension. More...
 
auto isEmpty () const -> bool override
 Check if the polyhedral surface is empty. More...
 
auto is3D () const -> bool override
 Check if the polyhedral surface has 3D coordinates. More...
 
auto isMeasured () const -> bool override
 Check if the polyhedral surface has measured coordinates. More...
 
auto dropZ () -> bool override
 Drop Z coordinate from all polygons. More...
 
auto dropM () -> bool override
 Drop M coordinate from all polygons. More...
 
auto swapXY () -> void override
 Swap X and Y coordinates of all polygons. More...
 
auto toTriangulatedSurface () const -> TriangulatedSurface
 Convert PolyhedralSurface to TriangulatedSurface. More...
 
auto numPatches () const -> size_t
 [SFA/OGC]Returns the number of patches More...
 
auto numPolygons () const -> size_t
 [SFA/OGC]Returns the number of polygons More...
 
auto patchN (size_t const &index) const -> const Polygon &
 [SFA/OGC]Returns the n-th patch More...
 
auto patchN (size_t const &index) -> Polygon &
 [SFA/OGC]Returns the n-th patch More...
 
void addPatch (const Polygon &patch)
 Adds a polygonal patch to the PolyhedralSurface. More...
 
void addPatch (Polygon *patch)
 Adds a polygonal patch to the PolyhedralSurface. More...
 
void addPatch (std::unique_ptr< Polygon > patch)
 Adds a polygonal patch to the PolyhedralSurface. More...
 
void addPatches (const PolyhedralSurface &polyhedralSurface)
 add patches from an other PolyhedralSurface More...
 
auto polygonN (size_t const &index) const -> const Polygon &
 [SFA/OGC]Returns the n-th polygon More...
 
auto polygonN (size_t const &index) -> Polygon &
 [SFA/OGC]Returns the n-th polygon More...
 
void addPolygon (const Polygon &polygon)
 add a polygon to the PolyhedralSurface More...
 
void addPolygon (Polygon *polygon)
 add a polygon to the PolyhedralSurface More...
 
void addPolygons (const PolyhedralSurface &polyhedralSurface)
 add polygons from an other PolyhedralSurface More...
 
void setPatchN (const Geometry &geometry, size_t const &idx)
 Sets the n-th Geometry, starting at zero. More...
 
void setPatchN (Geometry *geometry, size_t const &idx)
 Sets the n-th Geometry, starting at zero. More...
 
void setPatchN (std::unique_ptr< Geometry > geometry, size_t const &idx)
 Sets the n-th patch in the PolyhedralSurface. More...
 
void setPatchN (const Polygon &patch, size_t const &idx)
 Sets the n-th Patch, starting at zero. More...
 
void setPatchN (Polygon *patch, size_t const &idx)
 Sets the n-th Patch, starting at zero. More...
 
void setPatchN (std::unique_ptr< Polygon > patch, size_t const &idx)
 Sets the n-th patch in the PolyhedralSurface. More...
 
template<typename Polyhedron >
auto toPolyhedron_3 () const -> std::unique_ptr< Polyhedron >
 Convert to CGAL::Polyhedron_3. 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...
 
auto toSurfaceMesh () const -> Surface_mesh_3
 Convert PolyhedralSurface 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...
 
void push_back (const Polygon &polygon)
 Add a polygon patch (container compatibility) More...
 

Detailed Description

A PolyhedralSurface in SFA modeled as a Polygon soup.

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

Member Typedef Documentation

Const iterator type for polyhedral surface patches.

Const reference type for container compatibility.

Iterator type for polyhedral surface patches.

Reference type for container compatibility.

Value type for container compatibility.

Constructor & Destructor Documentation

SFCGAL::PolyhedralSurface::PolyhedralSurface ( )
default

Empty PolyhedralSurface constructor.

SFCGAL::PolyhedralSurface::PolyhedralSurface ( const std::vector< Polygon > &  polygons)

Constructor with a vector of polygons.

Parameters
polygonsVector of polygons to initialize the surface
SFCGAL::PolyhedralSurface::PolyhedralSurface ( const std::unique_ptr< Geometry > &  geometry)

Constructor with a Geometry.

Parameters
geometryThe geometry to convert to polyhedral surface
template<typename Polyhedron >
SFCGAL::PolyhedralSurface::PolyhedralSurface ( const Polyhedron &  poly)
inline

Constructor from a Polyhedron (detail::MarkedPolyhedron or CGAL::Polyhedron_3)

Template Parameters
PolyhedronThe CGAL polyhedron type
Parameters
polyThe polyhedron to convert
SFCGAL::PolyhedralSurface::PolyhedralSurface ( const Mesh &  sm,
bool  simplifyTriangulation = true 
)

Constructor from a CGAL::Surface_mesh.

Parameters
smThe surface mesh to convert
simplifyTriangulationIf set to true, the conversion reconstructs patches by merging adjacent triangles (i.e. removes the triangulation). Boundaries, including holes, are kept.

If set to false, the output surface is fully triangulated.

SFCGAL::PolyhedralSurface::PolyhedralSurface ( const InexactMesh &  inexactMesh)

Constructor from an inexact CGAL::Surface_mesh.

Parameters
inexactMeshThe inexact surface mesh to convert
SFCGAL::PolyhedralSurface::PolyhedralSurface ( const PolyhedralSurface &  other)

Copy constructor.

Parameters
otherThe polyhedral surface to copy from
SFCGAL::PolyhedralSurface::~PolyhedralSurface ( )
overridedefault

destructor

Member Function Documentation

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

Accept a geometry visitor.

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

Accept a const geometry visitor.

Parameters
visitorConst visitor to accept
void SFCGAL::PolyhedralSurface::addPatch ( const Polygon &  patch)

Adds a polygonal patch to the PolyhedralSurface.

Parameters
patchThe Polygon object representing the new patch to add.
void SFCGAL::PolyhedralSurface::addPatch ( Polygon *  patch)

Adds a polygonal patch to the PolyhedralSurface.

Parameters
patchA raw pointer to the Polygon object representing the new patch to add. Ownership of this patch is moved into the PolyhedralSurface.
Deprecated:
The unique_ptr version should be used instead
void SFCGAL::PolyhedralSurface::addPatch ( std::unique_ptr< Polygon >  patch)

Adds a polygonal patch to the PolyhedralSurface.

Parameters
patchA unique pointer to the Polygon object representing the new patch to add. Ownership of this patch is moved into the PolyhedralSurface.
void SFCGAL::PolyhedralSurface::addPatches ( const PolyhedralSurface &  polyhedralSurface)

add patches from an other PolyhedralSurface

Parameters
polyhedralSurfaceThe polyhedral surface to add patches from
void SFCGAL::PolyhedralSurface::addPolygon ( const Polygon &  polygon)

add a polygon to the PolyhedralSurface

Parameters
polygonThe polygon to add
Deprecated:
see addPatch()
void SFCGAL::PolyhedralSurface::addPolygon ( Polygon *  polygon)

add a polygon to the PolyhedralSurface

Parameters
polygonThe polygon to add
Deprecated:
see addPatch()
void SFCGAL::PolyhedralSurface::addPolygons ( const PolyhedralSurface &  polyhedralSurface)

add polygons from an other PolyhedralSurface

Parameters
polyhedralSurfaceThe polyhedral surface to add polygons from
Deprecated:
see addPatches()
auto SFCGAL::PolyhedralSurface::begin ( ) -> iterator
inline

Get iterator to beginning of patches.

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

Get const iterator to beginning of patches.

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

Get the coordinate dimension.

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

Get the dimension of the polyhedral surface.

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

Drop M coordinate from all polygons.

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

Drop Z coordinate from all polygons.

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

Get iterator to end of patches.

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

Get const iterator to end of patches.

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

Get the geometry type as string.

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

Get the geometry type identifier.

Returns
TYPE_POLYHEDRALSURFACE
auto SFCGAL::PolyhedralSurface::is3D ( ) const -> bool
override

Check if the polyhedral surface has 3D coordinates.

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

Check if the polyhedral surface is empty.

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

Check if the polyhedral surface has measured coordinates.

Returns
true if measured, false otherwise
auto SFCGAL::PolyhedralSurface::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::PolyhedralSurface::numPatches ( ) const -> size_t
inline

[SFA/OGC]Returns the number of patches

Returns
Number of polygonal patches in the surface
Warning
PolyhedralSurface is treated as one geometry. numGeometries returns 1 or 0 for empty PolyhedralSurface
auto SFCGAL::PolyhedralSurface::numPolygons ( ) const -> size_t
inline

[SFA/OGC]Returns the number of polygons

Returns
Number of polygons in the surface
Warning
PolyhedralSurface is treated as one geometry. numGeometries returns 1 or 0 for empty PolyhedralSurface
Deprecated:
see numPatches
See also
numGeometries()
auto SFCGAL::PolyhedralSurface::operator= ( PolyhedralSurface  other) -> PolyhedralSurface &

assign operator

Parameters
otherThe polyhedral surface to assign from
Returns
Reference to this polyhedral surface
auto SFCGAL::PolyhedralSurface::patchN ( size_t const &  index) const -> const Polygon &
inline

[SFA/OGC]Returns the n-th patch

Parameters
indexThe index of the patch to get
Returns
Const reference to the nth patch
auto SFCGAL::PolyhedralSurface::patchN ( size_t const &  index) -> Polygon &
inline

[SFA/OGC]Returns the n-th patch

Parameters
indexThe index of the patch to get
Returns
Reference to the nth patch
auto SFCGAL::PolyhedralSurface::polygonN ( size_t const &  index) const -> const Polygon &
inline

[SFA/OGC]Returns the n-th polygon

Parameters
indexIndex of the polygon to get
Returns
Const reference to the nth polygon
Deprecated:
see patchN()
auto SFCGAL::PolyhedralSurface::polygonN ( size_t const &  index) -> Polygon &
inline

[SFA/OGC]Returns the n-th polygon

Parameters
indexIndex of the polygon to get
Returns
Reference to the nth polygon
Deprecated:
see patchN()
void SFCGAL::PolyhedralSurface::push_back ( const Polygon &  polygon)
inline

Add a polygon patch (container compatibility)

Parameters
polygonThe polygon to add as a patch
template<class Archive >
void SFCGAL::PolyhedralSurface::serialize ( Archive &  ar,
const unsigned  int 
)
inline

Serializer.

Parameters
arArchive for serialization
void SFCGAL::PolyhedralSurface::setPatchN ( const Geometry &  geometry,
size_t const &  idx 
)

Sets the n-th Geometry, starting at zero.

Parameters
geometryGeometry to set (must be a polygon)
idxIndex of the patch to set
void SFCGAL::PolyhedralSurface::setPatchN ( Geometry *  geometry,
size_t const &  idx 
)

Sets the n-th Geometry, starting at zero.

Parameters
geometryPointer to geometry (must be a polygon)
idxIndex of the patch to set
Note
The ownership of the polygon is taken. The caller is not responsible anymore of its deallocation.
Deprecated:
The unique_ptr version should be used instead
void SFCGAL::PolyhedralSurface::setPatchN ( std::unique_ptr< Geometry >  geometry,
size_t const &  idx 
)

Sets the n-th patch in the PolyhedralSurface.

Replaces the patch at the specified index with the provided one. Only polygon 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::PolyhedralSurface::setPatchN ( const Polygon &  patch,
size_t const &  idx 
)

Sets the n-th Patch, starting at zero.

Parameters
patchPolygon patch to set
idxIndex of the patch to set
void SFCGAL::PolyhedralSurface::setPatchN ( Polygon *  patch,
size_t const &  idx 
)

Sets the n-th Patch, starting at zero.

Parameters
patchPointer to polygon patch
idxIndex of the patch to set
Note
The ownership of the polygon is taken. The caller is not responsible anymore of its deallocation.
Deprecated:
The unique_ptr version should be used instead
void SFCGAL::PolyhedralSurface::setPatchN ( std::unique_ptr< Polygon >  patch,
size_t const &  idx 
)

Sets the n-th patch in the PolyhedralSurface.

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

Parameters
patchA unique pointer to the Polygon object to set. Ownership is transferred to this class.
idxThe zero-based index of the patch to replace.
auto SFCGAL::PolyhedralSurface::swapXY ( ) -> void
override

Swap X and Y coordinates of all polygons.

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

Convert to CGAL::Polyhedron_3.

Returns
Unique pointer to CGAL polyhedron representation
auto SFCGAL::PolyhedralSurface::toSurfaceMesh ( ) const -> Surface_mesh_3

Convert PolyhedralSurface to CGAL::Surface_mesh.

Returns
CGAL Surface_mesh representation of the polyhedral surface
auto SFCGAL::PolyhedralSurface::toTriangulatedSurface ( ) const -> TriangulatedSurface

Convert PolyhedralSurface to TriangulatedSurface.

Returns
A triangulated surface representation