CGAL 5.4 - Polygon Mesh Processing

Functions to triangulate faces, and to refine and fair regions of a polygon mesh.

Classes

struct  CGAL::Polygon_mesh_processing::Triangulate_faces::Default_visitor< PolygonMesh >
 Default new face visitor model of PMPTriangulateFaceVisitor. More...
 

Functions

template<class InputMesh , class OutputMesh , class BottomFunctor , class TopFunctor , class NamedParameters1 , class NamedParameters2 >
void CGAL::Polygon_mesh_processing::extrude_mesh (const InputMesh &input, OutputMesh &output, const BottomFunctor &bot, const TopFunctor &top, const NamedParameters1 &np_in, const NamedParameters2 &np_out)
 performs a generalized extrusion of input and puts it in output. More...
 
template<class InputMesh , class OutputMesh , class NamedParameters1 , class NamedParameters2 >
void CGAL::Polygon_mesh_processing::extrude_mesh (const InputMesh &input, OutputMesh &output, Vector_3 v, const NamedParameters1 &np_in, const NamedParameters2 &np_out)
 fills output with a closed mesh bounding the volume swept by input when translating its vertices by v. More...
 
template<typename TriangleMesh , typename VertexRange , typename NamedParameters >
bool CGAL::Polygon_mesh_processing::fair (TriangleMesh &tmesh, const VertexRange &vertices, const NamedParameters &np)
 fairs a region on a triangle mesh. More...
 
template<class TriangleMesh , class NamedParameters >
void CGAL::Polygon_mesh_processing::minimal_angle_remeshing (TriangleMesh &tm, const NamedParameters &np)
 remeshes a triangule mesh using a minimal angle optimization approach. More...
 
template<typename VertexRange , typename TriangleMesh , typename NamedParameters >
void CGAL::Polygon_mesh_processing::random_perturbation (VertexRange vertices, TriangleMesh &tmesh, const double &perturbation_max_size, const NamedParameters &np)
 randomly perturbs the locations of vertices of a triangulated surface mesh. More...
 
template<typename TriangleMesh , typename NamedParameters >
void CGAL::Polygon_mesh_processing::random_perturbation (TriangleMesh &tmesh, const double &perturbation_max_size, const NamedParameters &np)
 same as above, but all non-border vertices of tmesh are perturbed.
 
template<typename TriangleMesh , typename FaceRange , typename FaceOutputIterator , typename VertexOutputIterator , typename NamedParameters >
std::pair< FaceOutputIterator, VertexOutputIterator > CGAL::Polygon_mesh_processing::refine (TriangleMesh &tmesh, const FaceRange &faces, FaceOutputIterator faces_out, VertexOutputIterator vertices_out, const NamedParameters &np)
 refines a region of a triangle mesh More...
 
template<typename PolygonMesh , typename FaceRange , typename NamedParameters >
void CGAL::Polygon_mesh_processing::isotropic_remeshing (const FaceRange &faces, const double &target_edge_length, PolygonMesh &pmesh, const NamedParameters &np)
 remeshes a triangulated region of a polygon mesh. More...
 
template<typename PolygonMesh , typename EdgeRange , typename NamedParameters >
void CGAL::Polygon_mesh_processing::split_long_edges (const EdgeRange &edges, const double &max_length, PolygonMesh &pmesh, const NamedParameters &np)
 splits the edges listed in edges into sub-edges that are not longer than the given threshold max_length. More...
 
template<typename TriangleMesh , typename FaceRange , typename NamedParameters >
void CGAL::Polygon_mesh_processing::smooth_mesh (const FaceRange &faces, TriangleMesh &tmesh, const NamedParameters &np)
 smooths a triangulated region of a polygon mesh. More...
 
template<typename TriangleMesh , typename FaceRange , typename NamedParameters >
void CGAL::Polygon_mesh_processing::smooth_shape (const FaceRange &faces, TriangleMesh &tmesh, const double time, const NamedParameters &np)
 smooths the overall shape of the mesh by using the mean curvature flow. More...
 
template<typename PolygonMesh , typename NamedParameters >
bool CGAL::Polygon_mesh_processing::triangulate_face (typename boost::graph_traits< PolygonMesh >::face_descriptor f, PolygonMesh &pmesh, const NamedParameters &np)
 triangulates a single face of a polygon mesh. More...
 
template<typename FaceRange , typename PolygonMesh , typename NamedParameters >
bool CGAL::Polygon_mesh_processing::triangulate_faces (FaceRange face_range, PolygonMesh &pmesh, const NamedParameters &np)
 triangulates given faces of a polygon mesh. More...
 
template<typename PolygonMesh , typename NamedParameters >
bool CGAL::Polygon_mesh_processing::triangulate_faces (PolygonMesh &pmesh, const NamedParameters &np)
 triangulates all faces of a polygon mesh. More...
 

Function Documentation

◆ extrude_mesh() [1/2]

template<class InputMesh , class OutputMesh , class BottomFunctor , class TopFunctor , class NamedParameters1 , class NamedParameters2 >
void CGAL::Polygon_mesh_processing::extrude_mesh ( const InputMesh &  input,
OutputMesh &  output,
const BottomFunctor &  bot,
const TopFunctor &  top,
const NamedParameters1 &  np_in,
const NamedParameters2 &  np_out 
)

#include <CGAL/Polygon_mesh_processing/extrude.h>

performs a generalized extrusion of input and puts it in output.

This function extrudes the open surface mesh input and puts the result in output. The mesh generated is a closed surface mesh with a bottom and top part, both having the same graph combinatorics as input (except that the orientation of the faces of the bottom part is reversed). The bottom and the top parts are connected by a triangle strip between boundary cycles. The coordinates of the points associated to the vertices of the bottom and top part are first initialized to the same value as the corresponding vertices of input. Then for each vertex, a call to bot and top is done for the vertices of the bottom part and the top part, respectively.

Attention
output may be self intersecting.
Template Parameters
InputMesha model of FaceListGraph
OutputMesha model of FaceListGraph and MutableFaceGraph
NamedParameters1a sequence of Named Parameters for InputMesh
NamedParameters2a sequence of Named Parameters for OutputMesh
BottomFunctora functor providing
void operator()`(boost::graph_traits<InputMesh>::vertex_descriptor input_v,boost::graph_traits<OutputMesh>::vertex_descriptor output_v)
where output_v is the copy of input_v from input into the bottom part of output.
TopFunctora functor providing a similar operator() as BottomFunctor.
Parameters
inputan open surface mesh to extrude.
outputa surface mesh that will contain the result of the extrusion.
botfunctor that will transform all points copied from input in order to shape the bottom part of the extrusion.
topfunctor that will transform all points copied from input in order to shape the top part of the extrusion.
np_inan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of input
  • Type: a class model of ReadablePropertyMap with boost::graph_traits<InputMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, input)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available for the vertices of input.
Parameters
np_outan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of ouput
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<OutputMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, ouput)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available for the vertices of ouput.

◆ extrude_mesh() [2/2]

template<class InputMesh , class OutputMesh , class NamedParameters1 , class NamedParameters2 >
void CGAL::Polygon_mesh_processing::extrude_mesh ( const InputMesh &  input,
OutputMesh &  output,
Vector_3  v,
const NamedParameters1 &  np_in,
const NamedParameters2 &  np_out 
)

#include <CGAL/Polygon_mesh_processing/extrude.h>

fills output with a closed mesh bounding the volume swept by input when translating its vertices by v.

The mesh is oriented so that the faces corresponding to input in output have the same orientation.

Attention
output may be self intersecting.
Template Parameters
InputMesha model of the concept FaceListGraph
OutputMesha model of the concept FaceListGraph and MutableFaceGraph
Vector_3vector type from the same CGAL kernel as the point of the vertex point map used for OutputMesh.
NamedParameters1a sequence of Named Parameters for InputMesh
NamedParameters2a sequence of Named Parameters for OutputMesh
Parameters
inputan open surface mesh to extrude.
outputa surface mesh that will contain the result of the extrusion.
vthe vector defining the direction of the extrusion
np_inan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of input
  • Type: a class model of ReadablePropertyMap with boost::graph_traits<InputMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, input)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available for the vertices of input.
Parameters
np_outan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of output
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<OutputMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, output)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available for the vertices of output.

◆ fair()

template<typename TriangleMesh , typename VertexRange , typename NamedParameters >
bool CGAL::Polygon_mesh_processing::fair ( TriangleMesh &  tmesh,
const VertexRange &  vertices,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/fair.h>

fairs a region on a triangle mesh.

The points of the selected vertices are relocated to yield an as-smooth-as-possible surface patch, based on solving a linear bi-Laplacian system with boundary constraints, described in [3]. The optional parameter fairing_continuity gives the ability to control the tangential continuity C n of the output mesh.

The region described by vertices might contain multiple disconnected components. Note that the mesh connectivity is not altered in any way, only vertex locations get updated.

Fairing might fail if fixed vertices, which are used as boundary conditions, do not suffice to solve constructed linear system.

Note that if the vertex range to which fairing is applied contains all the vertices of the triangle mesh, fairing does not fail, but the mesh gets shrinked to CGAL::ORIGIN.

Template Parameters
TriangleMesha model of FaceGraph and MutableFaceGraph
VertexRangea range of vertex descriptors of TriangleMesh, model of Range. Its iterator type is InputIterator.
NamedParametersa sequence of Named Parameters
Parameters
tmeshthe triangle mesh with patches to be faired
verticesthe vertices of the patches to be faired (the positions of only those vertices will be changed)
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of tmesh
  • Type: a class model of ReadablePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, tmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available for the vertices of tmesh.

  • A value controling the tangential continuity of the output surface patch. The possible values are 0, 1 and 2, refering to the C0, C1 and C2 continuity.
  • Type: unsigned int
  • Default: 1
  • Extra: The larger fairing_continuity gets, the more fixed vertices are required.

Returns
true if fairing is successful, otherwise no vertices are relocated
Precondition
is_triangle_mesh(tmesh)
Warning
This function involves linear algebra, that is computed using a non-exact floating-point arithmetic.
Todo:
accuracy of solvers are not good, for example when there is no boundary condition pre_factor should fail, but it does not.
Examples:
Polygon_mesh_processing/refine_fair_example.cpp.

◆ isotropic_remeshing()

template<typename PolygonMesh , typename FaceRange , typename NamedParameters >
void CGAL::Polygon_mesh_processing::isotropic_remeshing ( const FaceRange &  faces,
const double &  target_edge_length,
PolygonMesh &  pmesh,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/remesh.h>

remeshes a triangulated region of a polygon mesh.

This operation sequentially performs edge splits, edge collapses, edge flips, tangential relaxation and projection to the initial surface to generate a smooth mesh with a prescribed edge length.

Template Parameters
PolygonMeshmodel of MutableFaceGraph. The descriptor types boost::graph_traits<PolygonMesh>::face_descriptor and boost::graph_traits<PolygonMesh>::halfedge_descriptor must be models of Hashable.
FaceRangerange of boost::graph_traits<PolygonMesh>::face_descriptor, model of Range. Its iterator type is ForwardIterator.
NamedParametersa sequence of Named Parameters
Parameters
pmesha polygon mesh with triangulated surface patches to be remeshed
facesthe range of triangular faces defining one or several surface patches to be remeshed
target_edge_lengththe edge length that is targeted in the remeshed patch. If 0 is passed then only the edge-flip, tangential relaxation, and projection steps will be done.
npan optional sequence of Named Parameters among the ones listed below
Precondition
if constraints protection is activated, the constrained edges must not be longer than 4/3*target_edge_length
Optional Named Parameters
  • a property map associating points to the vertices of pmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<PolygonMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, pmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in PolygonMesh.

  • an instance of a geometric traits class
  • Type: a class model of Kernel
  • Default: a CGAL Kernel deduced from the point type, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.
  • Extra: Exact constructions kernels are not supported by this function.

  • a property map associating to each face of pmesh a unique index between 0 and num_faces(pmesh) - 1
  • Type: a class model of ReadablePropertyMap with boost::graph_traits<PolygonMesh>::face_descriptor as key type and std::size_t as value type
  • Default: an automatically indexed internal map

  • the number of iterations for the sequence of atomic operations performed (listed in the above description)
  • Type: unsigned int
  • Default: 1

  • a property map containing the constrained-or-not status of each edge of pmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<PolygonMesh>::edge_descriptor as key type and bool as value type. It must be default constructible.
  • Default: a default property map where no edge is constrained
  • Extra: A constrained edge can be split or collapsed, but not flipped, nor its endpoints moved by smoothing.
  • Extra: Sub-edges generated by splitting are set to be constrained.
  • Extra: Patch boundary edges (i.e. incident to only one face in the range) are always considered as constrained edges.

  • a property map containing the constrained-or-not status of each vertex of pmesh.
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<PolygonMesh>::vertex_descriptor as key type and bool as value type. It must be default constructible.
  • Default: a default property map where no vertex is constrained
  • Extra: A constrained vertex cannot be modified during remeshing.

  • If true, the edges set as constrained in edge_is_constrained_map (or by default the boundary edges) are not split nor collapsed during remeshing.
  • Type: Boolean
  • Default: false
  • Extra: Note that around constrained edges that have their length higher than twice target_edge_length, remeshing will fail to provide good quality results. It can even fail to terminate because of cascading vertex insertions.

  • If true, the edges set as constrained in edge_is_constrained_map (or by default the boundary edges) are collapsed during remeshing.
  • Type: Boolean
  • Default: true
  • Extra: This value is ignored if protect_constraints is true.

  • a property map with the patch id's associated to the faces of faces
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<PolygonMesh>::face_descriptor as key type and the desired property, model of CopyConstructible and LessThanComparable as value type.
  • Default: a default property map where each face is associated with the ID of the connected component it belongs to. Connected components are computed with respect to the constrained edges listed in the property map edge_is_constrained_map
  • Extra: The map is updated during the remeshing process while new faces are created.

  • whether edges that are too long with respect to the given sizing are split
  • Type: Boolean
  • Default: true

  • whether edges that are too short with respect to the given sizing are collapsed
  • Type: Boolean
  • Default: true

  • whether edge flips are performed to improve shape and valence
  • Type: Boolean
  • Default: true

  • the number of iterations of tangential relaxation that are performed at each iteration of the remeshing process
  • Type: unsigned int
  • Default: 1

  • If true, the end vertices of the edges set as constrained in edge_is_constrained_map and boundary edges move along the constrained polylines they belong to.}
  • Type: Boolean
  • Default: false

  • whether vertices should be reprojected on the input surface after creation or displacement
  • Type: Boolean
  • Default: true

  • A function object used to project input vertices (moved by the smoothing) and created vertices
  • Type: Unary functor that provides Point_3 operator()(vertex_descriptor), Point_3 being the value type of the vertex point map.
  • Default: If not provided, vertices are projected on the input surface mesh.
See also
split_long_edges()
Todo:
Deal with exact constructions Kernel. The only thing that makes sense is to guarantee that the output vertices are exactly on the input surface. To do so, we can do every construction in double, and use an exact process for projection. For each vertex, the AABB_tree would be used in an inexact manner to find the triangle on which projection has to be done. Then, use CGAL::intersection(triangle, line) in the exact constructions kernel to get a point which is exactly on the surface.
Examples:
Polygon_mesh_processing/corefinement_difference_remeshed.cpp, Polygon_mesh_processing/hausdorff_bounded_error_distance_example.cpp, Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp, Polygon_mesh_processing/isotropic_remeshing_example.cpp, and Polygon_mesh_processing/polyhedral_envelope_mesh_containment.cpp.

◆ minimal_angle_remeshing()

template<class TriangleMesh , class NamedParameters >
void CGAL::Polygon_mesh_processing::minimal_angle_remeshing ( TriangleMesh &  tm,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/minimal_angle_remeshing.h>

remeshes a triangule mesh using a minimal angle optimization approach.

This operation applies carefully prioritized local operations to greedily search for the coarsest mesh with minimal interior angle threshold and the approximation error threshold defined by the user. The local operations include edge split, edge collapse, edge flip (optional), vertex relocation, and projection to the initial triangular mesh.

Template Parameters
TriangleMeshmodel of MutableFaceGraph. The descriptor types boost::graph_traits<PolygonMesh>::face_descriptor and boost::graph_traits<TriangleMesh>::halfedge_descriptor must be models of Hashable. If TriangleMesh has an internal property map for CGAL::face_index_t, and no face_index_map is given as a named parameter, then the internal one must be initialized
NamedParametersa sequence of Named Parameters
Parameters
tmthe triangle mesh to be remeshed
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • an instance of a geometric traits class
  • Type: a class model of Kernel
  • Default: a CGAL Kernel deduced from the point type, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.
  • Extra: Exact constructions kernels are not supported by this function.

  • The approximation error, expressed as the percentage of diagonal length of the input surface mesh.
  • Type: double
  • Default: 0.2
  • The minimal angle that the remesh surface mesh should achieve.
  • Type: double
  • Default: 30
  • The maximal mesh complexity that the remesh surface mesh should maintain, expressed as the number of vertices of the remesh surface mesh.
  • Type: unsigned int
  • Default: 100000000
  • The minimal step for angle improvement. If a local operator improves the minimal angle less than this value, then it is considered the minimal angle has not been improved.
  • Type: double
  • Default: 0.1

  • Indicates whether we apply the local operator Edge_flip when improving the minimal angle. Experiments show that enable the edge flipping achieves much better results
  • Type: Boolean
  • Default: true
  • Indicates whether we want to improve the minimal angle, or the vertex valences when flipping an edge. Experiments show that Improve_the_minimal_angle is better.
  • Type: EdgeFlipStrategy
  • Default: EdgeFlipStrategy::k_improve_angle
  • Indicates whether we perform Edge_flip after applying edge split or edge collapse, such that the local valance of the new generated vertex can be improved. Experiments show that enabling this is better.
  • Type: Boolean
  • Default: true
  • Indicates whether we perform Vertex_relocate after applying other local operators, such as edge split, edge collapse. Note we do not perform Vertex_relocate after edge flip in order to perverse sharp features. Experiments show that enabling this is better than not.
  • Type: Boolean
  • Default: true

  • The options for Vertex_relocation, we now have barycenter or CVT barycenter. Barycenter is simply the average of the one-ring vertices, which is also called Laplacian-operation. Instead, the CVT barycenter is the Centroid Voronoi Tessellation center of the one-ring vertices. Experiments show that the CVT barycenter is better.
  • Type: RelocateStrategy
  • Default: RelocateStrategy::k_cvt_barycenter
  • Indicate whether we want to keep the vertex in one-ring region when performing Edge_collapse or Vertex_relocate. This was indicated in Fig. 4 of our paper. Experiments show that disabling this is much better. However, we may have some folder-overs in some results.
  • Type: Boolean
  • Default: false
  • Indicates whether we construct the local AABB tree or not when simulating the edge collapse operator. If it is true, we use the constructed local AABB tree to update the links from input surface mesh to remesh surface mesh; Otherwise, we update the links directly. Experiments show that the efficiencies for both cases are almost the same.
  • Type: Boolean
  • Default: true
  • In some rare cases, the software traps into local dead loops (e.g., edge split -> edge collapse -> edge split ->edge collapse...). Hence, we maintain a global collapse list, such that if an edge is collapsed not long ago (recorded in the list), we deny the edge collapse when it can be in later steps. This parameter indicates the maximum size of the collapse list. The larger this value is, the less possibility that the software traps into local dead loops, but higher computational and memory cost. Experiments show that this strategy is really effective.
  • Type: unsigned int
  • Default: 10

  • Due to the randomness of sampling, sometimes the max error threshold cannot be strictly bounded to the threshold. If this parameter is enabled, we explicitly decrease the max error as long as we find the Hausdorff distance between the input and the remesh exceeds the threshold. This will make sure the approximation error is strictly bounded regardless of the sampling randomness.
  • Type: Boolean
  • Default: true
  • If this parameter is enabled, we output the detailed information when each local operator is applied. The detailed information may include current maximal error, minimal angle, or the size of the dynamic priority queue.
  • Type: Boolean
  • Default: true
  • If this parameter is enabled, we apply the initial mesh simplification before improving the minimal angles. This reduces the mesh complexity around 20-30% on average.
  • Type: Boolean
  • Default: true
  • If this parameter is enabled, we apply the final vertex relocation after improving the minimal angles to the min angle threshold. This will improve the average quality of the triangles with respect to the parameter Smooth angle delta. The smaller Smooth angle delta is set, the better results we get along with the higher computational cost.
  • Type: Boolean
  • Default: true

  • The number of samples per facet on input surface mesh.
  • Type: unsigned int
  • Default: 10
  • The number of samples per facet on remesh surface mesh.
  • Type: unsigned int
  • Default: 10
  • The maximal number of samplers per unit area. This parameter is used to avoid too dense sampling.
  • Type: unsigned int
  • Default: 10000
  • The minimal number of samples per triangle. This parameter is used to guarantee that each triangle, no matter how small it is, has certain number of samples on it.
  • Type: unsigned int
  • Default: 1

  • The large this parameter is, the more uniform the samples in the facets are. However, the computational cost will be dramatically higher as well.
  • Type: unsigned int
  • Default: 1
  • The option of sample number strategy on remesh surface mesh. If it is Fixed, then the number of samples per facet is roughly the same as the one on the input surface mesh; If it is Variable, then the number of samples per facet is variable with respect to the size of facets of the remesh surface mesh: the more facets the remesh surface mesh has, the smaller number of samples we generate on each facet of the remesh surface mesh. The Variable option makes the total samples on the input surface mesh and remesh surface mesh roughly the same.
  • Type: SampleNumberStrategy
  • Default: SampleNumberStrategy::k_fixed
  • The option of sample strategy. If it is uniform, then the number of samples per facet is proportional to its area; If it is adaptive, then the number of samples per facet is roughly the same.
  • Type: SampleStrategy
  • Default: SampleStrategy::k_adaptive
  • If this parameter is enabled, the vertex samples, edge samples and the facet samples partition the area of the surface mesh, respectively (we call the partition area as the capacity of each sample); If it is disabled, all the three types of samples will partition the area of the surface mesh together. In the former case, the feature samples (include the vertex samples and the edge samples) own higher area weights; while in the latter case, all the samples have the same area weights. Enabling this parameter preserves features better, but sacrifices the overall approximation error, because the facet samples dominates all the samples.
  • Type: Boolean
  • Default: false

  • The maximal value of Gaussian curvature, expressed as the times of PI. If a Gaussian curvature exceeds some value, it will be clamped to this value.
  • Type: double
  • Default: 1.0
  • The scale of the Gaussian curvature. If dividing a Gaussian curvature with this scale and the result exceeds Sum theta (PI), then it is clamped to Sum theta (PI).
  • Type: double
  • Default: 0.5
  • The maximal value of large dihedral angle value, expressed as the times of PI. If the large dihedral angle exceeds some value, it will be clamped to this value.
  • Type: double
  • Default: 1.0
  • The scale of the large dihedral angle. If dividing the large dihedral angle with this scale and the result exceeds Dihedral theta (PI), then it is clamped to Dihedral theta (PI).
  • Type: double
  • Default: 0.5

  • This parameter is only used when getting the initial position of the vertex after applying edge collapse. If the feature intensity difference between the two end points is smaller than their maximal value multiplied with this parameter, then the midpoint will be selected as the initial position; otherwise, the end point with higher feature intensity will be selected.
  • Type: double
  • Default: 0.15
  • This parameter is used for vertex classification. Please refer to Fig. 10 in the paper for more detailed explanation.
  • Type: double
  • Default: 0.5
  • If this parameter is enabled, we calculate the edge types (crease edge or non-crease edge) of the remesh surface mesh in advance, and then maintain the edge types explicitly during the whole remeshing process. Otherwise, we calculate the edge types according to the given parameters each time when a local operator is applied.
  • Type: Boolean
  • Default: false
  • If this parameter is enabled, the weight for each sample is its according area multiplied by its feature intensity; Otherwise, the weight is its according area. Enabling this parameter keeps the features better.
  • Type: Boolean
  • Default: false

  • The number of iterations we perform when optimizing a vertex position. Please refer to the first row of Fig. 15 in the paper for more details.
  • Type: unsigned int
  • Default: 2
  • The ratio to get to the optimal position when optimizing a vertex position. Refer to the second row of Fig. 15 in the paper for more details.
  • Type: double
  • Default: 0.9
  • The stencil ring size when collecting the samples from input surface mesh to remesh surface mesh. Please refer to the gray region of Fig. 3 as well as the discussion in Sec. 6.1 in the paper for more details.
  • Type: unsigned int
  • Default: 1
  • Options for vertex position optimization. If it is Approximation, then the vertex position is just the optimal position we calculated; otherwise, the vertex position is the projection of the optimal position to the input surface mesh. Please refer to Sec. 6.2 in the paper for more details.
  • Type: OptimizeStrategy
  • Default: OptimizeStrategy::k_approximation

  • The facet sample types used for optimizing a vertex position.
  • Type: OptimizeType
  • Default: OptimizeType::k_both

  • The edge sample types used for optimizing a vertex position.
  • Type: OptimizeType
  • Default: OptimizeType::k_both

  • The vertex sample types used for optimizing a vertex position. Optimize after local operations: If this parameter is enabled, we perform the vertex position optimization after each local operator is applied.
  • Type: OptimizeType
  • Default: OptimizeType::k_both

  • If this parameter is enabled, we perform the vertex position optimization after each local operator is applied.
  • Type: Boolean
  • Default: true

◆ random_perturbation()

template<typename VertexRange , typename TriangleMesh , typename NamedParameters >
void CGAL::Polygon_mesh_processing::random_perturbation ( VertexRange  vertices,
TriangleMesh &  tmesh,
const double &  perturbation_max_size,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/random_perturbation.h>

randomly perturbs the locations of vertices of a triangulated surface mesh.

By default, the vertices are re-projected onto the input surface after perturbation. Note that no geometric checks are done after the perturbation (face orientation might become incorrect and self-intersections might be introduced).

Template Parameters
VertexRangemodel of Range, holding vertices of type boost::graph_traits<TriangleMesh>::vertex_descriptor. Its iterator type is ForwardIterator.
TriangleMeshmodel of MutableFaceGraph.
NamedParametersa sequence of Named Parameters
Parameters
verticesthe range of vertices to be perturbed
tmeshthe triangulated surface mesh
perturbation_max_sizethe maximal length of moves that can be applied to vertices of tmesh.
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of tmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, tmesh)

  • an instance of a geometric traits class
  • Type: a class model of Kernel
  • Default: a CGAL Kernel deduced from the point type, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.

  • a property map containing the constrained-or-not status of each vertex of tmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and bool as value type. It must be default constructible.
  • Default: a default property map where no vertex is constrained
  • Extra: A constrained vertex cannot be modified at all during perturbation

  • indicates whether vertices are reprojected on the input surface after their coordinates random perturbation
  • Type: Boolean
  • Default: true

  • a value to seed the random number generator, and make the perturbation deterministic
  • Type: unsigned int
  • Default: unsigned int(-1)

◆ refine()

template<typename TriangleMesh , typename FaceRange , typename FaceOutputIterator , typename VertexOutputIterator , typename NamedParameters >
std::pair<FaceOutputIterator, VertexOutputIterator> CGAL::Polygon_mesh_processing::refine ( TriangleMesh &  tmesh,
const FaceRange &  faces,
FaceOutputIterator  faces_out,
VertexOutputIterator  vertices_out,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/refine.h>

refines a region of a triangle mesh

Template Parameters
TriangleMeshmodel of MutableFaceGraph
FaceRangerange of face descriptors, model of Range. Its iterator type is InputIterator.
FaceOutputIteratormodel of OutputIterator holding boost::graph_traits<TriangleMesh>::face_descriptor for patch faces
VertexOutputIteratormodel of OutputIterator holding boost::graph_traits<TriangleMesh>::vertex_descriptor for patch vertices
NamedParametersa sequence of Named Parameters
Parameters
tmeshtriangle mesh with patches to be refined
facesthe range of faces defining the patches to refine
faces_outoutput iterator into which descriptors of new faces are recorded
vertices_outoutput iterator into which descriptors of new vertices are recorded
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of tmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, tmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in TriangleMesh.

  • a factor to control density of the output mesh, where larger values lead to denser refinements
  • Type: double
  • Default: \( \sqrt{2}\)
  • Extra: The density of vertices of faces_out is this factor times higher than the vertices of faces.
Returns
pair of faces_out and vertices_out
Precondition
is_triangle_mesh(tmesh)
Todo:
current algorithm iterates 10 times at most, since (I guess) there is no termination proof.
Examples:
Polygon_mesh_processing/refine_fair_example.cpp.

◆ smooth_mesh()

template<typename TriangleMesh , typename FaceRange , typename NamedParameters >
void CGAL::Polygon_mesh_processing::smooth_mesh ( const FaceRange &  faces,
TriangleMesh &  tmesh,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/smooth_mesh.h>

smooths a triangulated region of a polygon mesh.

This function attempts to make the triangle angle and area distributions as uniform as possible by moving (non-constrained) vertices.

Angle-based smoothing does not change the combinatorial information of the mesh. Area-based smoothing might change the combinatorial information, unless specified otherwise. It is also possible to make the smoothing algorithm "safer" by rejecting moves that, when applied, would worsen the quality of the mesh, e.g. that would decrease the value of the smallest angle around a vertex or create self-intersections.

Optionally, the points are reprojected after each iteration.

Template Parameters
TriangleMeshmodel of MutableFaceGraph.
FaceRangerange of boost::graph_traits<TriangleMesh>::face_descriptor, model of Range. Its iterator type is ForwardIterator.
NamedParametersa sequence of Named Parameters
Parameters
tmesha polygon mesh with triangulated surface patches to be smoothed.
facesthe range of triangular faces defining one or several surface patches to be smoothed.
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • the number of iterations for the sequence of the smoothing iterations performed
  • Type: unsigned int
  • Default: 1

  • value to indicate whether angle-based smoothing should be used
  • Type: Boolean
  • Default: true

  • value to indicate whether area-based smoothing should be used
  • Type: Boolean
  • Default: true

  • a property map associating points to the vertices of tmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, tmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in TriangleMesh.

  • an instance of a geometric traits class
  • Type: a class model of Kernel
  • Default: a CGAL Kernel deduced from the point type, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.

  • If true, vertex moves that would worsen the mesh are ignored.
  • Type: Boolean
  • Default: false

  • If true, area-based smoothing will be completed by a phase of Delaunay-based edge-flips to prevent the creation of elongated triangles.
  • Type: Boolean
  • Default: true

  • If true, points are projected onto the initial surface after each iteration.
  • Type: Boolean
  • Default: true

  • a property map containing the constrained-or-not status of each vertex of tmesh.
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and bool as value type. It must be default constructible.
  • Default: a default property map where no vertex is constrained
  • Extra: A constrained vertex cannot be modified at all during smoothing.

  • a property map containing the constrained-or-not status of each edge of tmesh.
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<TriangleMesh>::edge_descriptor as key type and bool as value type. It must be default constructible.
  • Default: a default property map where no edge is constrained
  • Extra: A constrained edge cannot be modified at all during smoothing.
Warning
The third party library Ceres is required to use area-based smoothing.
Precondition
tmesh does not contain any degenerate faces
Examples:
Polygon_mesh_processing/mesh_smoothing_example.cpp.

◆ smooth_shape()

template<typename TriangleMesh , typename FaceRange , typename NamedParameters >
void CGAL::Polygon_mesh_processing::smooth_shape ( const FaceRange &  faces,
TriangleMesh &  tmesh,
const double  time,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/smooth_shape.h>

smooths the overall shape of the mesh by using the mean curvature flow.

The effect depends on the curvature of each area and on a time step which represents the amount by which vertices are allowed to move. The result conformally maps the initial surface to a sphere.

Template Parameters
TriangleMeshmodel of MutableFaceGraph.
FaceRangerange of boost::graph_traits<TriangleMesh>::face_descriptor, model of Range. Its iterator type is ForwardIterator.
NamedParametersa sequence of Named Parameters
Parameters
tmesha polygon mesh with triangulated surface patches to be smoothed.
facesthe range of triangular faces defining one or several surface patches to be smoothed.
timea time step that corresponds to the speed by which the surface is smoothed. A larger time step results in faster convergence but details may be distorted to have a larger extent compared to more iterations with a smaller step. Typical values scale in the interval (1e-6, 1].
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • the number of iterations for the sequence of the smoothing iterations performed
  • Type: unsigned int
  • Default: 1

  • a property map associating points to the vertices of tmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, tmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in TriangleMesh.

  • an instance of a geometric traits class
  • Type: a class model of Kernel
  • Default: a CGAL Kernel deduced from the point type, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.

  • a property map containing the constrained-or-not status of each vertex of tmesh.
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and bool as value type. It must be default constructible.
  • Default: a default property map where no vertex is constrained
  • Extra: A constrained vertex cannot be modified at all during smoothing.

Warning
This function involves linear algebra, that is computed using a non-exact floating-point arithmetic.
Examples:
Polygon_mesh_processing/shape_smoothing_example.cpp.

◆ split_long_edges()

template<typename PolygonMesh , typename EdgeRange , typename NamedParameters >
void CGAL::Polygon_mesh_processing::split_long_edges ( const EdgeRange &  edges,
const double &  max_length,
PolygonMesh &  pmesh,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/remesh.h>

splits the edges listed in edges into sub-edges that are not longer than the given threshold max_length.

Note this function is useful to split constrained edges before calling isotropic_remeshing() with protection of constraints activated (to match the constrained edge length required by the remeshing algorithm to be guaranteed to terminate)

Template Parameters
PolygonMeshmodel of MutableFaceGraph that has an internal property map for CGAL::vertex_point_t.
EdgeRangerange of boost::graph_traits<PolygonMesh>::edge_descriptor, model of Range. Its iterator type is InputIterator.
NamedParametersa sequence of Named Parameters
Parameters
pmesha polygon mesh
edgesthe range of edges to be split if they are longer than given threshold
max_lengththe edge length above which an edge from edges is split into to sub-edges
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of pmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<PolygonMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, pmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in PolygonMesh.

  • a property map associating to each face of pmesh a unique index between 0 and num_faces(pmesh) - 1
  • Type: a class model of ReadablePropertyMap with boost::graph_traits<PolygonMesh>::face_descriptor as key type and std::size_t as value type
  • Default: an automatically indexed internal map

  • a property map containing the constrained-or-not status of each edge of pmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<PolygonMesh>::edge_descriptor as key type and bool as value type. It must be default constructible.
  • Default: a default property map where no edge is constrained
  • Extra: A constrained edge can be split or collapsed, but not flipped, nor its endpoints moved by smoothing.
See also
isotropic_remeshing()
Examples:
Polygon_mesh_processing/isotropic_remeshing_example.cpp.

◆ triangulate_face()

template<typename PolygonMesh , typename NamedParameters >
bool CGAL::Polygon_mesh_processing::triangulate_face ( typename boost::graph_traits< PolygonMesh >::face_descriptor  f,
PolygonMesh &  pmesh,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>

triangulates a single face of a polygon mesh.

This function depends on the package 2D Triangulations

Template Parameters
PolygonMesha model of FaceListGraph and MutableFaceGraph
NamedParametersa sequence of Named Parameters
Parameters
fface to be triangulated
pmeshthe polygon mesh to which the face to be triangulated belongs
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of pmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<PolygonMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, pmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in PolygonMesh.

  • an instance of a geometric traits class
  • Type: a class model of Kernel
  • Default: a CGAL Kernel deduced from the point type, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.

  • a visitor that enables to track how faces are triangulated into subfaces
  • Type: a class model of PMPTriangulateFaceVisitor
  • Default: Triangulate_faces::Default_visitor<PolygonMesh>
  • Extra: Note that the visitor will be copied, so it must not have any data member that does not have a reference-like type.
Returns
true if the face has been triangulated.

◆ triangulate_faces() [1/2]

template<typename FaceRange , typename PolygonMesh , typename NamedParameters >
bool CGAL::Polygon_mesh_processing::triangulate_faces ( FaceRange  face_range,
PolygonMesh &  pmesh,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>

triangulates given faces of a polygon mesh.

This function depends on the package 2D Triangulations

Template Parameters
FaceRangerange of boost::graph_traits<PolygonMesh>::face_descriptor, model of Range. Its iterator type is InputIterator.
PolygonMesha model of FaceListGraph and MutableFaceGraph
NamedParametersa sequence of Named Parameters
Parameters
face_rangethe range of faces to be triangulated
pmeshthe polygon mesh to be triangulated
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of pmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<PolygonMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, pmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in PolygonMesh.

  • an instance of a geometric traits class
  • Type: a class model of Kernel
  • Default: a CGAL Kernel deduced from the point type, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.

  • a visitor that enables to track how faces are triangulated into subfaces
  • Type: a class model of PMPTriangulateFaceVisitor
  • Default: Triangulate_faces::Default_visitor<PolygonMesh>
  • Extra: Note that the visitor will be copied, so it must not have any data member that does not have a reference-like type. `
Returns
true if all the faces have been triangulated.
See also
triangulate_face()
Examples:
Polygon_mesh_processing/locate_example.cpp, Polygon_mesh_processing/triangulate_faces_example.cpp, and Polygon_mesh_processing/triangulate_faces_split_visitor_example.cpp.

◆ triangulate_faces() [2/2]

template<typename PolygonMesh , typename NamedParameters >
bool CGAL::Polygon_mesh_processing::triangulate_faces ( PolygonMesh &  pmesh,
const NamedParameters &  np 
)

#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>

triangulates all faces of a polygon mesh.

This function depends on the package 2D Triangulations

Template Parameters
PolygonMesha model of FaceListGraph and MutableFaceGraph
NamedParametersa sequence of Named Parameters
Parameters
pmeshthe polygon mesh to be triangulated
npan optional sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • a property map associating points to the vertices of pmesh
  • Type: a class model of ReadWritePropertyMap with boost::graph_traits<PolygonMesh>::vertex_descriptor as key type and Point_3 as value type
  • Default: boost::get(CGAL::vertex_point, pmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in PolygonMesh.

  • an instance of a geometric traits class
  • Type: a class model of Kernel
  • Default: a CGAL Kernel deduced from the point type, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.

  • a visitor that enables to track how faces are triangulated into subfaces
  • Type: a class model of PMPTriangulateFaceVisitor
  • Default: Triangulate_faces::Default_visitor<PolygonMesh>
  • Extra: Note that the visitor will be copied, so it must not have any data member that does not have a reference-like type.
Returns
true if all the faces have been triangulated.
See also
triangulate_face()