- This topic has 6 replies, 4 voices, and was last updated 9 years ago by .
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- You must be logged in to reply to this topic.
Home › Forum › SOFA › Programming with SOFA › [SOLVED] Saving new vertices of deformed mesh
Hello,
How can I get the primary positions and also the corresponding new positions of mesh vertices in a deformed object? I need to save theses vertices (for example as a matrix) for further processing in another software(MATLAB).
Thank you for your help in advance.
Zahra
Hi,
there is a family of components (modules/SofaExporter) that do what you want. You could use VTKExporter or OBJExporter for example. Note that you need a visual model if you use OBJExporter. You can also write your own exporter.
Alex
In SOFA simulation window press “O” and that will create 2 files in your current directory(the folder where your .scn file was) open those files with notepad and one of them will show all the vertices and other values related to vertices of the object. Change the name of those files, run your simulation and at whatever time during simulation you need deformed vertices, stop the simulation, press “O” the 2 files will be created again, change their name if you need to get more new positions of vertices.
C:\Users\User\Documents\GitHub\sofa\examples\Demos\simpleshere.scn
I used this scene there is just one sphere in it with 12 vertices, I deleted constraints from the scene and made the object fall under gravity when I press “O” in simulation at initial position and after some time, temp1_0000.MTL and temp1_0000.OBJ files were created in same directory both times(file name remains same that’s why changing name is important otherwise the same files are just updated), then I plotted those points with alphabet v in start in MATLAB to confirm this using scatter3(x,y,z) command and the results seem right.
Zargham
I forgot to mention that’s alphabet O not zero.
Dear Alex and Zargham,
Thank you for your quick great helps.
Zahra
How can I export the vertices to obj file while I make some deformations on the mesh with shift+left button? Pressing “o” while I use shift+left button does not work.
Dear Zahra,
Pressing “O” only works for the visual model.
Otherwise, you can use the OBJExporter component in your scene in order to export it.
Cheers,
Hugo
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.