|
CGAL 6.3 - 3D Mesh Smoothing
|
#include <CGAL/Mesh_smoothing_3/Mesh_smoothing_3.h>
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.
| TetrahedralMesh | encodes the volumetric mesh and must be a model of MeshDataStructure. |
| BoundaryMesh | represents 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. |
| EdgeNetwork | represents 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. |
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. | |
| 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.
| coords | vector with center of each polygon | |
| surface_ids | vector with patch ids of each polygon as defined in BoundaryMesh | |
| radii | vector with indicator of the average edge length for each polygon | |
| [out] | results | vector with target plane for each polygon |
| 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.
| coord | center of polygon |
| surface_id | patch id of the polygon as defined in BoundaryMesh |
| radius | indicator of the average edge length of the polygon |
| 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.
| polygons | vector with a vector of points for each polygon | |
| surface_ids | vector with patch ids of each polygon as defined in BoundaryMesh | |
| [out] | results | vector with target plane for each polygon |
| 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.
| polygon | vector containing the current points of the polygon |
| surface_id | patch id of the polygon as defined in BoundaryMesh |
| 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.
| coords | vector with center of each edge | |
| curve_ids | vector with curve id of each edge as defined in EdgeNetwork | |
| radii | vector with edge length of each edge | |
| [out] | results | vector with target curve tangent for each edge |
| 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.
| coord | center of edge |
| curve_id | id of the curve as defined in EdgeNetwork |
| radius | edge length |
| 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.
| edges | vector with couple of points for each edge | |
| curve_ids | vector with curve ids of each edge as defined in EdgeNetwork | |
| [out] | results | vector with target curve tangent for each edge |
| 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.
| edge | array containing the two points of the edge |
| curve_id | id of the curve as defined in EdgeNetwork |
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.