mdally / Voronoi

C++ implementation of Fortune's Algorithm for computing bounded Voronoi diagrams
MIT License
25 stars 14 forks source link

question regarding polygons #8

Open Leo1906 opened 6 years ago

Leo1906 commented 6 years ago

First let me thank you for your hard work and your efficient code! I have a question regarding the use of your code. I need to get the voronoi tesselation exported as polygons. Your code (as far as I can see) only gives me a bunch of line strings which plotted look like polygons but in fact are not related to each other.. am I right? Is there a way to get the information about which lines form a enclosed polygon? So I know the number of polygons by providing the number of points but I don't know when to cut the output of lines to a complete polygon. Can you help me here? You know your code probably better than me from just reading :)

KoraktorXV commented 6 years ago

you can get the "polygons" in the Cells unsigned int index; //from 0 to amount of Vornoi Cells unsigned int edge_index; Diagram diagram; //the Diagram you are working in Cell c = diagram->cells.at(index); // the Cell at index, order is random c->halfEdges[edge_index];//you get the points with c->halfEdges[edge_index]-> startPoint(); or c->halfEdges[edge_index]-> endPoint();

every Cell is a Convex Shape (NOT splitet in TRIAS it´s an NGon) so it is already in a useful form, you only have to convert it in your format.

Leo1906 commented 6 years ago

Thanks, that works perfectly! :) Everything is fine now :D