and I need to store in numpy arrays the information that I am able to store in an STL file without having to export and import again in STL format. Information consists of the coordinates of the 3 points of triangles and the normal vector.
if it is specifically only a numpy array you need to store and reload, numpy has a save function. For more general objects (including ngsolve objects, such as GridFunctions, FESpaces…), you could use pythons pickle module:
[code]import numpy as np
import pickle
x = np.array([1,2,3])
y = np.array([4,5,6])
pickle.dump([x,y], open(“filename”, “wb”))
Thank you Henry.
However, I want to avoid exporting my mesh into an STL file then read it again to get it stored into a numpy array.
Is there another way to get, for a 3D surface mesh, the coordinates of the 3 points of each elementary triangle (facet) and the local normal vector?
Thanks a lot for your time.
Regards,
MA
not from within netgen. You could always compute a normal as
[tex]\bf n = \frac{ e_1\times e_2}{\Vert e_1\times e_2 \Vert} [/tex]
where
[tex]\bf e_i = v_i - v_3 [/tex]
for i = 1,2 are two of the triangle edges. But these might not be outward pointing.