-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Tetrahedral remeshing - deal with c3t3 complex edges #7909
Merged
sloriot
merged 14 commits into
CGAL:master
from
janetournois:Tet_remeshing-from_c3t3-jtournois
Dec 18, 2023
+230
−72
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9c2eba3
simplify example code using Boolean_property_map
janetournois a66999d
fill the edge_is_constrained_map based on the c3t3 complex edges
janetournois 4ad8027
add example using edge_is_constrained_map in convert_to_triangulation_3
janetournois ef7ab56
add missing using
janetournois a91f8d0
doc
janetournois 3584d34
fix example name
janetournois 1d5bef3
use ordered pair
janetournois d98a623
collect features and use edge_is_constrained_map in demo code
janetournois 43b8b69
use is_in_complex() inside bigger condition
janetournois f6a9886
add missing namespace
janetournois d09e1fe
add missing template
janetournois b0361f7
set_index(v) must be able dimension -1 to deal with far points
janetournois 2874c2b
add debug counting far points
janetournois f241f4b
rename example with shorter name
janetournois File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
96 changes: 96 additions & 0 deletions
96
Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.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,96 @@ | ||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> | ||
|
||
#include <CGAL/Mesh_triangulation_3.h> | ||
#include <CGAL/Mesh_complex_3_in_triangulation_3.h> | ||
#include <CGAL/Mesh_criteria_3.h> | ||
|
||
#include <CGAL/Polyhedral_mesh_domain_with_features_3.h> | ||
#include <CGAL/make_mesh_3.h> | ||
|
||
#include <CGAL/tetrahedral_remeshing.h> | ||
|
||
#include <CGAL/IO/File_medit.h> | ||
|
||
// Domain | ||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; | ||
typedef CGAL::Mesh_polyhedron_3<K>::type Polyhedron; | ||
typedef CGAL::Polyhedral_mesh_domain_with_features_3<K> Mesh_domain; | ||
|
||
#ifdef CGAL_CONCURRENT_MESH_3 | ||
typedef CGAL::Parallel_tag Concurrency_tag; | ||
#else | ||
typedef CGAL::Sequential_tag Concurrency_tag; | ||
#endif | ||
|
||
// Triangulation for Meshing | ||
typedef CGAL::Mesh_triangulation_3<Mesh_domain, CGAL::Default, Concurrency_tag>::type Tr; | ||
typedef CGAL::Mesh_complex_3_in_triangulation_3< | ||
Tr, Mesh_domain::Corner_index, Mesh_domain::Curve_index> C3t3; | ||
|
||
// Criteria | ||
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria; | ||
|
||
// Triangulation for Remeshing | ||
typedef CGAL::Triangulation_3<typename Tr::Geom_traits, | ||
typename Tr::Triangulation_data_structure> Triangulation_3; | ||
using Vertex_handle = Triangulation_3::Vertex_handle; | ||
|
||
using Vertex_pair = std::pair<Vertex_handle, Vertex_handle>; | ||
using Constraints_set = std::unordered_set<Vertex_pair, boost::hash<Vertex_pair>>; | ||
using Constraints_pmap = CGAL::Boolean_property_map<Constraints_set>; | ||
|
||
|
||
// To avoid verbose function and named parameters call | ||
using namespace CGAL::parameters; | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
const std::string fname = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/fandisk.off"); | ||
std::ifstream input(fname); | ||
Polyhedron polyhedron; | ||
input >> polyhedron; | ||
if (input.fail() || !CGAL::is_triangle_mesh(polyhedron)) { | ||
std::cerr << "Error: Input invalid " << fname << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
// Create domain | ||
Mesh_domain domain(polyhedron); | ||
|
||
// Get sharp features | ||
domain.detect_features(); | ||
|
||
// Mesh criteria | ||
Mesh_criteria criteria(edge_size = 0.025, | ||
facet_angle = 25, facet_size = 0.05, facet_distance = 0.005, | ||
cell_radius_edge_ratio = 3, cell_size = 0.05); | ||
|
||
// Mesh generation | ||
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria); | ||
|
||
CGAL::dump_c3t3(c3t3, "out"); | ||
|
||
Constraints_set constraints; | ||
Constraints_pmap constraints_pmap(constraints); | ||
|
||
Triangulation_3 tr = CGAL::convert_to_triangulation_3(std::move(c3t3), | ||
CGAL::parameters::edge_is_constrained_map(constraints_pmap)); | ||
|
||
//note we use the move semantic, with std::move(c3t3), | ||
// to avoid a copy of the triangulation by the function | ||
// `CGAL::convert_to_triangulation_3()` | ||
// After the call to this function, c3t3 is an empty and valid C3t3. | ||
//It is possible to use : CGAL::convert_to_triangulation_3(c3t3), | ||
// Then the triangulation is copied and duplicated, and c3t3 remains as is. | ||
|
||
const double target_edge_length = 0.1;//coarsen the mesh | ||
CGAL::tetrahedral_isotropic_remeshing(tr, target_edge_length, | ||
CGAL::parameters::number_of_iterations(3) | ||
.edge_is_constrained_map(constraints_pmap)); | ||
|
||
std::ofstream out("out_remeshed.mesh"); | ||
CGAL::IO::write_MEDIT(out, tr); | ||
out.close(); | ||
|
||
return EXIT_SUCCESS; | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line should be:
note the double quotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janetournois This discussion is still left unsolved. And it seems Albert it right. The result in a local doc compilation is the following:
(I will convert this comment to a issue afterward.)