Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] CGAL::intersection()

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] CGAL::intersection()


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] CGAL::intersection()
  • Date: Tue, 25 Mar 2014 12:00:24 +0100
  • Organization: GeometryFactory

Hi Bernhard,

I'm sure you are aware of:
http://www.cgal.org/FAQ.html#inexact_NT

This intersection code is rather naive and make use of
constructions to determine the intersection. That is to
say it does check if the triangles have a common edge.

However, there are several ways to handle the issue depending
on the context you are using this code without having to resort
to exact arithmetic.

Best,

Sebastien.

PS: if you are using CGAL 4.3 there was a bug in this function fixed in 4.4 http://www.cgal.org/releases.html#release4.4


On 03/25/2014 11:30 AM, Bernhard Kornberger wrote:
Hi!

I tried to compute the intersection of two triangles but the result
can't be assigned to any of the types named in the documentation,
see the minimal example below. Any hints?

#include <fstream>
#include <string.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point_3;
typedef K::Triangle_3 Triangle_3;
typedef K::Segment_3 Segment_3;
typedef K::Line_3 Line_3;
typedef K::Vector_3 Vector_3;
typedef K::Plane_3 Plane_3;

using namespace std;



int main(int argc,char* argv[])
{
Point_3 p0(5067.44,429.864,1191.84);
Point_3 p1(5069.42,430.425,1191.38);
Point_3 p2(5069.03,431.185,1192.48);
Triangle_3 t0(p0,p1,p2);
Point_3 p3(5071.17,432.114,1192.12);
Triangle_3 t1(p3,p2,p1);

if(!CGAL::do_intersect(t0,t1)) return 0;

cout<<"Intersection of two triangles:"<<endl;
cout<<t0<<endl;
cout<<t1<<endl;
CGAL::Object obj(CGAL::intersection(t0,t1));

Segment_3 iss;
Point_3 isp;
std::vector<Point_3> vIsps;
Triangle_3 ist;
if(CGAL::assign(iss,obj)) cout<<"segment"<<endl;
else if(CGAL::assign(isp,obj)) cout<<"point"<<endl;
else if(CGAL::assign(vIsps,obj)) cout<<"vector of points"<<endl;
else if(CGAL::assign(ist,obj)) cout<<"triangle"<<endl;
else cout<<"BUG BUG BUG"<<endl;
return 0;
}

Best regards
Bernhard Kornberger





Archive powered by MHonArc 2.6.18.

Top of Page