Skip to content
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

Halfedge linked list #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

fjwong
Copy link

@fjwong fjwong commented Jan 23, 2017

This PR introduces a HalfedgeList object (a doubly-linked list) to replace arrays in Voronoi cells. It seems a lot of time is spent on garbage collection when the createEdge method is called, since it needs to push new objects to the halfedges array of the corresponding cells.

At least in Chrome and Safari, this change gives a significant speed up when running the benchmark and Lloyd's relaxation demos with 10000 vertices.

Please note that this change would break code that needs to iterate through the existing halfedges array of the cell object though.

Iterating through halfedges would need to be done in this manner:

var halfedge = cell.halfedges.first;

while(halfedge) {
    // Do something with the halfedge here
    // ...
    halfedge = halfedge.next;
}

Also, the HalfedgeList object is declared within the prototype of the Cell object. I'm not sure whether this is the right way to go or not. I tried declaring this within the prototype of the Voronoi object, like the Cell and Halfedge objects, but couldn't find a way to call the HalfedgeList constructor from within the Cell object's methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant