Skip to content

add intersection of two AABB_tree#9501

Open
LeoValque wants to merge 45 commits into
CGAL:mainfrom
LeoValque:AABB-add_parallellization
Open

add intersection of two AABB_tree#9501
LeoValque wants to merge 45 commits into
CGAL:mainfrom
LeoValque:AABB-add_parallellization

Conversation

@LeoValque

@LeoValque LeoValque commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Add a parallellization of AABB_tree::build() (without any mutex) to improve running time.

Add PMP::AABB_self_intersections(), a variant of PMP::self_intersections() that used an AABB_tree instead of CGAL::box_intersection_d.

Todo

  • Add proper benchmark

Release Management

@LeoValque LeoValque changed the title add parallellization of AABB_tree::build and add variant of PMP::self_intersections using AABB_tree add variant of PMP::self_intersections using AABB_tree May 28, 2026
@sloriot sloriot added the depends on another PR This pull-request should only be merged after other ones. label May 29, 2026
@LeoValque

Copy link
Copy Markdown
Contributor Author

/build:v0

@github-actions

Copy link
Copy Markdown

The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/9501/v0/Manual/index.html

@LeoValque LeoValque added the Speed label Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/9501/v0/Manual/index.html

@LeoValque

Copy link
Copy Markdown
Contributor Author

/force-build:v0

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/9501/v0/Manual/index.html

@afabri afabri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to add a documented function in PMP?

Comment thread AABB_tree/benchmark/AABB_tree/CMakeLists.txt Outdated
Comment thread AABB_tree/benchmark/AABB_tree/tree_construction.cpp Outdated
Comment thread AABB_tree/benchmark/AABB_tree/tree_construction.cpp Outdated
Comment thread AABB_tree/benchmark/AABB_tree/tree_queries.cpp Outdated

bool do_intersect(const Query& query, const Node& node) const
{
#if 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean up

Comment thread AABB_tree/include/CGAL/AABB_trees/intersection.h Outdated
Comment thread AABB_tree/include/CGAL/AABB_tree.h Outdated
@LeoValque

Copy link
Copy Markdown
Contributor Author

Do you plan to add a documented function in PMP?

Not in this PR

@LeoValque LeoValque changed the title add variant of PMP::self_intersections using AABB_tree add intersection of two AABB_tree Jul 8, 2026
@sloriot

sloriot commented Jul 15, 2026

Copy link
Copy Markdown
Member

Successfully tested in CGAL-6.3-Ic-31

@LeoValque
LeoValque requested review from MaelRL and sloriot July 16, 2026 06:46

@sloriot sloriot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You imported code from PMP but you left the code duplicated in PMP. Any reason why PMP shall not use the new code?

Comment thread AABB_tree/doc/AABB_tree/aabb_tree.txt Outdated
Comment thread AABB_tree/doc/AABB_tree/aabb_tree.txt Outdated
Comment thread AABB_tree/doc/AABB_tree/aabb_tree.txt Outdated
Comment thread AABB_tree/doc/AABB_tree/Doxyfile.in Outdated
#if 1
return m_traits.do_intersect_object()(query, compute_transformed_bbox(node.bbox()));
#else
return Convex_hull_3::do_intersect(query, node.bbox(), parameters::transformation(Aff_transformation_3<Kernel>(m_transfo)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the conclusion on this one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do_overlap(compute_ntransformed_bbox) is about 5× faster than do_intersect(bb1, bb2, transform), but both are still two orders of magnitude slower than do_overlap without a transformation.
The best solution would probably be to implement a specialized do_intersect function for a bounding box and an OBB.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall you remove the #if?

Comment thread AABB_tree/include/CGAL/AABB_tree.h Outdated
m_p_search_tree = std::make_unique<const Search_tree>(first, beyond);
std::unique_ptr<Search_tree> p_search_tree = std::make_unique<Search_tree>(first, beyond);
p_search_tree->template build<ConcurrencyTag>();
m_p_search_tree = std::move(p_search_tree);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need a temporary variable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because m_p_search_tree points a const and build() is not a const method.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds strange that you cannot call a function but can override it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't override it.

p_search_tree is not const, so I can call build() without any issue. Once it's moved to m_p_search_tree, however, it becomes const.

Previously, build() was called from the constructor, but that doesn't allow me to pass the ConcurrencyTag. That's why I separated the build() call from the constructor.

Comment thread AABB_tree/test/AABB_tree/aabb_test_two_trees_intersection.cpp Outdated
Comment thread Kernel_23/doc/Kernel_23/CGAL/Bbox_3.h Outdated
Comment thread Kernel_23/include/CGAL/Kernel/Same_uncertainty.h
return zmax() - zmin();
}

inline double Bbox_3::squared_diagonal_length() const {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a similar function used in the demo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which demo?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is in the demo, it can be replaced as soon as the convenience function is added to Bbox_3.

Comment thread AABB_tree/include/CGAL/AABB_tree.h
@github-actions github-actions Bot removed the Tested label Jul 16, 2026
@github-actions

Copy link
Copy Markdown

This pull-request was previously marked with the label Tested, but has been modified with new commits. That label has been removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

depends on another PR This pull-request should only be merged after other ones. Enhancement Speed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants