JustasB / BlenderNEURON

Exports 3D structure and activity from NEURON simulator to Blender
http://blenderNEURON.org
MIT License
27 stars 7 forks source link

SoA or AoS? #22

Closed Helveg closed 3 years ago

Helveg commented 3 years ago

What do you think is computationally most efficient inside of Blender? A structure of arrays (x_vector, y_vector, z_vector, radius_vector) or an array of structures [point1, point2, point3]?

In the new API this information is only ever used once in principle to iterate over and "extrude" the CurveContainer. Once the Blender object for a Cell is constructed we throw away the data that constructed it to reduce memory and in the (I think rare) case that someone wants to read something about the cell they just constructed I'd like to read that out of the Blender object.

For these purposes, SoA or AoS?

Helveg commented 3 years ago

Since I'd like to keep this a minimal effort endeavour and prevent "premature optimization" I'm mostly in favor of keeping the current description, the coords, unless problems arise or were already known to you?

Could you tell me though where the logic is that parses the coords from the RPC into the coords that are used in the CurveContainer, they seem to be different in nature, the latter being numpy-like?

JustasB commented 3 years ago

So the SoA format was chosen because that's the format used by the optimized Blender foreach_set method when setting the coordinates of the bezier curves.

Take a look at this method, I think this will answer your 2nd question: https://github.com/JustasB/BlenderNEURON/blob/7297e6aa45722f35908b707d0020b0519a6bc60d/blenderneuron/blender/views/curvecontainer.py#L108

BTW, the sections are constructed by creating a Bezier curve object in Blender and then assigning radius to the 3D points: image

Helveg commented 3 years ago

Ok!