-
Notifications
You must be signed in to change notification settings - Fork 1.6k
add intersection of two AABB_tree #9501
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
Open
LeoValque
wants to merge
44
commits into
CGAL:main
Choose a base branch
from
LeoValque:AABB-add_parallellization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 37 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
3076b28
Combine two orientation tests in one with only the third point being …
afabri 613c369
fix and timer
afabri 34e8912
Deal correctly with underflow/overflow
afabri 01c0d1b
Add #include
afabri 4680634
Add operator to Homogeneous
afabri 5e6ff98
Add operator to Homogeneous
afabri 94aa198
Fix determinants()
afabri 2dafa20
Add documentation
afabri c6f560e
Parallellized build of AABB_tree
LeoValque 5fadfb6
alternative version of PMP::self_intersections using AABB
LeoValque abca24c
Merge remote-tracking branch 'afabri/Kernel-combine_orientation-GF' i…
LeoValque a1fafcf
add example and benchmark of AABB_self_intersections
LeoValque 11100ee
add AABB_meshes_intersections of two different meshes
LeoValque 13b741f
Add two tree traversal intersection detection
LeoValque 9274515
Two tree intersection of meshes and mixed AABB box_intersection for i…
LeoValque 572bb8e
Benchmark meshes intersection
LeoValque d570a86
Improvement of AABB two tree traversals
LeoValque 2bbe6b5
Create a intersection meshes fonction using a callback instead of an …
LeoValque 68af801
Reorganize two_tree_traversal and AABB_two_tree_traversal_traits
LeoValque 2cebb83
Make API and Documentation of intersection of two AABB trees
LeoValque 233d5d3
Change traversal strategy to traverse biggest bbox first
LeoValque 6d958a3
Doc update
LeoValque 1fa9eb5
Add benchmark code in PMP
LeoValque c9e7a5a
remove benchmark code of two tree traversal in AABB_tree
LeoValque 65a76ee
Add test for AABB_trees::do_intersect and AABB_trees::all_pair_of_int…
LeoValque 827401b
Tree construction benchmarks
LeoValque 17aaeb3
Parallelization of kd-tree construction in AABB-tree
LeoValque 38b4eb9
Update performance in the user manual and apply first patch of sugges…
LeoValque 6c8a889
Second patch of suggestion from the review
LeoValque d4a984e
Solve a unused warning when not link with TBB
LeoValque b533687
Update documentation
LeoValque c1cec3c
Add figure of documentation
LeoValque 7349667
Add transformation parameter to CGALL::AABB_trees::do_intersect()
LeoValque 6021eba
Various cleanup
LeoValque ca78bf8
aabb_two_trees_intersection.cpp
LeoValque 9ed3515
Solve check headers error
LeoValque a8f5d08
<CGAL/Bbox_3.h> in Primive_helper.h
LeoValque 7e992cb
Use Aff_transformation_repC3 instead of Aff_transformation_3 in CGAL:…
LeoValque 91af779
Apply suggestions from the review
LeoValque 2e7ada2
Merge remote-tracking branch 'origin/main' into AABB-add_parallelliza…
LeoValque 89b449b
Solved aabb_two_trees_intersection error
LeoValque ec68ced
Solved warnings and errors in the testsuite
LeoValque 13618f2
Add primitives for AABB tree on a triangkle soup
LeoValque 66db995
Solved unused warning in the testsuite
LeoValque File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.