#include <CGAL/basic.h>
|
| |
|
introduces an uninitialized variable.
| |
|
| |
|
Copy constructor.
| |
Objects of type CGAL_Object are normally created via the global function
|
| ||
|
|
| |
| Creates an object that contains t. | ||
|
|
| Assignment. |
Assignment of an object of type CGAL_Object to an object of type T is done using
|
| ||
|
|
| |
| assigns o to c if o was constructed from an object of type T. Returns true, if the assignment was possible. | ||
There is also a member function to check whether an object of type CGAL_Object contains an object.
|
|
| returns true, if object does not contain an object. |
{
CGAL_Point_2< CGAL_Cartesian<double> > point;
CGAL_Segment_2< CGAL_Cartesian<double> > segment, segment_1, segment_2;
cin >> segment_1 >> segment_2;
CGAL_Object obj = CGAL_intersection(segment_1, segment_2);
if (CGAL_assign(point, obj)) {
/* do something with point */
} else if ((CGAL_assign(segment, obj)) {
/* do something with segment*/
}
/* there was no intersection */
}
The intersection routine itself looks roughly as follows:
template < class R >
CGAL_Object CGAL_intersection(CGAL_Segment_2<R> s1, CGAL_Segment_2<R> s2)
{
if (/* intersection in a point */ ) {
CGAL_Point_2<R> p = ... ;
return CGAL_make_object(p);
} else if (/* intersection in a segment */ ) {
CGAL_Segment_2<R> s = ... ;
return CGAL_make_object(s);
}
return CGAL_Object();
}