CGAL::Geomview_stream

Definition

An object of the class Geomview_stream is a stream in which geometric objects can be inserted and where geometric objects can be extracted from. The constructor starts Geomview either on the local either on a remote machine.

#include <CGAL/IO/Geomview_stream.h>

Creation

Geomview_stream gs ( Bbox_3 bbox = Bbox_3(0,0,0, 1,1,1),
const char *machine = NULL,
const char *login = NULL);
Introduces a Geomview stream gs with a camera that sees the bounding box. The command geomview must be in the user's PATH. If machine and login are not NULL, Geomview is started on the remote machine using rsh.

Operations

Output Operators for CGAL Kernel Classes

At the moment not all classes of the CGAL kernel have output operators. 2D objects are embedded in the xy-plane.

template <class R>
Geomview_stream& Geomview_stream& G << Point_2<R> p
Inserts the point p into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Point_3<R> p
Inserts the point p into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Segment_2<R> s
Inserts the segment s into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Segment_3<R> s
Inserts the segment s into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Ray_2<R> r
Inserts the ray r into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Ray_3<R> r
Inserts the ray r into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Line_2<R> l
Inserts the line l into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Line_3<R> l
Inserts the line l into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Triangle_2<R> t
Inserts the triangle t into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Triangle_3<R> t
Inserts the triangle t into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Tetrahedron_3<R> t
Inserts the tetrahedron t into the stream gs.

template <class R>
Geomview_stream& Geomview_stream& G << Sphere_3<R> s
Inserts the sphere s into the stream gs.

Geomview_stream& Geomview_stream& G << Bbox_2 b
Inserts the bounding box b into the stream gs.

Geomview_stream& Geomview_stream& G << Bbox_3 b
Inserts the bounding box b into the stream gs.

template < class InputIterator >
void
gs.draw_triangles ( InputIterator begin,
InputIterator end)
[begin;end) is an iterator range with value type Triangle_3<R>. This method uses the OFF format to draw several triangles at once, which is much faster than drawing them one by one.

Input Operators for CGAL Kernel Classes

At the moment input is only provided for points. The user has to select a point on the pick plane with the right mouse button. The pick plane can be moved anywhere with the left mouse button, before a point is entered.

template <class R>
Geomview_stream& Geomview_stream& G >> Point_3<R>& p
Extracts the point p from the stream gs. The point is echoed by default, and it depends on the stream echo mode status.

Output Operators for CGAL Basic Library Classes

#include <CGAL/IO/Polyhedron_geomview_ostream.h>

template <class Traits, class HDS>
Geomview_stream& Geomview_stream &G << Polyhedron_3<Traits,HDS> P
Inserts the polyhedron P into the stream gs.

#include <CGAL/IO/Triangulation_geomview_ostream_2.h>

template <class GT, class TDS>
Geomview_stream& Geomview_stream &G << Triangulation_2<GT,TDS> T
Inserts the 2D triangulation T into the stream gs. The actual output depends on whether the stream is in wired mode or not. Also note that in the case of terrains (when GT::Point_2 is Point_3<R>), then the 3D terrain is displayed.

#include <CGAL/IO/Triangulation_geomview_ostream_3.h>

template <class GT, class TDS>
Geomview_stream& Geomview_stream &G << Triangulation_3<GT,TDS> T
Inserts the 3D triangulation T into the stream gs. The actual output depends on whether the stream is in wired mode or not.

Colors

Geomview distinguishes between edge and face colors. The edge color is at the same time the color of vertices.

Geomview_stream& gs << Color c Makes c the color of vertices, edges and faces in subsequent IO operations.

Color gs.set_bg_color ( Color c)
Changes the background color. Returns the old value.

Color gs.set_vertex_color ( Color c)
Changes the vertex color. Returns the old value.

Color gs.set_edge_color ( Color c)
Changes the edge color. Returns the old value.

Color gs.set_face_color ( Color c)
Changes the face color. Returns the old value.

Miscellaneous

void gs.clear () Deletes all objects.

void gs.pickplane () Creates a pickplane (useful after a clear).

void gs.look_recenter ()
Positions the camera in a way that all objects can be seen.

int gs.get_line_width ()
Returns the line width.

int gs.set_line_width ( int w)
Sets the line width to w. Returns the previous value.

double gs.get_vertex_radius ()
Returns the radius of vertices.

double gs.set_vertex_radius ( double r)
Sets the radius of vertices to d. Returns the previous value.

string gs.get_new_id ( string s)
Used to obtain unique identifier names passed to Geomview. On successive calls with the same s value, it will return a string which is s appended with the numbers 0, then 1, then 2... Note that all counters are reset when clear() is called.

bool gs.set_wired ( bool b)
Sets wired mode. In wired mode, some structures output only there edges, not there surfaces. Returns the previous value. By default, wired mode is off.

bool gs.get_wired () Returns true iff wired mode is on.


begin of advanced section  advanced  begin of advanced section

Advanced and Developers Features

The following functions are helpful if you develop your own insert and extract functions. The following functions allow to pass a string from Geomview and to read data sent back by Geomview.

Geomview_stream& gs << string s Inserts string s into the stream.

Geomview_stream& gs >> char* s Extracts a string s from the stream.
Precondition: You have to allocate enough memory.

Geomview_stream& gs << int i Inserts i into the stream. Puts whitespace around if the stream is in ascii mode.

Geomview_stream& gs << unsigned int i
Inserts i into the stream. Puts whitespace around if the stream is in ascii mode.

Geomview_stream& gs << long i Inserts i into the stream. Puts whitespace around if the stream is in ascii mode. Currently implemented by converting to int, so it can be truncated on 64 bit platforms.

Geomview_stream& gs << unsigned long i
Inserts i into the stream. Puts whitespace around if the stream is in ascii mode. Currently implemented by converting to unsigned int, so it can be truncated on 64 bit platforms.

Geomview_stream& gs << double d Inserts double d into the stream. Puts whitespace around if the stream is in ascii mode.

bool gs.set_trace ( bool b)
Sets tracing on. The data that are sent to Geomview are also sent to cerr. Returns the previous value. By default tracing is off.

bool gs.get_trace () Returns true iff tracing is on.

bool gs.set_raw ( bool b)
Sets raw mode. In raw mode, kernel points are output without headers and footers, just the coordinates (in binary or ascii mode). This allows the implementation of the stream functions for other objects to re-use the code for points internally, by temporary saving the raw mode to true, and restoring it after. Returns the previous value. By default, raw mode is off.

bool gs.get_raw () Returns true iff raw mode is on.

bool gs.set_echo ( bool b)
Sets echo mode. In echo mode, when you select a point in Geomview, the point is actually sent back to Geomview. Returns the previous value. By default, echo mode is on.

bool gs.get_echo () Returns true iff echo mode is on.

bool gs.set_binary_mode ( bool b = true)
Sets whether we are in binary mode.

bool gs.set_ascii_mode ( bool b = true)
Sets whether we are in ascii mode.

bool gs.get_binary_mode ()
Returns true iff gs is in binary mode.

bool gs.get_ascii_mode ()
Returns true iff gs is in ascii mode.

end of advanced section  advanced  end of advanced section

Implementation

The constructor forks a process and establishes two pipes between the processes. The forked process is then overlaid with Geomview. The file descriptors stdin and stdout of Geomview are hooked on the two pipes.

All insert operators construct expressions in gcl, the Geomview command language, which is a subset of LISP. These expressions are sent to Geomview via the pipe. The extract operators notify interest for a certain kind of events. When such an event happens Geomview sends a description of the event in gcl and the extract operator has to parse this expression.

In order to implement further insert and extract operators you should take a look at the implementation and at the Geomview manual.