Skip to Content.
Sympa Menu

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

Subject: CGAL users discussion list

List archive

[cgal-discuss] CGAL::intersection()


Chronological Thread 
  • From: Bernhard Kornberger <>
  • To:
  • Subject: [cgal-discuss] CGAL::intersection()
  • Date: Tue, 25 Mar 2014 11:30:46 +0100

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