From a0948a9dacbcc0f114f252a9992d697da6d7e22f Mon Sep 17 00:00:00 2001 From: Clement Jamin Date: Tue, 1 Jul 2014 11:34:40 +0200 Subject: [PATCH] Remove the "domain" parameter of the exuder It had been added for the parallel version, but it's not needed anymore --- .../Mesh_3_optimization_plugin_cgal_code.cpp | 5 +- .../Mesh_3/mesh_implicit_ellipsoid.cpp | 2 +- .../mesh_optimization_lloyd_example.cpp | 2 +- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 88 +++++++++---------- Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h | 84 ++++++++---------- Mesh_3/include/CGAL/exude_mesh_3.h | 12 ++- Mesh_3/include/CGAL/refine_mesh_3.h | 1 - Mesh_3/test/Mesh_3/test_meshing_utilities.h | 2 +- 8 files changed, 91 insertions(+), 105 deletions(-) diff --git a/Mesh_3/demo/Mesh_3/Mesh_3_optimization_plugin_cgal_code.cpp b/Mesh_3/demo/Mesh_3/Mesh_3_optimization_plugin_cgal_code.cpp index 16260496cbd..8307be69868 100644 --- a/Mesh_3/demo/Mesh_3/Mesh_3_optimization_plugin_cgal_code.cpp +++ b/Mesh_3/demo/Mesh_3/Mesh_3_optimization_plugin_cgal_code.cpp @@ -677,8 +677,7 @@ class Optimization_function < Domain, Exude_parameters > typedef C3t3::Triangulation Tr; typedef CGAL::Mesh_3::Min_dihedral_angle_criterion Sc; typedef Exude_visitor Visitor; - typedef CGAL::Mesh_3::Slivers_exuder< - C3t3,Domain,Sc,Visitor> Exuder; + typedef CGAL::Mesh_3::Slivers_exuder Exuder; typedef Optimization_function_base< Domain > Base; @@ -716,7 +715,7 @@ protected: if ( NULL != exude_ ) { return CGAL::MESH_OPTIMIZATION_UNKNOWN_ERROR; } // Create exuder - exude_ = new Exuder(c3t3, domain, criterion_); + exude_ = new Exuder(c3t3, criterion_); if ( NULL == exude_ ) { return CGAL::MESH_OPTIMIZATION_UNKNOWN_ERROR; } // Set time_limit diff --git a/Mesh_3/examples/Mesh_3/mesh_implicit_ellipsoid.cpp b/Mesh_3/examples/Mesh_3/mesh_implicit_ellipsoid.cpp index 66de13b3476..dbc162aa2c4 100644 --- a/Mesh_3/examples/Mesh_3/mesh_implicit_ellipsoid.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_implicit_ellipsoid.cpp @@ -60,7 +60,7 @@ int main() CGAL::perturb_mesh_3(c3t3, domain, time_limit=5, sliver_bound=12); // Exudation - CGAL::exude_mesh_3(c3t3, domain); + CGAL::exude_mesh_3(c3t3); // Output medit_file.open("out_optimized.mesh"); diff --git a/Mesh_3/examples/Mesh_3/mesh_optimization_lloyd_example.cpp b/Mesh_3/examples/Mesh_3/mesh_optimization_lloyd_example.cpp index 04a2b869653..01b093b893b 100644 --- a/Mesh_3/examples/Mesh_3/mesh_optimization_lloyd_example.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_optimization_lloyd_example.cpp @@ -52,7 +52,7 @@ int main() no_perturb(), no_exude()); CGAL::lloyd_optimize_mesh_3(c3t3_bis, domain, time_limit=30); - CGAL::exude_mesh_3(c3t3_bis, domain, sliver_bound=10, time_limit=10); + CGAL::exude_mesh_3(c3t3_bis, sliver_bound=10, time_limit=10); // Output std::ofstream medit_file("out.mesh"); diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index e27bc1b4c55..426617802c3 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -3393,54 +3393,54 @@ bool C3T3_helpers:: try_lock_and_get_incident_cells(const Vertex_handle& v, Cell_vector &cells) const -{ - // We need to lock v individually first, to be sure v->cell() is valid - if (!try_lock_vertex(v)) - return false; - - Cell_handle d = v->cell(); - if (!try_lock_element(d)) // LOCK { - unlock_all_elements(); - return false; - } - cells.push_back(d); - d->tds_data().mark_in_conflict(); - int head=0; - int tail=1; - do { - Cell_handle c = cells[head]; + // We need to lock v individually first, to be sure v->cell() is valid + if (!try_lock_vertex(v)) + return false; - for (int i=0; i<4; ++i) { - if (c->vertex(i) == v) - continue; - Cell_handle next = c->neighbor(i); - - if (!try_lock_element(next)) // LOCK - { - BOOST_FOREACH(Cell_handle& ch, - std::make_pair(cells.begin(), cells.end())) - { - ch->tds_data().clear(); - } - cells.clear(); - unlock_all_elements(); - return false; - } - if (! next->tds_data().is_clear()) - continue; - cells.push_back(next); - ++tail; - next->tds_data().mark_in_conflict(); + Cell_handle d = v->cell(); + if (!try_lock_element(d)) // LOCK + { + unlock_all_elements(); + return false; } - ++head; - } while(head != tail); - BOOST_FOREACH(Cell_handle& ch, std::make_pair(cells.begin(), cells.end())) - { - ch->tds_data().clear(); + cells.push_back(d); + d->tds_data().mark_in_conflict(); + int head=0; + int tail=1; + do { + Cell_handle c = cells[head]; + + for (int i=0; i<4; ++i) { + if (c->vertex(i) == v) + continue; + Cell_handle next = c->neighbor(i); + + if (!try_lock_element(next)) // LOCK + { + BOOST_FOREACH(Cell_handle& ch, + std::make_pair(cells.begin(), cells.end())) + { + ch->tds_data().clear(); + } + cells.clear(); + unlock_all_elements(); + return false; + } + if (! next->tds_data().is_clear()) + continue; + cells.push_back(next); + ++tail; + next->tds_data().mark_in_conflict(); + } + ++head; + } while(head != tail); + BOOST_FOREACH(Cell_handle& ch, std::make_pair(cells.begin(), cells.end())) + { + ch->tds_data().clear(); + } + return true; } - return true; -} template template diff --git a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h index 346567ccf8f..14c461fb7b5 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h +++ b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -361,7 +360,6 @@ private: template < typename C3T3, - typename MeshDomain, typename SliverCriteria, typename Visitor_ = Null_exuder_visitor, typename FT = typename C3T3::Triangulation::Geom_traits::FT @@ -379,7 +377,7 @@ public: // Types private: // Types - typedef Slivers_exuder Self; + typedef Slivers_exuder Self; typedef typename C3T3::Triangulation Tr; typedef typename Tr::Weighted_point Weighted_point; @@ -426,10 +424,7 @@ private: // Types // Should define // - after_cell_pumped(std::size_t cells_left_number) typedef Visitor_ Visitor; - - // Helper - typedef class C3T3_helpers C3T3_helpers; - + using Base::get_lock_data_structure; public: // methods @@ -442,7 +437,6 @@ public: // methods * max_weight(v) < d*dist(v,nearest_vertice(v)) */ Slivers_exuder(C3T3& c3t3, - const MeshDomain& domain, const SliverCriteria& criterion, double d = 0.45); @@ -458,9 +452,6 @@ public: // methods WallClockTimer t; #endif - // Reset sliver value cache - helper_.reset_cache(); - Mesh_optimization_return_code ret = pump_vertices(sliver_criteria_.sliver_bound(), visitor); @@ -866,7 +857,6 @@ private: bool initialized_; SliverCriteria sliver_criteria_; - C3T3_helpers helper_; // Timer double time_limit_; @@ -931,9 +921,9 @@ private: -template -Slivers_exuder:: -Slivers_exuder(C3T3& c3t3, const Md& domain, const SC& criteria, double d) +template +Slivers_exuder:: +Slivers_exuder(C3T3& c3t3, const SC& criteria, double d) : Base(c3t3.bbox(), Concurrent_mesher_config::get().locking_grid_num_cells_per_axis) , c3t3_(c3t3) @@ -944,7 +934,6 @@ Slivers_exuder(C3T3& c3t3, const Md& domain, const SC& criteria, double d) , num_of_treated_vertices_(0) , initialized_(false) , sliver_criteria_(criteria) - , helper_(c3t3_,domain,get_lock_data_structure()) , time_limit_(-1) , running_time_() { @@ -953,10 +942,10 @@ Slivers_exuder(C3T3& c3t3, const Md& domain, const SC& criteria, double d) } -template +template template Mesh_optimization_return_code -Slivers_exuder:: +Slivers_exuder:: pump_vertices(double sliver_criterion_limit, Visitor& visitor) { @@ -1103,10 +1092,10 @@ pump_vertices(double sliver_criterion_limit, } // end function pump_vertices -template +template template bool -Slivers_exuder:: +Slivers_exuder:: pump_vertex(const Vertex_handle& pumped_vertex, bool *could_lock_zone) { @@ -1130,9 +1119,9 @@ pump_vertex(const Vertex_handle& pumped_vertex, } -template +template void -Slivers_exuder:: +Slivers_exuder:: initialize_prestar_and_criterion_values(const Vertex_handle& v, Pre_star& pre_star, Sliver_values& criterion_values, @@ -1143,8 +1132,9 @@ initialize_prestar_and_criterion_values(const Vertex_handle& v, // Parallel if (could_lock_zone) { - if (!helper_.try_lock_and_get_incident_cells(v, incident_cells)) + if (!tr_.try_lock_and_get_incident_cells(v, incident_cells)) { + this->unlock_all_elements(); *could_lock_zone = false; return; } @@ -1183,9 +1173,9 @@ initialize_prestar_and_criterion_values(const Vertex_handle& v, } -template +template bool -Slivers_exuder:: +Slivers_exuder:: expand_prestar(const Cell_handle& cell_to_add, const Vertex_handle& pumped_vertex, Pre_star& pre_star, @@ -1279,9 +1269,9 @@ expand_prestar(const Cell_handle& cell_to_add, } -template +template double -Slivers_exuder:: +Slivers_exuder:: get_best_weight(const Vertex_handle& v, bool *could_lock_zone) const { // Get pre_star and criterion_values @@ -1364,9 +1354,9 @@ get_best_weight(const Vertex_handle& v, bool *could_lock_zone) const } -template -typename Slivers_exuder::Umbrella -Slivers_exuder:: +template +typename Slivers_exuder::Umbrella +Slivers_exuder:: get_umbrella(const Facet_vector& facets, const Vertex_handle& v) const { @@ -1387,10 +1377,10 @@ get_umbrella(const Facet_vector& facets, } -template +template template void -Slivers_exuder:: +Slivers_exuder:: restore_cells_and_boundary_facets( const Boundary_facets_from_outside& boundary_facets_from_outside, const Vertex_handle& new_vertex) @@ -1442,9 +1432,9 @@ restore_cells_and_boundary_facets( -template -typename Slivers_exuder::Ordered_edge -Slivers_exuder::get_opposite_ordered_edge( +template +typename Slivers_exuder::Ordered_edge +Slivers_exuder::get_opposite_ordered_edge( const Facet& facet, const Vertex_handle& vertex) const { @@ -1472,9 +1462,9 @@ Slivers_exuder::get_opposite_ordered_edge( } -template +template void -Slivers_exuder:: +Slivers_exuder:: restore_internal_facets(const Umbrella& umbrella, const Vertex_handle& new_vertex) { @@ -1500,10 +1490,10 @@ restore_internal_facets(const Umbrella& umbrella, } -template +template template void -Slivers_exuder:: +Slivers_exuder:: update_mesh(const Weighted_point& new_point, const Vertex_handle& old_vertex, bool *could_lock_zone) @@ -1565,10 +1555,10 @@ update_mesh(const Weighted_point& new_point, #ifdef CGAL_LINKED_WITH_TBB // For parallel version -template +template template void -Slivers_exuder:: +Slivers_exuder:: enqueue_task(Cell_handle ch, unsigned int erase_counter, double value) { this->enqueue_work( @@ -1580,10 +1570,10 @@ enqueue_task(Cell_handle ch, unsigned int erase_counter, double value) #ifdef CGAL_MESH_3_DEBUG_SLIVERS_EXUDER -template +template template bool -Slivers_exuder:: +Slivers_exuder:: check_pre_star(const Pre_star& pre_star, Input_facet_it begin, Input_facet_it end, @@ -1687,9 +1677,9 @@ check_pre_star(const Pre_star& pre_star, -template +template bool -Slivers_exuder:: +Slivers_exuder:: check_pre_star(const Pre_star& pre_star, const Weighted_point& wp, const Vertex_handle& vh) const @@ -1716,9 +1706,9 @@ check_pre_star(const Pre_star& pre_star, } -template +template bool -Slivers_exuder:: +Slivers_exuder:: check_ratios(const Sliver_values& criterion_values, const Weighted_point& wp, const Vertex_handle& vh) const diff --git a/Mesh_3/include/CGAL/exude_mesh_3.h b/Mesh_3/include/CGAL/exude_mesh_3.h index ce24b1dfa20..de3eecf9986 100644 --- a/Mesh_3/include/CGAL/exude_mesh_3.h +++ b/Mesh_3/include/CGAL/exude_mesh_3.h @@ -38,34 +38,32 @@ BOOST_PARAMETER_FUNCTION( (Mesh_optimization_return_code), exude_mesh_3, parameters::tag, - (required (in_out(c3t3),*) (domain,*) ) + (required (in_out(c3t3),*) ) (optional (time_limit_, *, 0 ) (sliver_bound_, *, parameters::default_values::exude_sliver_bound ) ) ) { - return exude_mesh_3_impl(c3t3, domain, time_limit_, sliver_bound_); + return exude_mesh_3_impl(c3t3, time_limit_, sliver_bound_); } -template +template Mesh_optimization_return_code exude_mesh_3_impl(C3T3& c3t3, - const MeshDomain& domain, const double time_limit, const double sliver_bound) { - typedef MeshDomain Md; typedef typename C3T3::Triangulation Tr; typedef Mesh_3::Min_dihedral_angle_criterion Sc; //typedef Mesh_3::Radius_radio_criterion Sc; - typedef typename Mesh_3::Slivers_exuder Exuder; + typedef typename Mesh_3::Slivers_exuder Exuder; // Create exuder Sc criterion(sliver_bound, c3t3.triangulation()); - Exuder exuder(c3t3, domain, criterion); + Exuder exuder(c3t3, criterion); // Set time_limit exuder.set_time_limit(time_limit); diff --git a/Mesh_3/include/CGAL/refine_mesh_3.h b/Mesh_3/include/CGAL/refine_mesh_3.h index d7208c8ce06..0c4cc81a56f 100644 --- a/Mesh_3/include/CGAL/refine_mesh_3.h +++ b/Mesh_3/include/CGAL/refine_mesh_3.h @@ -463,7 +463,6 @@ void refine_mesh_3_impl(C3T3& c3t3, exude_time_limit = exude.time_limit(); exude_mesh_3(c3t3, - domain, parameters::time_limit = exude_time_limit, parameters::sliver_bound = exude.bound()); } diff --git a/Mesh_3/test/Mesh_3/test_meshing_utilities.h b/Mesh_3/test/Mesh_3/test_meshing_utilities.h index 1e81bb73d95..49ee9ed8b52 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_utilities.h +++ b/Mesh_3/test/Mesh_3/test_meshing_utilities.h @@ -129,7 +129,7 @@ struct Tester // Quality should increase C3t3 exude_c3t3(c3t3); std::cerr << "Exude...\n"; - CGAL::exude_mesh_3(exude_c3t3, domain); + CGAL::exude_mesh_3(exude_c3t3); verify_c3t3(exude_c3t3,domain,domain_type,v,v,f,f); verify_c3t3_quality(c3t3,exude_c3t3); verify_c3t3_volume(exude_c3t3, volume*0.95, volume*1.05);