#include <CGAL/basic.h>
|
| |
|
introduces an uninitialized variable.
| |
|
| |
|
Copy constructor.
| |
Objects of type Object are normally created via the global function
|
| ||
|
|
| |
| Creates an object that contains t. | ||
|
|
| Assignment. |
Assignment of an object of type 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 Object contains an object.
|
|
| returns true, if object does not contain an object. |
In the following example, the object class is used as return value for the intersection computation, as there are possibly different return values.
{
Point_2< Cartesian<double> > point;
Segment_2< Cartesian<double> > segment, segment_1, segment_2;
std::cin >> segment_1 >> segment_2;
Object obj = intersection(segment_1, segment_2);
if (assign(point, obj)) {
/* do something with point */
} else if ((assign(segment, obj)) {
/* do something with segment*/
}
/* there was no intersection */
}
The intersection routine itself looks roughly as follows:
template < class R >
Object intersection(Segment_2<R> s1, Segment_2<R> s2)
{
if (/* intersection in a point */ ) {
Point_2<R> p = ... ;
return make_object(p);
} else if (/* intersection in a segment */ ) {
Segment_2<R> s = ... ;
return make_object(s);
}
return Object();
}