Navigation: Up, Table of Contents, Bibliography, Index, Title Page

Window Stream (CGAL_Window_stream)

Definition

An object of type CGAL_Window_stream is a two-dimensional window for graphical IO. The input and output operations performs a mapping from object coordinates to window coordinates. The class CGAL_Window_stream provides input and output operators for the classes which are defined in the CGAL kernel.

The class CGAL_Window_stream is derived from the LEDA class window and inherits its rich functionality.

#include <CGAL/IO/Window_stream.h>

Creation

CGAL_Window_stream W ( int width, int height);
creates a window W of width × height pixels.

Operations

void W.init ( CGAL_Bbox_2 b = CGAL_Bbox_2(0, 0, 1, 1))
Defines the part of the object space that is mapped to the physical window.
void W.init ( double xmin, double xmax, double ymin)
Defines the part of the object space that is mapped to the physical window.

Output Operators

The output operator is defined for all geometric classes in the CGAL kernel.

CGAL_Window_stream&
CGAL_Window_stream &W << CGAL_Class c
inserts object c in the stream W.
CGAL_Window_stream&
CGAL_Window_stream &W << CGAL_Color c
changes the foreground color for the next objects that will be inserted in W.

Input Operators

The input operator is defined for all geometric classes in the CGAL kernel. The coordinates of the geometric objects are in object space. Data are entered with the left mouse button.

CGAL_Window_stream&
CGAL_Window_stream &W >> CGAL_Class &c
extracts object c from the stream W.

Example

It is important that the window stream header file gets included after the inclusion of the header files of geometric classes that get inserted to or extracted from the window stream.


#include <CGAL/Cartesian.h>
#include <CGAL/Segment_2.h>
#include <CGAL/IO/Window_stream.h>

typedef CGAL_Point_2< CGAL_Cartesian<double> >     Point;
typedef CGAL_Segment_2< CGAL_Cartesian<double> >   Segment;

int main()
{
    Point p(0,1), q(2,2);
    Segment s(p,q);

    CGAL_Window_stream W(100,100);
    W.init(0,10,10);

    W << CGAL_RED << s << CGAL_BLACK << p << q ;
    W >> s >> p;
    return 1;
}


Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The CGAL Project. Wed, January 20, 1999.