Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
voronoi.c
Package: leda.tar.gz [view]
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 2k
Category:
Mathimatics-Numerical algorithms
Development Platform:
MultiPlatform
- #include <LEDA/plane_alg.h>
- #include <LEDA/subdivision.h>
- #include <LEDA/window.h>
- main()
- {
- window W;
- W.init(0,1000,0);
- int node_width = 4;
- int line_width = 1;
- int input = 1;
- int grid_width = 0;
- int N = 100;
- panel P("VORONOI");
- P.text_item("This program computes the Voronoi diagram for a set ");
- P.text_item("of point sites S in the plane. There are two ways of ");
- P.text_item("defining set S. Mouse input: Use the left button to ");
- P.text_item("insert a sequence of points and terminate the input ");
- P.text_item("by clicking the right button. Random input: Give the ");
- P.text_item("number of random points to be created by the program.");
- P.text_item("The Voronoi diagram Vor(S) is computed and shown. Now");
- P.text_item("you can define query points with the left button, for");
- P.text_item("each of which a point location in Vor(S) is performed.");
- P.text_item("Terminate the program by clicking the right button. ");
- P.text_item(" ");
- P.choice_item("INPUT",input,"RANDOM","MOUSE");
- P.int_item("GRID",grid_width,0,40,10);
- P.int_item("SITES",N);
- P.int_item("node width",node_width,1,10);
- P.int_item("line width",line_width,1,5);
- P.open(W);
- W.set_node_width(node_width);
- W.set_line_width(line_width);
- double x, y;
- point c;
- double R = 1000; // length of the "infinite rays"
- list<point> sites;
- W.clear();
- if (input)
- { W.init(0,1000,0,grid_width);
- while ( W >> c )
- { W << c;
- sites.append(c);
- }
- }
- else
- { while (N--)
- { c = point(rand_int(100,900),rand_int(100,900));
- W << c;
- sites.append(c);
- }
- }
- cout << "Computing Voronoi diagramn";
- newline;
- edge e;
- GRAPH<point,point> G;
- VORONOI(sites,R,G);
- // Draw Graph
- forall_edges(e,G) W.draw_segment(G[source(e)], G[target(e)]);
- cout << "Computing subdivisionn";
- newline;
- subdivision<point> S(G);
- // locate points
- W.message("Give query points!");
- W.set_mode(xor_mode);
- face f = nil;
- while (W.read_mouse(x,y)!=3)
- { if (f!=nil) // delete previously located site
- W.draw_filled_node(S.inf(f));
- f = S.locate_point(point(x,y));
- W.draw_filled_node(S.inf(f));
- cout << S.inf(f);
- newline;
- }
- return 0;
- }