tinyply icon indicating copy to clipboard operation
tinyply copied to clipboard

Provide custom memory for vertices

Open HiImJulien opened this issue 3 years ago • 3 comments

Hey there!

Given a class mesh, which (pre-)allocates it's own memory for storing up to n vertices. I cannot modify this class. Can I instruct TinyPly to use the preallocate memory instead of it allocating its own memory and having to copy the vertices?

HiImJulien avatar Aug 20 '20 23:08 HiImJulien

Can you explain you use-case a little bit more? It's the first time someone has requested this feature so I'm curious to know more. It's challenging namely because it's unclear (as an application developer) how much memory you need to preallocate and then what happens if the library needs to allocate more. Lots of things to consider :)

ddiakopoulos avatar Oct 28 '20 04:10 ddiakopoulos

The use case is pretty simple: Avoid unnecessary allocations and copies for big sets of data.

The storage size for per-element properties can be calculated pretty easily, thus preallocation can occur after the header was parsed. For lists, I agree, that's a real pain in the back, requiring you to iterate through each row and reading the element count.

HiImJulien avatar Oct 30 '20 19:10 HiImJulien

I'm also interested in this feature. I'm using tinply as a loader in a python library which returns NumPy arrays. I'm often using this loader for massive meshes which take up a lot of memory. I would like to have tinyply load directly into the buffer allocated for the NumPy array rather than make a copy.

fwilliams avatar Jul 01 '22 15:07 fwilliams