Subject: CGAL users discussion list
List archive
- From: jana jelenki <>
- To:
- Subject: Re[2]: [cgal-discuss] Speeding up Intersection
- Date: Wed, 05 May 2021 16:37:45 +0300
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=Pass
- Ironport-hdrordr: A9a23:Yx8mCaEL+vRg9U4cpLqEdseALOonbusQ8zAX/mp2TgFYddHdqtC2kJ0gpHjJoRsyeFVlo9CPP6GcXWjRnKQe3aA9NaqvNTOGhEKEKoVr7YzBzy2lIS3x8eZBybxtGpIUNPTeFl5/5Pyb3CCZCNAm+d+d7eSTqNy29RpQZCVLT40l0AtjEAacFSRNNW17LL40DoCV6MYChxfIQwV0Uu2BCnMIX/fOqrTw/fqLDnA7LiUq9RWUineQ4KP6eiLouCs2aS9Fwrsp7AH+4mnEz5ik2svLqSPh6w==
- Ironport-phdr: A9a23:Kb7Mzx/B9IoRJ/9uWRy7ngc9DhMPi/DPJgcQr6AfoPdwSMyLwZ3uMQTl6Ol3ixeRBMOHsqMC0bGJ+PG5EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCe5bL9oMhm7owfcusYSjId/N6081gbHrnxUdupM2GhmP0iTnxHy5sex+J5s7SFdsO8/+sBDTKv3Yb02QaRXAzo6PW814tbrtQTYQguU+nQcSGQWnQFWDAXD8Rr3Q43+sir+tup6xSmaIcj7Rq06VDi+86tmTgLjhSEaPDA77W7XkNR9gqJFrhy8qBNxxIDaYJuPOvR9YqzSf90aSHFbUcpNSyBMGJmxY5cNAucHIO1Wr5P9p1wLrRamBwmjHuXvxSVVjX/0w6I61/ouEQfF3AwhAtkDt3TUrNHrO6gJXuC61rLFzTDZYPNX3Tfx8pLIcg04rPyKQLl/ftbfx1M1GAPZklWft5blPzWN2+kRs2aW8eptWP6ghWI7pAx8vCSjy8gihITHiY8Z11LJ+yp2zos6ONC1R0F1bN66HZdNqSyXNJZ6T80gTm11tys3zKANt5C8fCgP0psnxhjfZuSGc4iO+BLjVfyeLS12hHJ/fr+0mhW88VC4x+HhVcS50ExGoypfntXRuH0A1gbf5tWDR/dj+EqqxCyB2BrJ6u5eJEA5jarbJIAlwr43jpcTv0vOEy/ylUnsja+abEAk9fKp6+TjeLnmvIKcO5d1igH4LKsuhtSyDfk7PwUORWSW+f6w2KDt8ED4WrlGk/k7nrfBvJDfP8sbp6q5AwFP0oYk7hayFzem0NAGknYcI1JKYgmKj43zNFHPJPD0F+2/g0m0nDdx2//GJqHhAonKLnXbjLjhcqxy60pFxAUuzNBf/I5bCqwaIPLoQULxr9zZDhohMwOu2ernCdN91pkfWW2VGKOZPrnS4he14PkyKbyMeJMNo2S6bOM04ubny34/g14UO6ezmoAGbWixWfVgLULeanXlhpINEHwBoxElH9Hsk0CIcSJWYyOyQ74k/WN8T5m3CJ/KAIGrmr2ImimhWYZHY3hPTVGKH3CvfIqNX7IAaTmZP9R6wQECTqWrd4IxyUSuqBPi0OggafHF/zUR85Plztl8oePJ0goj8CR9SMWb3WbKRG59miYERiQ9wbtk8nB6n1yM2Kw9j/1DHsFI/NtIVB07PNjS1b9ABsj2Sz7GK9WATl/uQNiiDDcyT5plw9sDaUl0M9CrjxSFxTf8UJEPkLneBpUy++re0nz8IcV8gyLG0KQrgFAOR8JOMSu8m/gspEDoG4fVnhDBxO6RfqMG0XuVnE+ziFGWtUQdazZeFKXIWXd3TkWK8IW/5wXHRr6qT646YFIp4f7HEbNDb5jStXsDXO3qUPzbamO13X2tV07g7oPJV5LjfiAm5AuYDUEFlw4J+nPuHQ03ByPnuX+MVVRT
Hi Sebastien,
below is an MWE, that sums up my code. I have numbers that span from 1.0e-7 to 100, therefore the strange looking points.
Result of this intersection is a Segment_3:
P1: 66.666666722222 50.0000001 0
P2: 100.0000001 50.0000001 0
P2: 100.0000001 50.0000001 0
It takes nearly 0.1ms for each intersection. So 10s for 100,000 intersections. Can this be sped up by another kernel or data type? I tested for example inexact construction but it gave wrong results.
Best
#include <CGAL/Exact_predicates_exact_constructions_kernel.h> #include <iostream> #include <chrono> typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef Kernel::Point_3 Point3; typedef Kernel::Triangle_3 Triangle3; int main() { std::vector<Point3> APoints(3); std::vector<Point3> BPoints(3); APoints[0] = Point3(0, 0, 0); APoints[1] = Point3(100.0000001, 0, 0); APoints[2] = Point3(100.0000001, 100.0000001, 0); BPoints[0] = Point3(0, 50.0000001, -100.0000001); BPoints[1] = Point3(200.0000001, 50.0000001, -100.0000001); BPoints[2] = Point3(200.0000001, 50.0000001, 200.0000001); Triangle3 TriangleA(APoints[0], APoints[1], APoints[2]); Triangle3 TriangleB(BPoints[0], BPoints[1], BPoints[2]); int end = 100000; auto start = std::chrono::high_resolution_clock::now(); for (int i = 0; i < end; i++) auto result = CGAL::intersection(TriangleA, TriangleB); auto finish = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> elapsed = finish - start; std::cerr << elapsed.count() << "\t" << elapsed.count() / end * 1000 << std::endl; }
Среда, 5 мая 2021, 15:30 +03:00 от Sebastien Loriot <>:
Without seeing any code it is hard to tell. Are you using do_intersect
or intersection?
Best,
Sebastien.
On 5/4/21 9:01 AM, jana jelenki ( via cgal-discuss Mailing
List) wrote:> Hi,
> I find this topic very interesting. I already use spatial partitioning
> and also OpenMP. For an average Triangle_3 Triangle_3 intersection my
> program needs on average 0.1ms in release mode. I also use the exact
> kernel. Is this the limit of the CGLAL implementation, are there any
> numbers or benchmarks? Or can you squeeze there even further?
> Best
>
> Вторник, 4 мая 2021, 6:35 +03:00 от Andrew Cunningham
> <>:
> Hi Anish,
> Since your code is a N^2 algorithm , it's not surprising that this is
> taking a long time. The first thing that comes to mind is to bound
> each triangle with a CGAL AABB (BoundingBox) and use CGAL AABB
> algorithms to find the pairs of intersecting bounding boxes(pairs of
> potential triangle intersections). That would make a huge difference
> in execution time.
> And once you have done that, you could loop over the intersecting
> pairs and use OpenMP or other threading approaches like TBB to process
> the intersecting pairs in parallel. I personally have had great
> success with OpenMP tasks and CGAL.
>
> Andrew
>
> On Mon, May 3, 2021 at 1:17 PM Rasal Raj, Anish
> <
> </compose?To=anish.rasal@rwth%2daachen.de>> wrote:
> >
> > Hello Guys,
> >
> > I have recently started working with CGAL. I have a doubt.
> >
> >
> > I am using CGAL intersection operation on a list of triangles.
> currently, it takes some time to complete the information. What are
> the possible ways to improve the execution time?
> >
> >
> > Note: the list of triangles contains around 25k triangles. I have
> attached a sample code with this e-mail. I am using
> Exact_predicates_exact_constructions_kernel kernel.
> >
> >
> > --
> > You are currently subscribed to cgal-discuss.
> > To unsubscribe or access the archives, go to
> > https://sympa.inria.fr/sympa/info/cgal-discuss
> <https://sympa.inria.fr/sympa/info/cgal-discuss>
> >
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss
> <https://sympa.inria.fr/sympa/info/cgal-discuss>
>
> --
> jana jelenki
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss
>
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
--
jana jelenki
jana jelenki
- [cgal-discuss] Speeding up Intersection, Rasal Raj, Anish, 05/03/2021
- Re: [cgal-discuss] Speeding up Intersection, Andrew Cunningham, 05/04/2021
- Re[2]: [cgal-discuss] Speeding up Intersection, jana jelenki, 05/04/2021
- Re: [cgal-discuss] Speeding up Intersection, Sebastien Loriot, 05/05/2021
- Re[2]: [cgal-discuss] Speeding up Intersection, jana jelenki, 05/05/2021
- Re: [cgal-discuss] Speeding up Intersection, Sebastien Loriot, 05/05/2021
- Re[2]: [cgal-discuss] Speeding up Intersection, jana jelenki, 05/05/2021
- Re: [cgal-discuss] Speeding up Intersection, Sebastien Loriot, 05/05/2021
- Re[2]: [cgal-discuss] Speeding up Intersection, jana jelenki, 05/05/2021
- Re: [cgal-discuss] Speeding up Intersection, Sebastien Loriot, 05/05/2021
- Re[2]: [cgal-discuss] Speeding up Intersection, jana jelenki, 05/05/2021
- Re: [cgal-discuss] Speeding up Intersection, Sebastien Loriot, 05/05/2021
- Re[2]: [cgal-discuss] Speeding up Intersection, jana jelenki, 05/04/2021
- Re: [cgal-discuss] Speeding up Intersection, Andrew Cunningham, 05/04/2021
Archive powered by MHonArc 2.6.19+.