Skip to content
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

Mesh_3 - add surface_only() named parameter #8781

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Mesh_3/examples/Mesh_3/remesh_polyhedral_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main()
facet_distance(0.001));

// Mesh generation
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, params::no_perturb().no_exude());
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, params::surface_only());

// Output the facets of the c3t3 to an OFF file. The facets will not be
// oriented.
Expand Down
85 changes: 49 additions & 36 deletions Mesh_3/include/CGAL/Mesh_3/Mesher_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ class Mesher_3
}

/// Launch mesh refinement
double refine_mesh(std::string dump_after_refine_surface_prefix = "");
double refine_mesh(std::string dump_after_refine_surface_prefix = "",
const bool surface_only = false);

/// Debug
std::string debug_info() const;
Expand Down Expand Up @@ -417,7 +418,7 @@ Mesher_3<C3T3,MC,MD>::Mesher_3(C3T3& c3t3,
template<class C3T3, class MC, class MD>
double
Mesher_3<C3T3,MC,MD>::
refine_mesh(std::string dump_after_refine_surface_prefix)
refine_mesh(std::string dump_after_refine_surface_prefix, const bool surface_only)
{
CGAL::Real_timer timer;
timer.start();
Expand Down Expand Up @@ -481,7 +482,12 @@ refine_mesh(std::string dump_after_refine_surface_prefix)

dump_c3t3(r_c3t3_, dump_after_refine_surface_prefix);

if(!forced_stop())
if(surface_only)
{
for(auto cit = r_tr.finite_cells_begin(); cit != r_tr.finite_cells_end(); ++cit)
r_c3t3_.remove_from_complex(cit);
}
else if(!forced_stop())
{
// Then scan volume and refine it
CGAL_MESH_3_TASK_BEGIN(scan_cells_task_handle);
Expand Down Expand Up @@ -575,42 +581,49 @@ refine_mesh(std::string dump_after_refine_surface_prefix)

facets_visitor_.activate();

std::cerr << "Start volume scan...";
CGAL_MESH_3_TASK_BEGIN(scan_cells_task_handle);
cells_mesher_.scan_triangulation();
CGAL_MESH_3_TASK_END(scan_cells_task_handle);
refinement_stage = REFINE_ALL;
std::cerr << "end scan. [Bad tets:" << cells_mesher_.size() << "]";
std::cerr << std::endl << std::endl;
elapsed_time += timer.time();
dump_c3t3(r_c3t3_, dump_after_refine_surface_prefix);
timer.stop(); timer.reset(); timer.start();

std::cerr << "Refining...\n";
std::cerr << "Legend of the following line: "
<< "(#vertices,#steps," << cells_mesher_.debug_info_header()
<< ")\n";
std::cerr << "(" << r_tr.number_of_vertices() << ","
<< nbsteps << "," << cells_mesher_.debug_info() << ")";

CGAL_MESH_3_TASK_BEGIN(refine_volume_mesh_task_handle);
while ( ! cells_mesher_.is_algorithm_done() &&
! forced_stop() )
if(surface_only)
{
cells_mesher_.one_step(cells_visitor_);
std::cerr
<< boost::format("\r \r"
"(%1%,%2%,%3%) (%|4$.1f| vertices/s)")
% r_tr.number_of_vertices()
% nbsteps % cells_mesher_.debug_info()
% (nbsteps / timer.time());
++nbsteps;
for(auto cit = r_tr.finite_cells_begin(); cit != r_tr.finite_cells_end(); ++cit)
r_c3t3_.remove_from_complex(cit);
}
CGAL_MESH_3_TASK_END(refine_volume_mesh_task_handle);
std::cerr << std::endl;
else
{
std::cerr << "Start volume scan...";
CGAL_MESH_3_TASK_BEGIN(scan_cells_task_handle);
cells_mesher_.scan_triangulation();
CGAL_MESH_3_TASK_END(scan_cells_task_handle);
refinement_stage = REFINE_ALL;
std::cerr << "end scan. [Bad tets:" << cells_mesher_.size() << "]";
std::cerr << std::endl << std::endl;
elapsed_time += timer.time();
dump_c3t3(r_c3t3_, dump_after_refine_surface_prefix);
timer.stop(); timer.reset(); timer.start();

std::cerr << "Refining...\n";
std::cerr << "Legend of the following line: "
<< "(#vertices,#steps," << cells_mesher_.debug_info_header()
<< ")\n";
std::cerr << "(" << r_tr.number_of_vertices() << ","
<< nbsteps << "," << cells_mesher_.debug_info() << ")";

std::cerr << "Total refining volume time: " << timer.time() << "s" << std::endl;
std::cerr << "Total refining time: " << timer.time()+elapsed_time << "s" << std::endl;
CGAL_MESH_3_TASK_BEGIN(refine_volume_mesh_task_handle);
while ( ! cells_mesher_.is_algorithm_done() &&
! forced_stop() )
{
cells_mesher_.one_step(cells_visitor_);
std::cerr
<< boost::format("\r \r"
"(%1%,%2%,%3%) (%|4$.1f| vertices/s)")
% r_tr.number_of_vertices()
% nbsteps % cells_mesher_.debug_info()
% (nbsteps / timer.time());
++nbsteps;
}
CGAL_MESH_3_TASK_END(refine_volume_mesh_task_handle);
std::cerr << std::endl;
std::cerr << "Total refining volume time: " << timer.time() << "s" << std::endl;
}
std::cerr << "Total refining time: " << timer.time() + elapsed_time << "s" << std::endl;
std::cerr << std::endl;

CGAL_postcondition(r_tr.is_valid());
Expand Down
7 changes: 4 additions & 3 deletions Mesh_3/include/CGAL/refine_mesh_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ void refine_mesh_3_impl(C3T3& c3t3,
, mesh_options.pointer_to_stop_atomic_boolean
#endif
);
double refine_time = mesher.refine_mesh(mesh_options.dump_after_refine_surface_prefix);
double refine_time = mesher.refine_mesh(mesh_options.dump_after_refine_surface_prefix,
mesh_options.surface_only);
c3t3.clear_manifold_info();

dump_c3t3(c3t3, mesh_options.dump_after_refine_prefix);
Expand Down Expand Up @@ -387,7 +388,7 @@ void refine_mesh_3_impl(C3T3& c3t3,
}

// Perturbation
if ( perturb )
if ( perturb && !mesh_options.surface_only )
{
double perturb_time_limit = refine_time;

Expand All @@ -403,7 +404,7 @@ void refine_mesh_3_impl(C3T3& c3t3,
}

// Exudation
if ( exude )
if ( exude && !mesh_options.surface_only )
{
double exude_time_limit = refine_time;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ struct Mesh_3_options {
, dump_after_exude_prefix()
, number_of_initial_points(-1)
, nonlinear_growth_of_balls(nonlinear)
, surface_only(false)
, maximal_number_of_vertices(0)
, pointer_to_error_code(0)
#ifndef CGAL_NO_ATOMIC
Expand All @@ -157,6 +158,7 @@ struct Mesh_3_options {
std::string dump_after_exude_prefix;
int number_of_initial_points;
bool nonlinear_growth_of_balls;
bool surface_only;
std::size_t maximal_number_of_vertices;
Mesh_error_code* pointer_to_error_code;
#ifndef CGAL_NO_ATOMIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,16 @@ features(const MeshDomain& /*domain*/)
typedef Named_function_parameters<::CGAL::parameters::internal::Features_options, ::CGAL::internal_np::features_option_param_t, CGAL_NP_BASE> Param;
return CGAL_NP_BUILD(Param,Generator()());
}

// -----------------------------------
// Surface only (replacing Surface_mesher)
// -----------------------------------
inline Named_function_parameters<::CGAL::parameters::internal::Mesh_3_options, ::CGAL::internal_np::mesh_param_t, CGAL_NP_BASE>
surface_only()
{
typedef Named_function_parameters<::CGAL::parameters::internal::Mesh_3_options, ::CGAL::internal_np::mesh_param_t, CGAL_NP_BASE> Param;
::CGAL::parameters::internal::Mesh_3_options options;

options.surface_only = true;
return CGAL_NP_BUILD(Param, options);
}