Math-Geometry-Voronoi-1.3/0000755000076400007640000000000011226157602013624 5ustar samsamMath-Geometry-Voronoi-1.3/heap.c0000755000076400007640000000441411226155444014715 0ustar samsam /*** HEAP.C ***/ #include "vdefs.h" int PQmin, PQcount, PQhashsize ; Halfedge * PQhash ; void PQinsert(Halfedge * he, Site * v, double offset) { Halfedge * last, * next ; he->vertex = v ; ref(v) ; he->ystar = v->coord.y + offset ; last = &PQhash[ PQbucket(he)] ; while ((next = last->PQnext) != (Halfedge *)NULL && (he->ystar > next->ystar || (he->ystar == next->ystar && v->coord.x > next->vertex->coord.x))) { last = next ; } he->PQnext = last->PQnext ; last->PQnext = he ; PQcount++ ; } void PQdelete(Halfedge * he) { Halfedge * last; if(he -> vertex != (Site *) NULL) { last = &PQhash[PQbucket(he)] ; while (last -> PQnext != he) { last = last->PQnext ; } last->PQnext = he->PQnext; PQcount-- ; deref(he->vertex) ; he->vertex = (Site *)NULL ; } } int PQbucket(Halfedge * he) { int bucket ; if (he->ystar < ymin) bucket = 0; else if (he->ystar >= ymax) bucket = PQhashsize-1; else bucket = (he->ystar - ymin)/deltay * PQhashsize; if (bucket < 0) { bucket = 0 ; } if (bucket >= PQhashsize) { bucket = PQhashsize-1 ; } if (bucket < PQmin) { PQmin = bucket ; } return (bucket); } int PQempty(void) { return (PQcount == 0) ; } Point PQ_min(void) { Point answer ; while (PQhash[PQmin].PQnext == (Halfedge *)NULL) { ++PQmin ; } answer.x = PQhash[PQmin].PQnext->vertex->coord.x ; answer.y = PQhash[PQmin].PQnext->ystar ; return (answer) ; } Halfedge * PQextractmin(void) { Halfedge * curr ; curr = PQhash[PQmin].PQnext ; PQhash[PQmin].PQnext = curr->PQnext ; PQcount-- ; return (curr) ; } void PQinitialize(void) { int i ; PQcount = PQmin = 0 ; PQhashsize = 4 * sqrt_nsites ; PQhash = (Halfedge *)myalloc(PQhashsize * sizeof *PQhash) ; for (i = 0 ; i < PQhashsize; i++) { PQhash[i].PQnext = (Halfedge *)NULL ; } } Math-Geometry-Voronoi-1.3/t/0000755000076400007640000000000011226157602014067 5ustar samsamMath-Geometry-Voronoi-1.3/t/02real.t0000644000076400007640000000120711226155444015343 0ustar samsamuse strict; use warnings; use Test::More qw(no_plan); BEGIN { use_ok('Math::Geometry::Voronoi') or die } # run a test with some real data - around 1000 points on an integer grid use vars qw(@POINTS); do "t/real_data.txt"; my $geo = Math::Geometry::Voronoi->new(points => \@POINTS); $geo->compute(); my @geo_polys = $geo->polygons(normalize_vertices => sub { int($_[0]) }); my @polygons; foreach my $poly (@geo_polys) { my ($p, @verts) = @$poly; my $point = $POINTS[$p]; next unless $point->[3] == 5017; push @polygons, { poly => \@verts, point => $point }; } # known real value is(@polygons, 101); Math-Geometry-Voronoi-1.3/t/real_data.txt0000644000076400007640000036577711226155444016577 0ustar samsamour @POINTS = ( [ '3803040', '-8448970', '2920', '4912' ], [ '3803220', '-8449060', '2920', '4912' ], [ '3803329', '-8449110', '2920', '4912' ], [ '3803410', '-8449300', '2920', '4912' ], [ '3803410', '-8449150', '2920', '4912' ], [ '3803420', '-8449290', '2920', '4912' ], [ '3803430', '-8449430', '2920', '4912' ], [ '3803430', '-8449280', '2920', '4912' ], [ '3803430', '-8449270', '2920', '4912' ], [ '3803440', '-8449420', '2920', '4912' ], [ '3803440', '-8449410', '2920', '4912' ], [ '3803440', '-8449250', '2920', '4912' ], [ '3803450', '-8449240', '2920', '4912' ], [ '3803459', '-8449230', '2920', '4912' ], [ '3803470', '-8449380', '2920', '4912' ], [ '3803479', '-8449360', '2920', '4912' ], [ '3803479', '-8449190', '2920', '4912' ], [ '3803490', '-8449350', '2920', '4912' ], [ '3803499', '-8449200', '2920', '4912' ], [ '3803520', '-8449310', '2920', '4912' ], [ '3803550', '-8449270', '2920', '4912' ], [ '3803550', '-8449260', '2920', '4912' ], [ '3803590', '-8449240', '2920', '4912' ], [ '3802990', '-8449520', '2921', '4912' ], [ '3803000', '-8449510', '2921', '4912' ], [ '3803000', '-8449500', '2921', '4912' ], [ '3803020', '-8449660', '2921', '4912' ], [ '3803050', '-8449440', '2921', '4912' ], [ '3803080', '-8449720', '2921', '4912' ], [ '3803080', '-8449590', '2921', '4912' ], [ '3803090', '-8449730', '2921', '4912' ], [ '3803090', '-8449630', '2921', '4912' ], [ '3803090', '-8449620', '2921', '4912' ], [ '3803090', '-8449590', '2921', '4912' ], [ '3803100', '-8449610', '2921', '4912' ], [ '3803110', '-8449590', '2921', '4912' ], [ '3803130', '-8449570', '2921', '4912' ], [ '3803130', '-8449330', '2921', '4912' ], [ '3803140', '-8449560', '2921', '4912' ], [ '3803150', '-8449540', '2921', '4912' ], [ '3803230', '-8449590', '2922', '4912' ], [ '3803240', '-8449570', '2922', '4912' ], [ '3803260', '-8449550', '2922', '4912' ], [ '3803260', '-8449540', '2922', '4912' ], [ '3803270', '-8449860', '2922', '4912' ], [ '3803270', '-8449520', '2922', '4912' ], [ '3803340', '-8449410', '2922', '4912' ], [ '3803349', '-8449570', '2922', '4912' ], [ '3803349', '-8449390', '2922', '4912' ], [ '3803360', '-8449550', '2922', '4912' ], [ '3803360', '-8449370', '2922', '4912' ], [ '3803370', '-8449720', '2922', '4912' ], [ '3803390', '-8449330', '2922', '4912' ], [ '3803410', '-8449310', '2922', '4912' ], [ '3803430', '-8449630', '2922', '4912' ], [ '3803520', '-8449500', '2922', '4912' ], [ '3803530', '-8449490', '2922', '4912' ], [ '3803550', '-8449470', '2922', '4912' ], [ '3803560', '-8449450', '2922', '4912' ], [ '3803570', '-8449440', '2922', '4912' ], [ '3803590', '-8449410', '2922', '4912' ], [ '3803600', '-8449390', '2922', '4912' ], [ '3803620', '-8449370', '2922', '4912' ], [ '3802800', '-8449220', '2923', '4912' ], [ '3802810', '-8449230', '2923', '4912' ], [ '3802830', '-8449300', '2923', '4912' ], [ '3802859', '-8449400', '2923', '4912' ], [ '3802859', '-8449270', '2923', '4912' ], [ '3802879', '-8449270', '2923', '4912' ], [ '3802890', '-8449480', '2923', '4912' ], [ '3802890', '-8449260', '2923', '4912' ], [ '3802900', '-8449510', '2923', '4912' ], [ '3802950', '-8449260', '2923', '4912' ], [ '3802950', '-8449250', '2923', '4912' ], [ '3802950', '-8449220', '2923', '4912' ], [ '3802960', '-8449280', '2923', '4912' ], [ '3802970', '-8449300', '2923', '4912' ], [ '3802970', '-8449290', '2923', '4912' ], [ '3802990', '-8449330', '2923', '4912' ], [ '3802940', '-8449030', '2924', '4912' ], [ '3802940', '-8449020', '2924', '4912' ], [ '3802970', '-8449380', '2924', '4912' ], [ '3803140', '-8449530', '2924', '4912' ], [ '3803179', '-8449510', '2924', '4912' ], [ '3803179', '-8449500', '2924', '4912' ], [ '3803190', '-8449150', '2924', '4912' ], [ '3803199', '-8449140', '2924', '4912' ], [ '3803199', '-8449130', '2924', '4912' ], [ '3803210', '-8449130', '2924', '4912' ], [ '3803280', '-8449190', '2924', '4912' ], [ '3803290', '-8449320', '2924', '4912' ], [ '3803290', '-8449170', '2924', '4912' ], [ '3803300', '-8449310', '2924', '4912' ], [ '3803309', '-8449140', '2924', '4912' ], [ '3803320', '-8449460', '2924', '4912' ], [ '3803320', '-8449130', '2924', '4912' ], [ '3803349', '-8449240', '2924', '4912' ], [ '3803360', '-8449220', '2924', '4912' ], [ '3803380', '-8449190', '2924', '4912' ], [ '3805749', '-8447700', '3625', '4922' ], [ '3805789', '-8447750', '3625', '4922' ], [ '3805830', '-8447790', '3625', '4922' ], [ '3805860', '-8447830', '3625', '4922' ], [ '3806040', '-8447760', '3625', '4922' ], [ '3806049', '-8447760', '3625', '4922' ], [ '3806060', '-8448320', '3625', '4922' ], [ '3806060', '-8447780', '3625', '4922' ], [ '3806060', '-8447770', '3625', '4922' ], [ '3806069', '-8447790', '3625', '4922' ], [ '3806089', '-8447810', '3625', '4922' ], [ '3806130', '-8448400', '3625', '4922' ], [ '3806130', '-8447850', '3625', '4922' ], [ '3806160', '-8448480', '3625', '4922' ], [ '3806210', '-8448290', '3625', '4922' ], [ '3806219', '-8448290', '3625', '4922' ], [ '3806230', '-8448280', '3625', '4922' ], [ '3806290', '-8448200', '3625', '4922' ], [ '3806069', '-8448300', '3626', '4922' ], [ '3806140', '-8448200', '3626', '4922' ], [ '3806270', '-8448010', '3626', '4922' ], [ '3806280', '-8448440', '3626', '4922' ], [ '3806290', '-8448420', '3626', '4922' ], [ '3806290', '-8447500', '3626', '4922' ], [ '3805700', '-8447470', '3627', '4922' ], [ '3805769', '-8447550', '3627', '4922' ], [ '3805780', '-8447560', '3627', '4922' ], [ '3805789', '-8447570', '3627', '4922' ], [ '3805800', '-8447580', '3627', '4922' ], [ '3805810', '-8447440', '3627', '4922' ], [ '3805820', '-8447450', '3627', '4922' ], [ '3805850', '-8447640', '3627', '4922' ], [ '3805860', '-8447650', '3627', '4922' ], [ '3805870', '-8447660', '3627', '4922' ], [ '3805930', '-8447730', '3627', '4922' ], [ '3805939', '-8447740', '3627', '4922' ], [ '3805980', '-8447620', '3627', '4922' ], [ '3805990', '-8447790', '3627', '4922' ], [ '3806000', '-8447650', '3627', '4922' ], [ '3806049', '-8447700', '3627', '4922' ], [ '3806110', '-8447670', '3627', '4922' ], [ '3806120', '-8447590', '3627', '4922' ], [ '3806140', '-8447700', '3627', '4922' ], [ '3806150', '-8447550', '3627', '4922' ], [ '3806170', '-8447730', '3627', '4922' ], [ '3806170', '-8447570', '3627', '4922' ], [ '3806180', '-8447580', '3627', '4922' ], [ '3806190', '-8447750', '3627', '4922' ], [ '3806190', '-8447600', '3627', '4922' ], [ '3806190', '-8447590', '3627', '4922' ], [ '3806199', '-8447600', '3627', '4922' ], [ '3806210', '-8447780', '3627', '4922' ], [ '3806210', '-8447610', '3627', '4922' ], [ '3806230', '-8447640', '3627', '4922' ], [ '3803680', '-8447720', '2943', '4931' ], [ '3803690', '-8447730', '2943', '4931' ], [ '3803700', '-8447740', '2943', '4931' ], [ '3803730', '-8447770', '2943', '4931' ], [ '3803740', '-8447790', '2943', '4931' ], [ '3803759', '-8447780', '2943', '4931' ], [ '3803770', '-8447770', '2943', '4931' ], [ '3803770', '-8447760', '2943', '4931' ], [ '3803779', '-8447760', '2943', '4931' ], [ '3803779', '-8447750', '2943', '4931' ], [ '3803799', '-8447850', '2943', '4931' ], [ '3803810', '-8447860', '2943', '4931' ], [ '3803820', '-8447870', '2943', '4931' ], [ '3803830', '-8447880', '2943', '4931' ], [ '3803830', '-8447870', '2943', '4931' ], [ '3803830', '-8447830', '2943', '4931' ], [ '3803840', '-8447820', '2943', '4931' ], [ '3803840', '-8447810', '2943', '4931' ], [ '3803870', '-8447930', '2943', '4931' ], [ '3803970', '-8448040', '2943', '4931' ], [ '3803230', '-8448100', '2944', '4931' ], [ '3803250', '-8448120', '2944', '4931' ], [ '3803270', '-8448150', '2944', '4931' ], [ '3803290', '-8448150', '2944', '4931' ], [ '3803300', '-8448140', '2944', '4931' ], [ '3803309', '-8448130', '2944', '4931' ], [ '3803309', '-8448120', '2944', '4931' ], [ '3803320', '-8448100', '2944', '4931' ], [ '3803340', '-8448230', '2944', '4931' ], [ '3803420', '-8448330', '2944', '4931' ], [ '3803470', '-8448320', '2944', '4931' ], [ '3803499', '-8448430', '2944', '4931' ], [ '3803790', '-8448320', '2945', '4931' ], [ '3803799', '-8448340', '2945', '4931' ], [ '3803810', '-8448350', '2945', '4931' ], [ '3803810', '-8448340', '2945', '4931' ], [ '3803850', '-8448230', '2945', '4931' ], [ '3803860', '-8448240', '2945', '4931' ], [ '3803870', '-8448250', '2945', '4931' ], [ '3803880', '-8448260', '2945', '4931' ], [ '3803980', '-8448140', '2945', '4931' ], [ '3803980', '-8448050', '2945', '4931' ], [ '3803980', '-8448040', '2945', '4931' ], [ '3803990', '-8448060', '2945', '4931' ], [ '3803990', '-8448050', '2945', '4931' ], [ '3804000', '-8448070', '2945', '4931' ], [ '3804000', '-8448060', '2945', '4931' ], [ '3804010', '-8448080', '2945', '4931' ], [ '3804010', '-8448070', '2945', '4931' ], [ '3804020', '-8448080', '2945', '4931' ], [ '3803240', '-8448090', '2946', '4931' ], [ '3803260', '-8448070', '2946', '4931' ], [ '3803300', '-8448010', '2946', '4931' ], [ '3803309', '-8447980', '2946', '4931' ], [ '3803329', '-8448100', '2946', '4931' ], [ '3803329', '-8448090', '2946', '4931' ], [ '3803340', '-8448090', '2946', '4931' ], [ '3803340', '-8448080', '2946', '4931' ], [ '3803349', '-8448070', '2946', '4931' ], [ '3803459', '-8448080', '2946', '4931' ], [ '3803470', '-8448070', '2946', '4931' ], [ '3803479', '-8448050', '2946', '4931' ], [ '3803490', '-8448040', '2946', '4931' ], [ '3803490', '-8448030', '2946', '4931' ], [ '3803499', '-8448030', '2946', '4931' ], [ '3803499', '-8448020', '2946', '4931' ], [ '3803550', '-8447780', '2946', '4931' ], [ '3803550', '-8447770', '2946', '4931' ], [ '3803560', '-8447760', '2946', '4931' ], [ '3803629', '-8447810', '2947', '4931' ], [ '3803640', '-8447820', '2947', '4931' ], [ '3803660', '-8447840', '2947', '4931' ], [ '3803690', '-8447880', '2947', '4931' ], [ '3803700', '-8447710', '2947', '4931' ], [ '3803720', '-8447670', '2947', '4931' ], [ '3803730', '-8447660', '2947', '4931' ], [ '3803740', '-8447650', '2947', '4931' ], [ '3803790', '-8447990', '2947', '4931' ], [ '3803799', '-8448000', '2947', '4931' ], [ '3803810', '-8448000', '2947', '4931' ], [ '3803910', '-8448120', '2947', '4931' ], [ '3803910', '-8448110', '2947', '4931' ], [ '3803920', '-8448130', '2947', '4931' ], [ '3803929', '-8448140', '2947', '4931' ], [ '3803360', '-8448240', '2948', '4931' ], [ '3803400', '-8448180', '2948', '4931' ], [ '3803450', '-8448300', '2948', '4931' ], [ '3803450', '-8448290', '2948', '4931' ], [ '3803450', '-8448100', '2948', '4931' ], [ '3803459', '-8448280', '2948', '4931' ], [ '3803490', '-8448240', '2948', '4931' ], [ '3803510', '-8448200', '2948', '4931' ], [ '3803530', '-8448170', '2948', '4931' ], [ '3803550', '-8448140', '2948', '4931' ], [ '3803560', '-8448380', '2948', '4931' ], [ '3803580', '-8448100', '2948', '4931' ], [ '3803590', '-8448080', '2948', '4931' ], [ '3803600', '-8448070', '2948', '4931' ], [ '3803629', '-8448030', '2948', '4931' ], [ '3803629', '-8448020', '2948', '4931' ], [ '3803640', '-8448010', '2948', '4931' ], [ '3803649', '-8447990', '2948', '4931' ], [ '3803660', '-8448250', '2948', '4931' ], [ '3803660', '-8447980', '2948', '4931' ], [ '3803670', '-8447970', '2948', '4931' ], [ '3803680', '-8447950', '2948', '4931' ], [ '3803690', '-8447940', '2948', '4931' ], [ '3803690', '-8447930', '2948', '4931' ], [ '3803700', '-8448190', '2948', '4931' ], [ '3803700', '-8447920', '2948', '4931' ], [ '3803740', '-8448430', '2948', '4931' ], [ '3803740', '-8448130', '2948', '4931' ], [ '3803759', '-8448450', '2948', '4931' ], [ '3803759', '-8448090', '2948', '4931' ], [ '3803779', '-8448060', '2948', '4931' ], [ '3803810', '-8448020', '2948', '4931' ], [ '3805639', '-8448680', '3634', '4933' ], [ '3805030', '-8450000', '3635', '4933' ], [ '3805110', '-8450100', '3635', '4933' ], [ '3805180', '-8450170', '3635', '4933' ], [ '3805190', '-8450190', '3635', '4933' ], [ '3805449', '-8450140', '3636', '4933' ], [ '3805469', '-8449990', '3636', '4933' ], [ '3805490', '-8450010', '3636', '4933' ], [ '3805520', '-8450040', '3636', '4933' ], [ '3805530', '-8450050', '3636', '4933' ], [ '3805550', '-8450080', '3636', '4933' ], [ '3805560', '-8450090', '3636', '4933' ], [ '3805560', '-8449940', '3636', '4933' ], [ '3805590', '-8449970', '3636', '4933' ], [ '3805590', '-8449960', '3636', '4933' ], [ '3805599', '-8450130', '3636', '4933' ], [ '3805610', '-8450140', '3636', '4933' ], [ '3805619', '-8449990', '3636', '4933' ], [ '3805639', '-8450020', '3636', '4933' ], [ '3805769', '-8450170', '3636', '4933' ], [ '3805169', '-8449830', '3637', '4933' ], [ '3805200', '-8449860', '3637', '4933' ], [ '3805210', '-8449870', '3637', '4933' ], [ '3805310', '-8449990', '3637', '4933' ], [ '3805340', '-8450010', '3637', '4933' ], [ '3805270', '-8450170', '3638', '4933' ], [ '3805340', '-8450090', '3638', '4933' ], [ '3805500', '-8449870', '3638', '4933' ], [ '3805500', '-8449860', '3638', '4933' ], [ '3805520', '-8449890', '3638', '4933' ], [ '3805540', '-8449910', '3638', '4933' ], [ '3805550', '-8449780', '3638', '4933' ], [ '3805570', '-8449760', '3638', '4933' ], [ '3805720', '-8449850', '3638', '4933' ], [ '3805120', '-8447450', '2949', '4934' ], [ '3805130', '-8447470', '2949', '4934' ], [ '3805130', '-8447460', '2949', '4934' ], [ '3805160', '-8447510', '2949', '4934' ], [ '3805169', '-8447510', '2949', '4934' ], [ '3805190', '-8447560', '2949', '4934' ], [ '3805270', '-8447350', '2949', '4934' ], [ '3805270', '-8447340', '2949', '4934' ], [ '3805340', '-8448080', '2949', '4934' ], [ '3805350', '-8448080', '2949', '4934' ], [ '3805360', '-8448050', '2949', '4934' ], [ '3805390', '-8448020', '2949', '4934' ], [ '3805390', '-8448010', '2949', '4934' ], [ '3805400', '-8447790', '2949', '4934' ], [ '3805410', '-8447980', '2949', '4934' ], [ '3805430', '-8447830', '2949', '4934' ], [ '3805460', '-8447860', '2949', '4934' ], [ '3805510', '-8447910', '2949', '4934' ], [ '3805530', '-8447930', '2949', '4934' ], [ '3805550', '-8447960', '2949', '4934' ], [ '3805570', '-8447980', '2949', '4934' ], [ '3804920', '-8448480', '2950', '4934' ], [ '3804930', '-8448490', '2950', '4934' ], [ '3805030', '-8448230', '2950', '4934' ], [ '3805070', '-8448660', '2950', '4934' ], [ '3805070', '-8448650', '2950', '4934' ], [ '3805090', '-8448680', '2950', '4934' ], [ '3805100', '-8448320', '2950', '4934' ], [ '3805110', '-8448330', '2950', '4934' ], [ '3805120', '-8448330', '2950', '4934' ], [ '3805130', '-8448350', '2950', '4934' ], [ '3805140', '-8448360', '2950', '4934' ], [ '3805149', '-8448370', '2950', '4934' ], [ '3805160', '-8448590', '2950', '4934' ], [ '3805160', '-8448580', '2950', '4934' ], [ '3805169', '-8448540', '2950', '4934' ], [ '3805220', '-8448450', '2950', '4934' ], [ '3805240', '-8448620', '2950', '4934' ], [ '3805240', '-8448470', '2950', '4934' ], [ '3805270', '-8448660', '2950', '4934' ], [ '3805270', '-8448650', '2950', '4934' ], [ '3805299', '-8448690', '2950', '4934' ], [ '3805340', '-8448590', '2950', '4934' ], [ '3805340', '-8448580', '2950', '4934' ], [ '3805350', '-8448330', '2951', '4934' ], [ '3805370', '-8448340', '2951', '4934' ], [ '3805390', '-8448370', '2951', '4934' ], [ '3805400', '-8448380', '2951', '4934' ], [ '3805400', '-8448150', '2951', '4934' ], [ '3805410', '-8448380', '2951', '4934' ], [ '3805410', '-8448160', '2951', '4934' ], [ '3805420', '-8448400', '2951', '4934' ], [ '3805449', '-8448560', '2951', '4934' ], [ '3805460', '-8448540', '2951', '4934' ], [ '3805500', '-8448250', '2951', '4934' ], [ '3805510', '-8448270', '2951', '4934' ], [ '3805540', '-8448300', '2951', '4934' ], [ '3805550', '-8448310', '2951', '4934' ], [ '3805560', '-8448330', '2951', '4934' ], [ '3805590', '-8448360', '2951', '4934' ], [ '3805599', '-8448340', '2951', '4934' ], [ '3805610', '-8448330', '2951', '4934' ], [ '3805630', '-8448290', '2951', '4934' ], [ '3805650', '-8448270', '2951', '4934' ], [ '3805660', '-8448250', '2951', '4934' ], [ '3804910', '-8447620', '2952', '4934' ], [ '3804950', '-8448460', '2952', '4934' ], [ '3804960', '-8448450', '2952', '4934' ], [ '3804970', '-8448430', '2952', '4934' ], [ '3804979', '-8447730', '2952', '4934' ], [ '3804990', '-8448400', '2952', '4934' ], [ '3804999', '-8447700', '2952', '4934' ], [ '3805010', '-8447470', '2952', '4934' ], [ '3805030', '-8447650', '2952', '4934' ], [ '3805030', '-8447640', '2952', '4934' ], [ '3805040', '-8447590', '2952', '4934' ], [ '3805040', '-8447580', '2952', '4934' ], [ '3805060', '-8447610', '2952', '4934' ], [ '3805100', '-8448250', '2952', '4934' ], [ '3805130', '-8448210', '2952', '4934' ], [ '3805149', '-8448180', '2952', '4934' ], [ '3805160', '-8448170', '2952', '4934' ], [ '3805169', '-8448160', '2952', '4934' ], [ '3805169', '-8448150', '2952', '4934' ], [ '3805160', '-8448340', '2953', '4934' ], [ '3805169', '-8448340', '2953', '4934' ], [ '3805169', '-8448330', '2953', '4934' ], [ '3805180', '-8448320', '2953', '4934' ], [ '3805180', '-8448310', '2953', '4934' ], [ '3805190', '-8448310', '2953', '4934' ], [ '3805210', '-8448050', '2953', '4934' ], [ '3805240', '-8448080', '2953', '4934' ], [ '3805250', '-8448400', '2953', '4934' ], [ '3805250', '-8448390', '2953', '4934' ], [ '3805260', '-8448380', '2953', '4934' ], [ '3805270', '-8448370', '2953', '4934' ], [ '3805299', '-8448150', '2953', '4934' ], [ '3805319', '-8448300', '2953', '4934' ], [ '3805319', '-8448290', '2953', '4934' ], [ '3805330', '-8448190', '2953', '4934' ], [ '3805380', '-8448240', '2953', '4934' ], [ '3805390', '-8448250', '2953', '4934' ], [ '3805420', '-8448050', '2953', '4934' ], [ '3805430', '-8448310', '2953', '4934' ], [ '3805430', '-8448300', '2953', '4934' ], [ '3805440', '-8448310', '2953', '4934' ], [ '3805449', '-8448070', '2953', '4934' ], [ '3805460', '-8448340', '2953', '4934' ], [ '3805469', '-8448340', '2953', '4934' ], [ '3805480', '-8448360', '2953', '4934' ], [ '3805490', '-8448370', '2953', '4934' ], [ '3805490', '-8448120', '2953', '4934' ], [ '3805510', '-8448150', '2953', '4934' ], [ '3805570', '-8448220', '2953', '4934' ], [ '3801610', '-8446560', '2982', '4939' ], [ '3801680', '-8446640', '2982', '4939' ], [ '3801720', '-8446690', '2982', '4939' ], [ '3801770', '-8446740', '2982', '4939' ], [ '3801740', '-8446930', '2983', '4939' ], [ '3801750', '-8446960', '2983', '4939' ], [ '3801750', '-8446880', '2983', '4939' ], [ '3801760', '-8446810', '2983', '4939' ], [ '3801770', '-8446730', '2983', '4939' ], [ '3801939', '-8446890', '2984', '4939' ], [ '3801970', '-8446860', '2984', '4939' ], [ '3801870', '-8446950', '2985', '4939' ], [ '3801870', '-8446930', '2985', '4939' ], [ '3801870', '-8446920', '2985', '4939' ], [ '3801880', '-8446950', '2985', '4939' ], [ '3801910', '-8446920', '2985', '4939' ], [ '3801930', '-8446900', '2985', '4939' ], [ '3804210', '-8444570', '3701', '4949' ], [ '3804330', '-8444820', '3701', '4949' ], [ '3804340', '-8444810', '3701', '4949' ], [ '3804350', '-8444800', '3701', '4949' ], [ '3804370', '-8444790', '3701', '4949' ], [ '3804529', '-8444910', '3701', '4949' ], [ '3804529', '-8444900', '3701', '4949' ], [ '3804529', '-8444890', '3701', '4949' ], [ '3804540', '-8444870', '3701', '4949' ], [ '3804549', '-8444850', '3701', '4949' ], [ '3804580', '-8444600', '3701', '4949' ], [ '3804590', '-8444590', '3701', '4949' ], [ '3804600', '-8444580', '3701', '4949' ], [ '3804600', '-8444570', '3701', '4949' ], [ '3804650', '-8444850', '3701', '4949' ], [ '3804650', '-8444830', '3701', '4949' ], [ '3804679', '-8444600', '3701', '4949' ], [ '3804900', '-8444800', '3701', '4949' ], [ '3804920', '-8444700', '3701', '4949' ], [ '3804930', '-8444730', '3701', '4949' ], [ '3804829', '-8444910', '3702', '4949' ], [ '3805060', '-8444400', '3702', '4949' ], [ '3805070', '-8444460', '3702', '4949' ], [ '3805070', '-8444450', '3702', '4949' ], [ '3805070', '-8444420', '3702', '4949' ], [ '3805070', '-8444410', '3702', '4949' ], [ '3805100', '-8444690', '3702', '4949' ], [ '3805110', '-8444700', '3702', '4949' ], [ '3805110', '-8444690', '3702', '4949' ], [ '3805130', '-8444290', '3702', '4949' ], [ '3805140', '-8444410', '3702', '4949' ], [ '3805140', '-8444390', '3702', '4949' ], [ '3805140', '-8444380', '3702', '4949' ], [ '3805160', '-8444610', '3702', '4949' ], [ '3805160', '-8444600', '3702', '4949' ], [ '3805169', '-8444620', '3702', '4949' ], [ '3805180', '-8444260', '3702', '4949' ], [ '3805200', '-8444240', '3702', '4949' ], [ '3805210', '-8444520', '3702', '4949' ], [ '3805210', '-8444510', '3702', '4949' ], [ '3805230', '-8444220', '3702', '4949' ], [ '3805240', '-8444330', '3702', '4949' ], [ '3805260', '-8444410', '3702', '4949' ], [ '3805290', '-8444300', '3702', '4949' ], [ '3805310', '-8444190', '3702', '4949' ], [ '3805370', '-8444210', '3702', '4949' ], [ '3804610', '-8444280', '3703', '4949' ], [ '3804620', '-8444290', '3703', '4949' ], [ '3804640', '-8444320', '3703', '4949' ], [ '3804650', '-8444330', '3703', '4949' ], [ '3804670', '-8444350', '3703', '4949' ], [ '3804710', '-8444390', '3703', '4949' ], [ '3804750', '-8444290', '3703', '4949' ], [ '3804750', '-8444280', '3703', '4949' ], [ '3804810', '-8443940', '3703', '4949' ], [ '3804810', '-8443930', '3703', '4949' ], [ '3804820', '-8444170', '3703', '4949' ], [ '3804820', '-8444160', '3703', '4949' ], [ '3804820', '-8444120', '3703', '4949' ], [ '3804820', '-8444070', '3703', '4949' ], [ '3804820', '-8443890', '3703', '4949' ], [ '3804869', '-8444060', '3703', '4949' ], [ '3804880', '-8444070', '3703', '4949' ], [ '3804890', '-8444110', '3703', '4949' ], [ '3804910', '-8444260', '3703', '4949' ], [ '3804920', '-8444260', '3703', '4949' ], [ '3804930', '-8444260', '3703', '4949' ], [ '3804940', '-8444260', '3703', '4949' ], [ '3804950', '-8444400', '3703', '4949' ], [ '3804970', '-8444490', '3703', '4949' ], [ '3804979', '-8444570', '3703', '4949' ], [ '3805260', '-8444080', '3703', '4949' ], [ '3805290', '-8444080', '3703', '4949' ], [ '3805370', '-8444110', '3703', '4949' ], [ '3804099', '-8449570', '3695', '4950' ], [ '3804110', '-8449590', '3695', '4950' ], [ '3804110', '-8449580', '3695', '4950' ], [ '3804110', '-8449450', '3695', '4950' ], [ '3804140', '-8449460', '3695', '4950' ], [ '3804170', '-8449490', '3695', '4950' ], [ '3804190', '-8449520', '3695', '4950' ], [ '3804190', '-8449510', '3695', '4950' ], [ '3804210', '-8449540', '3695', '4950' ], [ '3804220', '-8449670', '3695', '4950' ], [ '3804240', '-8449660', '3695', '4950' ], [ '3804240', '-8449650', '3695', '4950' ], [ '3804249', '-8449640', '3695', '4950' ], [ '3804260', '-8449630', '3695', '4950' ], [ '3804270', '-8449610', '3695', '4950' ], [ '3804280', '-8449610', '3695', '4950' ], [ '3804450', '-8449640', '3695', '4950' ], [ '3803710', '-8449890', '3696', '4950' ], [ '3803720', '-8449690', '3696', '4950' ], [ '3803750', '-8449660', '3696', '4950' ], [ '3803770', '-8449620', '3696', '4950' ], [ '3803779', '-8449970', '3696', '4950' ], [ '3803779', '-8449790', '3696', '4950' ], [ '3803779', '-8449610', '3696', '4950' ], [ '3803790', '-8449790', '3696', '4950' ], [ '3803790', '-8449780', '3696', '4950' ], [ '3803790', '-8449600', '3696', '4950' ], [ '3803799', '-8449770', '3696', '4950' ], [ '3803810', '-8449760', '3696', '4950' ], [ '3803820', '-8449740', '3696', '4950' ], [ '3803830', '-8449730', '3696', '4950' ], [ '3803830', '-8449550', '3696', '4950' ], [ '3803850', '-8449700', '3696', '4950' ], [ '3803860', '-8449680', '3696', '4950' ], [ '3803870', '-8449670', '3696', '4950' ], [ '3803880', '-8449660', '3696', '4950' ], [ '3803900', '-8449640', '3696', '4950' ], [ '3803900', '-8449630', '3696', '4950' ], [ '3803910', '-8449640', '3696', '4950' ], [ '3803949', '-8449690', '3696', '4950' ], [ '3803970', '-8449710', '3696', '4950' ], [ '3804010', '-8449760', '3696', '4950' ], [ '3804010', '-8449750', '3696', '4950' ], [ '3804020', '-8449770', '3696', '4950' ], [ '3804040', '-8449790', '3697', '4950' ], [ '3804079', '-8449830', '3697', '4950' ], [ '3804090', '-8449840', '3697', '4950' ], [ '3804099', '-8449850', '3697', '4950' ], [ '3804110', '-8449960', '3697', '4950' ], [ '3804120', '-8449880', '3697', '4950' ], [ '3804150', '-8449910', '3697', '4950' ], [ '3804200', '-8449840', '3697', '4950' ], [ '3804210', '-8449830', '3697', '4950' ], [ '3804220', '-8449810', '3697', '4950' ], [ '3804240', '-8449790', '3697', '4950' ], [ '3804249', '-8449770', '3697', '4950' ], [ '3804260', '-8450040', '3697', '4950' ], [ '3804260', '-8449910', '3697', '4950' ], [ '3804260', '-8449750', '3697', '4950' ], [ '3804280', '-8449740', '3697', '4950' ], [ '3804290', '-8449900', '3697', '4950' ], [ '3804300', '-8449890', '3697', '4950' ], [ '3804379', '-8450040', '3697', '4950' ], [ '3804470', '-8449950', '3697', '4950' ], [ '3804490', '-8449920', '3697', '4950' ], [ '3803900', '-8449540', '3698', '4950' ], [ '3803910', '-8449370', '3698', '4950' ], [ '3803920', '-8449180', '3698', '4950' ], [ '3803940', '-8449380', '3698', '4950' ], [ '3803940', '-8449370', '3698', '4950' ], [ '3803940', '-8449150', '3698', '4950' ], [ '3803960', '-8449390', '3698', '4950' ], [ '3803980', '-8449570', '3698', '4950' ], [ '3804000', '-8449590', '3698', '4950' ], [ '3804000', '-8449580', '3698', '4950' ], [ '3804010', '-8449600', '3698', '4950' ], [ '3804020', '-8449600', '3698', '4950' ], [ '3804030', '-8449620', '3698', '4950' ], [ '3804030', '-8449420', '3698', '4950' ], [ '3804030', '-8449410', '3698', '4950' ], [ '3804050', '-8449420', '3698', '4950' ], [ '3804090', '-8449440', '3698', '4950' ], [ '3803840', '-8449900', '3699', '4950' ], [ '3803910', '-8449790', '3699', '4950' ], [ '3803990', '-8449670', '3699', '4950' ], [ '3804040', '-8449600', '3699', '4950' ], [ '3804050', '-8449660', '3699', '4950' ], [ '3804050', '-8449600', '3699', '4950' ], [ '3804099', '-8449730', '3699', '4950' ], [ '3804099', '-8449720', '3699', '4950' ], [ '3804110', '-8449510', '3699', '4950' ], [ '3804120', '-8449690', '3699', '4950' ], [ '3804140', '-8449670', '3699', '4950' ], [ '3804150', '-8449650', '3699', '4950' ], [ '3804160', '-8449640', '3699', '4950' ], [ '3804170', '-8449630', '3699', '4950' ], [ '3804170', '-8449620', '3699', '4950' ], [ '3804190', '-8449590', '3699', '4950' ], [ '3802140', '-8447900', '3174', '4986' ], [ '3802129', '-8443020', '3228', '5010' ], [ '3802150', '-8443000', '3228', '5010' ], [ '3802340', '-8443080', '3228', '5010' ], [ '3801770', '-8442970', '3229', '5010' ], [ '3801820', '-8443010', '3229', '5010' ], [ '3801830', '-8443010', '3229', '5010' ], [ '3802579', '-8443970', '3230', '5010' ], [ '3802610', '-8443950', '3230', '5010' ], [ '3802660', '-8443930', '3230', '5010' ], [ '3802670', '-8443920', '3230', '5010' ], [ '3802770', '-8443870', '3230', '5010' ], [ '3802800', '-8443770', '3230', '5010' ], [ '3802830', '-8443840', '3230', '5010' ], [ '3802830', '-8443770', '3230', '5010' ], [ '3802840', '-8443770', '3230', '5010' ], [ '3802890', '-8443770', '3230', '5010' ], [ '3802920', '-8443810', '3230', '5010' ], [ '3802930', '-8443830', '3230', '5010' ], [ '3802970', '-8443890', '3230', '5010' ], [ '3801939', '-8442980', '3231', '5010' ], [ '3801990', '-8442990', '3231', '5010' ], [ '3802200', '-8443080', '3231', '5010' ], [ '3802490', '-8443130', '3231', '5010' ], [ '3802500', '-8443150', '3231', '5010' ], [ '3802500', '-8442980', '3231', '5010' ], [ '3802510', '-8443180', '3231', '5010' ], [ '3802520', '-8443210', '3231', '5010' ], [ '3802530', '-8443260', '3231', '5010' ], [ '3802600', '-8443160', '3231', '5010' ], [ '3802300', '-8443470', '3232', '5010' ], [ '3802310', '-8443470', '3232', '5010' ], [ '3802320', '-8443620', '3232', '5010' ], [ '3802330', '-8443610', '3232', '5010' ], [ '3802360', '-8443550', '3232', '5010' ], [ '3802389', '-8443490', '3232', '5010' ], [ '3802400', '-8443470', '3232', '5010' ], [ '3802409', '-8443670', '3232', '5010' ], [ '3802429', '-8443620', '3232', '5010' ], [ '3802440', '-8443610', '3232', '5010' ], [ '3802440', '-8443600', '3232', '5010' ], [ '3802460', '-8443560', '3232', '5010' ], [ '3802470', '-8443540', '3232', '5010' ], [ '3802470', '-8443530', '3232', '5010' ], [ '3802590', '-8443280', '3232', '5010' ], [ '3802720', '-8443170', '3232', '5010' ], [ '3802230', '-8443640', '3233', '5010' ], [ '3802239', '-8443610', '3233', '5010' ], [ '3802239', '-8443600', '3233', '5010' ], [ '3802270', '-8443550', '3233', '5010' ], [ '3802290', '-8443850', '3233', '5010' ], [ '3802290', '-8443430', '3233', '5010' ], [ '3802300', '-8443840', '3233', '5010' ], [ '3802330', '-8443790', '3233', '5010' ], [ '3802340', '-8443770', '3233', '5010' ], [ '3802360', '-8443750', '3233', '5010' ], [ '3802370', '-8443730', '3233', '5010' ], [ '3802389', '-8443700', '3233', '5010' ], [ '3802400', '-8443690', '3233', '5010' ], [ '3802460', '-8443870', '3233', '5010' ], [ '3802470', '-8443880', '3233', '5010' ], [ '3802490', '-8443890', '3233', '5010' ], [ '3802510', '-8443900', '3233', '5010' ], [ '3802579', '-8443760', '3233', '5010' ], [ '3802620', '-8443760', '3233', '5010' ], [ '3802640', '-8443760', '3233', '5010' ], [ '3802650', '-8443760', '3233', '5010' ], [ '3802660', '-8443760', '3233', '5010' ], [ '3802720', '-8443870', '3233', '5010' ], [ '3802729', '-8443860', '3233', '5010' ], [ '3802729', '-8443770', '3233', '5010' ], [ '3802760', '-8443860', '3233', '5010' ], [ '3802770', '-8443770', '3233', '5010' ], [ '3802780', '-8443770', '3233', '5010' ], [ '3802840', '-8443820', '3233', '5010' ], [ '3802859', '-8443800', '3233', '5010' ], [ '3803600', '-8445730', '3350', '5017' ], [ '3803620', '-8445690', '3350', '5017' ], [ '3803629', '-8445680', '3350', '5017' ], [ '3803640', '-8445900', '3350', '5017' ], [ '3803640', '-8445850', '3350', '5017' ], [ '3803660', '-8445930', '3350', '5017' ], [ '3803680', '-8445940', '3350', '5017' ], [ '3803690', '-8445960', '3350', '5017' ], [ '3803870', '-8446140', '3350', '5017' ], [ '3803870', '-8445960', '3350', '5017' ], [ '3803900', '-8446190', '3350', '5017' ], [ '3803910', '-8446010', '3350', '5017' ], [ '3803920', '-8446210', '3350', '5017' ], [ '3803929', '-8446230', '3350', '5017' ], [ '3803940', '-8446240', '3350', '5017' ], [ '3803949', '-8446250', '3350', '5017' ], [ '3803960', '-8446270', '3350', '5017' ], [ '3803970', '-8446100', '3350', '5017' ], [ '3803980', '-8446100', '3350', '5017' ], [ '3804000', '-8446140', '3350', '5017' ], [ '3804030', '-8446180', '3350', '5017' ], [ '3804050', '-8446210', '3350', '5017' ], [ '3804070', '-8446240', '3350', '5017' ], [ '3804070', '-8446230', '3350', '5017' ], [ '3804220', '-8446440', '3350', '5017' ], [ '3803790', '-8446750', '3351', '5017' ], [ '3803799', '-8446750', '3351', '5017' ], [ '3803820', '-8446750', '3351', '5017' ], [ '3803850', '-8446760', '3351', '5017' ], [ '3803860', '-8446760', '3351', '5017' ], [ '3803870', '-8446760', '3351', '5017' ], [ '3803880', '-8446770', '3351', '5017' ], [ '3803980', '-8447230', '3351', '5017' ], [ '3803990', '-8447240', '3351', '5017' ], [ '3804010', '-8447270', '3351', '5017' ], [ '3804020', '-8447290', '3351', '5017' ], [ '3804020', '-8447120', '3351', '5017' ], [ '3804030', '-8447300', '3351', '5017' ], [ '3804030', '-8447150', '3351', '5017' ], [ '3804050', '-8447170', '3351', '5017' ], [ '3804070', '-8447350', '3351', '5017' ], [ '3804070', '-8447200', '3351', '5017' ], [ '3804079', '-8447210', '3351', '5017' ], [ '3804090', '-8447380', '3351', '5017' ], [ '3804090', '-8447230', '3351', '5017' ], [ '3804099', '-8447240', '3351', '5017' ], [ '3804110', '-8447250', '3351', '5017' ], [ '3804120', '-8447270', '3351', '5017' ], [ '3803940', '-8446680', '3352', '5017' ], [ '3803949', '-8446690', '3352', '5017' ], [ '3803949', '-8446680', '3352', '5017' ], [ '3803990', '-8446590', '3352', '5017' ], [ '3804030', '-8446790', '3352', '5017' ], [ '3804040', '-8446810', '3352', '5017' ], [ '3804040', '-8446530', '3352', '5017' ], [ '3804050', '-8446830', '3352', '5017' ], [ '3804050', '-8446820', '3352', '5017' ], [ '3804050', '-8446530', '3352', '5017' ], [ '3804060', '-8447020', '3352', '5017' ], [ '3804060', '-8446840', '3352', '5017' ], [ '3804070', '-8447040', '3352', '5017' ], [ '3804140', '-8446950', '3352', '5017' ], [ '3804140', '-8446940', '3352', '5017' ], [ '3804170', '-8446980', '3352', '5017' ], [ '3804190', '-8446630', '3352', '5017' ], [ '3803580', '-8446620', '3353', '5017' ], [ '3803640', '-8446550', '3353', '5017' ], [ '3803649', '-8446550', '3353', '5017' ], [ '3803690', '-8446130', '3353', '5017' ], [ '3803700', '-8446520', '3353', '5017' ], [ '3803700', '-8446140', '3353', '5017' ], [ '3803730', '-8446510', '3353', '5017' ], [ '3803790', '-8446500', '3353', '5017' ], [ '3803790', '-8446270', '3353', '5017' ], [ '3803810', '-8446290', '3353', '5017' ], [ '3803830', '-8446320', '3353', '5017' ], [ '3803840', '-8446490', '3353', '5017' ], [ '3803840', '-8446350', '3353', '5017' ], [ '3803850', '-8446360', '3353', '5017' ], [ '3803860', '-8446470', '3353', '5017' ], [ '3803860', '-8446370', '3353', '5017' ], [ '3803870', '-8446390', '3353', '5017' ], [ '3803880', '-8446440', '3353', '5017' ], [ '3803910', '-8446450', '3353', '5017' ], [ '3803929', '-8446490', '3353', '5017' ], [ '3803929', '-8446480', '3353', '5017' ], [ '3803940', '-8446370', '3353', '5017' ], [ '3803960', '-8446540', '3353', '5017' ], [ '3803990', '-8446320', '3353', '5017' ], [ '3804000', '-8446310', '3353', '5017' ], [ '3804010', '-8446300', '3353', '5017' ], [ '3804020', '-8446290', '3353', '5017' ], [ '3804030', '-8446650', '3353', '5017' ], [ '3804040', '-8446660', '3353', '5017' ], [ '3804079', '-8446600', '3353', '5017' ], [ '3804090', '-8446710', '3353', '5017' ], [ '3804090', '-8446570', '3353', '5017' ], [ '3804099', '-8446520', '3353', '5017' ], [ '3804110', '-8446490', '3353', '5017' ], [ '3804110', '-8446470', '3353', '5017' ], [ '3804120', '-8446450', '3353', '5017' ], [ '3805950', '-8450150', '3619', '5035' ], [ '3805980', '-8450170', '3619', '5035' ], [ '3805990', '-8450180', '3619', '5035' ], [ '3806000', '-8450200', '3619', '5035' ], [ '3806010', '-8450200', '3619', '5035' ], [ '3806199', '-8450160', '3619', '5035' ], [ '3806199', '-8450150', '3619', '5035' ], [ '3806120', '-8450150', '3623', '5035' ], [ '3806140', '-8450150', '3623', '5035' ], [ '3806170', '-8450170', '3623', '5035' ], [ '3806180', '-8450170', '3623', '5035' ], [ '3806210', '-8450180', '3623', '5035' ], [ '3806250', '-8450190', '3623', '5035' ], [ '3806280', '-8450150', '3623', '5035' ], [ '3806290', '-8450010', '3623', '5035' ], [ '3805230', '-8449050', '3639', '5036' ], [ '3805250', '-8449030', '3639', '5036' ], [ '3805270', '-8449010', '3639', '5036' ], [ '3805280', '-8448990', '3639', '5036' ], [ '3805280', '-8448890', '3639', '5036' ], [ '3805290', '-8448970', '3639', '5036' ], [ '3805290', '-8448900', '3639', '5036' ], [ '3805299', '-8448860', '3639', '5036' ], [ '3805330', '-8448950', '3639', '5036' ], [ '3805340', '-8448900', '3639', '5036' ], [ '3805360', '-8448880', '3639', '5036' ], [ '3805420', '-8449050', '3639', '5036' ], [ '3805420', '-8449040', '3639', '5036' ], [ '3805420', '-8449010', '3639', '5036' ], [ '3805420', '-8448790', '3639', '5036' ], [ '3805420', '-8448780', '3639', '5036' ], [ '3805430', '-8449060', '3639', '5036' ], [ '3805430', '-8449050', '3639', '5036' ], [ '3805430', '-8449000', '3639', '5036' ], [ '3805440', '-8448980', '3639', '5036' ], [ '3805490', '-8448910', '3639', '5036' ], [ '3805500', '-8448890', '3639', '5036' ], [ '3805500', '-8448760', '3639', '5036' ], [ '3805570', '-8448830', '3639', '5036' ], [ '3804580', '-8448850', '3640', '5036' ], [ '3804679', '-8448880', '3640', '5036' ], [ '3804710', '-8448980', '3640', '5036' ], [ '3804780', '-8449270', '3640', '5036' ], [ '3804820', '-8449310', '3640', '5036' ], [ '3804849', '-8449400', '3640', '5036' ], [ '3804860', '-8449350', '3640', '5036' ], [ '3804860', '-8449160', '3640', '5036' ], [ '3804860', '-8449150', '3640', '5036' ], [ '3804920', '-8449300', '3640', '5036' ], [ '3804950', '-8449260', '3640', '5036' ], [ '3804990', '-8449400', '3640', '5036' ], [ '3804999', '-8449310', '3640', '5036' ], [ '3805210', '-8449540', '3641', '5036' ], [ '3805280', '-8449170', '3641', '5036' ], [ '3805299', '-8449150', '3641', '5036' ], [ '3805360', '-8449060', '3641', '5036' ], [ '3805370', '-8449050', '3641', '5036' ], [ '3805370', '-8449040', '3641', '5036' ], [ '3805380', '-8449160', '3641', '5036' ], [ '3805390', '-8449280', '3641', '5036' ], [ '3805410', '-8449250', '3641', '5036' ], [ '3805410', '-8449120', '3641', '5036' ], [ '3805420', '-8449110', '3641', '5036' ], [ '3805430', '-8449230', '3641', '5036' ], [ '3805430', '-8449220', '3641', '5036' ], [ '3805520', '-8449100', '3641', '5036' ], [ '3805540', '-8449060', '3641', '5036' ], [ '3805560', '-8449040', '3641', '5036' ], [ '3805610', '-8448970', '3641', '5036' ], [ '3804740', '-8448660', '3642', '5036' ], [ '3804760', '-8448680', '3642', '5036' ], [ '3804800', '-8448720', '3642', '5036' ], [ '3804860', '-8448790', '3642', '5036' ], [ '3804869', '-8448810', '3642', '5036' ], [ '3804869', '-8448780', '3642', '5036' ], [ '3804880', '-8448770', '3642', '5036' ], [ '3804880', '-8448760', '3642', '5036' ], [ '3804890', '-8448750', '3642', '5036' ], [ '3804920', '-8448710', '3642', '5036' ], [ '3804930', '-8448690', '3642', '5036' ], [ '3804940', '-8448680', '3642', '5036' ], [ '3804960', '-8448660', '3642', '5036' ], [ '3804960', '-8448650', '3642', '5036' ], [ '3805030', '-8448980', '3642', '5036' ], [ '3804890', '-8448460', '3643', '5036' ], [ '3804920', '-8448490', '3643', '5036' ], [ '3804950', '-8448520', '3643', '5036' ], [ '3805050', '-8448930', '3643', '5036' ], [ '3805050', '-8448630', '3643', '5036' ], [ '3805060', '-8448920', '3643', '5036' ], [ '3805070', '-8448910', '3643', '5036' ], [ '3805070', '-8448900', '3643', '5036' ], [ '3805080', '-8448900', '3643', '5036' ], [ '3805110', '-8448850', '3643', '5036' ], [ '3805120', '-8448830', '3643', '5036' ], [ '3805130', '-8449010', '3643', '5036' ], [ '3805130', '-8449000', '3643', '5036' ], [ '3805130', '-8448720', '3643', '5036' ], [ '3805140', '-8449000', '3643', '5036' ], [ '3805160', '-8448970', '3643', '5036' ], [ '3805169', '-8448950', '3643', '5036' ], [ '3805200', '-8448910', '3643', '5036' ], [ '3805270', '-8448810', '3643', '5036' ], [ '3805299', '-8448770', '3643', '5036' ], [ '3805319', '-8448740', '3643', '5036' ], [ '3805360', '-8448680', '3643', '5036' ], [ '3804780', '-8448830', '3644', '5036' ], [ '3804800', '-8448800', '3644', '5036' ], [ '3804840', '-8448890', '3644', '5036' ], [ '3804869', '-8448930', '3644', '5036' ], [ '3804900', '-8448950', '3644', '5036' ], [ '3804920', '-8448920', '3644', '5036' ], [ '3804950', '-8448880', '3644', '5036' ], [ '3804970', '-8448860', '3644', '5036' ], [ '3804999', '-8448810', '3644', '5036' ], [ '3805010', '-8448800', '3644', '5036' ], [ '3805010', '-8448790', '3644', '5036' ], [ '3805030', '-8448770', '3644', '5036' ], [ '3805040', '-8448760', '3644', '5036' ], [ '3805040', '-8448750', '3644', '5036' ], [ '3805060', '-8449110', '3644', '5036' ], [ '3805060', '-8449100', '3644', '5036' ], [ '3805070', '-8449100', '3644', '5036' ], [ '3805100', '-8449050', '3644', '5036' ], [ '3805100', '-8449040', '3644', '5036' ], [ '3805120', '-8449020', '3644', '5036' ], [ '3805190', '-8449120', '3644', '5036' ], [ '3805190', '-8449110', '3644', '5036' ], [ '3805200', '-8449100', '3644', '5036' ], [ '3805210', '-8449090', '3644', '5036' ], [ '3805210', '-8449080', '3644', '5036' ], [ '3805220', '-8449070', '3644', '5036' ], [ '3805560', '-8447780', '3653', '5038' ], [ '3805599', '-8447820', '3653', '5038' ], [ '3805610', '-8447860', '3653', '5038' ], [ '3805630', '-8447960', '3653', '5038' ], [ '3805630', '-8447670', '3653', '5038' ], [ '3805670', '-8447710', '3653', '5038' ], [ '3805700', '-8447750', '3653', '5038' ], [ '3805710', '-8447660', '3653', '5038' ], [ '3805730', '-8447890', '3653', '5038' ], [ '3805730', '-8447780', '3653', '5038' ], [ '3805740', '-8447790', '3653', '5038' ], [ '3805760', '-8447810', '3653', '5038' ], [ '3805760', '-8447710', '3653', '5038' ], [ '3805780', '-8447960', '3653', '5038' ], [ '3805780', '-8447730', '3653', '5038' ], [ '3805800', '-8447970', '3653', '5038' ], [ '3805800', '-8447760', '3653', '5038' ], [ '3805810', '-8447870', '3653', '5038' ], [ '3805820', '-8447890', '3653', '5038' ], [ '3805430', '-8448590', '3654', '5038' ], [ '3805460', '-8448530', '3654', '5038' ], [ '3805469', '-8448720', '3654', '5038' ], [ '3805469', '-8448710', '3654', '5038' ], [ '3805480', '-8448710', '3654', '5038' ], [ '3805480', '-8448690', '3654', '5038' ], [ '3805480', '-8448510', '3654', '5038' ], [ '3805490', '-8448690', '3654', '5038' ], [ '3805500', '-8448670', '3654', '5038' ], [ '3805510', '-8448660', '3654', '5038' ], [ '3805530', '-8448630', '3654', '5038' ], [ '3805560', '-8448580', '3654', '5038' ], [ '3805580', '-8448560', '3654', '5038' ], [ '3805619', '-8448500', '3654', '5038' ], [ '3805630', '-8448480', '3654', '5038' ], [ '3805680', '-8449330', '3654', '5038' ], [ '3805680', '-8448590', '3654', '5038' ], [ '3805690', '-8449340', '3654', '5038' ], [ '3805710', '-8449250', '3654', '5038' ], [ '3805749', '-8449400', '3654', '5038' ], [ '3805760', '-8448670', '3654', '5038' ], [ '3805800', '-8449290', '3654', '5038' ], [ '3805789', '-8449460', '3655', '5038' ], [ '3805840', '-8449390', '3655', '5038' ], [ '3805860', '-8449350', '3655', '5038' ], [ '3805990', '-8449280', '3655', '5038' ], [ '3806000', '-8448880', '3655', '5038' ], [ '3806000', '-8448870', '3655', '5038' ], [ '3806010', '-8448870', '3655', '5038' ], [ '3806020', '-8448850', '3655', '5038' ], [ '3806030', '-8448840', '3655', '5038' ], [ '3806060', '-8449000', '3655', '5038' ], [ '3806069', '-8448980', '3655', '5038' ], [ '3806089', '-8448950', '3655', '5038' ], [ '3806280', '-8449330', '3655', '5038' ], [ '3805550', '-8447950', '3656', '5038' ], [ '3805560', '-8447960', '3656', '5038' ], [ '3805630', '-8448040', '3656', '5038' ], [ '3805680', '-8448550', '3656', '5038' ], [ '3805680', '-8447980', '3656', '5038' ], [ '3805700', '-8448000', '3656', '5038' ], [ '3805710', '-8448510', '3656', '5038' ], [ '3805730', '-8448480', '3656', '5038' ], [ '3805730', '-8448020', '3656', '5038' ], [ '3805740', '-8448460', '3656', '5038' ], [ '3805749', '-8448130', '3656', '5038' ], [ '3805749', '-8448040', '3656', '5038' ], [ '3805769', '-8448420', '3656', '5038' ], [ '3805769', '-8448050', '3656', '5038' ], [ '3805860', '-8448300', '3656', '5038' ], [ '3805870', '-8447950', '3656', '5038' ], [ '3805720', '-8448620', '3657', '5038' ], [ '3805749', '-8448580', '3657', '5038' ], [ '3805749', '-8448570', '3657', '5038' ], [ '3805760', '-8448560', '3657', '5038' ], [ '3805769', '-8448540', '3657', '5038' ], [ '3805789', '-8448700', '3657', '5038' ], [ '3805789', '-8448520', '3657', '5038' ], [ '3805840', '-8448450', '3657', '5038' ], [ '3805860', '-8448630', '3657', '5038' ], [ '3805870', '-8448640', '3657', '5038' ], [ '3805880', '-8448580', '3657', '5038' ], [ '3805910', '-8448560', '3657', '5038' ], [ '3805919', '-8448840', '3657', '5038' ], [ '3805919', '-8448570', '3657', '5038' ], [ '3805919', '-8448560', '3657', '5038' ], [ '3805960', '-8448890', '3657', '5038' ], [ '3805960', '-8448740', '3657', '5038' ], [ '3805970', '-8448900', '3657', '5038' ], [ '3805990', '-8448710', '3657', '5038' ], [ '3806000', '-8448690', '3657', '5038' ], [ '3806020', '-8448670', '3657', '5038' ], [ '3806140', '-8448190', '3657', '5038' ], [ '3806150', '-8448190', '3657', '5038' ], [ '3803779', '-8448410', '3704', '5041' ], [ '3803820', '-8448350', '3704', '5041' ], [ '3803840', '-8448330', '3704', '5041' ], [ '3803860', '-8448560', '3704', '5041' ], [ '3803880', '-8448540', '3704', '5041' ], [ '3803890', '-8448250', '3704', '5041' ], [ '3803900', '-8448520', '3704', '5041' ], [ '3803940', '-8448410', '3704', '5041' ], [ '3803940', '-8448400', '3704', '5041' ], [ '3803949', '-8448170', '3704', '5041' ], [ '3803980', '-8448510', '3704', '5041' ], [ '3803990', '-8448500', '3704', '5041' ], [ '3803990', '-8448490', '3704', '5041' ], [ '3803990', '-8448300', '3704', '5041' ], [ '3804000', '-8448480', '3704', '5041' ], [ '3804000', '-8448310', '3704', '5041' ], [ '3804000', '-8448300', '3704', '5041' ], [ '3804030', '-8448430', '3704', '5041' ], [ '3804040', '-8448350', '3704', '5041' ], [ '3804079', '-8448540', '3704', '5041' ], [ '3804079', '-8448530', '3704', '5041' ], [ '3804090', '-8448520', '3704', '5041' ], [ '3803320', '-8449110', '3705', '5041' ], [ '3803340', '-8449120', '3705', '5041' ], [ '3803609', '-8449180', '3705', '5041' ], [ '3803629', '-8449150', '3705', '5041' ], [ '3803649', '-8449110', '3705', '5041' ], [ '3803680', '-8449080', '3705', '5041' ], [ '3803690', '-8449060', '3705', '5041' ], [ '3803710', '-8449030', '3705', '5041' ], [ '3803720', '-8449220', '3705', '5041' ], [ '3803750', '-8449180', '3705', '5041' ], [ '3803759', '-8449170', '3705', '5041' ], [ '3803770', '-8449150', '3705', '5041' ], [ '3803790', '-8449120', '3705', '5041' ], [ '3803799', '-8449110', '3705', '5041' ], [ '3803799', '-8448900', '3705', '5041' ], [ '3803820', '-8449070', '3705', '5041' ], [ '3803830', '-8449070', '3705', '5041' ], [ '3803850', '-8449040', '3705', '5041' ], [ '3803860', '-8449020', '3706', '5041' ], [ '3803900', '-8448970', '3706', '5041' ], [ '3803910', '-8449200', '3706', '5041' ], [ '3803940', '-8449160', '3706', '5041' ], [ '3803940', '-8448910', '3706', '5041' ], [ '3803949', '-8448820', '3706', '5041' ], [ '3803960', '-8448810', '3706', '5041' ], [ '3803970', '-8448790', '3706', '5041' ], [ '3803990', '-8448760', '3706', '5041' ], [ '3804020', '-8448720', '3706', '5041' ], [ '3804030', '-8448700', '3706', '5041' ], [ '3804040', '-8448690', '3706', '5041' ], [ '3804099', '-8448810', '3706', '5041' ], [ '3804099', '-8448790', '3706', '5041' ], [ '3804099', '-8448780', '3706', '5041' ], [ '3804099', '-8448760', '3706', '5041' ], [ '3804099', '-8448750', '3706', '5041' ], [ '3803450', '-8448780', '3707', '5041' ], [ '3803470', '-8448760', '3707', '5041' ], [ '3803499', '-8448720', '3707', '5041' ], [ '3803570', '-8448780', '3707', '5041' ], [ '3803580', '-8448800', '3707', '5041' ], [ '3803580', '-8448790', '3707', '5041' ], [ '3803580', '-8448600', '3707', '5041' ], [ '3803600', '-8448810', '3707', '5041' ], [ '3803609', '-8448830', '3707', '5041' ], [ '3803649', '-8448710', '3707', '5041' ], [ '3803649', '-8448700', '3707', '5041' ], [ '3803660', '-8448890', '3707', '5041' ], [ '3803670', '-8448670', '3707', '5041' ], [ '3803799', '-8448970', '3707', '5041' ], [ '3803799', '-8448590', '3707', '5041' ], [ '3803810', '-8448600', '3707', '5041' ], [ '3803820', '-8449000', '3707', '5041' ], [ '3803910', '-8448700', '3707', '5041' ], [ '3803920', '-8448710', '3707', '5041' ], [ '3803620', '-8448950', '3708', '5041' ], [ '3803629', '-8448940', '3708', '5041' ], [ '3803700', '-8448840', '3708', '5041' ], [ '3803700', '-8448830', '3708', '5041' ], [ '3803720', '-8448810', '3708', '5041' ], [ '3803720', '-8448800', '3708', '5041' ], [ '3803720', '-8448660', '3708', '5041' ], [ '3803779', '-8448730', '3708', '5041' ], [ '3803860', '-8448820', '3708', '5041' ], [ '3803900', '-8448860', '3708', '5041' ], [ '3803920', '-8448680', '3708', '5041' ] ); Math-Geometry-Voronoi-1.3/t/00basic.t0000644000076400007640000000447011226155444015504 0ustar samsamuse strict; use warnings; use Test::More qw(no_plan); BEGIN { use_ok('Math::Geometry::Voronoi') or die } use Scalar::Util qw(looks_like_number); eval { my $geo = Math::Geometry::Voronoi->new() }; like($@, qr/mandatory parameter/i); my @points = ( [ 1, 2 ], [ 1, 3 ], [ 2, 2 ], [ 0, 1 ], [ 0, 10 ], [ 0.5, 11 ] ); my $geo = Math::Geometry::Voronoi->new(points => \@points); # check sorting is($geo->xmin, 0); is($geo->xmax, 2); is($geo->ymin, 1); is($geo->ymax, 11); is_deeply($geo->points, [[ 0, 1 ], [ 1, 2 ], [ 2, 2 ], [ 1, 3 ], [ 0, 10 ], [ 0.5, 11 ]] ); eval { $geo->compute() }; ok(!$@); isa_ok($geo->lines, 'ARRAY'); isa_ok($geo->edges, 'ARRAY'); isa_ok($geo->vertices, 'ARRAY'); foreach my $line (@{$geo->lines}) { is(@$line, 5); my ($a, $b, $c, $p1, $p2) = @$line; # p1 and p2 are indexes into points[] or -1 for infinite like($p1, qr/^-?\d+$/); like($p2, qr/^-?\d+$/); cmp_ok($p1, '>=', -1); cmp_ok($p1, '<', @points); cmp_ok($p2, '>=', -1); cmp_ok($p2, '<', @points); # a, b and c are floats ok(looks_like_number($a)); ok(looks_like_number($b)); ok(looks_like_number($c)); } foreach my $edge (@{$geo->edges}) { is(@$edge, 3); my ($l, $v1, $v2) = @$edge; # l is a line index like($l, qr/^-?\d+$/); cmp_ok($l, '>=', 0); cmp_ok($l, '<', @{$geo->lines}); # v1 and v2 are vertex indecies, or -1 for infinite like($v1, qr/^-?\d+$/); cmp_ok($v1, '>=', -1); cmp_ok($v1, '<', @{$geo->vertices}); like($v2, qr/^-?\d+$/); cmp_ok($v2, '>=', -1); cmp_ok($v2, '<', @{$geo->vertices}); } foreach my $vertex (@{$geo->vertices}) { is(@$vertex, 2); my ($x, $y) = @$vertex; # x and y are points on the map - should be numbers ok(looks_like_number($x)); ok(looks_like_number($y)); } # try computing some polygons my @polygons = $geo->polygons; ok(@polygons); foreach my $poly (@polygons) { my ($p, @verts) = @$poly; # p is a point index like($p, qr/^-?\d+$/); cmp_ok($p, '>=', 0); cmp_ok($p, '<', @points); # the rest are graph points foreach my $vert (@verts) { ok(looks_like_number($vert->[0])); ok(looks_like_number($vert->[1])); } } Math-Geometry-Voronoi-1.3/output.c0000755000076400007640000001450611226155444015343 0ustar samsam /*** OUTPUT.C ***/ #include #include "vdefs.h" extern int triangulate, plot, debug ; extern double ymax, ymin, xmax, xmin ; extern AV *lines_out, *edges_out, *vertices_out; double pxmin, pxmax, pymin, pymax, cradius; void openpl(void) { } #pragma argsused void line(double ax, double ay, double bx, double by) { } #pragma argsused void circle(double ax, double ay, double radius) { } #pragma argsused void range(double pxmin, double pxmax, double pymin, double pymax) { } void out_bisector(Edge * e) { if (triangulate && plot && !debug) { line(e->reg[0]->coord.x, e->reg[0]->coord.y, e->reg[1]->coord.x, e->reg[1]->coord.y) ; } if (!triangulate && !plot && !debug) { // fprintf(stderr, "l %f %f %f %d %d\n", e->a, e->b, e->c, e->reg[le]->sitenbr, e->reg[re]->sitenbr) ; SV *vals[5]; vals[0] = newSVnv(e->a); vals[1] = newSVnv(e->b); vals[2] = newSVnv(e->c); vals[3] = newSViv(e->reg[le]->sitenbr); vals[4] = newSViv(e->reg[re]->sitenbr); av_push(lines_out, newRV_noinc((SV*) av_make(5, vals))); sv_free(vals[0]); sv_free(vals[1]); sv_free(vals[2]); sv_free(vals[3]); sv_free(vals[4]); } if (debug) { printf("line(%d) %gx+%gy=%g, bisecting %d %d\n", e->edgenbr, e->a, e->b, e->c, e->reg[le]->sitenbr, e->reg[re]->sitenbr) ; } } void out_ep(Edge * e) { if (!triangulate && plot) { clip_line(e) ; } if (!triangulate && !plot) { //printf("e %d", e->edgenbr); //printf(" %d ", e->ep[le] != (Site *)NULL ? e->ep[le]->sitenbr : -1) ; //printf("%d\n", e->ep[re] != (Site *)NULL ? e->ep[re]->sitenbr : -1) ; SV *vals[3]; vals[0] = newSViv(e->edgenbr); vals[1] = newSViv(e->ep[le] != (Site *)NULL ? e->ep[le]->sitenbr : -1); vals[2] = newSViv(e->ep[re] != (Site *)NULL ? e->ep[re]->sitenbr : -1); av_push(edges_out, newRV_noinc((SV*) av_make(3, vals))); sv_free(vals[0]); sv_free(vals[1]); sv_free(vals[2]); } } void out_vertex(Site * v) { if (!triangulate && !plot && !debug) { //printf ("v %f %f\n", v->coord.x, v->coord.y) ; SV *vals[2]; vals[0] = newSVnv(v->coord.x); vals[1] = newSVnv(v->coord.y); av_push(vertices_out, newRV_noinc((SV*)av_make(2, vals))); sv_free(vals[0]); sv_free(vals[1]); } if (debug) { printf("vertex(%d) at %f %f\n", v->sitenbr, v->coord.x, v->coord.y) ; } } void out_site(Site * s) { if (!triangulate && plot && !debug) { circle (s->coord.x, s->coord.y, cradius) ; } if (!triangulate && !plot && !debug) { // fprintf(stderr, "s %f %f\n", s->coord.x, s->coord.y) ; } if (debug) { printf("site (%d) at %f %f\n", s->sitenbr, s->coord.x, s->coord.y) ; } } void out_triple(Site * s1, Site * s2, Site * s3) { if (triangulate && !plot && !debug) { printf("%d %d %d\n", s1->sitenbr, s2->sitenbr, s3->sitenbr) ; } if (debug) { printf("circle through left=%d right=%d bottom=%d\n", s1->sitenbr, s2->sitenbr, s3->sitenbr) ; } } void plotinit(void) { double dx, dy, d ; dy = ymax - ymin ; dx = xmax - xmin ; d = ( dx > dy ? dx : dy) * 1.1 ; pxmin = xmin - (d-dx) / 2.0 ; pxmax = xmax + (d-dx) / 2.0 ; pymin = ymin - (d-dy) / 2.0 ; pymax = ymax + (d-dy) / 2.0 ; cradius = (pxmax - pxmin) / 350.0 ; openpl() ; range(pxmin, pymin, pxmax, pymax) ; } void clip_line(Edge * e) { Site * s1, * s2 ; double x1, x2, y1, y2 ; if (e->a == 1.0 && e->b >= 0.0) { s1 = e->ep[1] ; s2 = e->ep[0] ; } else { s1 = e->ep[0] ; s2 = e->ep[1] ; } if (e->a == 1.0) { y1 = pymin ; if (s1 != (Site *)NULL && s1->coord.y > pymin) { y1 = s1->coord.y ; } if (y1 > pymax) { return ; } x1 = e->c - e->b * y1 ; y2 = pymax ; if (s2 != (Site *)NULL && s2->coord.y < pymax) { y2 = s2->coord.y ; } if (y2 < pymin) { return ; } x2 = e->c - e->b * y2 ; if (((x1 > pxmax) && (x2 > pxmax)) || ((x1 < pxmin) && (x2 < pxmin))) { return ; } if (x1 > pxmax) { x1 = pxmax ; y1 = (e->c - x1) / e->b ; } if (x1 < pxmin) { x1 = pxmin ; y1 = (e->c - x1) / e->b ; } if (x2 > pxmax) { x2 = pxmax ; y2 = (e->c - x2) / e->b ; } if (x2 < pxmin) { x2 = pxmin ; y2 = (e->c - x2) / e->b ; } } else { x1 = pxmin ; if (s1 != (Site *)NULL && s1->coord.x > pxmin) { x1 = s1->coord.x ; } if (x1 > pxmax) { return ; } y1 = e->c - e->a * x1 ; x2 = pxmax ; if (s2 != (Site *)NULL && s2->coord.x < pxmax) { x2 = s2->coord.x ; } if (x2 < pxmin) { return ; } y2 = e->c - e->a * x2 ; if (((y1 > pymax) && (y2 > pymax)) || ((y1 < pymin) && (y2 pymax) { y1 = pymax ; x1 = (e->c - y1) / e->a ; } if (y1 < pymin) { y1 = pymin ; x1 = (e->c - y1) / e->a ; } if (y2 > pymax) { y2 = pymax ; x2 = (e->c - y2) / e->a ; } if (y2 < pymin) { y2 = pymin ; x2 = (e->c - y2) / e->a ; } } line(x1,y1,x2,y2); } Math-Geometry-Voronoi-1.3/geometry.c0000755000076400007640000001167111226155444015636 0ustar samsam /*** GEOMETRY.C ***/ #include #include "vdefs.h" double deltax, deltay ; int nedges, sqrt_nsites, nvertices ; Freelist efl ; void geominit(void) { freeinit(&efl, sizeof(Edge)) ; nvertices = nedges = 0 ; sqrt_nsites = sqrt(nsites+4) ; deltay = ymax - ymin ; deltax = xmax - xmin ; } Edge * bisect(Site * s1, Site * s2) { double dx, dy, adx, ady ; Edge * newedge ; newedge = (Edge *)getfree(&efl) ; newedge->reg[0] = s1 ; newedge->reg[1] = s2 ; ref(s1) ; ref(s2) ; newedge->ep[0] = newedge->ep[1] = (Site *)NULL ; dx = s2->coord.x - s1->coord.x ; dy = s2->coord.y - s1->coord.y ; adx = dx>0 ? dx : -dx ; ady = dy>0 ? dy : -dy ; newedge->c = s1->coord.x * dx + s1->coord.y * dy + (dx*dx + dy*dy) * 0.5 ; if (adx > ady) { newedge->a = 1.0 ; newedge->b = dy/dx ; newedge->c /= dx ; } else { newedge->b = 1.0 ; newedge->a = dx/dy ; newedge->c /= dy ; } newedge->edgenbr = nedges ; out_bisector(newedge) ; nedges++ ; return (newedge) ; } Site * intersect(Halfedge * el1, Halfedge * el2) { Edge * e1, * e2, * e ; Halfedge * el ; double d, xint, yint ; int right_of_site ; Site * v ; e1 = el1->ELedge ; e2 = el2->ELedge ; if ((e1 == (Edge*)NULL) || (e2 == (Edge*)NULL)) { return ((Site *)NULL) ; } if (e1->reg[1] == e2->reg[1]) { return ((Site *)NULL) ; } d = (e1->a * e2->b) - (e1->b * e2->a) ; if ((-1.0e-10 < d) && (d < 1.0e-10)) { return ((Site *)NULL) ; } xint = (e1->c * e2->b - e2->c * e1->b) / d ; yint = (e2->c * e1->a - e1->c * e2->a) / d ; if ((e1->reg[1]->coord.y < e2->reg[1]->coord.y) || (e1->reg[1]->coord.y == e2->reg[1]->coord.y && e1->reg[1]->coord.x < e2->reg[1]->coord.x)) { el = el1 ; e = e1 ; } else { el = el2 ; e = e2 ; } right_of_site = (xint >= e->reg[1]->coord.x) ; if ((right_of_site && (el->ELpm == le)) || (!right_of_site && (el->ELpm == re))) { return ((Site *)NULL) ; } v = (Site *)getfree(&sfl) ; v->refcnt = 0 ; v->coord.x = xint ; v->coord.y = yint ; return (v) ; } /*** returns 1 if p is to right of halfedge e ***/ int right_of(Halfedge * el, Point * p) { Edge * e ; Site * topsite ; int right_of_site, above, fast ; double dxp, dyp, dxs, t1, t2, t3, yl ; e = el->ELedge ; topsite = e->reg[1] ; right_of_site = (p->x > topsite->coord.x) ; if (right_of_site && (el->ELpm == le)) { return (1) ; } if(!right_of_site && (el->ELpm == re)) { return (0) ; } if (e->a == 1.0) { dyp = p->y - topsite->coord.y ; dxp = p->x - topsite->coord.x ; fast = 0 ; if ((!right_of_site & (e->b < 0.0)) || (right_of_site & (e->b >= 0.0))) { fast = above = (dyp >= e->b*dxp) ; } else { above = ((p->x + p->y * e->b) > (e->c)) ; if (e->b < 0.0) { above = !above ; } if (!above) { fast = 1 ; } } if (!fast) { dxs = topsite->coord.x - (e->reg[0])->coord.x ; above = (e->b * (dxp*dxp - dyp*dyp)) < (dxs * dyp * (1.0 + 2.0 * dxp / dxs + e->b * e->b)) ; if (e->b < 0.0) { above = !above ; } } } else /*** e->b == 1.0 ***/ { yl = e->c - e->a * p->x ; t1 = p->y - yl ; t2 = p->x - topsite->coord.x ; t3 = yl - topsite->coord.y ; above = ((t1*t1) > ((t2 * t2) + (t3 * t3))) ; } return (el->ELpm == le ? above : !above) ; } void endpoint(Edge * e, int lr, Site * s) { e->ep[lr] = s ; ref(s) ; if (e->ep[re-lr] == (Site *)NULL) { return ; } out_ep(e) ; deref(e->reg[le]) ; deref(e->reg[re]) ; makefree((Freenode *)e, (Freelist *) &efl) ; } double dist(Site * s, Site * t) { double dx,dy ; dx = s->coord.x - t->coord.x ; dy = s->coord.y - t->coord.y ; return (sqrt(dx*dx + dy*dy)) ; } void makevertex(Site * v) { v->sitenbr = nvertices++ ; out_vertex(v) ; } void deref(Site * v) { if (--(v->refcnt) == 0 ) { makefree((Freenode *)v, (Freelist *)&sfl) ; } } void ref(Site * v) { ++(v->refcnt) ; } Math-Geometry-Voronoi-1.3/memory.c0000755000076400007640000000326611226155444015314 0ustar samsam /*** MEMORY.C ***/ #include #include /* malloc(), exit() */ #include "vdefs.h" extern int sqrt_nsites, siteidx ; char** memory_map; int nallocs = 0; void freeinit(Freelist * fl, int size) { fl->head = (Freenode *)NULL ; fl->nodesize = size ; } char * getfree(Freelist * fl) { int i ; Freenode * t ; if (fl->head == (Freenode *)NULL) { t = (Freenode *) myalloc(sqrt_nsites * fl->nodesize) ; for(i = 0 ; i < sqrt_nsites ; i++) { makefree((Freenode *)((char *)t+i*fl->nodesize), fl) ; } } t = fl->head ; fl->head = (fl->head)->nextfree ; return ((char *)t) ; } void makefree(Freenode * curr, Freelist * fl) { curr->nextfree = fl->head ; fl->head = curr ; } int total_alloc; char * myalloc(unsigned n) { char * t ; if ((t=(char*)malloc(n)) == (char *) 0) { fprintf(stderr,"Insufficient memory processing site %d (%d bytes in use, asked for %u)\n", siteidx, total_alloc, n) ; exit(0) ; } total_alloc += n ; if (nallocs % 1000 == 0) { if (nallocs == 0) { Newz(0, memory_map, (nallocs+1000), char*); } else { Renew(memory_map, (nallocs+1000), char*); Zero( memory_map+nallocs, 1000, char*); } total_alloc += (1000 * sizeof(void *)); } memory_map[nallocs++] = t; return (t) ; } void free_all(void) { int i; for (i=0; inew(points => \@points); my $result = $geo->compute(); #use Devel::Size qw(size total_size); #print "OBJ SIZE: " . total_size($geo); #print "RESULT SIZE: " . total_size($result); #print "DATA SIZE: " . total_size(\@points); print "."; } Math-Geometry-Voronoi-1.3/README0000644000076400007640000000230411226155444014505 0ustar samsamMath::Geometry::Voronoi ======================= This module computes Voronoi diagrams from a set of input points. Info on Voronoi diagrams can be found here: http://en.wikipedia.org/wiki/Voronoi_diagram This module is a wrapper around a C implementation found here: http://www.derekbradley.ca/voronoi.html Which is itself a modification of code by Steve Fortune, the inventor of the algorithm used (Fortune's algorithm): http://cm.bell-labs.com/who/sjf/ INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: Params::Validate Scalar::Util List::Util AUTHOR Sam Tregar COPYRIGHT AND LICENSE As far as I can tell the underlying C code used here never had a license attached to it, or if it did I couldn't find any trace of it. If this worries you please contact Steve and Derek through the links above. The Perl and XS code in this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available. Math-Geometry-Voronoi-1.3/META.yml0000664000076400007640000000073111226157602015100 0ustar samsam# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Math-Geometry-Voronoi version: 1.3 version_from: lib/Math/Geometry/Voronoi.pm installdirs: site requires: Class::Accessor: 0 List::Util: 0 Params::Validate: 0 Scalar::Util: 0 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.30 Math-Geometry-Voronoi-1.3/voronoi_core.c0000755000076400007640000000665311226155444016512 0ustar samsam /*** VORONOI.C ***/ #include "vdefs.h" extern Site * bottomsite ; extern Halfedge * ELleftend, * ELrightend ; /*** implicit parameters: nsites, sqrt_nsites, xmin, xmax, ymin, ymax, : deltax, deltay (can all be estimates). : Performance suffers if they are wrong; better to make nsites, : deltax, and deltay too big than too small. (?) ***/ void voronoi(Site *(*nextsite)(void)) { Site * newsite, * bot, * top, * temp, * p, * v ; Point newintstar ; int pm ; Halfedge * lbnd, * rbnd, * llbnd, * rrbnd, * bisector ; Edge * e ; PQinitialize() ; bottomsite = (*nextsite)() ; out_site(bottomsite) ; ELinitialize() ; newsite = (*nextsite)() ; while (1) { if(!PQempty()) { newintstar = PQ_min() ; } if (newsite != (Site *)NULL && (PQempty() || newsite -> coord.y < newintstar.y || (newsite->coord.y == newintstar.y && newsite->coord.x < newintstar.x))) {/* new site is smallest */ { out_site(newsite) ; } lbnd = ELleftbnd(&(newsite->coord)) ; rbnd = ELright(lbnd) ; bot = rightreg(lbnd) ; e = bisect(bot, newsite) ; bisector = HEcreate(e, le) ; ELinsert(lbnd, bisector) ; p = intersect(lbnd, bisector) ; if (p != (Site *)NULL) { PQdelete(lbnd) ; PQinsert(lbnd, p, dist(p,newsite)) ; } lbnd = bisector ; bisector = HEcreate(e, re) ; ELinsert(lbnd, bisector) ; p = intersect(bisector, rbnd) ; if (p != (Site *)NULL) { PQinsert(bisector, p, dist(p,newsite)) ; } newsite = (*nextsite)() ; } else if (!PQempty()) /* intersection is smallest */ { lbnd = PQextractmin() ; llbnd = ELleft(lbnd) ; rbnd = ELright(lbnd) ; rrbnd = ELright(rbnd) ; bot = leftreg(lbnd) ; top = rightreg(rbnd) ; out_triple(bot, top, rightreg(lbnd)) ; v = lbnd->vertex ; makevertex(v) ; endpoint(lbnd->ELedge, lbnd->ELpm, v); endpoint(rbnd->ELedge, rbnd->ELpm, v) ; ELdelete(lbnd) ; PQdelete(rbnd) ; ELdelete(rbnd) ; pm = le ; if (bot->coord.y > top->coord.y) { temp = bot ; bot = top ; top = temp ; pm = re ; } e = bisect(bot, top) ; bisector = HEcreate(e, pm) ; ELinsert(llbnd, bisector) ; endpoint(e, re-pm, v) ; deref(v) ; p = intersect(llbnd, bisector) ; if (p != (Site *) NULL) { PQdelete(llbnd) ; PQinsert(llbnd, p, dist(p,bot)) ; } p = intersect(bisector, rrbnd) ; if (p != (Site *) NULL) { PQinsert(bisector, p, dist(p,bot)) ; } } else { break ; } } for( lbnd = ELright(ELleftend) ; lbnd != ELrightend ; lbnd = ELright(lbnd)) { e = lbnd->ELedge ; out_ep(e) ; } } Math-Geometry-Voronoi-1.3/voronoi_main.c0000755000076400007640000000260311226155444016475 0ustar samsam/*** MAIN.C ***/ #include #include /* realloc(), qsort() */ #include "vdefs.h" Site * readone(void), * nextone(void) ; void readsites(void) ; int sorted, triangulate, plot, debug, nsites, siteidx ; double xmin, xmax, ymin, ymax ; Site * sites ; Freelist sfl ; AV *lines_out, *edges_out, *vertices_out; int compute_voronoi(Site *sites_in, int nsites_in, double xmin_in, double xmax_in, double ymin_in, double ymax_in, int debug_in, AV *lines_out_in, AV *edges_out_in, AV *vertices_out_in) { int c ; Site *(*next)() ; freeinit(&sfl, sizeof(Site)) ; sorted = triangulate = plot = debug = 0 ; debug = debug_in; lines_out = lines_out_in; edges_out = edges_out_in; vertices_out = vertices_out_in; nsites = nsites_in; sites = sites_in; xmin = xmin_in; xmax = xmax_in; ymin = ymin_in; ymax = ymax_in; next = nextone; siteidx = 0 ; geominit() ; if (plot) { plotinit() ; } voronoi(next) ; free_all(); return (0) ; } /*** return a single in-storage site ***/ Site * nextone(void) { Site * s ; if (siteidx < nsites) { s = &sites[siteidx++]; return (s) ; } else { return ((Site *)NULL) ; } } Math-Geometry-Voronoi-1.3/Voronoi.xs0000644000076400007640000000375411226155444015646 0ustar samsam#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include "vdefs.h" MODULE = Math::Geometry::Voronoi PACKAGE = Math::Geometry::Voronoi SV * compute_voronoi_xs(points_ref, xmin, xmax, ymin, ymax) SV *points_ref double xmin double xmax double ymin double ymax PREINIT: Site *sites; SV *ref, *sv, *sv_x, *sv_y; AV *av; AV *points; I32 i; int debug = 0; I32 num_points; SV **svp; AV *lines, *edges, *vertices; HV *result; CODE: { points = (AV *) SvRV(points_ref); num_points = av_len(points) + 1; // translate points AV into Sites array for use by voronoi C code sites = (Site *) myalloc(num_points * sizeof(Site)); for (i = 0; i < num_points; i++) { svp = av_fetch(points, i, 0); if (!svp) croak("Failed to fetch points[%d]!", i); ref = *svp; if (!SvROK(ref)) croak("Points array must be an array of arrays!"); sv = SvRV(ref); if (SvTYPE(sv) != SVt_PVAV) croak("Points array must be an array of arrays!"); av = (AV *) sv; if (av_len(av) < 1) croak("Points array must be an array of arrays with 2 values not %d!", av_len(av)); svp = av_fetch(av, 0, 0); if (!svp) croak("Failed to fetch points[%d][0]!", i); sv_x = *svp; svp = av_fetch(av, 1, 0); if (!svp) croak("Failed to fetch points[%d][1]!", i); sv_y = *svp; sites[i].coord.x = SvNV(sv_x); sites[i].coord.y = SvNV(sv_y); sites[i].sitenbr = i; sites[i].refcnt = 0 ; } // setup arrays to hold results lines = newAV(); edges = newAV(); vertices = newAV(); compute_voronoi(sites, num_points, xmin, xmax, ymin, ymax, debug, lines, edges, vertices); result = newHV(); hv_store(result, "lines", strlen("lines"), newRV_noinc((SV*) lines), 0); hv_store(result, "edges", strlen("edges"), newRV_noinc((SV*) edges), 0); hv_store(result, "vertices", strlen("vertices"), newRV_noinc((SV*) vertices), 0); } RETVAL = newRV_noinc((SV*) result); OUTPUT: RETVAL Math-Geometry-Voronoi-1.3/examples/0000755000076400007640000000000011226157602015442 5ustar samsamMath-Geometry-Voronoi-1.3/examples/voronoi.cgi0000755000076400007640000000572511226156672017643 0ustar samsam#!/usr/bin/perl -w use strict; # A simple CGI which runs a random set of points through the module # and displays the resulting polygons using the tag supported # by recent versions of Firefox and Safari. You can run it as a CGI # or from the command line like: # # perl ./voronoi.cgi > foo.html use Math::Geometry::Voronoi; use HTML::Template; use CGI qw/header/; my $text = do { local $/; }; my $template = HTML::Template->new(scalarref => \$text, die_on_bad_params => 0, loop_context_vars => 1); my $cgi = CGI->new(); my $n = $cgi->param('n') || 1000; $template->param(n => $n); die "What are you trying to do to me?" if $n > 5000; my $xsize = $cgi->param('xsize') || 1000; $template->param(xsize => $xsize); my $ysize = $cgi->param('ysize') || 500; $template->param(ysize => $ysize); my @points = map { [int(rand($xsize)), int(rand($ysize))] } (0 .. $n - 1); my %seen; @points = grep { not $seen{$_->[0], $_->[1]}++ } @points; my $geo = Math::Geometry::Voronoi->new(points => \@points); $geo->compute; my @polygons = $geo->polygons(normalize_vertices => sub { int($_[0]) }); my @poly; foreach my $poly ($geo->polygons) { my ($p, @verts) = @$poly; next if grep { $_->[0] > $xsize + 100 } @verts; next if grep { $_->[1] > $ysize + 100 } @verts; next if grep { $_->[0] < -100 } @verts; next if grep { $_->[1] < -100 } @verts; push @poly, { points => [ map { {x => int($_->[0]), y => int($_->[1])} } (@verts, $verts[0]) ], color => rand_color()}; } $template->param(polygons => \@poly); print header(), $template->output; sub rand_color { return join(',', map int(rand(255)), (1 .. 3)); } __DATA__ Math::Geometry::Voronoi Demo

Math::Geometry::Voronoi Demo

This is a demo of the Math::Geometry::Voronoi Perl module. To learn more, read the fine manual.

The image below shows a diagram containing random points. Only the complete polygons returned from the polygons() method are shown, which is why nothing is drawn around the edges. If you don't see anything please try again with Firefox - your browser may not support the new HTML <canvas> tag.

Math-Geometry-Voronoi-1.3/ppport.h0000644000076400007640000007211511226155444015331 0ustar samsam /* ppport.h -- Perl/Pollution/Portability Version 2.011 * * Automatically Created by Devel::PPPort on Tue Jun 10 09:44:46 2008 * * Do NOT edit this file directly! -- Edit PPPort.pm instead. * * Version 2.x, Copyright (C) 2001, Paul Marquess. * Version 1.x, Copyright (C) 1999, Kenneth Albanowski. * This code may be used and distributed under the same license as any * version of Perl. * * This version of ppport.h is designed to support operation with Perl * installations back to 5.004, and has been tested up to 5.8.1. * * If this version of ppport.h is failing during the compilation of this * module, please check if a newer version of Devel::PPPort is available * on CPAN before sending a bug report. * * If you are using the latest version of Devel::PPPort and it is failing * during compilation of this module, please send a report to perlbug@perl.com * * Include all following information: * * 1. The complete output from running "perl -V" * * 2. This file. * * 3. The name & version of the module you were trying to build. * * 4. A full log of the build that failed. * * 5. Any other information that you think could be relevant. * * * For the latest version of this code, please retreive the Devel::PPPort * module from CPAN. * */ /* * In order for a Perl extension module to be as portable as possible * across differing versions of Perl itself, certain steps need to be taken. * Including this header is the first major one, then using dTHR is all the * appropriate places and using a PL_ prefix to refer to global Perl * variables is the second. * */ /* If you use one of a few functions that were not present in earlier * versions of Perl, please add a define before the inclusion of ppport.h * for a static include, or use the GLOBAL request in a single module to * produce a global definition that can be referenced from the other * modules. * * Function: Static define: Extern define: * newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL * */ /* To verify whether ppport.h is needed for your module, and whether any * special defines should be used, ppport.h can be run through Perl to check * your source code. Simply say: * * perl -x ppport.h *.c *.h *.xs foo/bar*.c [etc] * * The result will be a list of patches suggesting changes that should at * least be acceptable, if not necessarily the most efficient solution, or a * fix for all possible problems. It won't catch where dTHR is needed, and * doesn't attempt to account for global macro or function definitions, * nested includes, typemaps, etc. * * In order to test for the need of dTHR, please try your module under a * recent version of Perl that has threading compiled-in. * */ /* #!/usr/bin/perl @ARGV = ("*.xs") if !@ARGV; %badmacros = %funcs = %macros = (); $replace = 0; foreach () { $funcs{$1} = 1 if /Provide:\s+(\S+)/; $macros{$1} = 1 if /^#\s*define\s+([a-zA-Z0-9_]+)/; $replace = $1 if /Replace:\s+(\d+)/; $badmacros{$2}=$1 if $replace and /^#\s*define\s+([a-zA-Z0-9_]+).*?\s+([a-zA-Z0-9_]+)/; $badmacros{$1}=$2 if /Replace (\S+) with (\S+)/; } foreach $filename (map(glob($_),@ARGV)) { unless (open(IN, "<$filename")) { warn "Unable to read from $file: $!\n"; next; } print "Scanning $filename...\n"; $c = ""; while () { $c .= $_; } close(IN); $need_include = 0; %add_func = (); $changes = 0; $has_include = ($c =~ /#.*include.*ppport/m); foreach $func (keys %funcs) { if ($c =~ /#.*define.*\bNEED_$func(_GLOBAL)?\b/m) { if ($c !~ /\b$func\b/m) { print "If $func isn't needed, you don't need to request it.\n" if $changes += ($c =~ s/^.*#.*define.*\bNEED_$func\b.*\n//m); } else { print "Uses $func\n"; $need_include = 1; } } else { if ($c =~ /\b$func\b/m) { $add_func{$func} =1 ; print "Uses $func\n"; $need_include = 1; } } } if (not $need_include) { foreach $macro (keys %macros) { if ($c =~ /\b$macro\b/m) { print "Uses $macro\n"; $need_include = 1; } } } foreach $badmacro (keys %badmacros) { if ($c =~ /\b$badmacro\b/m) { $changes += ($c =~ s/\b$badmacro\b/$badmacros{$badmacro}/gm); print "Uses $badmacros{$badmacro} (instead of $badmacro)\n"; $need_include = 1; } } if (scalar(keys %add_func) or $need_include != $has_include) { if (!$has_include) { $inc = join('',map("#define NEED_$_\n", sort keys %add_func)). "#include \"ppport.h\"\n"; $c = "$inc$c" unless $c =~ s/#.*include.*XSUB.*\n/$&$inc/m; } elsif (keys %add_func) { $inc = join('',map("#define NEED_$_\n", sort keys %add_func)); $c = "$inc$c" unless $c =~ s/^.*#.*include.*ppport.*$/$inc$&/m; } if (!$need_include) { print "Doesn't seem to need ppport.h.\n"; $c =~ s/^.*#.*include.*ppport.*\n//m; } $changes++; } if ($changes) { open(OUT,">ppport.h.$$"); print OUT $c; close(OUT); open(DIFF, "diff -u $filename ppport.h.$$|"); while () { s!ppport\.h\.$$!$filename.patched!; print STDOUT; } close(DIFF); unlink("ppport.h.$$"); } else { print "Looks OK\n"; } } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef PERL_REVISION # ifndef __PATCHLEVEL_H_INCLUDED__ # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) /* Replace: 1 */ # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION /* Replace PERL_PATCHLEVEL with PERL_VERSION */ /* Replace: 0 */ # endif #endif #define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION) /* It is very unlikely that anyone will try to use this with Perl 6 (or greater), but who knows. */ #if PERL_REVISION != 5 # error ppport.h only works with Perl version 5 #endif /* PERL_REVISION != 5 */ #ifndef ERRSV # define ERRSV perl_get_sv("@",FALSE) #endif #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5)) /* Replace: 1 */ # define PL_Sv Sv # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_defgv defgv # define PL_dirty dirty # define PL_dowarn dowarn # define PL_hints hints # define PL_na na # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfpv rsfp # define PL_stdingv stdingv # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes /* Replace: 0 */ #endif #ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif #else # define PERL_UNUSED_DECL #endif #ifndef dNOOP # define NOOP (void)0 # define dNOOP extern int Perl___notused PERL_UNUSED_DECL #endif #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP # define dTHXa(x) dNOOP # define dTHXoa(x) dNOOP #endif #ifndef pTHX # define pTHX void # define pTHX_ # define aTHX # define aTHX_ #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif /* IV could also be a quad (say, a long long), but Perls * capable of those should have IVSIZE already. */ #if !defined(IVSIZE) && defined(LONGSIZE) # define IVSIZE LONGSIZE #endif #ifndef IVSIZE # define IVSIZE 4 /* A bold guess, but the best we can make. */ #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR #if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) #else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) #endif #define NUM2PTR(any,d) (any)(PTRV)(d) #define PTR2IV(p) INT2PTR(IV,p) #define PTR2UV(p) INT2PTR(UV,p) #define PTR2NV(p) NUM2PTR(NV,p) #if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) #else # define PTR2ul(p) INT2PTR(unsigned long,p) #endif #endif /* !INT2PTR */ #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif #ifndef gv_stashpvn # define gv_stashpvn(str,len,flags) gv_stashpv(str,flags) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((len) ? newSVpv ((data), (len)) : newSVpv ("", 0)) #endif #ifndef newRV_inc /* Replace: 1 */ # define newRV_inc(sv) newRV(sv) /* Replace: 0 */ #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif #ifndef newRV_noinc # ifdef __GNUC__ # define newRV_noinc(sv) \ ({ \ SV *nsv = (SV*)newRV(sv); \ SvREFCNT_dec(sv); \ nsv; \ }) # else # if defined(USE_THREADS) static SV * newRV_noinc (SV * sv) { SV *nsv = (SV*)newRV(sv); SvREFCNT_dec(sv); return nsv; } # else # define newRV_noinc(sv) \ (PL_Sv=(SV*)newRV(sv), SvREFCNT_dec(sv), (SV*)PL_Sv) # endif # endif #endif /* Provide: newCONSTSUB */ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63)) #if defined(NEED_newCONSTSUB) static #else extern void newCONSTSUB(HV * stash, char * name, SV *sv); #endif #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) void newCONSTSUB(stash,name,sv) HV *stash; char *name; SV *sv; { U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; newSUB( #if (PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22)) /* before 5.003_22 */ start_subparse(), #else # if (PERL_VERSION == 3) && (PERL_SUBVERSION == 22) /* 5.003_22 */ start_subparse(0), # else /* 5.003_23 onwards */ start_subparse(FALSE, 0), # endif #endif newSVOP(OP_CONST, 0, newSVpv(name,0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } #endif #endif /* newCONSTSUB */ #ifndef START_MY_CXT /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) /* This must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ #define START_MY_CXT #if (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION < 68 )) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ SV *my_cxt_sv = perl_get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ #define dMY_CXT \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #else /* single interpreter */ #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif #endif /* START_MY_CXT */ #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # else # if IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # endif # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef AvFILLp /* Older perls (<=5.003) lack AvFILLp */ # define AvFILLp AvFILL #endif #ifdef SvPVbyte # if PERL_REVISION == 5 && PERL_VERSION < 7 /* SvPVbyte does not work in perl-5.6.1, borrowed version for 5.7.3 */ # undef SvPVbyte # define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : my_sv_2pvbyte(aTHX_ sv, &lp)) static char * my_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } # endif #else # define SvPVbyte SvPV #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_nolen(sv)) static char * sv_2pv_nolen(pTHX_ register SV *sv) { STRLEN n_a; return sv_2pv(sv, &n_a); } #endif #ifndef get_cv # define get_cv(name,create) perl_get_cv(name,create) #endif #ifndef get_sv # define get_sv(name,create) perl_get_sv(name,create) #endif #ifndef get_av # define get_av(name,create) perl_get_av(name,create) #endif #ifndef get_hv # define get_hv(name,create) perl_get_hv(name,create) #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef eval_pv # define eval_pv perl_eval_pv #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #if (PERL_VERSION > 6) || ((PERL_VERSION == 6) && (PERL_SUBVERSION >= 1)) #define I32_CAST #else #define I32_CAST (I32*) #endif #ifndef grok_hex static UV _grok_hex (char *string, STRLEN *len, I32 *flags, NV *result) { NV r = scan_hex(string, *len, I32_CAST len); if (r > UV_MAX) { *flags |= PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = r; return UV_MAX; } return (UV)r; } # define grok_hex(string, len, flags, result) \ _grok_hex((string), (len), (flags), (result)) #endif #ifndef grok_oct static UV _grok_oct (char *string, STRLEN *len, I32 *flags, NV *result) { NV r = scan_oct(string, *len, I32_CAST len); if (r > UV_MAX) { *flags |= PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = r; return UV_MAX; } return (UV)r; } # define grok_oct(string, len, flags, result) \ _grok_oct((string), (len), (flags), (result)) #endif #if !defined(grok_bin) && defined(scan_bin) static UV _grok_bin (char *string, STRLEN *len, I32 *flags, NV *result) { NV r = scan_bin(string, *len, I32_CAST len); if (r > UV_MAX) { *flags |= PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = r; return UV_MAX; } return (UV)r; } # define grok_bin(string, len, flags, result) \ _grok_bin((string), (len), (flags), (result)) #endif #ifndef IN_LOCALE # define IN_LOCALE \ (PL_curcop == &PL_compiling ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 # define IS_NUMBER_NOT_INT 0x04 # define IS_NUMBER_NEG 0x08 # define IS_NUMBER_INFINITY 0x10 # define IS_NUMBER_NAN 0x20 #endif #ifndef grok_numeric_radix # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(aTHX_ sp, send) #define grok_numeric_radix Perl_grok_numeric_radix bool Perl_grok_numeric_radix(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #if (PERL_VERSION > 6) || ((PERL_VERSION == 6) && (PERL_SUBVERSION >= 1)) if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* pre5.6.0 perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif /* PERL_VERSION */ #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif /* grok_numeric_radix */ #ifndef grok_number #define grok_number Perl_grok_number int Perl_grok_number(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif /* grok_number */ #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #endif #ifndef PERL_MAGIC_envelem # define PERL_MAGIC_envelem 'e' #endif #ifndef PERL_MAGIC_fm # define PERL_MAGIC_fm 'f' #endif #ifndef PERL_MAGIC_regex_global # define PERL_MAGIC_regex_global 'g' #endif #ifndef PERL_MAGIC_isa # define PERL_MAGIC_isa 'I' #endif #ifndef PERL_MAGIC_isaelem # define PERL_MAGIC_isaelem 'i' #endif #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #endif #ifndef PERL_MAGIC_substr # define PERL_MAGIC_substr 'x' #endif #ifndef PERL_MAGIC_defelem # define PERL_MAGIC_defelem 'y' #endif #ifndef PERL_MAGIC_glob # define PERL_MAGIC_glob '*' #endif #ifndef PERL_MAGIC_arylen # define PERL_MAGIC_arylen '#' #endif #ifndef PERL_MAGIC_pos # define PERL_MAGIC_pos '.' #endif #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File ppport.h */ Math-Geometry-Voronoi-1.3/vdefs.h0000755000076400007640000000571011226155444015114 0ustar samsam#ifndef __VDEFS_H #define __VDEFS_H #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifndef NULL #define NULL 0 #endif #define DELETED -2 typedef struct tagFreenode { struct tagFreenode * nextfree; } Freenode ; typedef struct tagFreelist { Freenode * head; int nodesize; } Freelist ; typedef struct tagPoint { double x ; double y ; } Point ; /* structure used both for sites and for vertices */ typedef struct tagSite { Point coord ; int sitenbr ; int refcnt ; } Site ; typedef struct tagEdge { double a, b, c ; Site * ep[2] ; Site * reg[2] ; int edgenbr ; } Edge ; #define le 0 #define re 1 typedef struct tagHalfedge { struct tagHalfedge * ELleft ; struct tagHalfedge * ELright ; Edge * ELedge ; int ELrefcnt ; char ELpm ; Site * vertex ; double ystar ; struct tagHalfedge * PQnext ; } Halfedge ; /* edgelist.c */ void ELinitialize(void) ; Halfedge * HEcreate(Edge *, int) ; void ELinsert(Halfedge *, Halfedge *) ; Halfedge * ELgethash(int) ; Halfedge * ELleftbnd(Point *) ; void ELdelete(Halfedge *) ; Halfedge * ELright(Halfedge *) ; Halfedge * ELleft(Halfedge *) ; Site * leftreg(Halfedge *) ; Site * rightreg(Halfedge *) ; extern int ELhashsize ; extern Site * bottomsite ; extern Freelist hfl ; extern Halfedge * ELleftend, * ELrightend, **ELhash ; /* geometry.c */ void geominit(void) ; Edge * bisect(Site *, Site *) ; Site * intersect(Halfedge *, Halfedge *) ; int right_of(Halfedge *, Point *) ; void endpoint(Edge *, int, Site *) ; double dist(Site *, Site *) ; void makevertex(Site *) ; void deref(Site *) ; void ref(Site *) ; extern double deltax, deltay ; extern int nsites, nedges, sqrt_nsites, nvertices ; extern Freelist sfl, efl ; /* heap.c */ void PQinsert(Halfedge *, Site *, double) ; void PQdelete(Halfedge *) ; int PQbucket(Halfedge *) ; int PQempty(void) ; Point PQ_min(void) ; Halfedge * PQextractmin(void) ; void PQinitialize(void) ; extern int PQmin, PQcount, PQhashsize ; extern Halfedge * PQhash ; /* main.c */ extern int sorted, triangulate, plot, debug, nsites, siteidx ; extern double xmin, xmax, ymin, ymax ; extern Site * sites ; extern Freelist sfl ; extern AV *lines_out, *edges_out, *vertices_out; int compute_voronoi(Site *, int, double, double, double, double, int, AV*, AV*, AV*); /* getopt.c */ extern int getopt(int, char *const *, const char *); /* memory.c */ void freeinit(Freelist *, int) ; char *getfree(Freelist *) ; void makefree(Freenode *, Freelist *) ; char *myalloc(unsigned) ; void free_all(void); /* output.c */ void openpl(void) ; void line(double, double, double, double) ; void circle(double, double, double) ; void range(double, double, double, double) ; void out_bisector(Edge *) ; void out_ep(Edge *) ; void out_vertex(Site *) ; void out_site(Site *) ; void out_triple(Site *, Site *, Site *) ; void plotinit(void) ; void clip_line(Edge *) ; /* voronoi.c */ void voronoi(Site *(*)()) ; #endif Math-Geometry-Voronoi-1.3/edgelist.c0000755000076400007640000001040711226155444015577 0ustar samsam /*** EDGELIST.C ***/ #include "vdefs.h" int ELhashsize ; Site * bottomsite ; Freelist hfl ; Halfedge * ELleftend, * ELrightend, **ELhash ; int ntry, totalsearch ; void ELinitialize(void) { int i ; freeinit(&hfl, sizeof(Halfedge)) ; ELhashsize = 2 * sqrt_nsites ; ELhash = (Halfedge **)myalloc( sizeof(*ELhash) * ELhashsize) ; for (i = 0 ; i < ELhashsize ; i++) { ELhash[i] = (Halfedge *)NULL ; } ELleftend = HEcreate((Edge *)NULL, 0) ; ELrightend = HEcreate((Edge *)NULL, 0) ; ELleftend->ELleft = (Halfedge *)NULL ; ELleftend->ELright = ELrightend ; ELrightend->ELleft = ELleftend ; ELrightend->ELright = (Halfedge *)NULL ; ELhash[0] = ELleftend ; ELhash[ELhashsize-1] = ELrightend ; } Halfedge * HEcreate(Edge * e, int pm) { Halfedge * answer ; answer = (Halfedge *)getfree(&hfl) ; answer->ELedge = e ; answer->ELpm = pm ; answer->PQnext = (Halfedge *)NULL ; answer->vertex = (Site *)NULL ; answer->ELrefcnt = 0 ; return (answer) ; } void ELinsert(Halfedge * lb, Halfedge * new) { new->ELleft = lb ; new->ELright = lb->ELright ; (lb->ELright)->ELleft = new ; lb->ELright = new ; } /* Get entry from hash table, pruning any deleted nodes */ Halfedge * ELgethash(int b) { Halfedge * he ; if ((b < 0) || (b >= ELhashsize)) { return ((Halfedge *)NULL) ; } he = ELhash[b] ; if ((he == (Halfedge *)NULL) || (he->ELedge != (Edge *)DELETED)) { return (he) ; } /* Hash table points to deleted half edge. Patch as necessary. */ ELhash[b] = (Halfedge *)NULL ; if ((--(he->ELrefcnt)) == 0) { makefree((Freenode *)he, (Freelist *)&hfl) ; } return ((Halfedge *)NULL) ; } Halfedge * ELleftbnd(Point * p) { int i, bucket ; Halfedge * he ; /* Use hash table to get close to desired halfedge */ bucket = (p->x - xmin) / deltax * ELhashsize ; if (bucket < 0) { bucket = 0 ; } if (bucket >= ELhashsize) { bucket = ELhashsize - 1 ; } he = ELgethash(bucket) ; if (he == (Halfedge *)NULL) { for (i = 1 ; 1 ; i++) { if ((he = ELgethash(bucket-i)) != (Halfedge *)NULL) { break ; } if ((he = ELgethash(bucket+i)) != (Halfedge *)NULL) { break ; } } totalsearch += i ; } ntry++ ; /* Now search linear list of halfedges for the corect one */ if (he == ELleftend || (he != ELrightend && right_of(he,p))) { do { he = he->ELright ; } while (he != ELrightend && right_of(he,p)) ; he = he->ELleft ; } else { do { he = he->ELleft ; } while (he != ELleftend && !right_of(he,p)) ; } /*** Update hash table and reference counts ***/ if ((bucket > 0) && (bucket < ELhashsize-1)) { if (ELhash[bucket] != (Halfedge *)NULL) { (ELhash[bucket]->ELrefcnt)-- ; } ELhash[bucket] = he ; (ELhash[bucket]->ELrefcnt)++ ; } return (he) ; } /*** This delete routine can't reclaim node, since pointers from hash : table may be present. ***/ void ELdelete(Halfedge * he) { (he->ELleft)->ELright = he->ELright ; (he->ELright)->ELleft = he->ELleft ; he->ELedge = (Edge *)DELETED ; } Halfedge * ELright(Halfedge * he) { return (he->ELright) ; } Halfedge * ELleft(Halfedge * he) { return (he->ELleft) ; } Site * leftreg(Halfedge * he) { if (he->ELedge == (Edge *)NULL) { return(bottomsite) ; } return (he->ELpm == le ? he->ELedge->reg[le] : he->ELedge->reg[re]) ; } Site * rightreg(Halfedge * he) { if (he->ELedge == (Edge *)NULL) { return(bottomsite) ; } return (he->ELpm == le ? he->ELedge->reg[re] : he->ELedge->reg[le]) ; } Math-Geometry-Voronoi-1.3/MANIFEST0000644000076400007640000000050211226157602014752 0ustar samsamChanges edgelist.c geometry.c heap.c leak-test.pl lib/Math/Geometry/Voronoi.pm Makefile.PL MANIFEST memory.c output.c ppport.h README t/00basic.t vdefs.h voronoi_core.c Voronoi.xs voronoi_main.c t/02real.t t/real_data.txt examples/voronoi.cgi META.yml Module meta-data (added by MakeMaker) Math-Geometry-Voronoi-1.3/Changes0000644000076400007640000000113611226157562015125 0ustar samsamRevision history for Perl extension Math::Geometry::Voronoi. 1.3 - Added code to create polygons that intersect with the boundaries. (Adam Thomas) - Included example CGI code in examples/ directory. 1.2 - [Bug Fix] Fix compilation on 64-bit machines. (Dov Grobgeld) 1.1 - [Enhancement] changed underlying C code to use doubles instead of floats, extending range and reducing errors - [Bug Fix] Stop skipping the last point. - [Bug Fix] changed filenames to work on case-insensitive systems 1.0 Tue Jun 10 09:44:46 2008 - first version released Math-Geometry-Voronoi-1.3/lib/0000755000076400007640000000000011226157602014372 5ustar samsamMath-Geometry-Voronoi-1.3/lib/Math/0000755000076400007640000000000011226157602015263 5ustar samsamMath-Geometry-Voronoi-1.3/lib/Math/Geometry/0000755000076400007640000000000011226157602017056 5ustar samsamMath-Geometry-Voronoi-1.3/lib/Math/Geometry/Voronoi.pm0000644000076400007640000003045411226157302021052 0ustar samsampackage Math::Geometry::Voronoi; use 5.008; use strict; use warnings; our $VERSION = '1.3'; require XSLoader; XSLoader::load('Math::Geometry::Voronoi', $VERSION); use Params::Validate qw(validate ARRAYREF CODEREF); use List::Util qw(min max sum); use base 'Class::Accessor::Fast'; __PACKAGE__->mk_accessors( qw(points lines edges vertices xmin ymin xmax ymax)); sub new { my $pkg = shift; my %args = validate(@_, {points => {type => ARRAYREF}}); my $self = bless({points => $args{points}}, $pkg); $self->sort_points(); return $self; } # C code needs points sorted by y then by x and needs min and max for # both - should provide a way for the client to provide this sub sort_points { my $self = shift; my $points = $self->points(); @$points = sort { $a->[1] <=> $b->[1] || $a->[0] <=> $b->[0] } @$points; $self->ymin($points->[0][1]); $self->ymax($points->[-1][1]); my @x = map { $_->[0] } @$points; $self->xmin(min(@x)); $self->xmax(max(@x)); return; } sub compute { my $self = shift; my $result = compute_voronoi_xs($self->points, $self->xmin, $self->xmax, $self->ymin, $self->ymax); $self->lines($result->{lines}); $self->vertices($result->{vertices}); $self->edges($result->{edges}); return; } sub cmp_verts_ab { return cmp_verts($a,$b); } # a low x value is placed before a high x value. if both x values # are the same, a high y value is placed before a low y value. sub cmp_verts { return ($_[0]->[0] <=> $_[1]->[0] || $_[1]->[1] <=> $_[0]->[1] ); } sub vert_inside_bounds { my ($self, $x,$y) = @_; return ( $x >= $self->xmin and $x <= $self->xmax and $y >= $self->ymin and $y <= $self->ymax ); } sub boundry_interesection_verts { my($self, $a,$b,$c) = @_; my $verts = []; if($b){ my $v1 = [$self->xmin,($c-$a*$self->xmin)/$b]; my $v2 = [$self->xmax,($c-$a*$self->xmax)/$b]; push ( @$verts, $v1 ) if ( $self->vert_inside_bounds( @$v1 ) ); push ( @$verts, $v2 ) if ( $self->vert_inside_bounds( @$v2 ) ); } if($a){ my $v1 = [($c-$b*$self->ymax)/$a,$self->ymax]; my $v2 = [($c-$b*$self->ymin)/$a,$self->ymin]; push ( @$verts, $v1 ) if ( $self->vert_inside_bounds( @$v1 ) ); push ( @$verts, $v2 ) if ( $self->vert_inside_bounds( @$v2 ) ); } $verts; } sub polygons { my $self = shift; my %args = validate(@_, {normalize_vertices => {type => CODEREF, optional => 1 }, }); my $points = $self->points; my $lines = $self->lines; my $edges = $self->edges; my $vertices = $self->vertices; if (my $norm = $args{normalize_vertices}) { $vertices = [map { [$norm->($_->[0]), $norm->($_->[1])] } @$vertices]; } my @edges_by_point; EDGE: foreach my $edge (@$edges) { my ($l, $v1, $v2) = @$edge; next EDGE if( $v1 == -1 and $v2 == -1 ); my ($lon1, $lat1, $lon2, $lat2); my $ivs = $self->boundry_interesection_verts(@{$lines->[$l]}); $ivs = [sort cmp_verts_ab @$ivs]; if( my $norm = $args{normalize_vertices}) { $ivs = [map { [$norm->($_->[0]), $norm->($_->[1])] } @$ivs]; } ($lat1,$lon1) = @{$vertices->[$v1]} if( $v1 != -1 ); ($lat2,$lon2) = @{$vertices->[$v2]} if( $v2 != -1 ); if( $v1 == -1 ) { next EDGE unless( @$ivs and $lat2 +0 == $lat2 and $lon2 +0 == $lon2 ); if( cmp_verts( [$lat2,$lon2], $ivs->[0] ) > 0 ) { ($lat1,$lon1) = @{$ivs->[0]}; } elsif( cmp_verts( [$lat2,$lon2], $ivs->[1] ) > 0 ) { ($lat1,$lon1) = @{$ivs->[1]}; } else { next EDGE; } } if( $v2 == -1 ) { next EDGE unless( @$ivs and $lat1 +0 == $lat1 and $lon1 +0 == $lon1 ); if( cmp_verts( [$lat1,$lon1], $ivs->[1] ) < 0 ) { ($lat2,$lon2) = @{$ivs->[1]}; } elsif( cmp_verts( [$lat1,$lon1], $ivs->[0] ) < 0 ) { ($lat2,$lon2) = @{$ivs->[0]}; } else { next EDGE; } } # if any of the coords are NaN things break. next EDGE if( grep {$_ +0 != $_ } ($lat1,$lon1,$lat2,$lon2)); my ($p1, $p2) = ($lines->[$l][3], $lines->[$l][4]); if ($p1 != -1 and $p2 != -1) { foreach my $p ($p1, $p2) { push @{$edges_by_point[$p]}, [$lat1, $lon1, $lat2, $lon2]; } } } my @polygons; foreach my $p (0 .. $#$points) { my $stack = $edges_by_point[$p]; next unless $stack; # can't make a polygon with less than 2 edges next unless @$stack >= 2; my @poly = (); foreach my $this ( @$stack ) { if( !grep { $_->[0] == $this->[0] && $_->[1] == $this->[1] } @poly and $this->[0] +0 == $this->[0] and $this->[1] +0 == $this->[1] ) { push @poly, [$this->[0],$this->[1]]; } if( !grep { $_->[0] == $this->[2] && $_->[1] == $this->[3] } @poly and $this->[2] +0 == $this->[2] and $this->[3] +0 == $this->[3] ) { push @poly, [$this->[2],$this->[3]]; } } #TODO: if this point is the closest point to a corner... # add that corner as a vert on this poly # sort poly's verts (anti?) clockwise around the point $points->[$p]; @poly = sort { my($lat1,$lon1) = ( $a->[0] - $points->[$p]->[0], $a->[1] - $points->[$p]->[1] ); my($lat2,$lon2) = ( $b->[0] - $points->[$p]->[0], $b->[1] - $points->[$p]->[1] ); return atan2($lon1,$lat1) <=> atan2($lon2,$lat2); } @poly; # make a list of the first points push @polygons, [$p, map { [$_->[0], $_->[1]] } @poly]; } return @polygons; } sub _dump_poly { my $poly = shift; return "[ \n\t" . join(", \n\t", map { "[$_->[0],$_->[1]]" } @$poly) . " ]\n"; } 1; __END__ =head1 NAME Math::Geometry::Voronoi - compute Voronoi diagrams from sets of points =head1 SYNOPSIS use Math::Geometry::Voronoi; # load a set of points my @points = ([1, 2], [1, 3], [2, 2], [0, 1], [0, 10], [0.5, 11]); my $geo = Math::Geometry::Voronoi->new(points => \@points); # compute your diagram $geo->compute; # extract features my $lines = $geo->lines; my $edges = $geo->edges; my $vertices = $geo->vertices; # build polygons my @polygons = $geo->polygons; =head1 DESCRIPTION This module computes Voronoi diagrams from a set of input points. Info on Voronoi diagrams can be found here: http://en.wikipedia.org/wiki/Voronoi_diagram This module is a wrapper around a C implementation found here: http://www.derekbradley.ca/voronoi.html Which is itself a modification of code by Steve Fortune, the inventor of the algorithm used (Fortune's algorithm): http://cm.bell-labs.com/who/sjf/ I made changes to the C code to allow reading input and writing output to/from Perl data-structures. I also modified the memory allocation code to use Perl's memory allocator. Finally, I changed all floats to doubles to provide better precision and to match Perl's NVs. =head1 INTERFACE =head2 new my @points = ([1, 2], [1, 3], [2, 2], [0, 1], [0, 10], [0.5, 11]); my $geo = Math::Geometry::Voronoi->new(points => \@points); Create a new object, passing in a single required parameter called 'points'. This must be an array or arrays containing at least two values each, the X,Y values for your points. Any extra data will be ignored. =head2 points Returns the I set of points used by the voronoi algorithm. This is the ordering refered to by the lines() output below. =head2 compute Call this to build the diagram. Returns nothing. =head2 lines Returns an array ref containing arrays of lines in the output diagram. The data by index: 0: the a value in the ax + by = c equation for the line 1: the b value 2: the c value 3: the index of one point for which this line is the bisector. 4: the index of the other point for which this line is the bisector. Note that 3 and 4 are not the end-points of the line - they are points perpendicular to the line. Either 3 or 4 may be -1 meaning no point. =head2 vertices Returns an array ref containing arrays of vertices in the output diagram. These are the points which connect edges running along the lines. The data by index: 0: the x value 1: the y value =head2 edges Returns an array ref containing arrays of edges in the output diagram. An edge is defined as a segment of a line running between two vertices. The data by index: 0: the index of the line 1: the index of vertex 1 2: the index of vertex 2 Either 1 or 2 can be -1 meaning "infinite". =head2 polygons @polys = $geo->polygons(); This method attempts to assemble polygons from non-infinite edges in the diagram. This part of the code is written in Perl and is of my own invention. I needed this facility in order to color the diagrams created by this module. It seems to work reasonably well for my uses but I'm sure it's nowhere near the quality of Steve Fortune's code! Feedback welcome. This method returns a reference to an array containing first a point index and then a list of vertex coordinates. The point is the point inside the polygon and the vertices are in drawing order for the closed polygon surrounding the point. For example: @polys = ( $point_index, [$lat1, $lon1], [$lat2, $lon2], ... ); One optional parameter is available - normalize_vertices. This option is necessary because the algorithm used needs to match up points from one edge to another and doing that with floating point numbers requires some kind of normalization (otherwise 1.1 != 1.10001). For example, if your coordinates are on an integer grid you might do: @polys = $geo->polygons(normalize_vertices => sub { int($_[0]) }); Or if you're using floating point and your coordinates are useful down to 2 decimal places: @polys = $geo->polygons(normalize_vertices => sub { sprintf("%.2f", $_[0]) }); The point is to produce coordinates in a format where they will compare as equal textually, side-stepping the problem of comparing floats numerically. =head1 TODO Possible projects, if you're in the mood to help out: - Add the ability to combine polygons based on a mapping of same-type points. Map overlays get cluttered by internal lines with you're coloring multiple polygons the same. All edges connect exactly two polygons, so this should be relatively easy. Sadly, my limited math skills have thwarted me on this one - I spent several days but ultimately couldn't get it working reliably on all possible shapes. - Remove the need for the normalize_vertices option to polygons(), somehow (fuzzy matching?). - Setup a site where people can play with the module visually and see purty colors. Could be an excuse to play with the new canvas stuff in modern browsers. - Add tests that actually examine the output for sanity. So far the tests just look at the format and range of the output data - to see if it's actually doing a decent diagram I look at graphical output. =head1 AUTHOR Sam Tregar =head1 COPYRIGHT AND LICENSE As far as I can tell the underlying C code used here never had a license attached to it, or if it did I couldn't find any trace of it. If this worries you please contact Steve and Derek through the links above. The Perl and XS code in this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available. =cut Math-Geometry-Voronoi-1.3/Makefile.PL0000644000076400007640000000155611226155444015607 0ustar samsamuse 5.008; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile(NAME => 'Math::Geometry::Voronoi', VERSION_FROM => 'lib/Math/Geometry/Voronoi.pm', PREREQ_PM => {Params::Validate => 0, Scalar::Util => 0, List::Util => 0, Class::Accessor => 0}, ABSTRACT_FROM => 'lib/Math/Geometry/Voronoi.pm', AUTHOR => 'Sam Tregar ', LIBS => [''], DEFINE => '', INC => '-I.', OBJECT => 'voronoi_main.o edgelist.o heap.o geometry.o memory.o ' . 'output.o voronoi_core.o Voronoi.o');