-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PMP::isotropic_remeshing - add variable sizing field (#4891)
## Summary of Changes This PR introduces the possibility to chose a variable sizing field for isotropic remeshing. ## Release Management * Affected package(s): PMP * Feature/Small Feature (if any): [Here](https://cgal.geometryfactory.com/CGAL/Members/wiki/Features/Small_Features/Curvature-adaptive_remeshing) -- **pre-approval on 2023/10/24** * Link to compiled documentation (obligatory for small feature) [*wrong link name to be changed*](httpssss://wrong_URL_to_be_changed/Manual/Pkg) * License and copyright ownership: unchanged * Depends on #6760 ## TODO: - [x] check branch size (for @sloriot) - [x] handle the update of the interpolated curvature branch (for @sloriot)
- Loading branch information
Showing
24 changed files
with
1,947 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPSizingField.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/// \ingroup PkgPolygonMeshProcessingConcepts | ||
/// \cgalConcept | ||
/// | ||
/// The concept `PMPSizingField` defines the requirements for the sizing field | ||
/// used in `CGAL::Polygon_mesh_processing::isotropic_remeshing()` to define | ||
/// the target length for every individual edge during the remeshing process. | ||
/// | ||
/// \cgalHasModelsBegin | ||
/// \cgalHasModels{CGAL::Polygon_mesh_processing::Uniform_sizing_field} | ||
/// \cgalHasModels{CGAL::Polygon_mesh_processing::Adaptive_sizing_field} | ||
/// \cgalHasModelsEnd | ||
/// | ||
|
||
|
||
class PMPSizingField{ | ||
public: | ||
|
||
/// @name Types | ||
/// @{ | ||
|
||
/// Vertex descriptor type | ||
typedef boost::graph_traits<PolygonMesh>::vertex_descriptor vertex_descriptor; | ||
|
||
/// Halfedge descriptor type | ||
typedef boost::graph_traits<PolygonMesh>::halfedge_descriptor halfedge_descriptor; | ||
|
||
/// 3D point type matching the value type of the vertex property map passed to `CGAL::Polygon_mesh_processing::isotropic_remeshing()` | ||
typedef unspecified_type Point_3; | ||
|
||
/// Polygon mesh type matching the type passed to `CGAL::Polygon_mesh_processing::isotropic_remeshing()` | ||
typedef unspecified_type PolygonMesh; | ||
|
||
/// Number type matching the `FT` type of the geometric traits passed to `CGAL::Polygon_mesh_processing::isotropic_remeshing()` | ||
typedef unspecified_type FT; | ||
|
||
/// @} | ||
|
||
/// @name Functions | ||
/// @{ | ||
|
||
/// a function that returns the sizing value at `v`. | ||
FT at(const vertex_descriptor v) const; | ||
|
||
/// a function controlling edge split and edge collapse, | ||
/// returning the ratio of the current edge length and the local target edge length between | ||
/// the points of `va` and `vb` in case the current edge is too long, and `std::nullopt` otherwise. | ||
std::optional<FT> is_too_long(const vertex_descriptor va, | ||
const vertex_descriptor vb) const; | ||
|
||
/// a function controlling edge collapse by returning the ratio of the squared length of `h` and the | ||
/// local target edge length if it is too short, and `std::nullopt` otherwise. | ||
std::optional<FT> is_too_short(const halfedge_descriptor h, | ||
const PolygonMesh& pmesh) const; | ||
|
||
/// a function returning the location of the split point of the edge of `h`. | ||
Point_3 split_placement(const halfedge_descriptor h, | ||
const PolygonMesh& pmesh) const; | ||
|
||
/// a function that updates the sizing field value at the vertex `v`. | ||
void update(const vertex_descriptor v, | ||
const PolygonMesh& pmesh); | ||
|
||
/// @} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+309 KB
Polygon_mesh_processing/doc/Polygon_mesh_processing/fig/uniform_and_adaptive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...h_processing/examples/Polygon_mesh_processing/isotropic_remeshing_with_sizing_example.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> | ||
#include <CGAL/Surface_mesh.h> | ||
#include <CGAL/Polygon_mesh_processing/remesh.h> | ||
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h> | ||
#include <CGAL/Polygon_mesh_processing/Adaptive_sizing_field.h> | ||
|
||
#include <fstream> | ||
|
||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; | ||
typedef CGAL::Surface_mesh<K::Point_3> Mesh; | ||
|
||
namespace PMP = CGAL::Polygon_mesh_processing; | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/nefertiti.off"); | ||
|
||
Mesh mesh; | ||
if (!PMP::IO::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh)) { | ||
std::cerr << "Not a valid input file." << std::endl; | ||
return 1; | ||
} | ||
|
||
std::cout << "Start remeshing of " << filename | ||
<< " (" << num_faces(mesh) << " faces)..." << std::endl; | ||
|
||
const double tol = 0.001; | ||
const std::pair edge_min_max{0.001, 0.5}; | ||
PMP::Adaptive_sizing_field<Mesh> sizing_field(tol, edge_min_max, faces(mesh), mesh); | ||
unsigned int nb_iter = 5; | ||
|
||
PMP::isotropic_remeshing( | ||
faces(mesh), | ||
sizing_field, | ||
mesh, | ||
CGAL::parameters::number_of_iterations(nb_iter) | ||
.number_of_relaxation_steps(3) | ||
); | ||
|
||
CGAL::IO::write_polygon_mesh("out.off", mesh, CGAL::parameters::stream_precision(17)); | ||
|
||
std::cout << "Remeshing done." << std::endl; | ||
|
||
return 0; | ||
} |
Oops, something went wrong.