optimad / mimmo

Surface manipulation and mesh morphing library
http://optimad.github.io/mimmo
GNU Lesser General Public License v3.0
99 stars 21 forks source link

Rendering Lattice #140

Closed sararht closed 4 years ago

sararht commented 4 years ago

Hello,

I am using this library to create defects in .STL models. To make these defects I am using the Free Form Deformation (FFD) based on lattice parametrization.

I am interested in visualizing the lattice grid together with the stl model, in order to check if i am doing it right. Is there a way to do, or to save the lattice results in other format than .vtu?

Thanks in advance!

roccoarpa commented 4 years ago

Hi @sararht, unfortunately there is no other option up to now, except for the unstructured format vtu supported by Paraview. Basically lattices are saved as hexahedral meshes, we used the simplest way to do it for us. Anyway, if you are familiar with hexa mesh format, you could access the basic data of the lattice mesh from FFDLattice class, and expose it in a format convenient for you.

Once class is executed, to access data , for a lattice with a number of points NP= nx ny nz e number of cells NC = (nx-1)(ny-1)(nz-1):

1) to get point coordinates P : for(int i=0; i< NP; ++i){ P[i] = getGlobalPoint(i);} 2) to access list of dof on each P (coherently ordered as P), you have your list of DOF (those you push with setDisplacement), then find dof index list associated with P using method accessDOFFromGrid(ivector1D gNindex), where gNIndex is a vector of integer {0,1,2,3,...,NP-1} of size P. For example : FFDLattice lattice; ... lattice.setDisplacements(DOF); ... lattice.exec();

ivector1D Plist; for{int k=0; k<NP; ++k } Plist.push_back(k); ivector1D dofvsPmap = lattice.accessDOFFromGrid(Plist);

the dof for the i-th P is accessible as DOF[dofvsPmap[i]].

3) to access connectivity C of hexa cells (coherent with P ordering) : for(int j=0; j< NC; ++j){ C[j] = getCellNeighs(j);}. Here each C[j] is a 8 element array containing the index from P list that compose the j-th cell. The ordering is the same as described in the figure attached: Hexahedron

Hope it's clear. R.

sararht commented 4 years ago

Thanks for the info. For now I can view the Lattice with the STL model perfectly with Paraview. But the information on how to access the points will be useful in the future!

Thank you!