Skip to content
Open
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
c6f560e
Parallellized build of AABB_tree
LeoValque May 28, 2026
5fadfb6
alternative version of PMP::self_intersections using AABB
LeoValque May 28, 2026
abca24c
Merge remote-tracking branch 'afabri/Kernel-combine_orientation-GF' i…
LeoValque May 28, 2026
a1fafcf
add example and benchmark of AABB_self_intersections
LeoValque May 28, 2026
11100ee
add AABB_meshes_intersections of two different meshes
LeoValque May 29, 2026
13b741f
Add two tree traversal intersection detection
LeoValque Jun 2, 2026
9274515
Two tree intersection of meshes and mixed AABB box_intersection for i…
LeoValque Jun 4, 2026
572bb8e
Benchmark meshes intersection
LeoValque Jun 4, 2026
d570a86
Improvement of AABB two tree traversals
LeoValque Jun 4, 2026
2bbe6b5
Create a intersection meshes fonction using a callback instead of an …
LeoValque Jun 8, 2026
68af801
Reorganize two_tree_traversal and AABB_two_tree_traversal_traits
LeoValque Jun 9, 2026
2cebb83
Make API and Documentation of intersection of two AABB trees
LeoValque Jun 11, 2026
233d5d3
Change traversal strategy to traverse biggest bbox first
LeoValque Jun 11, 2026
6d958a3
Doc update
LeoValque Jun 11, 2026
1fa9eb5
Add benchmark code in PMP
LeoValque Jun 11, 2026
c9e7a5a
remove benchmark code of two tree traversal in AABB_tree
LeoValque Jun 11, 2026
65a76ee
Add test for AABB_trees::do_intersect and AABB_trees::all_pair_of_int…
LeoValque Jun 11, 2026
827401b
Tree construction benchmarks
LeoValque Jul 1, 2026
17aaeb3
Parallelization of kd-tree construction in AABB-tree
LeoValque Jul 1, 2026
38b4eb9
Update performance in the user manual and apply first patch of sugges…
LeoValque Jul 2, 2026
6c8a889
Second patch of suggestion from the review
LeoValque Jul 2, 2026
d4a984e
Solve a unused warning when not link with TBB
LeoValque Jul 2, 2026
b533687
Update documentation
LeoValque Jul 3, 2026
c1cec3c
Add figure of documentation
LeoValque Jul 3, 2026
7349667
Add transformation parameter to CGALL::AABB_trees::do_intersect()
LeoValque Jul 6, 2026
6021eba
Various cleanup
LeoValque Jul 7, 2026
ca78bf8
aabb_two_trees_intersection.cpp
LeoValque Jul 7, 2026
9ed3515
Solve check headers error
LeoValque Jul 7, 2026
a8f5d08
<CGAL/Bbox_3.h> in Primive_helper.h
LeoValque Jul 7, 2026
7e992cb
Use Aff_transformation_repC3 instead of Aff_transformation_3 in CGAL:…
LeoValque Jul 8, 2026
91af779
Apply suggestions from the review
LeoValque Jul 8, 2026
2e7ada2
Merge remote-tracking branch 'origin/main' into AABB-add_parallelliza…
LeoValque Jul 8, 2026
89b449b
Solved aabb_two_trees_intersection error
LeoValque Jul 8, 2026
ec68ced
Solved warnings and errors in the testsuite
LeoValque Jul 9, 2026
13618f2
Add primitives for AABB tree on a triangkle soup
LeoValque Jul 9, 2026
66db995
Solved unused warning in the testsuite
LeoValque Jul 10, 2026
72cb79b
Apply suggestions from the review
LeoValque Jul 16, 2026
ebdaa83
Clean Aff_transformation in intersection of AABB trees
LeoValque Jul 20, 2026
2fef643
Add squared_diagonal_length to Bbox_2
LeoValque Jul 20, 2026
e1a8132
Correct compilation error when using AABB_segment_primitive_2 with Po…
LeoValque Jul 20, 2026
036de9c
Remove aabb_tree_with_join
LeoValque Jul 20, 2026
d0d280f
Correct compilation error when using AABB_segment_primitive_2 with Po…
LeoValque Jul 20, 2026
7aeca73
Merge branch 'AABB-add_parallellization' of github.com:LeoValque/cgal…
LeoValque Jul 23, 2026
b5ad15a
Remove unwanted modification of cmakelist
LeoValque Jul 23, 2026
530e06f
Add rounding mode protection to traversal with transformation
LeoValque Jul 23, 2026
18e497d
Merge branch 'Minkowski2-replace_AABB_tree_with_join' into AABB-add_p…
LeoValque Jul 23, 2026
5144b77
Remove outdating asserts
LeoValque Jul 23, 2026
6a9a7f8
Solved a compile bug with Protect_FPU_rounding
LeoValque Jul 23, 2026
f6222ed
Correct result error in a test
LeoValque Jul 23, 2026
1d4dc30
Remove Protect_FPU_rounding and simply used interval_nt<true>
LeoValque Jul 24, 2026
8b1d4f4
Solved a memory issue when gettint the transformation from the parameter
LeoValque Jul 27, 2026
188e642
add missing dep
sloriot Jul 27, 2026
257cb5c
Solved a mismatch bug between a defined type and the type return by t…
LeoValque Jul 28, 2026
60e351a
Merge branch 'AABB-add_parallellization' of github.com:LeoValque/cgal…
LeoValque Jul 28, 2026
75c8a56
Revert unwanted local change in test_minkoswki_sum
LeoValque Jul 28, 2026
acfbe78
Solved a compilation error with not default constructible PointMap
LeoValque Jul 28, 2026
41019f9
Add test that produces VC warning
afabri Jul 29, 2026
83cef1e
untabify
afabri Jul 29, 2026
8fe54d2
assign to a reference and output
afabri Jul 29, 2026
6b14899
Solved a bug of a dereference a temporary after construct_source_2
LeoValque Jul 29, 2026
13e46fd
Merge branch 'AABB-add_parallellization' of github.com:LeoValque/cgal…
LeoValque Jul 29, 2026
068035a
Add missing const in AABB_segment_primitive_2 and add a test on vecto…
LeoValque Jul 29, 2026
3bbd97c
Avoid unused warnings
LeoValque Jul 29, 2026
0926ddf
Solved a bug when using AABB_trees::do_intersect() with primitive tha…
LeoValque Jul 30, 2026
82391e8
Merge remote-tracking branch 'cgal/main'
sloriot Jul 30, 2026
7b22845
Apply suggestions from code review
LeoValque Aug 10, 2026
7b36e62
Apply suggestions from the review
LeoValque Aug 10, 2026
05e20f3
missing include
sloriot Aug 10, 2026
c056448
import change log from SF
sloriot Aug 10, 2026
4a1de3f
Use new two trees intersection in Rigid collision
LeoValque Aug 12, 2026
edbfbf1
Merge branch 'AABB-add_parallellization' of github.com:LeoValque/cgal…
LeoValque Aug 12, 2026
fb25dc1
Fix an error in side_of_triangle_mesh
LeoValque Aug 12, 2026
1e9082a
Update wrong assert
LeoValque Aug 13, 2026
9961563
Compute intersection of two OBB directly in AABB traversal with trans…
LeoValque Aug 17, 2026
2dd6f02
Solve unfound mesh error
LeoValque Aug 18, 2026
5123e91
Remove unwanted leftover
LeoValque Aug 18, 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
12 changes: 11 additions & 1 deletion AABB_tree/benchmark/AABB_tree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ project(AABB_traits_benchmark)

find_package(CGAL REQUIRED)

create_single_source_cgal_program("test.cpp")
create_single_source_cgal_program("old_bench_AABB_tree.cpp")
create_single_source_cgal_program("tree_construction.cpp")
create_single_source_cgal_program("knot_generation.cpp")
create_single_source_cgal_program("tree_queries.cpp")

# google benchmark
find_package(benchmark QUIET)
Expand All @@ -17,3 +19,11 @@ if(benchmark_FOUND)
else()
message(STATUS "NOTICE: The benchmark 'tree_creation.cpp' requires the Google benchmark library, and will not be compiled.")
endif()

find_package(TBB QUIET)
include(CGAL_TBB_support)
if(TARGET CGAL::TBB_support)
target_link_libraries(tree_construction PRIVATE CGAL::TBB_support)
else()
message(STATUS "NOTICE: Intel TBB was not found. Sequential code will be used.")
endif()
122 changes: 122 additions & 0 deletions AABB_tree/benchmark/AABB_tree/knot_generation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@

#include <cmath>
#include <fstream>
#include <iostream>
#include <vector>

#include <CGAL/Simple_cartesian.h>
#include <CGAL/IO/polygon_soup_io.h>

using Kernel = CGAL::Simple_cartesian<double>;
using Point = Kernel::Point_3;
using Vector = Kernel::Vector_3;
using Triangle = std::array<int, 3>;

int main(int argc, char* argv[])
{
const std::string filename = argc > 1 ? argv[1] : "knot.off";

const int p = argc > 2 ? std::atoi(argv[2]) : 1; // Nb of major turns
const int q = argc > 3 ? std::atoi(argv[3]) : 6; // Nb of knot turns

const double R = argc > 4 ? std::atof(argv[4]) : 2.0; // major radius
const double r = argc > 5 ? std::atof(argv[5]) : 0.9; // knot radius
const double tube_radius = argc > 6 ? std::atof(argv[6]) : 0.4;

const int tubular_segments = argc > 7 ? std::atoi(argv[7]) : 120;
const int radial_segments = argc > 8 ? std::atoi(argv[8]) : 60;

const double exc = argc > 9 ? std::atof(argv[9]) : 1; // excentricity

std::vector<Point> vertices;
std::vector<Triangle> faces;

// Generate knot polyline
auto knot = [&](double t){
double cq = std::cos(q * t);
double sq = std::sin(q * t);
double factor = R + r * cq;
return Point(factor * std::cos(p * t),
factor * std::sin(p * t),
r * sq);
};
auto knot_derivative = [&](double t){
double cq = std::cos(q * t);
double sq = std::sin(q * t);
double cp = std::cos(p * t);
double sp = std::sin(p * t);

double factor = R + r*cq;
double dfactor = -r*q*sq;

return Vector(dfactor*cp - factor*p*sp,
dfactor*sp + factor*p*cp,
r*q*cq);
};

const double dt = 2.0 * M_PI / tubular_segments;
const double dr = 2.0 * M_PI / radial_segments;

// A normal to the knot axis
Vector N(1,0,0);
for(int i=0; i<tubular_segments; ++i)
{
double t = i * dt;

// knot point and its tangent
Point C = knot(t);
Vector T = knot_derivative(t);
// Compute bases of the plane on C
Vector B = CGAL::cross_product(N, T);
N = -CGAL::cross_product(B, T);
N /= CGAL::approximate_sqrt(N.squared_length());
B /= CGAL::approximate_sqrt(B.squared_length());

for(int j=0; j<radial_segments; ++j){
double phi = j * dr;
vertices.push_back(C + tube_radius*(exc*std::cos(phi)*N + 1/exc*std::sin(phi)*B));
}
}

auto idx = [&](int i, int j){
i %= tubular_segments;
j %= radial_segments;
return i * radial_segments + j;
};

for(int i=0; i<tubular_segments-1; ++i)
for(int j=0; j<radial_segments; ++j){
int v00 = idx(i , j );
int v10 = idx(i+1, j );
int v01 = idx(i , j+1);
int v11 = idx(i+1, j+1);

faces.push_back({v00,v10,v11});
faces.push_back({v00,v11,v01});
}

// To avoid a twist, we compute the offset that minimize the distance between a point at tubular index N-1 and tubular index 0
int n = tubular_segments-1;
int offset = 0;
double min = CGAL::squared_distance(vertices[idx(n, 0)], vertices[idx(0,0)]);
for(int j=1; j<radial_segments; ++j){
double sq = CGAL::squared_distance(vertices[idx(n, 0)], vertices[idx(0,j)]);
if(min >sq){
min = sq;
offset = j;
}
}
for(int j=0; j<radial_segments; ++j){
int v00 = idx(n, j );
int v10 = idx(0, j+offset);
int v01 = idx(n, j+1);
int v11 = idx(0, j+offset+1);

faces.push_back({v00,v10,v11});
faces.push_back({v00,v11,v01});
}

CGAL::IO::write_polygon_soup(filename, vertices, faces);

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <CGAL/Polygon_mesh_processing/transform.h>
#include <CGAL/Rigid_triangle_mesh_collision_detection.h>
#include <CGAL/Side_of_triangle_mesh.h>
#include <CGAL/Real_timer.h>
Comment thread
LeoValque marked this conversation as resolved.

#include <fstream>
#include <sstream>
Expand Down Expand Up @@ -157,17 +158,16 @@ int main(int argc, const char** argv)
std::string path = (argc>2)?argv[2]: CGAL::data_file_path("meshes/handle.off");

std::cout<< k<<" steps in "<<path<<std::endl;
CGAL::Real_timer t;
int nb_inter(0), nb_no_inter(0), nb_include(0),
naive_inter(0), naive_no_inter(0), naive_include(0);
auto start = std::chrono::steady_clock::now();
naive_test(k, path, naive_inter, naive_no_inter, naive_include);
auto end = std::chrono::steady_clock::now();
t.start();
naive_test(k, path, naive_inter, naive_no_inter, naive_include);
std::cout<<"Naive test : "<<naive_inter<<" collisions, "<<naive_include<<" inclusions, "<<naive_no_inter<<" no collision, calculated in "
<<std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms." << std::endl;
start = std::chrono::steady_clock::now();
<< t.time() << " ms." << std::endl;
t.stop(); t.reset(); t.start();
test_no_collision(k, path,nb_inter, nb_no_inter, nb_include);
end = std::chrono::steady_clock::now();
std::cout<<"With transform_traits: "<<nb_inter<<" collisions, "<<nb_include<<" inclusions, "<<nb_no_inter<<" no collision, calculated in "
<<std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms." << std::endl;
<< t.time() << " ms." << std::endl;
return 0;
}
57 changes: 45 additions & 12 deletions AABB_tree/benchmark/AABB_tree/tree_construction.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Polygon_mesh_processing/bbox.h>
#include <CGAL/IO/polygon_mesh_io.h>

#include <CGAL/Timer.h>
#include <CGAL/Real_timer.h>

#include <iostream>
#include <fstream>
Expand Down Expand Up @@ -61,30 +63,52 @@ struct Compute_bbox {
BBM bbm;
};

template <class K>
template <typename ConcurrencyTag, class K>
void run(std::string input)
{
typedef typename K::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> Mesh;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;

Mesh tm;
std::ifstream(input) >> tm;
CGAL::IO::read_polygon_mesh(input, tm);

{
Tree tree(faces(tm).begin(), faces(tm).end(), tm);
CGAL::Timer time;
CGAL::Real_timer time;
time.start();
tree.build();
time.stop();
tree.template build<ConcurrencyTag>();
std::cout << " build() time: " << time.time() << "\n";
tree.template accelerate_distance_queries<ConcurrencyTag>();
std::cout << " build() + build kd-tree time: " << time.time() << "\n";
}

{
typedef CGAL::dynamic_face_property_t<CGAL::Bbox_3> Face_bbox_tag;
typedef typename boost::property_map<Mesh, Face_bbox_tag >::type BboxMap;
typedef CGAL::AABB_traits_3<K, Primitive, BboxMap> BTraits;
typedef CGAL::AABB_tree<BTraits> BTree;

auto bb = get( Face_bbox_tag(), tm);
for(auto fd : faces(tm))
put(bb, fd, CGAL::Polygon_mesh_processing::face_bbox(fd, tm));

BTraits traits(bb);
BTree tree(traits);
tree.insert(faces(tm).begin(), faces(tm).end(), tm);
CGAL::Real_timer time;
time.start();
tree.template build<ConcurrencyTag>();
std::cout << " build() with reference bbox time: " << time.time() << "\n";
tree.template accelerate_distance_queries<ConcurrencyTag>();
std::cout << " build() with reference bbox + build kd-tree time: " << time.time() << "\n";
}

{
Tree tree(faces(tm).begin(), faces(tm).end(), tm);
CGAL::Timer time;
CGAL::Real_timer time;
time.start();

typedef CGAL::Pointer_property_map<CGAL::Bbox_3>::type BBM;
Expand All @@ -108,17 +132,26 @@ void run(std::string input)

Compute_bbox<BBM> compute_bbox(bbm);
Split_primitives<RPM> split_primitives(rpm);
tree.custom_build(compute_bbox, split_primitives);
time.stop();
tree.template custom_build<ConcurrencyTag>(compute_bbox, split_primitives);
std::cout << " custom_build() time: " << time.time() << "\n";
tree.template accelerate_distance_queries<ConcurrencyTag>();
std::cout << " custom_build() + build kd-tree time: " << time.time() << "\n";
}
}

int main(int, char** argv)
{
std::cout << "Build with Cartesian\n";
run<CGAL::Parallel_tag, CGAL::Simple_cartesian<double>>(argv[1]);
std::cout << "Build with Epick\n";
run<CGAL::Epick>(argv[1]);
run<CGAL::Parallel_tag, CGAL::Epick>(argv[1]);
std::cout << "Build with Epeck\n";
run<CGAL::Epeck>(argv[1]);
run<CGAL::Parallel_tag, CGAL::Epeck>(argv[1]);
std::cout << "Build with Cartesian (Sequential) \n";
run<CGAL::Sequential_tag, CGAL::Simple_cartesian<double>>(argv[1]);
std::cout << "Build with Epick (Sequential) \n";
run<CGAL::Sequential_tag, CGAL::Epick>(argv[1]);
std::cout << "Build with Epeck (Sequential) \n";
run<CGAL::Sequential_tag, CGAL::Epeck>(argv[1]);
return EXIT_SUCCESS;
}
2 changes: 1 addition & 1 deletion AABB_tree/benchmark/AABB_tree/tree_creation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ BENCHMARK(BM_Intersections);
int main(int argc, char** argv)
{
std::string default_file = CGAL::data_file_path("meshes/handle.off");
std::strint filename = argc > 2? argv[2] : default_file;
std::string filename = argc > 2? argv[2] : default_file;

{
std::ifstream input(filename);
Expand Down
Loading
Loading