Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1167c30
Naive parallellization of corefine
LeoValque May 27, 2026
02656bf
Merge remote-tracking branch 'afabri/Kernel-combine_orientation-GF' i…
LeoValque May 27, 2026
ec971da
Commit to not push and append
LeoValque May 28, 2026
0e175fb
Solved fusion conflict
LeoValque Jun 4, 2026
9dbe1ae
Make intersection_callback more generic
LeoValque Jun 8, 2026
a560f0e
Merge branch 'AABB-add_parallellization' into PMP-boolops_enhancement
LeoValque Jun 8, 2026
bb309c6
Merge branch 'AABB-add_parallellization' into PMP-boolops_enhancement
LeoValque Jun 15, 2026
13a1d3d
Replace box_d by AABB_tree and collect all edge-face intersection thr…
LeoValque Jun 15, 2026
2a71ce4
clean unused comment code
LeoValque Jun 15, 2026
e89dcc7
Rewrite construction of the output of boolean operations, write a spe…
LeoValque Jun 24, 2026
0389251
Parallelisation of fill_new_triangle_mesh
LeoValque Jun 25, 2026
91d2bb3
Add corefinement_mesh_union_bench
LeoValque Jun 25, 2026
5159e56
Add AABB_tree_build_helper
LeoValque Jul 10, 2026
b9bdd23
parallel_call of connected components
LeoValque Jul 10, 2026
b6b2b49
Merge branch 'AABB-add_parallellization' into PMP-boolops_enhancement
LeoValque Jul 23, 2026
7fecb19
Merge branch 'AABB-add_parallellization' into PMP-boolops_enhancement
LeoValque Jul 28, 2026
97e6580
Merge branch 'AABB-add_parallellization' into PMP-boolops_enhancement
LeoValque Jul 30, 2026
efb2c78
Merge remote-tracking branch 'origin/main' into PMP-bool_ops_parallel…
LeoValque Aug 27, 2026
f3dea33
uncomplete fusion
LeoValque Aug 27, 2026
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
4 changes: 4 additions & 0 deletions Box_intersection_d/include/CGAL/box_intersection_d.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ void box_intersection_segment_tree_d(
static_assert (!std::is_convertible<ConcurrencyTag, Parallel_tag>::value,
"Parallel_tag is enabled but TBB is unavailable.");
#else // CGAL_LINKED_WITH_TBB
// if(std::is_convertible<ConcurrencyTag, Parallel_tag>::value)
// {
// std::nth_element()
// }
if(std::is_convertible<ConcurrencyTag, Parallel_tag>::value)
{
// Here is an illustration for n=2.
Expand Down
2 changes: 2 additions & 0 deletions PMP_Boolean_operations/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ find_package(CGAL REQUIRED)

create_single_source_cgal_program("rotated_cubes_autorefinement.cpp")
create_single_source_cgal_program("coplanar_cubes_autorefinement.cpp")
create_single_source_cgal_program("corefinement_mesh_union_bench.cpp")

create_single_source_cgal_program("Performance/performance_snap_polygon_soup.cpp")
create_single_source_cgal_program("Robustness/robustness_snap_polygon_soup.cpp")
Expand All @@ -22,6 +23,7 @@ include(CGAL_TBB_support)
if(TARGET CGAL::TBB_support)
target_link_libraries(rotated_cubes_autorefinement PRIVATE CGAL::TBB_support)
target_link_libraries(coplanar_cubes_autorefinement PRIVATE CGAL::TBB_support)
target_link_libraries(corefinement_mesh_union_bench PRIVATE CGAL::TBB_support)
else()
message(STATUS "NOTICE: Intel TBB was not found. Sequential code will be used.")
endif()
235 changes: 235 additions & 0 deletions PMP_Boolean_operations/benchmark/corefinement_mesh_union_bench.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
#define CGAL_OUTPUT_BUILDER_RUNNING_TIME

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>

#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>

#include <CGAL/Real_timer.h>

#include <fstream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
// typedef CGAL::Exact_predicates_exact_constructions_kernel K;

typedef CGAL::Surface_mesh<K::Point_3> Mesh;

namespace PMP = CGAL::Polygon_mesh_processing;

struct Visitor_rep{

Visitor_rep(double normalize = 4)
: normalize(normalize)
{
t.start();
}

void progress_filtering_intersections(double d)
{
// d /= normalize;
// total += d;
// if(total > bound){
// // std::cout << std::setprecision(3) << total*100 << " % in " << std::setprecision(5) << t.time() << " sec." << std::endl;
// bound += 0.1;
// }
}

void start_triangulating_faces(std::size_t tf)
{
// tfaces = tf;
// bound_faces = tf/10;
}

void face_triangulation(std::size_t i)
{
// if(i> bound_faces){
// // std::cout << double(i)/double(tfaces) * 100 << " %" << std::endl;
// bound_faces += tfaces/10;
// }
}

void start_coplanar_faces(std::size_t tc)
{
// std::cout << "Visitor::start_coplanar_faces() at " << t.time() << " sec." << std::endl;
tcoplanar= tc;
count_coplanar = 0;
bound_coplanar = tcoplanar/10;
}

void intersection_of_coplanar_faces_step()
{
++count_coplanar;
if(count_coplanar> bound_coplanar){
// std::cout << "Visitor::coplanar_faces: " << double(count_coplanar)/double(tcoplanar) * 100 << " % " << std::endl;
bound_coplanar += tcoplanar/10;
}
}

void start_intersection_points(std::size_t ti)
{
// std::cout << "Visitor::start_intersection_points() at " << t.time() << " sec." << std::endl;
tintersection= ti;
count_intersection = 0;
bound_intersection = tintersection/10;
}

void edge_face_intersections_step()
{
++count_intersection;
if(count_intersection> bound_intersection){
// std::cout << "Visitor::intersection_points: " << double(count_intersection)/double(tintersection) * 100 << " % " << std::endl;
bound_intersection += tintersection/10;
}
}

double time() const
{
return t.time();
}

void reset_timer(){ t.stop(); t.reset(); t.start(); }

double normalize;
double bound = 0.1;
double total = 0;
std::size_t count = 0;

std::size_t bound_faces = 0;
std::size_t tfaces = 0;

std::size_t bound_coplanar = 0;
std::size_t tcoplanar = 0;
std::size_t count_coplanar = 0;

std::size_t bound_intersection = 0;
std::size_t tintersection = 0;
std::size_t count_intersection = 0;
CGAL::Real_timer t;
CGAL::Real_timer local;
};


struct Visitor :
public PMP::Corefinement::Default_visitor<Mesh>
{
std::shared_ptr<Visitor_rep> sptr;
mutable std::size_t tf_counter = 0;

Visitor()
: sptr(std::make_shared<Visitor_rep>())
{}

void progress_filtering_intersections(double d)
{
sptr->progress_filtering_intersections(d);
}

void start_filtering_intersections() const
{
// std::cout << "Visitor::start_filtering_intersections() at " << sptr->time() << " sec." << std::endl;
sptr->reset_timer();
}
void end_filtering_intersections() const
{
std::cout << "Filtering_intersections: " << sptr->time() << std::endl;
}

void start_triangulating_faces(std::size_t tf) const
{
std::cout << "Triangulate " << tf << " faces in ";
sptr->start_triangulating_faces(tf);
tf_counter = 0;
sptr->reset_timer();
}

void triangulating_faces_step() const
{
// sptr->face_triangulation(tf_counter++);
}

void end_triangulating_faces()const
{
std::cout << sptr->time() << " sec." << std::endl;
}

void start_handling_intersection_of_coplanar_faces(std::size_t i) const
{
sptr->start_coplanar_faces(i);
sptr->reset_timer();
}

void intersection_of_coplanar_faces_step() const
{
sptr->intersection_of_coplanar_faces_step();
}

void end_handling_intersection_of_coplanar_faces() const
{
std::cout << "Handling coplanar in " << sptr->time() << " sec." << std::endl;
}

void start_handling_edge_face_intersections(std::size_t i) const
{
sptr->start_intersection_points(i);
sptr->reset_timer();
}

void edge_face_intersections_step() const
{
sptr->edge_face_intersections_step();
}

void end_handling_edge_face_intersections() const
{
std::cout << "Compute intersection points in " << sptr->time() << " sec." << std::endl;
}

void start_building_output() const
{
sptr->reset_timer();
}

void end_building_output() const
{
std::cout << "Build the output in " << sptr->time() << " sec." << std::endl;
}
};


int main(int argc, char* argv[])
{
const std::string filename1 = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/blobby.off");
const std::string filename2 = (argc > 2) ? argv[2] : CGAL::data_file_path("meshes/eight.off");

Mesh mesh1, mesh2;
if(!CGAL::IO::read_polygon_mesh(filename1, mesh1) || !CGAL::IO::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}

CGAL::Real_timer rt;
CGAL::Timer t;
rt.start(); t.start();
Mesh out;
Visitor visitor;

bool valid_union = PMP::corefine_and_compute_union (mesh1, mesh2, out, CGAL::parameters::visitor(visitor).concurrency_tag(CGAL::Parallel_tag()));
// bool valid_union = PMP::corefine_and_compute_difference (mesh1, mesh2, out, CGAL::parameters::visitor(visitor).concurrency_tag(CGAL::Parallel_tag()));

std::cout << "Global timer = " << rt.time() << " sec." << " ( " << t.time() << " cpu time)" << std::endl;


if(valid_union)
{
std::cout << "Union was successfully computed\n";
CGAL::IO::write_polygon_mesh("union.off", out, CGAL::parameters::stream_precision(17));
return 0;
}

std::cout << "Union could not be computed\n";

return 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ if(TARGET CGAL::TBB_support)

create_single_source_cgal_program("corefinement_parallel_union_meshes.cpp")
target_link_libraries(corefinement_parallel_union_meshes PRIVATE CGAL::TBB_support)

target_link_libraries(corefinement_mesh_union_progress PRIVATE CGAL::TBB_support)
target_link_libraries(corefinement_mesh_union PRIVATE CGAL::TBB_support)
else()
message(STATUS "NOTICE: Intel TBB was not found. Sequential code will be used.")
endif()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>

#include <CGAL/Real_timer.h>

#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>

Expand All @@ -25,7 +27,11 @@ int main(int argc, char* argv[])
}

Mesh out;
bool valid_union = PMP::corefine_and_compute_union(mesh1,mesh2, out);
CGAL::Real_timer rt; CGAL::Timer t;
rt.start(); t.start();
// bool valid_union = PMP::corefine_and_compute_union(mesh1,mesh2, out);
bool valid_union = PMP::corefine_and_compute_union(mesh1,mesh2, out, CGAL::parameters::concurrency_tag(CGAL::Parallel_tag()));
std::cout << "run in " << rt.time() << " (" << t.time() << "s)" << std::endl;

if(valid_union)
{
Expand Down
Loading
Loading