Home › Forum › SOFA › Programming with SOFA › [SOLVED] Saving new vertices of deformed mesh
- This topic has 6 replies, 4 voices, and was last updated 10 years ago by
Hugo.
-
AuthorPosts
-
15 October 2015 at 20:40 #3769
Zahra
BlockedHello,
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
16 October 2015 at 09:40 #3770Alex Bilger
BlockedHi,
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
16 October 2015 at 09:51 #3771Saleem
BlockedIn 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
16 October 2015 at 10:09 #3772Saleem
BlockedI forgot to mention that’s alphabet O not zero.
16 October 2015 at 14:47 #3773Zahra
BlockedDear Alex and Zargham,
Thank you for your quick great helps.
Zahra
17 November 2015 at 17:47 #4161Zahra
BlockedHow 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.
17 November 2015 at 17:51 #4162Hugo
KeymasterDear 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
-
AuthorPosts
- You must be logged in to reply to this topic.
