-
Notifications
You must be signed in to change notification settings - Fork 1.6k
parallel lloyd_optimize_mesh_2 #5674
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
Open
yg42
wants to merge
4
commits into
CGAL:main
Choose a base branch
from
yg42:lloyd-threaded-branch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+256
−1
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
124 changes: 124 additions & 0 deletions
124
Mesh_2/examples/Mesh_2/test_parallel_Mesh_global_optimizer.cpp
This file contains hidden or 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,124 @@ | ||
| #define CGAL_MESH_2_OPTIMIZER_VERBOSE | ||
| #define CGAL_MESH_2_OPTIMIZERS_DEBUG | ||
| #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> | ||
| #include <CGAL/Constrained_Delaunay_triangulation_2.h> | ||
| #include <CGAL/Delaunay_mesher_2.h> | ||
| #include <CGAL/Delaunay_mesh_face_base_2.h> | ||
| #include <CGAL/Delaunay_mesh_vertex_base_2.h> | ||
|
|
||
| #include <CGAL/lloyd_optimize_mesh_2.h> | ||
| #include <CGAL/point_generators_2.h> | ||
| #include <CGAL/random_selection.h> | ||
|
|
||
| #include <CGAL/draw_triangulation_2.h> | ||
| #include <limits.h> | ||
|
|
||
|
|
||
| #include <CGAL/Delaunay_triangulation_2.h> | ||
| #include <CGAL/Delaunay_triangulation_adaptation_traits_2.h> | ||
| #include <CGAL/Delaunay_triangulation_adaptation_policies_2.h> | ||
|
|
||
|
|
||
| #include <iostream> | ||
|
|
||
|
|
||
|
|
||
| typedef CGAL::Exact_predicates_inexact_constructions_kernel K; | ||
| typedef CGAL::Delaunay_mesh_vertex_base_2<K> Vb; | ||
| typedef CGAL::Delaunay_mesh_face_base_2<K> Fb; | ||
| typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds; | ||
| typedef CGAL::Constrained_Delaunay_triangulation_2<K, Tds> CDT; | ||
| typedef CGAL::Delaunay_triangulation_2<K> DT; | ||
|
|
||
| typedef CDT::Point Point; | ||
| typedef CGAL::Creator_uniform_2<double,Point> Creator; | ||
|
|
||
| typedef CDT::Vertex_handle Vertex_handle; | ||
| typedef CDT::Vertex_iterator Vertex_iterator; | ||
|
|
||
| #define RADIUS 5.5 | ||
| #define RADIUS_BIRTH 5 | ||
| #define RADIUS_DEATH 5 | ||
|
|
||
|
|
||
| void cell_death(CDT &cdt) | ||
| { | ||
| CDT::Finite_vertices_iterator it; | ||
| // CDT::Vertex_handle v; // equivalent à l'iterateur | ||
|
|
||
| // std::vector<CDT::Vertex_handle> vector_vertices; | ||
| std::vector<CDT::Vertex_handle> vector_vertices; | ||
| std::vector<CDT::Vertex_handle> dead_cells; | ||
| std::vector<CDT::Vertex_handle>::iterator it_cells; | ||
| int count=0; | ||
| for (it = cdt.finite_vertices_begin(); | ||
| it!= cdt.finite_vertices_end(); | ||
| ++it) | ||
| { | ||
| // on ne garde que les points à l'intérieur des contraintes | ||
| // delete only points without constraints | ||
| if (!cdt.are_there_incident_constraints(it)) | ||
| { | ||
| vector_vertices.push_back(it); | ||
| count++; | ||
| } | ||
| } | ||
|
|
||
| int n =10; | ||
|
|
||
| random_selection(vector_vertices.begin(), vector_vertices.end(), n, | ||
| std::back_inserter(dead_cells)); | ||
|
|
||
|
|
||
| for (it_cells = dead_cells.begin(); it_cells!= dead_cells.end(); ++it_cells) | ||
| cdt.remove(*it_cells); | ||
|
|
||
| } | ||
|
|
||
| void cell_birth(CDT &cdt) | ||
| { | ||
| // insert random points | ||
| CGAL::Random_points_in_disc_2<Point,Creator> g(RADIUS_BIRTH); | ||
| int new_cells = 10; | ||
| for (int i=0; i<new_cells; ++i) | ||
| { | ||
| cdt.insert(*g++); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| int startSimu(int nb_points, int nb_iter) | ||
| { | ||
|
|
||
| CDT cdt; | ||
| // insert random points at first | ||
| CGAL::Random_points_in_disc_2<Point,Creator> g(RADIUS); | ||
| for (int i=0; i<nb_points; ++i) | ||
| { | ||
| cdt.insert(*g++); | ||
| } | ||
|
|
||
|
|
||
| // loop on birth death and lloyd optimization | ||
| for (int n=0; n<nb_iter; ++n) | ||
| { | ||
| lloyd_optimize_mesh_2(cdt, | ||
| CGAL::parameters::max_iteration_number = nb_iter, | ||
| CGAL::parameters::mark = false); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| /// main function | ||
| int main(int argc, char**argv) | ||
| { | ||
| // arguments | ||
| int nb_points = 20; // number of points | ||
| int nb_iter=5; // nb of iterations | ||
|
|
||
|
|
||
| return startSimu(nb_points, nb_iter); | ||
| } |
This file contains hidden or 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 hidden or 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
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.
this line should be replaced by
t, itBegin, itEndThere 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.
Do you mean this will solve the problem ?
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.
It should solve the problem, yes!
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.
However, the crash I was meeting was not the one you mention in the title message.