-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to work with Voronoi tessellations #11
Comments
hi, sorry for the late reply, for some reason I was not notified when you opened this issue. About your questions:
for edge in voronoiedges(tess)
a = geta(edge)
b = getb(edge)
gen_a = getgena(edge)
gen_b = getgenb(edge)
# push corners to cell a
push!(celledges[gen_a.index], a)
push!(celledges[gen_a.index], b)
# push corners to cell b
push!(celledges[gen_b.index], a)
push!(celledges[gen_b.index], b)
end this should be very efficient. Maybe I'll implement something like this next, so lets leave this issue open, and keep me updated if this works for you |
Hi Thanks for you reply! Regarding my second question: Regarding the corners, your interpretation of my question is correct :-)
(A small thing is that Best, Robert |
You have to use your own immutable IndexablePoint <: AbstractPoint2D
_x::Float64
_y::Float64
index::Int64
end You have to implement |
Ahh, that makes sense! Thank you! |
Returning to this old issue I have a new question. |
yes, more or less. You should not draw any line which has a corner as a generator. But then you'll find that a few cells have lines that stop where the corner cell was, whereas now they should actually continue further. This may or may not be a problem, depending what exactly you want to do Note that I fixed a bug with the generators, please use the latest code in master if you describe what exactly you want to achieve I may be able to better help :) Also |
for cells that don't share an external point ( ie 1,1 1,2 2,1 or 2,2) you should b getting correct corners The problem is for the cells that do share one of these special points. In this case just ignoring the special points will lead to incorrect corners. So a solution could be to use some cells that you don't care about as "padding" for the cells that you care about of course this should be properly fixed,maybe I'll do it soon. When I have some time that is :) |
In the end I would like to compute the area of each Voronoi cell intersected with the bounding box (allowed area) and the vector of area values should be ordered like the points in tess. Right now I'm making a Dict where the keys are the generators and the values of a key are the corners of the corresponding cell. |
are you getting good results with your solution? are you concerned with performance? |
I've only just implemented it and haven't tested performance yet :-) |
ok, please update me about the performance, and correctness, when you have some data -- Thanks! |
Sure! |
I'm running into performance problems: The generators of an edge may not be exactly equal to the original points in a |
I don't understand -- if you iterate over the |
I had not realized that |
Sorry about my long absence! I started thinking about indexing generators and forget to reply. Are you thinking about adding and index to |
see comments above -- you can easily add your own index (or whatever other data) into a point by subtyping to quote myself: You have to use your own Point2D type with an index, something like immutable IndexablePoint <: AbstractPoint2D
_x::Float64
_y::Float64
index::Int64
end You have to implement getx, gety, etc. and then extract the corners as above |
it may be worth adding a default indexed poit2d though... I'll open a separate issue on this |
Right! |
I hope I'm not missing something obvious, but I'm having problems with an immutable IndexablePoint <: AbstractPoint2D
_x::Float64
_y::Float64
index::Int64
end
getx(p::IndexablePoint) = p._x
gety(p::IndexablePoint) = p._y
getindex(p::IndexablePoint) = p.index When I try to push points to a tess with tess = DelaunayTessellation2D{IndexablePoint}
a = IndexablePoint(min_coord+rand()*width, min_coord+rand()*width, 1)
push!(tess, a)
ERROR: MethodError: `push!` has no method matching push!(::Type{VoronoiDelaunay.DelaunayTessellation2D{IndexablePoint}}, ::IndexablePoint)
Closest candidates are:
push!(::Any, ::Any, ::Any)
push!(::Any, ::Any, ::Any, ::Any...)
push!(::Array{Any,1}, ::ANY)
... Also, is it not a problem that the four corners doesn't have a default index, cf. #6 ? |
it works (and with no warnings) when doing the following:
see image below for a working example: |
Now my code runs -- and fast, too :-) What is a good way to share? Should I make a new repository? |
what exactly your codes does? this repository is only for the library... is your code relevant for the library? if its just using the library then yeah you should make a new repo. If it adds some functionality that could belong in the library then maybe it can be merged |
Collects corners of each Voronoi cell and at some point I would like it to compute the area of each cell. |
BTW: Is it possible to exclude the corner points from the tessellation? |
currently there is no good solution, I have to implement point deletion and then just remove those... currently what everybody does is just check in the loop for the corners and just skip them... |
Do you have a reference that describes how to implement point deletion? If so, I'd be happy to look into implementing it. |
ghost points are points from different processors, its good for making the algorithm distributed, not exactly what we need right now :) Regarding removing points, I have no reference, I have to research this a bit, there are algorithms of course its just a matter of finding the literature |
I have found some references on how to remove points, but that is for half point and quad edge data structures... |
FYI, I've collected the code I mentioned above in a package. |
Hi,
This looks like just the package I need:
I want to compute a Voronoi tessellation and then the area of each (bounded) cell.
However, playing around with the examples in the README there are some things I don't understand:
tess = DelaunayTessellation()
seems to produce the same output if I provide asizehint
input.tess
?voronoiedges
, can I extract the corners of a given cell?Can you help me out?
Thanks,
Robert
The text was updated successfully, but these errors were encountered: