\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 4.9 - Polygon Mesh Processing
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Combinatorial Repairing

Functions to orient polygon soups and to stitch geometrically identical boundaries.

Functions

template<class PolygonRange >
bool CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh (const PolygonRange &polygons)
 returns true if the soup of polygons defines a valid polygon mesh that can be handled by CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(). More...
 
template<class PolygonMesh , class Point , class Polygon >
void CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh (const std::vector< Point > &points, const std::vector< Polygon > &polygons, PolygonMesh &out)
 builds a polygon mesh from a soup of polygons. More...
 
template<typename PolygonMesh , typename HalfedgePairsRange , typename NamedParameters >
void CGAL::Polygon_mesh_processing::stitch_borders (PolygonMesh &pmesh, const HalfedgePairsRange &hedge_pairs_to_stitch, const NamedParameters &np)
 Stitches together border halfedges in a polygon mesh. More...
 
template<typename PolygonMesh , class NamedParameters >
void CGAL::Polygon_mesh_processing::stitch_borders (PolygonMesh &pmesh, const NamedParameters &np)
 Same as the other overload but the pairs of halfedges to be stitched are automatically found amongst all border halfedges. More...
 
template<class PointRange , class PolygonRange >
bool CGAL::Polygon_mesh_processing::orient_polygon_soup (PointRange &points, PolygonRange &polygons)
 tries to consistently orient a soup of polygons in 3D space. More...
 

Function Documentation

template<class PolygonRange >
bool CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh ( const PolygonRange &  polygons)

returns true if the soup of polygons defines a valid polygon mesh that can be handled by CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh().

It checks that each edge has at most two incident faces and such an edge is visited in opposite direction along the two face boundaries, no polygon has twice the same vertex, and the polygon soup describes a manifold surface. This function does not require a range of points as an argument since the check is purely topological. To each vertex of the mesh is associated an index that is used in the description of the boundaries of the polygons provided in polygons.

Template Parameters
PolygonRangea model of the concept RandomAccessContainer whose value_type is a model of the concept RandomAccessContainer whose value_type is std::size_t.
Parameters
polygonseach element in the range describes a polygon using the indices of the vertices.
See Also
orient_polygon_soup()

#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>

template<class PointRange , class PolygonRange >
bool CGAL::Polygon_mesh_processing::orient_polygon_soup ( PointRange &  points,
PolygonRange &  polygons 
)

tries to consistently orient a soup of polygons in 3D space.

When it is not possible to produce a combinatorial manifold surface, some points are duplicated. Because a polygon soup does not have any connectivity (each point has as many occurences as the number of polygons it belongs to), duplicating one point (or a pair of points) amounts to duplicate the polygon to which it belongs.

These points are either an endpoint of an edge incident to more than two polygons, an endpoint of an edge between two polygons with incompatible orientations (during the re-orientation process), or more generally a point p at which the intersection of an infinitesimally small ball centered at p with the polygons incident to it is not a topological disk.

The algorithm is described in [1].

Template Parameters
PointRangea model of the concepts RandomAccessContainer and BackInsertionSequence whose value type is the point type
PolygonRangea model of the concept RandomAccessContainer whose value_type is a model of the concept RandomAccessContainer whose value_type is std::size_t.
Parameters
pointspoints of the soup of polygons. Some points might be pushed back to resolve non-manifold or non-orientability issues.
polygonseach element in the vector describes a polygon using the index of the points in points. If needed the order of the indices of a polygon might be reversed.
Returns
true if the orientation operation succeded.
false if some points were duplicated, thus producing a self-intersecting polyhedron.

#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>

Examples:
Polygon_mesh_processing/polygon_soup_example.cpp.
template<class PolygonMesh , class Point , class Polygon >
void CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh ( const std::vector< Point > &  points,
const std::vector< Polygon > &  polygons,
PolygonMesh &  out 
)

builds a polygon mesh from a soup of polygons.

Precondition
the input polygon soup describes a consistently oriented polygon mesh.
Template Parameters
PolygonMesha model of MutableFaceGraph with an internal point property map
Pointa point type that has an operator [] to access coordinates
Polygona std::vector<std::size_t> containing the indices of the points of the face
Parameters
pointspoints of the soup of polygons
polygonseach element in the vector describes a polygon using the index of the points in points
outthe polygon mesh to be built
Precondition
CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(polygons)
See Also
CGAL::Polygon_mesh_processing::orient_polygon_soup()
CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh()

#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>

Examples:
Polygon_mesh_processing/polygon_soup_example.cpp.
template<typename PolygonMesh , typename HalfedgePairsRange , typename NamedParameters >
void CGAL::Polygon_mesh_processing::stitch_borders ( PolygonMesh &  pmesh,
const HalfedgePairsRange &  hedge_pairs_to_stitch,
const NamedParameters &  np 
)

Stitches together border halfedges in a polygon mesh.

The halfedges to be stitched are provided in hedge_pairs_to_stitch. For each pair p in this vector, p.second and its opposite will be removed from pmesh.

The vertices that get removed from pmesh are selected as follows: The pair of halfedges in hedge_pairs_to_stitch are processed linearly. Let p be such a pair. If the target of p.first has not been marked for deletion, then the source of p.second is. If the target of p.second has not been marked for deletion, then the source of p.first is. A vertex is marked for deletion if its corresponding point has already be seen with a vertex previously handled.

Precondition
For each halfedge in a pair of hedge_pairs_to_stitch, the corresponding edge is neither degenerated nor incident to a degenerate edge.
Template Parameters
PolygonMesha model of FaceListGraph and MutableFaceGraph that has a property map for boost::vertex_point_t
HalfedgePairsRangea range of std::pair<boost::graph_traits<PolygonMesh>::halfedge_descriptor, boost::graph_traits<PolygonMesh>::halfedge_descriptor>, model of Range. Its iterator type is InputIterator.
NamedParametersa sequence of Named Parameters
Parameters
pmeshthe polygon mesh to be modified by stitching
hedge_pairs_to_stitcha range of std::pair of halfedges to be stitched together
npoptional Named Parameters described below
Named Parameters
vertex_point_mapthe property map with the points associated to the vertices of pmesh

#include <CGAL/Polygon_mesh_processing/stitch_borders.h>

Examples:
Polygon_mesh_processing/stitch_borders_example.cpp.
template<typename PolygonMesh , class NamedParameters >
void CGAL::Polygon_mesh_processing::stitch_borders ( PolygonMesh &  pmesh,
const NamedParameters &  np 
)

Same as the other overload but the pairs of halfedges to be stitched are automatically found amongst all border halfedges.

Two border halfedges h1 and h2 are set to be stitched if the points associated to the source and target vertices of h1 are the same as those of the target and source vertices of h2 respectively.

Precondition
pmesh does not contains any degenerate border edge.
Template Parameters
PolygonMesha model of FaceListGraph and MutableFaceGraph that has a property map for boost::vertex_point_t
NamedParametersa sequence of Named Parameters
Parameters
pmeshthe polygon mesh to be modified by stitching
npoptional sequence of Named Parameters among the ones listed below
Named Parameters
vertex_point_mapthe property map with the points associated to the vertices of pmesh

#include <CGAL/Polygon_mesh_processing/stitch_borders.h>