From b5f6420288f6aed7bf62df7233a0385ec4d6623a Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Fri, 20 Sep 2024 16:32:25 +0900 Subject: [PATCH] [MechanicalLoad] Apply new factory registration mechanism (#4983) * apply new register mechanism to mechanicalload * fix unit tests * Apply suggestions from code review (correct description) Co-authored-by: Hugo * Apply suggestions from code review (update descriptions) Co-authored-by: Hugo --------- Co-authored-by: Hugo Co-authored-by: erik pernod --- .../mechanicalload/ConicalForceField.cpp | 10 ++-- .../mechanicalload/ConstantForceField.cpp | 10 ++-- .../DiagonalVelocityDampingForceField.cpp | 19 ++++---- .../mechanicalload/EdgePressureForceField.cpp | 8 ++-- .../mechanicalload/EllipsoidForceField.cpp | 9 ++-- .../sofa/component/mechanicalload/Gravity.cpp | 8 ++-- .../InteractionEllipsoidForceField.cpp | 8 ++-- .../mechanicalload/LinearForceField.cpp | 10 ++-- .../OscillatingTorsionPressureForceField.cpp | 10 ++-- .../mechanicalload/PlaneForceField.cpp | 17 +++---- .../mechanicalload/QuadPressureForceField.cpp | 9 ++-- .../mechanicalload/SphereForceField.cpp | 9 ++-- .../SurfacePressureForceField.cpp | 10 ++-- .../TaitSurfacePressureForceField.cpp | 10 ++-- .../mechanicalload/TorsionForceField.cpp | 9 ++-- .../TrianglePressureForceField.cpp | 9 ++-- .../UniformVelocityDampingForceField.cpp | 35 +++++++------- .../sofa/component/mechanicalload/init.cpp | 47 ++++++++++++++++++- .../tests/ConstantForceField_test.cpp | 1 + .../tests/PlaneForceField_test.cpp | 9 +++- Sofa/Component/src/sofa/component/init.cpp | 1 + 21 files changed, 163 insertions(+), 95 deletions(-) diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.cpp index c3199790730..1e43fa94fac 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.cpp @@ -29,11 +29,11 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; - -int ConicalForceFieldClass = core::RegisterObject("Repulsion applied by a cone toward the exterior") - .add< ConicalForceField >() - - ; +void registerConicalForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Outward repulsion applied by a cone geometry.") + .add< ConicalForceField >()); +} template class ConicalForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.cpp index e21d7a58001..c23afd22a42 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.cpp @@ -37,17 +37,17 @@ SReal ConstantForceField::getPotentialEnergy(const cor template <> SOFA_COMPONENT_MECHANICALLOAD_API SReal ConstantForceField::getPotentialEnergy(const core::MechanicalParams*, const DataVecCoord& ) const { return 0; } - - -int ConstantForceFieldClass = core::RegisterObject("Constant forces applied to given degrees of freedom") +void registerConstantForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Constant forces applied to given degrees of freedom.") .add< ConstantForceField >() .add< ConstantForceField >() .add< ConstantForceField >() .add< ConstantForceField >() .add< ConstantForceField >() - .add< ConstantForceField >() + .add< ConstantForceField >()); +} - ; template class SOFA_COMPONENT_MECHANICALLOAD_API ConstantForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API ConstantForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API ConstantForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/DiagonalVelocityDampingForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/DiagonalVelocityDampingForceField.cpp index ff44e31cd8c..9730af28897 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/DiagonalVelocityDampingForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/DiagonalVelocityDampingForceField.cpp @@ -31,15 +31,16 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int DiagonalVelocityDampingForceFieldClass = core::RegisterObject("Diagonal velocity damping") -.add< DiagonalVelocityDampingForceField >() -.add< DiagonalVelocityDampingForceField >() -.add< DiagonalVelocityDampingForceField >() -.add< DiagonalVelocityDampingForceField >() -.add< DiagonalVelocityDampingForceField >() -.add< DiagonalVelocityDampingForceField >() - -; +void registerDiagonalVelocityDampingForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Diagonal velocity damping.") + .add< DiagonalVelocityDampingForceField >() + .add< DiagonalVelocityDampingForceField >() + .add< DiagonalVelocityDampingForceField >() + .add< DiagonalVelocityDampingForceField >() + .add< DiagonalVelocityDampingForceField >() + .add< DiagonalVelocityDampingForceField >()); +} template class SOFA_COMPONENT_MECHANICALLOAD_API DiagonalVelocityDampingForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API DiagonalVelocityDampingForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.cpp index 66f559b9a40..b0218f0128a 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.cpp @@ -30,9 +30,11 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int EdgePressureForceFieldClass = core::RegisterObject("Apply a force on edges, distributed on the edge nodes") - .add< EdgePressureForceField >() - ; +void registerEdgePressureForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Apply a force on edges, distributed on the edge nodes.") + .add< EdgePressureForceField >()); +} template class SOFA_COMPONENT_MECHANICALLOAD_API EdgePressureForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.cpp index 2f2f7f07d42..96565119b1b 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.cpp @@ -30,13 +30,14 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int EllipsoidForceFieldClass = core::RegisterObject("Repulsion applied by an ellipsoid toward the exterior or the interior") - +void registerEllipsoidForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Outward / inward repulsion applied by an ellipsoid geometry.") .add< EllipsoidForceField >() .add< EllipsoidForceField >() - .add< EllipsoidForceField >() + .add< EllipsoidForceField >()); +} - ; template class SOFA_COMPONENT_MECHANICALLOAD_API EllipsoidForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API EllipsoidForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API EllipsoidForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/Gravity.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/Gravity.cpp index 155a48e59da..8ff97e10d36 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/Gravity.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/Gravity.cpp @@ -43,8 +43,10 @@ void Gravity::apply() getContext()->setGravity( f_gravity.getValue() ); } -int GravityClass = core::RegisterObject("Gravity in world coordinates") - .add< Gravity >() - ; +void registerGravity(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Gravity in world coordinates.") + .add< Gravity >()); +} } // namespace sofa::component::mechanicalload diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.cpp index 7aeb6ab3afd..4be67f8e0a3 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.cpp @@ -30,9 +30,11 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int InteractionEllipsoidForceFieldClass = core::RegisterObject("Repulsion applied by an ellipsoid toward the exterior or the interior") - .add< InteractionEllipsoidForceField >() - ; +void registerInteractionEllipsoidForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Outward / inward repulsion applied by an ellipsoid geometry, which can possibly act on several objects.") + .add< InteractionEllipsoidForceField >()); +} template class SOFA_COMPONENT_MECHANICALLOAD_API InteractionEllipsoidForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.cpp index 06cb2b18616..5a51209ab55 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.cpp @@ -30,21 +30,21 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int LinearForceFieldClass = core::RegisterObject("Linearly interpolated force applied to given degrees of freedom") +void registerLinearForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Linearly-interpolated force applied to given degrees of freedom.") .add< LinearForceField >() .add< LinearForceField >() .add< LinearForceField >() .add< LinearForceField >() - .add< LinearForceField >() -// .add< LinearForceField >() + .add< LinearForceField >()); +} - ; template class SOFA_COMPONENT_MECHANICALLOAD_API LinearForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API LinearForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API LinearForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API LinearForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API LinearForceField; -// template class SOFA_COMPONENT_MECHANICALLOAD_API LinearForceField; template <> diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/OscillatingTorsionPressureForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/OscillatingTorsionPressureForceField.cpp index b4be5090280..4203a8d4c54 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/OscillatingTorsionPressureForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/OscillatingTorsionPressureForceField.cpp @@ -30,11 +30,11 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; - -int OscillatingTorsionPressureForceFieldClass = core::RegisterObject("OscillatingTorsionPressure") - .add< OscillatingTorsionPressureForceField >() - - ; +void registerOscillatingTorsionPressureForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("OscillatingTorsionPressure.") + .add< OscillatingTorsionPressureForceField >()); +} template class SOFA_COMPONENT_MECHANICALLOAD_API OscillatingTorsionPressureForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.cpp index 7afe84e5e95..dd8b3d050ce 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.cpp @@ -30,14 +30,15 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int PlaneForceFieldClass = core::RegisterObject("Repulsion applied by a plane toward the exterior (half-space)") -.add< PlaneForceField >() -.add< PlaneForceField >() -.add< PlaneForceField >() -.add< PlaneForceField >() -.add< PlaneForceField >() - -; +void registerPlaneForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Repulsion along the normal to a plane.") + .add< PlaneForceField >() + .add< PlaneForceField >() + .add< PlaneForceField >() + .add< PlaneForceField >() + .add< PlaneForceField >()); +} template class SOFA_COMPONENT_MECHANICALLOAD_API PlaneForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API PlaneForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API PlaneForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.cpp index 8f5bc3e4108..bcdf50e94d3 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.cpp @@ -30,10 +30,11 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int QuadPressureForceFieldClass = core::RegisterObject("QuadPressure") - .add< QuadPressureForceField >() - - ; +void registerQuadPressureForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Pressure applied on a quadrangular geometry.") + .add< QuadPressureForceField >()); +} template class SOFA_COMPONENT_MECHANICALLOAD_API QuadPressureForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.cpp index ebca20db983..0cc3205ab65 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.cpp @@ -29,13 +29,14 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; - -int SphereForceFieldClass = core::RegisterObject("Repulsion applied by a sphere toward the exterior") +void registerSphereForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Outward repulsion applied by a sphere geometry") .add< SphereForceField >() .add< SphereForceField >() - .add< SphereForceField >() + .add< SphereForceField >()); +} - ; template class SOFA_COMPONENT_MECHANICALLOAD_API SphereForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API SphereForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API SphereForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.cpp index cb5f14d240a..1bd72153c26 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.cpp @@ -218,12 +218,14 @@ template <> void SurfacePressureForceField::verifyDerivative(VecDeriv& /*v_plus*/, VecDeriv& /*v*/, VecVec3DerivValues& /*DVval*/, VecVec3DerivIndices& /*DVind*/, const VecDeriv& /*Din*/) {} - using namespace sofa::defaulttype; -int SurfacePressureForceFieldClass = core::RegisterObject("SurfacePressure") - .add >() - .add >(); +void registerSurfacePressureForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Pressure applied on a generic surface (triangular or quadrangular).") + .add >() + .add >()); +} template class SOFA_COMPONENT_MECHANICALLOAD_API SurfacePressureForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API SurfacePressureForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.cpp index 5a9a0034cbc..a9ac4ee9d9a 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.cpp @@ -29,17 +29,17 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int TaitSurfacePressureForceFieldClass = core::RegisterObject("\ +void registerTaitSurfacePressureForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("\ This component computes the volume enclosed by a surface mesh \ and apply a pressure force following Tait's equation: $P = P_0 - B((V/V_0)^\\gamma - 1)$.\n\ This ForceField can be used to apply :\n\ * a constant pressure (set $B=0$ and use $P_0$)\n\ * an ideal gas pressure (set $\\gamma=1$ and use $B$)\n\ * a pressure from water (set $\\gamma=7$ and use $B$)") - .add< TaitSurfacePressureForceField >() - - ; - + .add< TaitSurfacePressureForceField >()); +} template class SOFA_COMPONENT_MECHANICALLOAD_API TaitSurfacePressureForceField; } // namespace sofa::component::mechanicalload diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.cpp index fff116937ba..f55f5429e78 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.cpp @@ -30,11 +30,12 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int TorsionForceFieldClass = core::RegisterObject("Applies a torque to specified points") +void registerTorsionForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Applies a torque to specified degrees of freedom.") .add< TorsionForceField >() - .add< TorsionForceField >() - -; + .add< TorsionForceField >()); +} template class SOFA_COMPONENT_MECHANICALLOAD_API TorsionForceField; template class SOFA_COMPONENT_MECHANICALLOAD_API TorsionForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.cpp index be048943b9f..fa0c81be6d1 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.cpp @@ -30,10 +30,11 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int TrianglePressureForceFieldClass = core::RegisterObject("TrianglePressure") - .add< TrianglePressureForceField >() - - ; +void registerTrianglePressureForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Pressure applied on a triangular geometry.") + .add< TrianglePressureForceField >()); +} template class SOFA_COMPONENT_MECHANICALLOAD_API TrianglePressureForceField; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/UniformVelocityDampingForceField.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/UniformVelocityDampingForceField.cpp index c53d069fe1e..97462e4e3c3 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/UniformVelocityDampingForceField.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/UniformVelocityDampingForceField.cpp @@ -31,23 +31,22 @@ namespace sofa::component::mechanicalload using namespace sofa::defaulttype; -int UniformVelocityDampingForceFieldClass = core::RegisterObject("Uniform velocity damping") -.add< UniformVelocityDampingForceField >() -.add< UniformVelocityDampingForceField >() -.add< UniformVelocityDampingForceField >() -.add< UniformVelocityDampingForceField >() -.add< UniformVelocityDampingForceField >() -.add< UniformVelocityDampingForceField >() - -; - - - template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; - template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; - template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; - template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; - template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; - template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; - +void registerUniformVelocityDampingForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Uniform velocity damping.") + .add< UniformVelocityDampingForceField >() + .add< UniformVelocityDampingForceField >() + .add< UniformVelocityDampingForceField >() + .add< UniformVelocityDampingForceField >() + .add< UniformVelocityDampingForceField >() + .add< UniformVelocityDampingForceField >()); +} + +template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; +template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; +template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; +template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; +template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; +template class SOFA_COMPONENT_MECHANICALLOAD_API UniformVelocityDampingForceField; } // namespace sofa::component::mechanicalload diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/init.cpp b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/init.cpp index d75ac38e91f..f72ad9ff58b 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/init.cpp +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/init.cpp @@ -21,13 +21,34 @@ ******************************************************************************/ #include #include +#include + namespace sofa::component::mechanicalload { - + +extern void registerConicalForceField(sofa::core::ObjectFactory* factory); +extern void registerConstantForceField(sofa::core::ObjectFactory* factory); +extern void registerDiagonalVelocityDampingForceField(sofa::core::ObjectFactory* factory); +extern void registerEdgePressureForceField(sofa::core::ObjectFactory* factory); +extern void registerEllipsoidForceField(sofa::core::ObjectFactory* factory); +extern void registerGravity(sofa::core::ObjectFactory* factory); +extern void registerInteractionEllipsoidForceField(sofa::core::ObjectFactory* factory); +extern void registerLinearForceField(sofa::core::ObjectFactory* factory); +extern void registerOscillatingTorsionPressureForceField(sofa::core::ObjectFactory* factory); +extern void registerPlaneForceField(sofa::core::ObjectFactory* factory); +extern void registerQuadPressureForceField(sofa::core::ObjectFactory* factory); +extern void registerSphereForceField(sofa::core::ObjectFactory* factory); +extern void registerSurfacePressureForceField(sofa::core::ObjectFactory* factory); +extern void registerTaitSurfacePressureForceField(sofa::core::ObjectFactory* factory); +extern void registerTorsionForceField(sofa::core::ObjectFactory* factory); +extern void registerTrianglePressureForceField(sofa::core::ObjectFactory* factory); +extern void registerUniformVelocityDampingForceField(sofa::core::ObjectFactory* factory); + extern "C" { SOFA_EXPORT_DYNAMIC_LIBRARY void initExternalModule(); SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleName(); SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleVersion(); + SOFA_EXPORT_DYNAMIC_LIBRARY void registerObjects(sofa::core::ObjectFactory* factory); } void initExternalModule() @@ -45,11 +66,35 @@ const char* getModuleVersion() return MODULE_VERSION; } +void registerObjects(sofa::core::ObjectFactory* factory) +{ + registerConicalForceField(factory); + registerConstantForceField(factory); + registerDiagonalVelocityDampingForceField(factory); + registerEdgePressureForceField(factory); + registerEllipsoidForceField(factory); + registerGravity(factory); + registerInteractionEllipsoidForceField(factory); + registerLinearForceField(factory); + registerOscillatingTorsionPressureForceField(factory); + registerPlaneForceField(factory); + registerQuadPressureForceField(factory); + registerSphereForceField(factory); + registerSurfacePressureForceField(factory); + registerTaitSurfacePressureForceField(factory); + registerTorsionForceField(factory); + registerTrianglePressureForceField(factory); + registerUniformVelocityDampingForceField(factory); +} + void init() { static bool first = true; if (first) { + // make sure that this plugin is registered into the PluginManager + sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME); + first = false; } } diff --git a/Sofa/Component/MechanicalLoad/tests/ConstantForceField_test.cpp b/Sofa/Component/MechanicalLoad/tests/ConstantForceField_test.cpp index 1fb8e0807d5..c182c7d8e38 100644 --- a/Sofa/Component/MechanicalLoad/tests/ConstantForceField_test.cpp +++ b/Sofa/Component/MechanicalLoad/tests/ConstantForceField_test.cpp @@ -76,6 +76,7 @@ struct ConstantForceField_test : public BaseSimulationTest, NumericTest +#include + #include #include @@ -114,7 +116,12 @@ struct PlaneForceField_test : public BaseSimulationTest * by the plane force field. * In the special case where : stiffness = 500, damping = 5 and maxForce = 0 (default values) */ - void SetUp() override {} + void SetUp() override + { + sofa::simpleapi::importPlugin("Sofa.Component.StateContainer"); + sofa::simpleapi::importPlugin("Sofa.Component.MechanicalLoad"); + } + void TearDown() override {} void setupDefaultScene() diff --git a/Sofa/Component/src/sofa/component/init.cpp b/Sofa/Component/src/sofa/component/init.cpp index 76a6d404440..783ca1c1aeb 100644 --- a/Sofa/Component/src/sofa/component/init.cpp +++ b/Sofa/Component/src/sofa/component/init.cpp @@ -79,6 +79,7 @@ void registerObjects(sofa::core::ObjectFactory* factory) factory->registerObjectsFromPlugin("Sofa.Component.Visual"); factory->registerObjectsFromPlugin("Sofa.Component.Playback"); factory->registerObjectsFromPlugin("Sofa.Component.SceneUtility"); + factory->registerObjectsFromPlugin("Sofa.Component.MechanicalLoad"); factory->registerObjectsFromPlugin("Sofa.Component.LinearSystem"); factory->registerObjectsFromPlugin("Sofa.Component.IO"); factory->registerObjectsFromPlugin("Sofa.Component.Controller");