- This topic has 2 replies, 2 voices, and was last updated 5 years, 6 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Home › Forum › SOFA › Programming with SOFA › [SOLVED] Compilation error while setValue to d_force in linearFF
Tagged: 64_bits, Linux_ubuntu, SOFA_1712
Hello,
I’m creating a linear force field and facing some difficulties in setting values to its member data (for example in the d_force
attribute).
Firstly, I declare a parameter “initForce” in my component header file:
typedef typename DataTypes::Coord::value_type Real;
Data<Real> initForce;
In the constructor of the component, I initialize it like this:
AwesomeComponent<DataTypes>::AwesomeComponent()
: initForce(initData(&initForce, 0.0, "initForce", "initial applied stretch force to all points"))
Then, I create a linear force field:
forcefield::LinearForceField<defaulttype::Vec3dTypes> tmp_lff;
forcefield::LinearForceField<defaulttype::Vec3dTypes>::SPtr l_forceField;
l_forceField = sofa::core::objectmodel::BaseObject::create<forcefield::LinearForceField<defaulttype::Vec3dTypes>>(&tmp_lff, force_node->getContext(), &lff_objDiscr);
Now when I set the value to the force directly like this:
l_forceField->d_force.setValue(sofa::defaulttype::Vec3dTypes::Coord::value_type(1.0));
Everything is fine!
But, when I set the value using “initForce” parameter (which I read directly from the scene file)
l_forceField->d_force.setValue(initForce);
I got a compilation error:
...AwesomeComponent.inl:305: error: no matching member function for call to 'setValue'
l_forceField->d_force.setValue(initForce);
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
Any hint how to pass the value through “initForce” parameter?
Thanks!
Noura
Solved!
Actually It should be simply :
l_forceField->d_force.setValue(initForce.getValue());
Noura
Thank you for sharing your solution and closing your issue.
Best,
Hugo
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.