Example POINT_SET Functionality
The following program generates a list
S of 10 rat_points in the square (-10,-10,10,10)
and defines a rat_point_set T using S . Then
it performs several operations on the T and prints the result.
#include <LEDA/core/list.h>
#include <LEDA/geo/rat_point.h>
#include <LEDA/geo/rat_point_set.h>
using namespace leda;
int main()
{
list<rat_point> S;random_points_in_square(10,10,S);
std::cout << "The points:" << std::endl;
rat_point p; forall(p,S) std::cout << p.to_point() << " " ;
std::cout << std::endl << std::endl;
rat_point_set T(S); //define rat_point_set
//bounding box
rat_point lower_left, upper_right;
T.get_bounding_box(lower_left,upper_right);
std::cout << "T.get_bounding_box(): (";
std::cout << lower_left << "," << upper_right << ")\n\n";
//convex hull
std::cout << "T.get_convex_hull():" << std::endl;
node v; list<node> CH=T.get_convex_hull();
forall(v,CH) {std::cout << "\t"; T.print_node(v); std::cout << std::endl;}
//dictionary operations
v=T.lookup(rat_point(3,4));
if (v==nil) {
T.insert(rat_point(3,4));
std::cout << "\npoint (3,4) inserted";
}
else std::cout << "\npoint (3,4) already contained in T";
v=T.lookup(rat_point(3,4));
std::cout << "\ndeleting point " << T.pos(v) << std::endl;
T.del(v);
//nearest neighbor
v=T.nearest_neighbor(rat_point(-1,-3));
std::cout << "\nT.nearest_neighbor((-1,1)): ";
T.print_node(v);
//range search
std::cout << "\n\nT.range_search((-4,-4),(3,3)): ";
list<node> L=T.range_search(rat_point(-4,-4),rat_point(3,3));
forall(v,L) { T.print_node(v); std::cout << " "; }
std::cout << std::endl;
return 0;
}
|
See also:
Point Sets
Data Types for 2D Geometry
Linear Lists
Generators for Geometric Objects
Dictionaries
Windows and Panels
Convex Hulls
Example of Point Location
and Drawing Operations for POINT_SET
Graphs and Related Data Types
Geometry
Geometry Algorithms
Manual Entries:
Manual
Page Point Sets
|