Repository navigation
Numpy triangles array - #11
Conversation
Co-authored-by: Chris Colbert <sccolbert@gmail.com>
Co-authored-by: Chris Colbert <sccolbert@gmail.com>
Co-authored-by: Chris Colbert <sccolbert@gmail.com>
d306834 to
3331669
Compare
|
Hi @sccolbert and thanks for the PR. 🙂 I've done it slightly different, please take a look and let me know what you think.
Let me know if you have any feedback, and I'll merge it otherwise. |
|
Hey there @artem-ogre, thanks for looking! The reason I went with the copy approach instead of a view, is because I am using the output before erasing the super triangle, and further edits to the triangulation would invalidate the view. The reason I don't erase is that the internal book-keeping of the erase is slow compared to what I need from the vertices after accounting for the presence of the of the super triangle. |
|
I think your updates are good. My only worry would be taking a view, doing something that would reallocate the internal vector memory, then reading from the view again, causing a corrupted view or a crash. |
|
Oh, and now that I have your attention, I have a WASM build of the core C++ lib that I could contribute, if you like? |
|
I wouldn't maintain WASM build but would be interested to see it if you decide to put it in public. I've myself experimented with an idea a while ago. |
|
FYI @sccolbert I added you to the contributors list in #13 |
|
Thanks! I appreciate that. |
This adds method to export the full triangles vector as a numpy array via a single memcopy. This avoids the overhead of converting to a list of python objects, and the overhead of iterating them into a numpy array. Since the lib already accepts buffer input, this is analogue for getting buffer output.
I also updated the binding the release the GIL where possible. This allows multiple independent triangulations to computed across Python threads.