-
Bruno Marques replied to the topic Bindings python for new data types in the forum Programming with SOFA 3 years, 6 months ago
Alright!
We ended up finding what was missing.
Whiile my new class type was well declared, it wasn’t registered to the PythonFactory, which handles the lookup of typenames to find out if the BaseData* object provided could be downcasted.In order to get the new type registered, a call to
SP_ADD_CLASS_IN_FACTORY(cvMatData,…
[Read more] -
Bruno Marques replied to the topic Bindings python for new data types in the forum Programming with SOFA 3 years, 6 months ago
Hi Lionel,
Thanks for your input!
I did that too. There are bindings for AssembledSystem in the compliant plugin, that is slightly different (it has a constructor and destructor, which uses a different SP_* macro.
But fundamentally, the implementation is the same:1. a
SP_DECLARE_TYPE(MyPythonType)
2. multiple static methods for python with the…[Read more] -
Bruno Marques started the topic Bindings python for new data types in the forum Programming with SOFA 3 years, 6 months ago
Hi!
I am implementing python bindings for a new data type (Opencv matrices), and looked into the image plugin and SofaPython’s bindings for inspiration, but didn’t succeed.
I also implemented this little test scene to check that my bindings work, that looks like this:
With my current implementation (that I…[Read more]
-
Bruno Marques replied to the topic Retrieve Sofa Scene's OpenGL Viewport from within a component in the forum Programming with SOFA 3 years, 6 months ago
Hi @hugo,
Thanks for your reply!
I investigated a bit further and found out a saveScreen() method in helper::gl::Capture.
This function does the screen grab (call to glreadpixels) in runSofa, but will not have the expected behavior in runSofa2.For now, since runSofa2 is not yet fully implemented, I will use runSofa whenever I need this…[Read more]
-
Bruno Marques started the topic Retrieve Sofa Scene's OpenGL Viewport from within a component in the forum Programming with SOFA 3 years, 7 months ago
Hi there,
I’m trying to retrieve the viewport of the scene view inside a SOFA component, but calling glGet(GL_VIEWPORT, &viewport) gives me the viewport of the entire window.
What I need, is the offset and sub-dimensions of the 3D scene view.With runSofa, I could manually compute the offset and thus get the exact Scene dimensions, because the…[Read more]
-
Bruno Marques replied to the topic Create my own "DataTypes" for template components in SOFA in the forum Programming with SOFA 4 years, 1 month ago
Hi,
I finally have the solution to my problem:
In order to create template components in Sofa, there is nothing more to do than overloading the templateName() method, inherited from Base.
The templateName function must simply send back, for each template class, the name you want to use in your scene file, coma separated.usually, your…[Read more]
-
Bruno Marques replied to the topic Create my own "DataTypes" for template components in SOFA in the forum Programming with SOFA 4 years, 1 month ago
Hi,
After a bit more research, I found out I over-complicated things:
I managed to get my templates working by templating my component over the source and destination type directly:
template<class SrcType, class DstType>
and for my own types (the cvKeypoint data structure) I implemented a DataTypeInfo as such:
template <>
[Read more]
struct… -
Bruno Marques replied to the topic Create my own "DataTypes" for template components in SOFA in the forum Programming with SOFA 4 years, 1 month ago
Hi,
After a bit more research, I found out I over-complicated things:
I managed to get my templates working by templating my component over the source and destination type directly:
template<class SrcType, class DstType>
and for my own types (the cvKeypoint data structure) I implemented a DataTypeInfo as such:
template <>
[Read more]
struct… -
Bruno Marques changed their profile picture 4 years, 1 month ago
-
Bruno Marques started the topic Create my own "DataTypes" for template components in SOFA in the forum Programming with SOFA 4 years, 1 month ago
Hi,
I have a few utility engines I implemented in SOFA, that performs type conversions of vector values. (for example SofaVec2iTocvKeypoint and vice versa, where cvKeypoint is a data structure holding a 2D point).
I am not a big fan of my implementation as I have a lot of code duplication for each of these components. I thought of have a single…[Read more]
-
Bruno Marques started the topic Create my own "DataTypes" for template components in SOFA in the forum Programming with SOFA 4 years, 1 month ago
Hi,
I have a few utility engines I implemented in SOFA, that performs type conversions of vector values. (for example SofaVec2iTocvKeypoint and vice versa, where cvKeypoint is a data structure holding a 2D point).
I am not a big fan of my implementation as I have a lot of code duplication for each of these components. I thought of have a single…[Read more]
-
Bruno Marques replied to the topic Preserve graph component's order in the forum Using SOFA 4 years, 1 month ago
Thank you Hugo,
After discussion with some pro users, it happens that my problem is a fake problem:
in the scene example of my first post, I show an example where component 3 and 4 actually depends on the output of Node1 and Node2.So logic would have that my components 3 and 4 would be in a subNode, whose parents are Node1 and Node2.
This is…[Read more]
-
Bruno Marques started the topic Preserve graph component's order in the forum Using SOFA 4 years, 2 months ago
Hi,
I have a scene that looks basically like this:
<Node root>
<Node 1>
<Component1 />
</Node>
<Node 2>
<Component2 />
</Node>
<Component3/>
<Component4 />
</Node>Component 3 uses some data from 1 and 2, and outputs some stuff to Component4.
Each component implements handleEvent() and prints its name when AnimateBeginEvent…[Read more] -
Bruno Marques replied to the topic Link SOFA as an external dependency in a c++ project in the forum Programming with SOFA 4 years, 6 months ago
Hi Jean-Nicolas
Thanks for your quick answer.
I tried what you said, but I got the same issue on windows. Though, I used CMAKE_PREFIX_PATH successfully on Linux, so it must be a CMake issue specific to Windows.Does anyone have any idea why it wouldn’t work on Windows?
Cheers,
Bruno -
Bruno Marques started the topic Link SOFA as an external dependency in a c++ project in the forum Programming with SOFA 4 years, 6 months ago
Hi there,
I would like to use SOFA packages as external dependencies of a c++ program, but can’t figure out how to specify it in my CMake file.
When using a library like OpenCV for instance, it is possible to do a ‘find_package’ after only providing an OpenCV_DIR entry in CMake. I would like to do the same with Sofa, by doing the following:…[Read more]
-
Bruno Marques replied to the topic Take a screenshot automatically with SofaPython in the forum Using SOFA 4 years, 7 months ago
Thank you Hugo,
I found a workaround for now (triggering scrot, a screenshooter utility) from python.
Though I think it can be a very usefull feature to add in Sofa. I will probably create a component for this in a near future 😉Cheers,
Bruno -
Bruno Marques started the topic Take a screenshot automatically with SofaPython in the forum Using SOFA 4 years, 7 months ago
Hi there,
I need to run a serie of parametrized simulations in sofa, that I will launch with sofaPython. These simulations must generate a screenshot. I know I can do that fron runsofa (by pressing “S”), but could it be triggered automatically from SofaPython?
Thanks in advance =)