-
Notifications
You must be signed in to change notification settings - Fork 1.6k
API proposal for 3D mesh smoothing #9576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 16 commits
3bccce8
59ffb37
d39cfb0
7d2aa30
0c0923c
30d445f
2da4b11
430677e
9792a23
3748179
d456da1
139c9c6
3467bab
fb234b7
e87fb37
2966fae
f35ab40
a283fe6
6a0abaf
62d9b63
d3ec736
f28b21c
453e0cc
807f960
6e72c0f
3a83780
72aaf7f
d59df6b
211b0b9
2f1d79f
d06496d
4a8249e
cd4072c
897da28
b7d3795
cae44ee
492c89c
7e82a0f
cde843b
05ba8bf
66dd9dd
be91ae8
dffa7ff
45405c3
bdfe8bd
50090f7
80eb5e4
ccdc917
67c24d1
01fe2ba
dfafa68
b902364
bde9b9a
0385457
68a5085
2c94f6a
ffdb6fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Copyright (c) 2016 GeometryFactory SARL (France). | ||
| // All rights reserved. | ||
| // | ||
| // This file is part of CGAL (www.cgal.org) | ||
| // | ||
| // $URL$ | ||
| // $Id$ | ||
| // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial | ||
| // | ||
| // Author(s) : Andreas Fabri | ||
| // | ||
| // Warning: this file is generated, see include/CGAL/license/README.md | ||
|
|
||
| #ifndef CGAL_LICENSE_MESH_SMOOTHING_3_H | ||
| #define CGAL_LICENSE_MESH_SMOOTHING_3_H | ||
|
|
||
| #include <CGAL/config.h> | ||
| #include <CGAL/license.h> | ||
|
|
||
| #ifdef CGAL_MESH_SMOOTHING_3_COMMERCIAL_LICENSE | ||
|
|
||
| # if CGAL_MESH_SMOOTHING_3_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE | ||
|
|
||
| # if defined(CGAL_LICENSE_WARNING) | ||
|
|
||
| CGAL_pragma_warning("Your commercial license for CGAL does not cover " | ||
| "this release of the 3D Mesh Smoothing package.") | ||
| # endif | ||
|
|
||
| # ifdef CGAL_LICENSE_ERROR | ||
| # error "Your commercial license for CGAL does not cover this release \ | ||
| of the 3D Mesh Smoothing package. \ | ||
| You get this error, as you defined CGAL_LICENSE_ERROR." | ||
| # endif // CGAL_LICENSE_ERROR | ||
|
|
||
| # endif // CGAL_MESH_SMOOTHING_3_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE | ||
|
|
||
| #else // no CGAL_MESH_SMOOTHING_3_COMMERCIAL_LICENSE | ||
|
|
||
| # if defined(CGAL_LICENSE_WARNING) | ||
| CGAL_pragma_warning("\nThe macro CGAL_MESH_SMOOTHING_3_COMMERCIAL_LICENSE is not defined." | ||
| "\nYou use the CGAL 3D Mesh Smoothing package under " | ||
| "the terms of the GPLv3+.") | ||
| # endif // CGAL_LICENSE_WARNING | ||
|
|
||
| # ifdef CGAL_LICENSE_ERROR | ||
| # error "The macro CGAL_MESH_SMOOTHING_3_COMMERCIAL_LICENSE is not defined.\ | ||
| You use the CGAL 3D Mesh Smoothing package under the terms of \ | ||
| the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR." | ||
| # endif // CGAL_LICENSE_ERROR | ||
|
|
||
| #endif // no CGAL_MESH_SMOOTHING_3_COMMERCIAL_LICENSE | ||
|
|
||
| #endif // CGAL_LICENSE_MESH_SMOOTHING_3_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /*! | ||
| \ingroup pkgMeshSmoothing3Concepts | ||
| \cgalConcept | ||
|
|
||
| The concept `MeshDataStructure` describes the way the tetrahedral mesh will be accessed and modified. | ||
|
|
||
| \sa `CGAL::Mesh_smoothing_3::Mesh_smoother` | ||
|
|
||
| */ | ||
| class MeshDataStructure { | ||
| public: | ||
|
|
||
| /// \name Types | ||
| /// @{ | ||
|
|
||
| /*! | ||
| Descriptor used to access a cell (tetrahedron) information | ||
| */ | ||
| using Cell_descriptor = unspecified_type; | ||
|
|
||
|
|
||
| /*! | ||
| Descriptor used to access a vertex information | ||
| */ | ||
| using Vertex_descriptor = unspecified_type; | ||
|
|
||
|
|
||
| /*! | ||
| Point type. | ||
| */ | ||
| using Point_3 = unspecified_type; | ||
|
|
||
| /// @} | ||
|
|
||
| /// \name Operations | ||
| /// The following functions are used to access and modify the mesh data: | ||
| /// @{ | ||
|
|
||
| /*! | ||
| std::size_t is optional but will avoid warnings. | ||
| */ | ||
| std::size_t nb_cells() const; | ||
|
|
||
| /*! | ||
|
|
||
| */ | ||
| std::size_t nb_vertices() const; | ||
|
|
||
| /*! | ||
| Access the coordinates of a vertex. | ||
| */ | ||
| Point_3 vertex_coordinates(Vertex_descriptor vertex) const; | ||
|
|
||
| /*! | ||
| Change the coordinates of a vertex. | ||
| */ | ||
| void set_vertex_coordinates(Vertex_descriptor vertex, Point_3 coord); | ||
|
|
||
| /*! | ||
| Provide an iterable range over the Cell_descriptors of the mesh | ||
| */ | ||
| unspecified_type cell_range() const; | ||
|
|
||
| /*! | ||
| Access the 4 vertices of a cell. | ||
| Returns container behaving like std::array<Vertex_descriptor, 4> | ||
| */ | ||
| unspecified_type cell_vertices(Cell_descriptor cell) const; | ||
|
|
||
| /*! | ||
| Optimal shape of the given cell. | ||
| Returns container behaving like std::array<Point_3, 4> | ||
| */ | ||
| unspecified_type cell_reference_shape(Cell_descriptor cell) const; | ||
|
|
||
| /// @} | ||
|
|
||
|
|
||
|
|
||
| }; /* end MeshDataStructure */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /*! | ||
| \ingroup pkgMeshSmoothing3Concepts | ||
| \cgalConcept | ||
|
|
||
| The concept `PolylinesDataStructure` describes the way the curves on the mesh will be accessed. | ||
|
|
||
| \sa `CGAL::Mesh_smoothing_3::Mesh_smoother` | ||
| \sa `MeshDataStructure` | ||
| \sa `SurfaceDataStructure` | ||
|
|
||
| */ | ||
| class PolylinesDataStructure { | ||
| public: | ||
|
|
||
| /// \name Types | ||
| /// @{ | ||
|
|
||
| /*! | ||
| Descriptor used to access a edge information | ||
| */ | ||
| using Edge_descriptor = unspecified_type; | ||
|
|
||
| /*! | ||
| Index associated with an edge to identify the curve it belongs to. This is used to query the curve information from the user. | ||
| */ | ||
| using Curve_index = unspecified_type; | ||
|
|
||
| /*! | ||
| Descriptor used to access a vertex information. Should be compatible with the one used in MeshDataStructure. | ||
| */ | ||
| using Vertex_descriptor = unspecified_type; | ||
|
|
||
|
|
||
| /// @} | ||
|
|
||
| /// \name Operations | ||
| /// The following functions are used to access surface data: | ||
| /// @{ | ||
|
|
||
| /*! | ||
| std::size_t is optional but will avoid warnings. | ||
| */ | ||
| std::size_t nb_edges() const; | ||
|
|
||
| /*! | ||
| Provides an iterable range over the Edge_descriptor of the mesh | ||
| */ | ||
| unspecified_type edge_range() const; | ||
|
|
||
| /*! | ||
| Returns an identifier (curve id, segment id, ...) related to an edge. | ||
| */ | ||
| Curve_index curve_id(Edge_descriptor edge) const; | ||
|
|
||
| /*! | ||
| Return the ith vertex of an edge (max 2). | ||
| */ | ||
| Vertex_descriptor edge_vertex(Edge_descriptor edge, unsigned i) const; | ||
|
|
||
| /// @} | ||
|
|
||
|
|
||
| }; /* end PolylinesDataStructure */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /*! | ||
| \ingroup pkgMeshSmoothing3Concepts | ||
| \cgalConcept | ||
|
|
||
| The concept `SurfaceDataStructure` describes the way the surface mesh will be accessed. | ||
|
|
||
| \sa `CGAL::Mesh_smoothing_3::Mesh_smoother` | ||
| \sa `MeshDataStructure` | ||
|
|
||
| */ | ||
| class SurfaceDataStructure { | ||
| public: | ||
|
|
||
| /// \name Types | ||
| /// @{ | ||
|
|
||
| /*! | ||
| Descriptor used to access face information | ||
| */ | ||
| using Face_descriptor = unspecified_type; | ||
|
|
||
|
|
||
| /*! | ||
| Vector type. | ||
| */ | ||
| using Normal_3 = unspecified_type; | ||
|
|
||
| /*! | ||
| Index associated with a surface patch to identify the patch it belongs to. This is used to query the patch information from the user. | ||
| */ | ||
| using Surface_patch_index = unspecified_type; | ||
|
|
||
| /// @} | ||
|
|
||
| /// \name Operations | ||
| /// The following functions are used to access surface data: | ||
| /// @{ | ||
|
|
||
| /*! | ||
| std::size_t is optional but will avoid warnings. | ||
| */ | ||
| std::size_t nb_faces() const; | ||
|
|
||
| /*! | ||
| Provides an iterable range over the Face_descriptor of the mesh | ||
| */ | ||
| unspecified_type face_range() const; | ||
|
|
||
| /*! | ||
| Returns the number of vertices of a face. std::size_t is optional but will avoid warnings. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. std::size_t must be backticked.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean with "optional" ? That it may also be
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the "less wordy" way to have a "size_type" instead of std::size_t? Triangulation_3 use its own typedef, but here I would see it as unecessary. Do I just use std::size_t? |
||
| */ | ||
| std::size_t nb_face_vertices(Face_descriptor face) const; | ||
|
|
||
| /*! | ||
| Returns an identifier (patch id, face id, ...) related to a face. | ||
| */ | ||
| Surface_patch_index patch_id(Face_descriptor face) const; | ||
|
|
||
| /*! | ||
| Provides an iterable range of Vertex_descriptor as defined in `MeshDataStructure` to iterate over the vertices of a face. | ||
| */ | ||
| unspecified_type face_vertices(Face_descriptor face) const; | ||
|
|
||
| /// @} | ||
|
|
||
|
|
||
|
|
||
| }; /* end SurfaceDataStructure */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| @INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} | ||
|
|
||
| PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 3D Mesh Smoothing" | ||
|
|
||
| # custom options for this package | ||
| HIDE_UNDOC_MEMBERS = true | ||
| HIDE_UNDOC_CLASSES = true | ||
|
|
||
| EXCLUDE += \ | ||
| include/CGAL/Mesh_smoothing_3/Mesh_smoothing_3.h \ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| namespace CGAL { | ||
|
|
||
| /*! | ||
|
|
||
| \mainpage User Manual | ||
|
|
||
| \anchor Chapter_3D_Mesh_smoothing | ||
|
|
||
| \cgalAutoToc | ||
|
|
||
| \author François Protais | ||
|
|
||
| \section secMeshSmoothing3 Volume Mesh Smoothing and Geometric Fitting | ||
|
|
||
| This package implements an optimization algorithm for improving the quality of | ||
| volumetric meshes and fitting them to geometric targets. 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. | ||
|
|
||
| \subsection ssecMeshSmoothingAlgorithm Smoothing and Fitting Algorithm | ||
|
|
||
| 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. | ||
|
fprotais marked this conversation as resolved.
Outdated
|
||
| 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 targets constrain boundary polygons to locally estimated tangent | ||
| planes; | ||
| - curve targets constrain selected mesh edges to target tangent directions; | ||
| - point targets attract individual vertices to prescribed positions. | ||
|
|
||
| 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. | ||
|
|
||
| \section secMeshSmoothing3API API | ||
|
|
||
| The main function of the package is `CGAL::boundary_aware_mesh_smoothing()`, | ||
| which takes a `CGAL::Mesh_complex_3_in_triangulation_3` as input and updates its vertex coordinates to improve element quality and fit to geometric targets. | ||
|
|
||
| \section secMeshSmoothing3Examples Examples | ||
|
|
||
| \subsection ssecMeshSmoothingC3t3 Direct Smoothing of a C3t3 | ||
|
|
||
| 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 | ||
| `boundary_aware_mesh_smoothing` is then called on the generated `C3t3`. | ||
|
|
||
| \cgalExample{Mesh_smoothing_3/c3t3_smooth.cpp} | ||
|
|
||
|
|
||
|
|
||
| */ | ||
| } /* namespace CGAL */ | ||
Uh oh!
There was an error while loading. Please reload this page.