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

Add an update method for iterative algorithms #48

Merged
merged 1 commit into from
Jun 18, 2019
Merged

Conversation

mourner
Copy link
Member

@mourner mourner commented Jun 18, 2019

Closes #36. @JobLeonard how does this look?

I opted for the simplest approach possible that wouldn't complicate the API much. So now the constructor only allocates all necessary arrays (except for hull which is small but of undetermined size before triangulation), while all the work happens in update:

const delaunay = new Delaunator(coords);
// modify coords
delaunay.update();

Also removes any explicit release of the temporary arrays because it doesn't seem too useful. If needed, this could be handled on the app side by GC:

const {hull, triangles, halfedges} = new Delaunator(coords);
// temporary arrays will be garbage-collected because they're no longer references by anything

@JobLeonard
Copy link
Contributor

how does this look?

It looks great! BRB, going to try it out :p

@JobLeonard
Copy link
Contributor

You know what, just reading from the page it's obvious that this works. And manually modifying the original coordinates array that was passed (or this.coords I guess) seems most sensible to me too: iterative changes means interacting with the raw array anyway.

So I'll just wait until this and d3-delaunay merges and update my Voronoi stippling notebook then :)

@mourner
Copy link
Member Author

mourner commented Jun 18, 2019

Cool! Before you can use it, d3-delaunay will probably also need an equivalent change, since currently it doesn't hold onto the delaunay object, extracting the triangulation info and throwing it out.

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.

Request: a mutable variant with an update method, for Voronoi relaxation purposes
2 participants