Home › Forum › SOFA › Using SOFA › [SOLVED] extracting the visual mesh and the force applied by mouse
Tagged: 64_bits, SOFA_1608, Windows_10
- This topic has 6 replies, 2 voices, and was last updated 7 years, 6 months ago by Zahra.
-
AuthorPosts
-
26 May 2017 at 17:32 #9192ZahraBlocked
Hi,
I have some questions and I think it is better to ask them via an example. I would appreciate if anyone would kindly help me:
In the “TutorialMappingLiverBarycentric.scn”:
1. Why the visual mesh extension is different from the behavior mesh one?
Is there any reason that .obj should be used for visual model? I am asking this because if I use another extension for the visual model, namely .obj to .msh, the visual object disappears at the run.2. How can I extract the mesh of the visual model? Using mesh exporter components just give me the behavior model.
3. How can I identify the force I apply to the object by mouse?
Thanks for any help in advance.
Zahra
30 May 2017 at 16:53 #9229HugoKeymasterHey Zahra,
Let me answer point by point:
1. there is no reason imposing that the behavior and visual meshes must have the same extension. Both can use any format. What is important is that:
- visual model: requires a surface mesh
- behavior model : if volumetric object (3D cases), requires a volumetric mesh.
The .msh extension should work. Could you share the piece of XML code displaying your visual model ?
2. to export the visual model, use the OBJExporter. (the semantic of this class is actually not appropriate, it should be VisualModelExporter)
3. the force resulting from the interaction will appear in the “force” vector the MechanicalObject of the liver.
Hope this helps.
Cheers,Hugo
8 June 2017 at 20:53 #9304ZahraBlockedDear Hugo,
Thank you for your guidance.
1. One of my mistakes was that I did not know I should use a surface mesh for the visual model. Now I am using a surface mesh for visual model, however, again I can not see it in the run.
This is the visual part of the xml code:<Node name="node3" > <OglModel template="ExtVec3f" name="visual" fileMesh="d:/work/phd/sofa/liver/liverfinal/testbygmsh/livertriangle181.gmsh" material="Default Diffuse 1 0.74902 0.74902 0 1 Ambient 1 0.2 0.2 0.2 1 Specular 0 1 1 1 1 Emissive 0 0 0 0 0 Shininess 0 45 " primitiveType="DEFAULT" blendEquation="GL_FUNC_ADD" sfactor="GL_SRC_ALPHA" dfactor="GL_ONE_MINUS_SRC_ALPHA" /> <BarycentricMapping template="Vec3d,ExtVec3f" name="barycentricMap2" input="@.." output="@visual" /> <MeshExporter name="meshExporter3" filename="c:/users/zahra/desktop/livertrianglenew181.gmsh" format="gmsh" edges="0" quads="0" tetras="0" hexas="0" exportEveryNumberOfSteps="1" exportAtBegin="1" exportAtEnd="1" /> </Node>
2. Must I just use OBJexporter, or I can use other exporters such as meshexporter? (I prefer to have it in .gmsh format to avoid mesh converting).
I use a high resolution mesh for behaviour model and a low resolution mesh for visual model.
When I use MeshExporter to export the visual model, the number of nodes of visual model are equal to the number of nodes in the behaviour model. How can I have a low resolution visual model?3. You mean I should look at the force vector in mechanicalobject while I apply a force by mouse? It does not appear in the force vector. Should I export it somehow?
for more information, here you can find the .scn and mesh files:
XML:
https://gist.github.com/zbounik/2efc7c0aa2da1fd5c38ebf60d3eac72bBehviour model:
https://gist.github.com/zbounik/924a6bff9683193477acf23156faee44Visual model:
https://gist.github.com/zbounik/74ea1e1d8e823fbabda6c0e38266171bThank you very much for your kind helps.
Best,
Zahra9 June 2017 at 18:50 #9307HugoKeymasterHey Zahra,
1. Indeed you need a surface mesh. But it is still not working because you need to give the OglModel a OBJ mesh not a msh one.
2. Yes, I would advise to keep the ObjExporter .. try and tell me if it works. Saving a obj as a gmsh is not big deal.
3. The forces should appear in the MechanicalObject. Are you sure the vector is well updated in the GUI ?
Best
Hugo
10 June 2017 at 08:32 #9310ZahraBlockedHi Hugo,
1. It is solved, Thank you.
2. I tried ObjExporter in “TutorialMappingLiverBarycentric.scn” for exporting the visual model: The run window does not open, and just an empty obj file is created, and this warning appeared:
FROM SOFA [OUT] >> [WARNING] [SofaSimulationGraph] the library has not been cleaned up (sofa::simulation::graph::cleanup() has never been called, see sofa/helper/init.h)
3. Um…How I can make sure if the vector is well updated in the GUI? I just open the MechanicalObject and look at the force vector, while at the same time I am applying a force by mouse to the object.
Best,
Zahra
10 June 2017 at 12:18 #9312HugoKeymasterHey Zahra,
1. Goooood !
2. Hmmm I did not really use it for a very long time. Maybe try with another exporter (VRKExporter) and specifying the field of position you want to export.
3. either in the GUI, there is an update button that should allow you to see the updated values (of forces for instance). Another solution would be to activate the flag verbose of your solver (I know it does exist for the EulerImplicit) it will print the position, velocity and force vector !Cheers
Hugo
10 June 2017 at 16:57 #9314ZahraBlockedDear Hugo,
…
2. It seems that vtkexporter is a better choice.
3. Just for giving a feedback: Updating the force vector in MechanicalObject does not make any change in the force vector. Activating the verbose flag, after a few seconds, makes sofa stop working.
So I think I should change my approach to my purpose. Thank you for all your helps.Best regards,
Zahra
-
AuthorPosts
- You must be logged in to reply to this topic.