mardi 2 mai 2017

How to extract the type and value of the result from this CGAL function call?

I am using CGAL for some geometric computations. Currently I need to intersect several simple geometric objects inside the plane such as lines, segments etc. for which the CGAL's intersection function is perfect.

However, I don't know how to deduce the return type of the value of the function.

Say I have to intersect an isorectangle (a rectangle with sides parallel to the X-Y axes) and a Line. The result can be either a Point_2 or a Segment_2.

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Line_2 Line_2;
typedef K::Iso_rectangle_2 Iso_rectangle_2;

Iso_rectangle_2  iso{Point_2{px,py}, Point_2{qx,qy}};
Line_2           line{a,b,c};
CGAL::cpp11::result_of<K::Intersect_2(Iso_rectangle_2, Line_2)>::type result = CGAL::intersection (iso,line);

In the above code, once result has been computed, how do I find out what its type and value is? Also if the line and rectangle don't intersect, is there a CGAL equivalent to boost::none indicating the absence of a value?

Aucun commentaire:

Enregistrer un commentaire