Home › Forum › SOFA › Programming with SOFA › Adding new template for MechanicalObject
Tagged: 64_bits, Linux_other, Plugin_other, SOFA_2006, template
- This topic has 4 replies, 3 voices, and was last updated 4 years ago by Froy.
-
AuthorPosts
-
18 September 2020 at 01:31 #17177jjcasmarBlocked
I want to replicate some of the functionality in Flexible plugin, and since I havent been able to make it work properly, I am trying to add some stuff of my own. In particular, I want to add a new template for deformation gradient types (3×3, 3×2, 2×2 and 1×1 matrices) but I am not sure how to create the types so that I can do a MechanicalObject<F33>.
Is there any tutorial on this?
5 October 2020 at 21:33 #17274HugoKeymaster6 October 2020 at 14:32 #17296FroyKeymasterHello,
There is no doc on this because it was not really intended to changeable easily, but could be a good idea to make it .
Anyway, I never really created a new “type” as Vect3Types or Rigid3Types (types instanced with MechanicalObject) but as I could see rapidly, your new “type” needs to implement some conditions/types/functions. For example it has to implement on what is a Coord, what is a Deriv, etc (see the lists of typedef in MechanicalObject.h).
It could be great also to know if you are starting from scratch; or if you already implemented some things and you are stuck on some technicalities.8 October 2020 at 19:06 #17332jjcasmarBlocked@Froy can you provide a bit more details or documentation on how to do this? I am trying to mimic what I see in other types, but I fail to actually make it work. I am having linking errors when I try to load my plugin.
[ERROR] [PluginManager] Plugin loading failed (/home/jjcasmar/projects/VNCSSofaPlugin/build/Debug/lib/libVNCSSofaPlugin.so): /home/jjcasmar/projects/VNCSSofaPlugin/build/Debug/lib/libVNCSSofaPlugin.so: undefined symbol: _ZTv0_n88_N4sofa4core5StateINS_11defaulttype14StdVectorTypesINS2_3VecILi9EdEES5_dEEE9baseWriteENS0_6TVecIdILNS0_7VecTypeE0ELNS0_9VecAccessE1EEE [ERROR] [RequiredPlugin(/home/jjcasmar/projects/VNCSSofaPlugin/build/Debug/lib/libVNCSSofaPlugin.so)] Plugin loading failed (/home/jjcasmar/projects/VNCSSofaPlugin/build/Debug/lib/libVNCSSofaPlugin.so): /home/jjcasmar/projects/VNCSSofaPlugin/build/Debug/lib/libVNCSSofaPlugin.so: undefined symbol: _ZTv0_n88_N4sofa4core5StateINS_11defaulttype14StdVectorTypesINS2_3VecILi9EdEES5_dEEE9baseWriteENS0_6TVecIdILNS0_7VecTypeE0ELNS0_9VecAccessE1EEE
I have tested two approaches:
1) Creating my own type which exposes Eigen::Matrix3d as Coord and Deriv types. Since this looks complicated, I decided to go to case 2
2) Using StdVectorTypes with a Vec9 for Coord and Deriv. This is the case I am trying to make it work right now.Some documentation on this will be really useful. I think that being able to use our own types in MechanicalObject gives a lot of freedom. What I am trying here is not possible wihout a custom templated MechanicalObject…
26 October 2020 at 19:20 #17455FroyKeymasterThere is no documentation right now on how to add a new Type for MechanicalObject.
What I can tell you from your linking error is that you need to include sofa/core/State.inl, as this file defines your missing symbols.
I suppose you did somewhere an instanciation like MechanicalObject. As MechanicalObject inherits State, it will the implementation in State.inl (you can see that State.cpp does an explicit instanciation on all standard datatypes). In any case, we appreciate your feedback and we are considering on writing a how-to on how to add a custom datatype in the future.
-
AuthorPosts
- You must be logged in to reply to this topic.