Repository navigation
Custom ForceField object not created due to incompatible type #3248
|
Having followed the implementation of FanForceField, I encountered several occurrences of the plugin not being successfully created upon loading a scene due to incompatible types. For example, Vec3Types is used here for FanForceField, but it would create issue if the context data type is Rigid3Types. While it's possible to get rid of this error by changing all occurrences of Vec3Types to Rigid3Types, similar issue will arise if the scene context is in Vec3Types. Is there a way to avoid this error entirely and have my custom force field plugin compatible with multiple data types? |
Replies: 1 comment 1 reply
|
Oh oh @YanzhouWang on 🔥 ! 👍 These types are called DataTypes in SOFA. Within one same node, the kind of degree of freedom is supposed to be the same. Therefore, the template of the Template programming of C++ allows us in SOFA to have implementations which support multiple data types. For the FanForceField, the supported templates (here only one) is given in the file : FanForceField.cpp. To get this Forcefield supporting other templates, additional lines should be written, e.g. .add< FanForceField<Rigid3Types> >(true);You can also take a look at the ConstantForceField of SOFA which could be a simple example:
|
Oh oh @YanzhouWang on 🔥 ! 👍
These types are called DataTypes in SOFA.
They are usually defined by the
MechanicalObjectby the Datatemplatewhich corresponds to the kind of degree of freedom which is computed in the simulation (Vec3d, Vec2d, Vec1d, Rigid3d ...).Within one same node, the kind of degree of freedom is supposed to be the same. Therefore, the template of the
MechanicalObjectand the associatedForceFieldmust be the same.Template programming of C++ allows us in SOFA to have implementations which support multiple data types. For the FanForceField, the supported templates (here only one) is given in the file : FanForceField.cpp. To get this Forcefield supporting other template…