rogach / jopenvoronoi Goto Github PK
View Code? Open in Web Editor NEWjava port of openvoronoi, library for computing 2D voronoi diagram for points and line-segments
License: GNU General Public License v3.0
java port of openvoronoi, library for computing 2D voronoi diagram for points and line-segments
License: GNU General Public License v3.0
I came up with this format for test-geometry:
http://pastebin.com/WEbkwXFV
There are pros and cons with any fileformat, but at least XML should be easily readable by both humans and computers using almost any programming language. There doesn't seem to be a good standard for compressed XML so I am using gzip because it was easy in python.
This also allows for a future arc-specification to be added.
If you think this is OK I can convert some openvoronoi tests to this format.
Previously I did code-coverage analysis for the tests - it would be interesting to know the minimum set of test-geometries that is 'complete' in the sense that code-coverage is close to 100%.
I had a try at using the jopenvoronoi library. First off, thanks very much for your efforts at porting this to Java, this is greatly appreciated.
I used the library to insert a small sample of point and line sites into a VoronoiDiagram. The lines are non-intersecting. The insert_line_site method threw an exception with the following information:
Exception in thread "main" java.lang.AssertionError: c < 30000
at org.rogach.jopenvoronoi.VoronoiDiagram.repair_face(VoronoiDiagram.java:1614)
at org.rogach.jopenvoronoi.VoronoiDiagram.insert_line_site(VoronoiDiagram.java:297)
at org.rogach.jopenvoronoi.VoronoiDiagram.insert_line_site(VoronoiDiagram.java:118)
I rearranged the order of the line insertions so that the lines were inserted roughly in a top to bottom order, and then the process worked correctly.
Is this a know issue, that lines must be inserted in some particular order? If so, what are the rules? Or is this a question for the author of openvoronoi?
Here is a sample code that demonstrates the problem:
//vertices
System.err.println("add vertices");
// line 1
Vertex v1=vd.insert_point_site(new Point(0.4688321320388161, 0.5721630761892574));
Vertex v2=vd.insert_point_site(new Point(0.5058348543325453, 0.6116864120228264));
// line 2
Vertex v3=vd.insert_point_site(new Point(0.4676644843944667, 0.14559440261470627));
Vertex v4=vd.insert_point_site(new Point(0.5299451505909778, 0.22422772973181948));
// line 3
// v1
Vertex v5=vd.insert_point_site(new Point(0.3990853987138186, 0.6415690863444968));
Vertex v6=vd.insert_point_site(new Point(0.3729122932912645, 0.6480077124468139));
Vertex v7=vd.insert_point_site(new Point(0.32779457738866813, 0.6143608857982717));
Vertex v8=vd.insert_point_site(new Point(0.22693297450513644, 0.5030910125880271));
// line 4
// v4
Vertex v9=vd.insert_point_site(new Point(0.6406656057326543, 0.3640239162472442));
Vertex v10=vd.insert_point_site(new Point(0.6448875654993259, 0.389081247971103));
Vertex v11=vd.insert_point_site(new Point(0.6330118434419065, 0.40878488410714986));
// v1
// line 5
// v8
Vertex v12=vd.insert_point_site(new Point(0.20962013060047913, 0.48303100856119374));
// line 6
// v12
// v4
// line 7
// v12
Vertex v13=vd.insert_point_site(new Point(0.14730087533143332, 0.41082760278911357));
//lines
// line 1
System.err.println("Adding line 1");
vd.insert_line_site(v1, v2);
// line 2
System.err.println("Adding line 2");
vd.insert_line_site(v3, v4);
// line 3
System.err.println("Adding line 3");
vd.insert_line_site(v1, v5);
vd.insert_line_site(v5, v6);
vd.insert_line_site(v6, v7);
vd.insert_line_site(v7, v8);
// line 4
System.err.println("Adding line 4");
vd.insert_line_site(v4, v9);
vd.insert_line_site(v9, v10);
vd.insert_line_site(v10, v11);
vd.insert_line_site(v11, v1);
// line 5
System.err.println("Adding line 5");
vd.insert_line_site(v8, v12);
// line 6
System.err.println("Adding line 6");
vd.insert_line_site(v12, v4);
// line 7
System.err.println("Adding line 7");
vd.insert_line_site(v12, v13);
The above code will trigger the error. After rearranging the insertion order by moving line 2 to the last insertion the algorithm works correctly.
Thanks,
Tom
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.