Home › Forum › SOFA › Using SOFA › [Beginner Question] sofa scenes, plugins and 3rd party applications
Tagged: communication, Linux_ubuntu, plugins, scenes, SOFA_2012
- This topic has 5 replies, 2 voices, and was last updated 3 years, 8 months ago by Alex Bilger.
-
AuthorPosts
-
30 March 2021 at 02:25 #19019OlumideBlocked
Hi,
I’m still relatively new to sofa, about to start creating my first few scenes and plugins, and I’d like to clarify the following issues:
- Can Sofa plugins only be created in C++? I suspect the answer is yes, but I’d like a confirmation.
- Can sofa scenes be defined in C++? I know they can be defined in XML (*.scn) and Python.
- Generally i.e. without specifics, what is the preferred way to integrate sofa with a 3rd party application? Mesh data exchange per time step perhaps? My goal is to farm out simulations to sofa and display the result in the other application.
30 March 2021 at 08:57 #19021Alex BilgerBlockedHi,
most of the plugins are actually written in C++. Check out the applications/plugins folder in the sources: https://github.com/alxbilger/sofa/tree/master/applications/plugins
Sofa scenes can be defined in C++. It’s just a bit more sport to write. If you use Sofa as a library you also have the option to load a xml or python scene and embed it in your application.
I am afraid you will need to make data copies at each time steps.
I don’t know if it’s practically possible with Sofa, but you may benefit from CUDA interoperability with your rendering system, in order to avoid the copies. But it’s a dependencies to Nvidia GPUs.Good luck
Alex
30 March 2021 at 16:30 #19022OlumideBlockedThanks @alexbilger
When you say “most” I take it you mean “some” plugins are written (entirely) in Python. Correct? I’ll search for examples.
Re Sofa scenes in C++: In the absence of an example, my initial guess would be to use sofa::simulation::Node class and follow the pattern in the XML scene files. This might be the preferred option as I am planning to integrate with a 3rd party application that provides a C++ API. Now, whether I run the sofa component as an external process with IPC is a different matter. I’m happy to use CUDA but interoperability with the rendering system is not an option. So I guess its going to be data copies per step, unless anyone has a better idea.
30 March 2021 at 16:42 #19023Alex BilgerBlockedI am not aware of a plugin written entirely in Python.
You are correct. Creating a scene in C++ follows the same description of a graph that is used in the xml scenes, similarly to how the scenes are created in Python.
My advice would be to try data copies first. Triy to minimize the copies. For example, copy only the vertices but not the triangles.
If performances are bad and if you have a very detailed visual model, you can try to implement the mapping in a shader of your main application. In that case, you can copy the mechanical model dofs, which may be faster to copy than the visual model vertices.31 March 2021 at 02:04 #19024OlumideBlockedStill on the subject of interop with a 3rd party application, what would be the standard/preferred way of running Sofa “headlessly”?
I realize that I am trying to use Sofa as an FEM backend, and I don’t know whether its design will permit this.
31 March 2021 at 08:46 #19025Alex BilgerBlockedUncheck the CMake variables related to OpenGL and Qt, and the applications such as RunSofa.
Yes, you can use Sofa as an external library. -
AuthorPosts
- You must be logged in to reply to this topic.