Algorithmic Solutions > LEDA > LEDA Guide > GeoWin > Programming Interface > Example Result Scenes and Update Functions

Example Result Scenes and Update Functions

The following program shows how to use result scenes and update functions of GeoWin.

The update function convex_hull() computes (the polygon of) the convex hull of a set of points in the plane.

The main function defines a GeoWin geow and a list<point> LP. The points are generated using an input scene sc_points of geow. The convex hull is represented by a result scene sc_hull using convex_hull as update function, sc_points as input scene, and "Convex Hull" as the name of the scene. geo_scene is a typedef for GeoScene*.

The boundary drawing color for sc_hull is set to blue and the scene is made visible.

Finally, geow is opened in interactive mode with edit scene sc_points. (See also Create and Open GeoWin.)

On the right there is a screenshot of the program after adding some points interactively. Clicking on the picture shows the GeoWin in original size.

Picture of GeoWin Edit and Result Scenes
#include <LEDA/graphics/geowin.h>
#include <LEDA/geo/float_geo_alg.h>

using namespace leda;

void convex_hull(const list<point>& L, list<polygon>& P)
{ P.clear(); P.append(CONVEX_HULL_POLY(L)); }

int main()
{
 GeoWin geow;
 list<point> LP;
 
 geo_scene sc_points = geow.new_scene(LP);  
                //edit scene for input of points

 geo_scene sc_hull = geow.new_scene(convex_hull, 
                          sc_points, "Convex hull");
                //result scene for convex hull

 geow.set_color(sc_hull, blue);
 geow.set_visible(sc_hull, true);
  
 geow.edit(sc_points);

 geow.get_window().screenshot("GeoWin_Edit_and_Result_Scenes");
 return 0;
}

See also:

GeoWin

Programming Interface

Interactive Interface

Create and Open GeoWin

Example Result Scenes and Update Objects


Linear Lists


Geometry

Basic Data Types for 2D Geometry


Geometry Algorithms

Convex Hull


Manual Pages:

Manual Page GeoWin




Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH