31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

geowin new scene and geowin get objects with GW as an additional first parameter.<br />

All new scene operations can get as an optional last parameter a pointer to a function<br />

that is used to compute the three-dimensional output of the scene. <strong>The</strong> type of such a<br />

function pointer f is<br />

void (∗f)(const T &, d3 window&, GRAPH &))<br />

where T is the type of the container used in the scene (for instance list). <strong>The</strong><br />

function gets a reference to the container of it’s scene, a reference to the output d3 window<br />

and to the parametrized graph describing the three-dimensional output. <strong>The</strong> function<br />

usually adds new nodes and edges to this graph. Note that every edge in the graph must<br />

have a reversal edge ( and the reversal information has to be set).<br />

Example:<br />

void segments_d3(const list& L,d3_window& W,<br />

GRAPH& H)<br />

{<br />

GRAPH G;<br />

segment iter;<br />

forall(iter,L) {<br />

node v1 = G.new_node(d3_point(iter.source().xcoord(),<br />

iter.source().ycoord(),0));<br />

node v2 = G.new_node(d3_point(iter.target().xcoord(),<br />

iter.target().ycoord(),0));<br />

edge e1 = G.new_edge(v1,v2);<br />

edge e2 = G.new_edge(v2,v1);<br />

G.set_reversal(e1,e2);<br />

}<br />

H.join(G);<br />

}<br />

In this simple example the function gets a list of segments. For every segment in the list<br />

two new nodes and two new edges are created. <strong>The</strong> reversal information is set for the two<br />

edges. At the end the local graph G is merged into H.<br />

<strong>The</strong> following templated new scene operation can be used to create edit scenes. <strong>The</strong><br />

CONTAINER has to be a list , where T is one of the following 2d <strong>LEDA</strong> kernel type<br />

• (rat )point<br />

• (rat )segment<br />

• (rat )line<br />

• (rat )circle<br />

• (rat )polygon

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!