Subject: CGAL users discussion list
List archive
- From: Sebastien Loriot <>
- To:
- Subject: Re: [cgal-discuss] Speeding up Intersection
- Date: Wed, 5 May 2021 15:43:01 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-hdrordr: A9a23:g5rqxakApqiusrWJ+gKakeaYp7XpDfKx3DAbvn1ZSRFFG/GwvcaogfgdyFvQgDEeRHkvlbm7Sc+9aFnb8oN45pRUAKe6UGDdyQyVBaxBza+n+T3vHCXi6vVQvJ0OT4FSAMD9ZGIK7/rSzxK/F78boeWv1ICNqaPgw2x2TQdsApsQiztRLgqACEV5SE1nKPMCZfmhz/FKrTahZngbB/7TbhJpM9TrncHBl57tfHc9ZyIP1Q/mt12VwYLhHwPd9hkTVC4n+8ZGzUH11zP4/bm498uwwhja22K71f5rpOc=
- Ironport-phdr: A9a23:L7o72xS6Zt0xK4kFw7/FZGTzONpsomCYAWYlgqEPu/d1aq2muq7aFwnh351FslbFUM3h5u5ejKKO6ua8AD1Gu83e+yFbOLV3FDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3OgV6PPn6FZDPhMqrye+y54fTYwJVjzahfL9+Nhq7oRjVu8UMn4dvJKQ8xhTNr3dVZu9b2X5mKVWPkhjm+8y+5oRj8yNeu/Ig885PT6D3dLkmQLJbETorLXk76NXkuhffQwSP4GAcUngNnRpTHwfF9hD6UYzvvSb8q+FwxTOVPczyTbAzRDSi86JmQwLmhSsbKzI09nzch8pth6xZvR2hvQRyzZPKboGbNPRwfa3Tct0VSmVDQslfWDdMAp+/YoYVE+YNIehVoov7qlATrRW+Hw6sBOb3xzFVmHD5xrc10/89EQHHwgMgGc8FvnLTrNXvNacSVvy1x7TPwDXYa/NW3i396InPchA9u/2MWLZwfNHeyUkqDQzFj1GQpZb5MDOS0+QAqm6W5PdvWuyzkWAosR1xoiSxycc2jInEno0bx03K+yh53os4K8O1RFB6bNCkDpdeuD2XO5V5TM4jQGxluTs2xL0It5O5YiQH1okqyRDRZvGbb4SG7AzuWemXLDxlinxlf7e/iAyz8Uim0uDzSsa030xOriZfldnMrH8N2wTN5seaUPRy5Fuu2TaR2ADV8O1LPF47mbLaK54n2L4wl4AcvV7NHi/snkj9kayYdl089+S29+jqZq/qq5ycOoNulw3yLKcjlta/DOgmKgQCQXKU9fih2LDm40L1XK9Fg/gonqXFrZzXIMoWqbSnDwNJ14su5RayAjek3dkdh3YKIl1IdA6CgofyP1zBPO73APKjjFmikzpn2/bLNaD7DJrXNHjMirLhcK5960FCzAozyshS55dOBbEAJPL/Q0HwtNnFAhMgPQy5w/jrBM9y1oMZXmKPDauZP73IvVCU4eIvJvGAZI4TuDnjN/go/+DigWM9lFMHfqSk3YEbZG2mEvllOUmUYWTgjs8EEWgQvwo+SOLqiEeFUT5Wf3uyRKY85jYhCIKnCofDWpqhgLmF3CqgEZ1WY3pJClGIEXvya4qEXPIMZDqIIsB9ijwESaShS4g52B6yuw/10b5nIvPJ9S0ZrpLsyMV15/bIlRwp7jx1D8Gd03mXQG1un2MIQSU23KFlrkBnxFeDy/swvvpDCNYG5+9VShxoctnH3uliApbzXBjAd5GHUhG9U9C+CHYwSNw2hNQBakI4F9S5hQ3YxHmXBaQInYCGFIBh8r7Ax2OjYIFm2nPe3e8giUMnS41BLyq9l6tn/k/SAYDO1E6WnqLveaUH1zPW7zS/yj+Fs0hcFQJxSq7YRms3Z03MrN2/6FmRYaWpDOEcPwFI0tKDJ60CTtrzjFJaDKP4PNPEYmWt3WK0LRmNz7KIKoHtfjNOj23mFEEYnlVLrj69Pg8kC3L5y0ruSQd2HFeqWHvCtPFkoRuTQUo9zgXMZEpkheLd0i5QvuSVTrYo5pxBuColrF1cGV+825fJDoPFqVc7OqpbZtw57RFM0meL72RVDtmbN6lnw2UmXUFytkLq2Q9wD+1ons0jrXdsxw13e/vw7Q==
Of course it depends on your real scenario but I would use something like this example:
https://doc.cgal.org/latest/Box_intersection_d/Box_intersection_d_2triangle_self_intersect_8cpp-example.html
with the do_intersect and a fast kernel without exact constructions
to collect pairs of triangles intersecting and then I'll use a kernel
with exact constructions to compute intersections.
Best,
Sebastien.
On 5/5/21 3:37 PM, jana jelenki ( via cgal-discuss Mailing List) wrote:
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
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_kernelKernel; typedef
Kernel::Point_3Point3; typedef Kernel::Triangle_3Triangle3;
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
> < </compose?To=cgal@a%2dcunningham.com>>:
> 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>
> </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>
> <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>
> <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
<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
- [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+.