CGAL 6.3 - 3D Mesh Smoothing
Loading...
Searching...
No Matches
CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork > Class Template Reference

#include <CGAL/Mesh_smoothing_3/Mesh_smoothing_3.h>

Definition

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
class CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >

smooth a tetrahedral mesh with optional constraints on the boundary and along a curve network

The class Mesh_smoother provides an interface to optimize a tetrahedral mesh with an energy, while allowing the user to specify soft-constraints on the boundary and along a curve network. This class is designed for linking with various mesh representations. For usage with CGAL common mesh representations, refer to C3t3_smoother.

Template Parameters
TetrahedralMeshencodes the volumetric mesh and must be a model of MeshDataStructure.
BoundaryMeshrepresents a set of selected polygons with points from Tetrahedral mesh that will be used to define surface constraints on TetrahedralMesh. It must be a model of SurfaceDataStructure.
EdgeNetworkrepresents a set of selected segments with points from Tetrahedral mesh that will be used to add curve constraints on TetrahedralMesh. It must be a model of PolylinesDataStructure.
See also
CGAL::Mesh_smoothing_3::C3t3_smoother
Examples
Mesh_smoothing_3/alpha_wrap_improvement.cpp.

Public Types

using Plane = std::tuple<Point_3, Normal_3, double>
 Plane type to which the boundary polygons should align.
using Boundary_point_query = std::function<Plane (Point_3 const &coord, Surface_patch_index surface_id, double radius)>
 Projection function.
using Boundary_polygon_query = std::function<Plane (std::vector<Point_3> const &polygon, Surface_patch_index surface_id)>
 Projection function.
using Boundary_point_batch_query = std::function<void (std::vector<Point_3> const &coords, std::vector<Surface_patch_index> &surface_ids, std::vector<double> &radii, std::vector<Plane> &results)>
 Batch projection function.
using Boundary_polygon_batch_query = std::function<void (std::vector<std::vector<Point_3>> const &polygons, std::vector<Surface_patch_index> &surface_id, std::vector<Plane> &results)>
 Batch projection function.
using Curve_tangent = std::tuple<Point_3, Normal_3, double>
 Tangent vector and point to which the curve segment should align.
using Curve_point_query = std::function<Curve_tangent (Point_3 const &coord, Curve_index curve_id, double radius)>
 Projection function.
using Curve_segment_query = std::function<Curve_tangent (std::array<Point_3, 2> const &edge, Curve_index curve_id)>
 Projection function.
using Curve_point_batch_query = std::function<void (std::vector<Point_3> const &coord, std::vector<Curve_index> &curve_ids, std::vector<double> &radius, std::vector<Curve_tangent> &results)>
 Batch projection function.
using Curve_segment_batch_query = std::function<void (std::vector<std::array<Point_3, 2>> const &edges, std::vector<Curve_index> &curve_ids, std::vector<Curve_tangent> &results)>
 Batch projection function.

Public Member Functions

 Mesh_smoother (TetrahedralMesh &mesh, BoundaryMesh const &boundary=BoundaryMesh(), EdgeNetwork const &edge_network=EdgeNetwork())
 Constructor of the class, it does not perform any operation.
void set_locked_boundary (bool locked=true)
 Locks (or unlock) all vertices contained in the input BoundaryMesh.
void set_max_number_of_iteration (unsigned number_of_iterations)
 Max number of high level iterations done by the smoother.
void set_vertex_lock (Vertex_descriptor vertex, bool locked=true)
 Hard-constraining a certain vertex to its current coordinates.
void set_vertex_dim_lock (Vertex_descriptor vertex, unsigned dimension, bool locked=true)
 Hard-constraining only 1 dimension for the given vertex.
void set_vertices_dim_locks (Vertex_descriptor_map< std::array< bool, 3 > > const &vertex_dimension_locks)
 Setting all of the locked vertices at once.
template<typename Container>
void set_locked_vertices (Container const &vertices)
 Helper function to set locked vertices from a container.
void clear_locks ()
 Remove all previously set locks.
void set_boundary_query (Boundary_point_query boundary_query)
 set constraint query for surface as a Boundary_point_query
void set_boundary_query (Boundary_polygon_query boundary_query)
 set constraint query for surface as a Boundary_polygon_query
void set_boundary_query (Boundary_point_batch_query boundary_query)
 set constraint query for surface as a Boundary_point_batch_query
void set_boundary_query (Boundary_polygon_batch_query boundary_query)
 set constraint query for surface as a Boundary_polygon_batch_query
void set_curves_query (Curve_point_query curve_query)
 set constraint query for curves as a Curve_point_query
void set_curves_query (Curve_segment_query curve_query)
 set constraint query for curves as a Curve_segment_query
void set_curves_query (Curve_point_batch_query curve_query)
 set constraint query for curves as a Curve_point_batch_query
void set_curves_query (Curve_segment_batch_query curve_query)
 set constraint query for curves as a Curve_segment_batch_query
void set_vertex_target_position (Vertex_descriptor v, Point_3 const &target_positions, double weight=1.0)
 set soft constraint for a given vertex
void set_vertex_target_positions (std::vector< std::tuple< Vertex_descriptor, Point_3, double > > const &target_positions)
 set the list of soft constraints for vertices.
template<typename Container>
void set_vertex_target_positions (Container const &target_positions)
 set soft constraints from a container of [vertex, coord] pairs.
void clear_vertex_target_positions ()
 Clear previously set vertex soft constraints.
void set_boundary_weight (double weight)
 Set the weight on the boundary term of the energy.
void set_boundary_weight (Parameters::BOUNDARY_WEIGHTING_MODE mode)
 Set boundary with pre-set recommended parameters.
bool run ()
 Start the optimization procedure.

Member Typedef Documentation

◆ Boundary_point_batch_query

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
using CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::Boundary_point_batch_query = std::function<void (std::vector<Point_3> const &coords, std::vector<Surface_patch_index> &surface_ids, std::vector<double> &radii, std::vector<Plane> &results)>

Batch projection function.

Equivalent of Boundary_point_query. Will be called in more systemic manner, so will produce slower results. Use if single calls are slower, or to avoid thread-safe requirements.

Parameters
coordsvector with center of each polygon
surface_idsvector with patch ids of each polygon as defined in BoundaryMesh
radiivector with indicator of the average edge length for each polygon
[out]resultsvector with target plane for each polygon

◆ Boundary_point_query

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
using CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::Boundary_point_query = std::function<Plane (Point_3 const &coord, Surface_patch_index surface_id, double radius)>

Projection function.

Parameters
coordcenter of polygon
surface_idpatch id of the polygon as defined in BoundaryMesh
radiusindicator of the average edge length of the polygon
Returns
Plane to which the polygon should align (usually closest tangential plane of the target geometry)
Warning
Must be thread safe – it will be called in an OpenMP context.

◆ Boundary_polygon_batch_query

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
using CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::Boundary_polygon_batch_query = std::function<void (std::vector<std::vector<Point_3>> const &polygons, std::vector<Surface_patch_index> &surface_id, std::vector<Plane> &results)>

Batch projection function.

Equivalent of Boundary_polygon_query. Will be called in more systemic manner, so will produce slower results. Use if single calls are slower, or to avoid thread-safe requirements.

Parameters
polygonsvector with a vector of points for each polygon
surface_idsvector with patch ids of each polygon as defined in BoundaryMesh
[out]resultsvector with target plane for each polygon

◆ Boundary_polygon_query

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
using CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::Boundary_polygon_query = std::function<Plane (std::vector<Point_3> const &polygon, Surface_patch_index surface_id)>

Projection function.

Parameters
polygonvector containing the current points of the polygon
surface_idpatch id of the polygon as defined in BoundaryMesh
Returns
Plane to which the polygon should align (usually closest tangential plane of the target geometry)
Warning
Must be thread safe – it will be called in an OpenMP context.

◆ Curve_point_batch_query

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
using CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::Curve_point_batch_query = std::function<void (std::vector<Point_3> const &coord, std::vector<Curve_index> &curve_ids, std::vector<double> &radius, std::vector<Curve_tangent> &results)>

Batch projection function.

Equivalent of Curve_point_query. Will be called in more systemic manner, so will produce slower results. Use if single calls are slower.

Parameters
coordsvector with center of each edge
curve_idsvector with curve id of each edge as defined in EdgeNetwork
radiivector with edge length of each edge
[out]resultsvector with target curve tangent for each edge

◆ Curve_point_query

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
using CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::Curve_point_query = std::function<Curve_tangent (Point_3 const &coord, Curve_index curve_id, double radius)>

Projection function.

Note
Thread safe is not required here – subject to change if specific cases require it.
Parameters
coordcenter of edge
curve_idid of the curve as defined in EdgeNetwork
radiusedge length
Returns
Curve_tangent to which the edge should align (usually closest tangential direction of the target geometry)

◆ Curve_segment_batch_query

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
using CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::Curve_segment_batch_query = std::function<void (std::vector<std::array<Point_3, 2>> const &edges, std::vector<Curve_index> &curve_ids, std::vector<Curve_tangent> &results)>

Batch projection function.

Equivalent of Curve_segment_query. Will be called in more systemic manner, so will produce slower results. Use if single calls are slower.

Parameters
edgesvector with couple of points for each edge
curve_idsvector with curve ids of each edge as defined in EdgeNetwork
[out]resultsvector with target curve tangent for each edge

◆ Curve_segment_query

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
using CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::Curve_segment_query = std::function<Curve_tangent (std::array<Point_3, 2> const &edge, Curve_index curve_id)>

Projection function.

Note
Thread safe is not required here – subject to change if specific cases require it.
Parameters
edgearray containing the two points of the edge
curve_idid of the curve as defined in EdgeNetwork
Returns
Curve_tangent to which the edge should align (usually closest tangential direction of the target geometry)

◆ Curve_tangent

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
using CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::Curve_tangent = std::tuple<Point_3, Normal_3, double>

Tangent vector and point to which the curve segment should align.

Last parameter is a weight that is used to indicate the importance of the constraint. By default, use the value 1.

◆ Plane

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
using CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::Plane = std::tuple<Point_3, Normal_3, double>

Plane type to which the boundary polygons should align.

the last parameter is a weight that is used to indicate the importance of the constraint. By default, use the value 1.

Member Function Documentation

◆ set_boundary_weight()

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
void CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::set_boundary_weight ( double weight)

Set the weight on the boundary term of the energy.

Default is 1. 10 will strongly enforce the boundary matching, 1e-3 will only have a slight effect, favoring the inside meshing. Warning: large value can lead to convergence issues if the boundary is not initialized on its contraint.

◆ set_locked_boundary()

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
void CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::set_locked_boundary ( bool locked = true)

Locks (or unlock) all vertices contained in the input BoundaryMesh.

It is independent from the other locking functions, and unlocking will not interfere with manually set locks. Set by default as true if no set_boundary_query is called.

◆ set_max_number_of_iteration()

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
void CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::set_max_number_of_iteration ( unsigned number_of_iterations)

Max number of high level iterations done by the smoother.

Each iteration can be seen as equivalent to a Newton step. Untangling may require a high number of iterations to converge (100), simple mesh improvement will usually require less (from 1 to 10). Default is 1000.

◆ set_vertex_target_positions()

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
void CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::set_vertex_target_positions ( std::vector< std::tuple< Vertex_descriptor, Point_3, double > > const & target_positions)

set the list of soft constraints for vertices.

Note that it overrides previously set vertex constraints.

◆ set_vertices_dim_locks()

template<typename TetrahedralMesh = default_structures::Empty_mesh, typename BoundaryMesh = default_structures::Empty_boundary<typename TetrahedralMesh::Vertex_descriptor>, typename EdgeNetwork = default_structures::Empty_edge_network<typename TetrahedralMesh::Vertex_descriptor>>
void CGAL::Mesh_smoothing_3::Mesh_smoother< TetrahedralMesh, BoundaryMesh, EdgeNetwork >::set_vertices_dim_locks ( Vertex_descriptor_map< std::array< bool, 3 > > const & vertex_dimension_locks)

Setting all of the locked vertices at once.

Use this function to maximize performance when having tricky locks configuration. Note that this will override all previously add locks, except those from set_locked_boundary.