|
CGAL 6.3 - 3D Mesh Smoothing
|
This package implements an optimization algorithm for improving the quality of volumetric meshes and fitting them to geometric targets. The method supports tetrahedral meshes but can be adapted to mixed meshes containing tetrahedra, pyramids, wedges, and hexahedra. It can be used to improve an already valid mesh, untangle an invalid mesh, or deform a mesh so that its boundary follows a prescribed geometry.
The algorithm only modifies vertex coordinates. It does not insert or remove vertices, change cell connectivity, or alter the combinatorial structure of the input mesh. Consequently, cell indices, material labels, adjacency relations, and other data attached to the mesh are preserved throughout the optimization.
The algorithm optimizes vertex positions according to an element-quality energy. It currently uses a conformal energy (MIPS3D) that improves the dihedral angles of the cells. Interior vertices are moved to improve the volume mesh, while boundary vertices can additionally be attracted towards a target geometry.
The energy possesses a barrier term preventing element inversion. For an initially valid mesh, all accepted optimization steps preserve element orientation, providing a validity guarantee while the element quality is improved. The use of a penalization approach allows the optimizer to start from an invalid meshes, and recover a valid configuration by untangling inverted elements.
Geometric targets can be specified at several dimensions:
Surface patches and curves may be assigned different identifiers, allowing different parts of the mesh to use different target geometries. Constraints are soft and weighted by default, so geometric fidelity can be balanced against element quality. Vertices, or individual coordinate dimensions, can also be locked when hard constraints are required. Combining surface, curve, and point targets allows smooth regions, sharp curves, corners, and user handles to be treated within the same optimization.
By recovering the tangent planes of the target geometry, the smoother can recover curvature discontinuities enabling automatic feature recovery/preservation.
The main API is provided by the templated class Mesh_smoothing_3::Mesh_smoother<TetrahedralMesh, BoundaryMesh, EdgeNetwork>. The three template parameters provide lightweight views of the volume cells, the selected boundary polygons, and the selected curve edges. These views supply descriptors and ranges for traversing the input data structure, access to vertex coordinates, and the reference shape associated with each cell. The optimizer updates the original mesh in place through its coordinate setter; no conversion to an internal mesh representation is required.
After construction, the smoother can be configured through member functions. Surface, curve, and point targets are respectively defined with set_boundary_query(), set_curves_query(), and set_vertex_target_position(). Additional functions control vertex locks, constraint weights and the maximum number of iterations. The optimization is started with run(). The optimization will directly modify the input mesh through the coordinate setter provided by the mesh view.
For a CGAL::Mesh_complex_3_in_triangulation_3, the convenience class Mesh_smoothing_3::C3t3_smoother<C3T3> directly adapts the volume cells, surface patches, and feature curves stored in the complex.
The following example demonstrates the direct use of the smoother on a CGAL::Mesh_complex_3_in_triangulation_3. A multi-domain C3t3 is generated from a labeled image and deformed to create an initial input. The C3t3_smoother is then constructed directly from the complex.
The volume cells, boundary facets, surface-patch indices, feature edges, and curve indices are read from the same C3t3; they do not need to be copied into separate arrays or converted to a standalone surface representation. Target queries are built from AABB trees associated with each surface patch and each feature curve. The smoother consequently improves the tetrahedra while keeping the boundary facets and feature edges aligned with their corresponding geometric targets.
Example: Mesh_smoothing_3/c3t3_smooth.cpp
Figure 69.1 Feature-preserving offsets for several Alpha Wrap gate sizes. The upper row shows the Alpha Wrap results, in which the stair edges remain rounded. The lower row shows the meshes after volume fitting, which recovers the sharp features while improving the underlying tetrahedral mesh.
The following example combines the 3D Alpha Wrapping package with volume mesh improvement. Alpha Wrap first generates a watertight offset surface and its underlying Delaunay triangulation. The cells inside the wrap are identified, and tetrahedral remeshing is applied to improve the sampling of the volume while leaving the boundary connectivity unchanged.
A first smoothing pass improves the tetrahedral elements with the boundary vertices fixed. The boundary is then released and a geometric query defines the target offset: each query point is projected onto the input triangle soup and displaced by the requested offset distance along the outward direction. The optimizer jointly moves the boundary and interior vertices to recover the offset geometry without sacrificing the quality of the volume cells.
Unlike point redistribution performed directly on the wrapped surface, the fitting energy allows neighboring boundary facets to align with different local target planes. Sharp edges and corners that were rounded by Alpha Wrap can therefore be recovered automatically, without explicitly extracting or tagging a feature graph.
Example: Mesh_smoothing_3/alpha_wrap_improvement.cpp