From b830c798eab33301d1ff105d0cfb12f441d6c3a3 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Thu, 10 Oct 2024 09:19:58 +0900 Subject: [PATCH 1/4] apply new register mechanism to solidmechanics --- .../fem/elastic/BeamFEMForceField.cpp | 19 ++++--- .../FastTetrahedralCorotationalForceField.cpp | 10 ++-- .../fem/elastic/HexahedralFEMForceField.cpp | 10 ++-- .../HexahedralFEMForceFieldAndMass.cpp | 11 ++-- .../fem/elastic/HexahedronFEMForceField.cpp | 11 ++-- .../HexahedronFEMForceFieldAndMass.cpp | 11 ++-- .../fem/elastic/QuadBendingFEMForceField.cpp | 8 +-- .../TetrahedralCorotationalFEMForceField.cpp | 11 ++-- .../fem/elastic/TetrahedronFEMForceField.cpp | 11 ++-- .../fem/elastic/TriangleFEMForceField.cpp | 10 ++-- .../TriangularAnisotropicFEMForceField.cpp | 10 ++-- .../fem/elastic/TriangularFEMForceField.cpp | 10 ++-- .../elastic/TriangularFEMForceFieldOptim.cpp | 10 ++-- .../solidmechanics/fem/elastic/init.cpp | 39 +++++++++++++- .../StandardTetrahedralFEMForceField.cpp | 10 ++-- ...etrahedronHyperelasticityFEMForceField.cpp | 12 ++--- .../solidmechanics/fem/hyperelastic/init.cpp | 18 ++++++- .../hyperelastic/material/PlasticMaterial.cpp | 18 +++++-- ...exahedronCompositeFEMForceFieldAndMass.cpp | 12 ++--- .../HexahedronCompositeFEMMapping.cpp | 15 ++---- ...nUniformHexahedralFEMForceFieldAndMass.cpp | 10 ++-- ...nUniformHexahedronFEMForceFieldAndMass.cpp | 11 ++-- .../solidmechanics/fem/nonuniform/init.cpp | 37 ++++++++++---- .../component/solidmechanics/fem/init.cpp | 13 +++++ .../spring/AngularSpringForceField.cpp | 9 ++-- .../spring/FastTriangularBendingSprings.cpp | 12 ++--- .../spring/FrameSpringForceField.cpp | 13 ++--- .../spring/GearSpringForceField.cpp | 12 ++--- .../spring/JointSpringForceField.cpp | 13 ++--- .../spring/MeshSpringForceField.cpp | 10 ++-- .../PolynomialRestShapeSpringsForceField.cpp | 11 ++-- .../spring/PolynomialSpringsForceField.cpp | 10 ++-- .../spring/QuadBendingSprings.cpp | 12 ++--- .../spring/QuadularBendingSprings.cpp | 12 ++--- .../spring/RegularGridSpringForceField.cpp | 11 ++-- .../spring/RepulsiveSpringForceField.cpp | 9 ++-- .../spring/RestShapeSpringsForceField.cpp | 11 ++-- .../spring/SpringForceField.cpp | 10 ++-- .../spring/TriangleBendingSprings.cpp | 10 ++-- .../spring/TriangularBendingSprings.cpp | 12 ++--- ...TriangularBiquadraticSpringsForceField.cpp | 10 ++-- .../TriangularQuadraticSpringsForceField.cpp | 13 ++--- .../spring/VectorSpringForceField.cpp | 11 ++-- .../component/solidmechanics/spring/init.cpp | 51 ++++++++++++++++++- .../TetrahedralTensorMassForceField.cpp | 10 ++-- .../TriangularTensorMassForceField.cpp | 12 ++--- .../solidmechanics/tensormass/init.cpp | 17 ++++++- .../sofa/component/solidmechanics/init.cpp | 18 ++++++- Sofa/Component/src/sofa/component/init.cpp | 1 + 49 files changed, 399 insertions(+), 258 deletions(-) diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.cpp index ef82818aa5b..cad84bcd07f 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.cpp @@ -25,17 +25,22 @@ #include -namespace sofa::component::solidmechanics::fem::elastic::_beamfemforcefield_ +namespace sofa::component::solidmechanics::fem::elastic { using namespace sofa::defaulttype; -// Register in the Factory -int BeamFEMForceFieldClass = core::RegisterObject("Beam finite elements") - .add< BeamFEMForceField >() - ; +void registerBeamFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Beam finite elements.") + .add< BeamFEMForceField >()); +} + +namespace _beamfemforcefield_ +{ -template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API BeamFEMForceField; + template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API BeamFEMForceField; +} // namespace _beamfemforcefield_ -} // namespace sofa::component::solidmechanics::fem::elastic::_beamfemforcefield_ \ No newline at end of file +} // namespace sofa::component::solidmechanics::fem::elastic \ No newline at end of file diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.cpp index 3d039596916..b53d9746a7e 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.cpp @@ -31,11 +31,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; -// Register in the Factory -int FastTetrahedralCorotationalForceFieldClass = core::RegisterObject("Fast Corotational Tetrahedral Mesh") - .add< FastTetrahedralCorotationalForceField >() - - ; +void registerFastTetrahedralCorotationalForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Fast Corotational Tetrahedral Mesh.") + .add< FastTetrahedralCorotationalForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API FastTetrahedralCorotationalForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.cpp index 918d7ffa755..8f1861c8d33 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.cpp @@ -30,11 +30,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; -// Register in the Factory -int HexahedralFEMForceFieldClass = core::RegisterObject("Hexahedral finite elements") - .add< HexahedralFEMForceField >() - - ; +void registerHexahedralFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Hexahedral finite elements.") + .add< HexahedralFEMForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API HexahedralFEMForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.cpp index e7e2606db6d..bb5d20549a4 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.cpp @@ -30,12 +30,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; - -// Register in the Factory -int HexahedralFEMForceFieldAndMassClass = core::RegisterObject("Hexahedral finite elements with mass") - .add< HexahedralFEMForceFieldAndMass >() - - ; +void registerHexahedralFEMForceFieldAndMass(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Hexahedral finite elements with mass") + .add< HexahedralFEMForceFieldAndMass >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API HexahedralFEMForceFieldAndMass; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.cpp index 7e17d08bdd9..d0a796b234d 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.cpp @@ -30,12 +30,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; - -// Register in the Factory -int HexahedronFEMForceFieldClass = core::RegisterObject("Hexahedral finite elements") - .add< HexahedronFEMForceField >() - - ; +void registerHexahedronFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Hexahedral finite elements.") + .add< HexahedronFEMForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API HexahedronFEMForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.cpp index 983b9b54257..79e828ac592 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.cpp @@ -29,12 +29,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; - -// Register in the Factory -int HexahedronFEMForceFieldAndMassClass = core::RegisterObject("Hexahedral finite elements with mass") - .add< HexahedronFEMForceFieldAndMass >() - - ; +void registerHexahedronFEMForceFieldAndMass(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Hexahedral finite elements with mass.") + .add< HexahedronFEMForceFieldAndMass >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API HexahedronFEMForceFieldAndMass; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/QuadBendingFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/QuadBendingFEMForceField.cpp index 6a4303787e1..e28740b453a 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/QuadBendingFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/QuadBendingFEMForceField.cpp @@ -34,9 +34,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; -// Register in the Factory -int QuadBendingFEMForceFieldClass = core::RegisterObject("Bending Quad finite elements") - .add< QuadBendingFEMForceField >(); +void registerQuadBendingFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Bending Quad finite elements") + .add< QuadBendingFEMForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API QuadBendingFEMForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.cpp index 9c11046c345..3d88496861e 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.cpp @@ -31,12 +31,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; - -// Register in the Factory -int TetrahedralCorotationalFEMForceFieldClass = core::RegisterObject("Corotational FEM Tetrahedral finite elements") - .add< TetrahedralCorotationalFEMForceField >() - - ; +void registerTetrahedralCorotationalFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Corotational FEM Tetrahedral finite elements") + .add< TetrahedralCorotationalFEMForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API TetrahedralCorotationalFEMForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedronFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedronFEMForceField.cpp index c44b23cb750..853c16850f8 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedronFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedronFEMForceField.cpp @@ -31,12 +31,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; - -// Register in the Factory -int TetrahedronFEMForceFieldClass = core::RegisterObject("Tetrahedral finite elements") - .add< TetrahedronFEMForceField >() - - ; +void registerTetrahedronFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Tetrahedral finite elements.") + .add< TetrahedronFEMForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API TetrahedronFEMForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangleFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangleFEMForceField.cpp index adb055b891b..6bb56243188 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangleFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangleFEMForceField.cpp @@ -31,11 +31,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; -// Register in the Factory -int TriangleFEMForceFieldClass = core::RegisterObject("Triangular finite elements for static topology") - .add< TriangleFEMForceField >() - - ; +void registerTriangleFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Triangular finite elements for static topology.") + .add< TriangleFEMForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API TriangleFEMForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularAnisotropicFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularAnisotropicFEMForceField.cpp index 94c3bedb4b7..a0df8632e60 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularAnisotropicFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularAnisotropicFEMForceField.cpp @@ -29,11 +29,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; -// Register in the Factory -int TriangularAnisotropicFEMForceFieldClass = core::RegisterObject("Triangular finite element model using anisotropic material") - .add< TriangularAnisotropicFEMForceField >() - - ; +void registerTriangularAnisotropicFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Triangular finite element model using anisotropic material.") + .add< TriangularAnisotropicFEMForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API TriangularAnisotropicFEMForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.cpp index 05407aa7d17..6224c5da527 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.cpp @@ -32,11 +32,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; -// Register in the Factory -int TriangularFEMForceFieldClass = core::RegisterObject("Corotational Triangular finite elements for dynamic topology") - .add< TriangularFEMForceField >() - - ; +void registerTriangularFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Corotational Triangular finite elements for dynamic topology.") + .add< TriangularFEMForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API TriangularFEMForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceFieldOptim.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceFieldOptim.cpp index e0c76616e40..5b31f4ce4d5 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceFieldOptim.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceFieldOptim.cpp @@ -30,11 +30,11 @@ namespace sofa::component::solidmechanics::fem::elastic using namespace sofa::defaulttype; -// Register in the Factory -int TriangularFEMForceFieldOptimClass = core::RegisterObject("Corotational Triangular finite elements") - .add< TriangularFEMForceFieldOptim >() - - ; +void registerTriangularFEMForceFieldOptim(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Corotational Triangular finite elements.") + .add< TriangularFEMForceFieldOptim >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API TriangularFEMForceFieldOptim; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/init.cpp b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/init.cpp index 5cb273e843a..db73328f65e 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/init.cpp +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/init.cpp @@ -21,13 +21,30 @@ ******************************************************************************/ #include #include +#include + namespace sofa::component::solidmechanics::fem::elastic { - + +extern void registerBeamFEMForceField(sofa::core::ObjectFactory* factory); +extern void registerFastTetrahedralCorotationalForceField(sofa::core::ObjectFactory* factory); +extern void registerHexahedralFEMForceField(sofa::core::ObjectFactory* factory); +extern void registerHexahedralFEMForceFieldAndMass(sofa::core::ObjectFactory* factory); +extern void registerHexahedronFEMForceField(sofa::core::ObjectFactory* factory); +extern void registerHexahedronFEMForceFieldAndMass(sofa::core::ObjectFactory* factory); +extern void registerQuadBendingFEMForceField(sofa::core::ObjectFactory* factory); +extern void registerTetrahedralCorotationalFEMForceField(sofa::core::ObjectFactory* factory); +extern void registerTetrahedronFEMForceField(sofa::core::ObjectFactory* factory); +extern void registerTriangleFEMForceField(sofa::core::ObjectFactory* factory); +extern void registerTriangularAnisotropicFEMForceField(sofa::core::ObjectFactory* factory); +extern void registerTriangularFEMForceField(sofa::core::ObjectFactory* factory); +extern void registerTriangularFEMForceFieldOptim(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 +62,31 @@ const char* getModuleVersion() return MODULE_VERSION; } +void registerObjects(sofa::core::ObjectFactory* factory) +{ + registerBeamFEMForceField(factory); + registerFastTetrahedralCorotationalForceField(factory); + registerHexahedralFEMForceField(factory); + registerHexahedralFEMForceFieldAndMass(factory); + registerHexahedronFEMForceField(factory); + registerHexahedronFEMForceFieldAndMass(factory); + registerQuadBendingFEMForceField(factory); + registerTetrahedralCorotationalFEMForceField(factory); + registerTetrahedronFEMForceField(factory); + registerTriangleFEMForceField(factory); + registerTriangularAnisotropicFEMForceField(factory); + registerTriangularFEMForceField(factory); + registerTriangularFEMForceFieldOptim(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/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.cpp index e51180f60cc..24aa7522ae4 100644 --- a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.cpp @@ -31,11 +31,11 @@ namespace sofa::component::solidmechanics::fem::hyperelastic using namespace sofa::defaulttype; -// Register in the Factory -int StandardTetrahedralFEMForceFieldClass = core::RegisterObject("Generic Tetrahedral finite elements") -.add< StandardTetrahedralFEMForceField >() - -; +void registerStandardTetrahedralFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Generic Tetrahedral finite elements.") + .add< StandardTetrahedralFEMForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_HYPERELASTIC_API StandardTetrahedralFEMForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.cpp b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.cpp index 804a8d681ff..77af2c6b2dd 100644 --- a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.cpp +++ b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.cpp @@ -31,13 +31,11 @@ namespace sofa::component::solidmechanics::fem::hyperelastic using namespace sofa::defaulttype; -//////////****************To register in the factory****************** - -// Register in the Factory -int TetrahedronHyperelasticityFEMForceFieldClass = core::RegisterObject("Generic Tetrahedral finite elements") -.add< TetrahedronHyperelasticityFEMForceField >() - -; +void registerTetrahedronHyperelasticityFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Generic Hyperelastic Tetrahedral finite elements.") + .add< TetrahedronHyperelasticityFEMForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_HYPERELASTIC_API TetrahedronHyperelasticityFEMForceField; diff --git a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/init.cpp b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/init.cpp index c26f27ac8d9..10d9577fb07 100644 --- a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/init.cpp +++ b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/init.cpp @@ -21,13 +21,19 @@ ******************************************************************************/ #include #include +#include + namespace sofa::component::solidmechanics::fem::hyperelastic { - + extern void registerPlasticMaterial(sofa::core::ObjectFactory* factory); + extern void registerStandardTetrahedralFEMForceField(sofa::core::ObjectFactory* factory); + extern void registerTetrahedronHyperelasticityFEMForceField(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 +51,21 @@ const char* getModuleVersion() return MODULE_VERSION; } +void registerObjects(sofa::core::ObjectFactory* factory) +{ + registerPlasticMaterial(factory); + registerStandardTetrahedralFEMForceField(factory); + registerTetrahedronHyperelasticityFEMForceField(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/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/material/PlasticMaterial.cpp b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/material/PlasticMaterial.cpp index 0668c960b85..58ab6a5e6c8 100644 --- a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/material/PlasticMaterial.cpp +++ b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/material/PlasticMaterial.cpp @@ -24,7 +24,11 @@ #include #include #include -namespace sofa::component::solidmechanics::fem::hyperelastic::material + +namespace sofa::component::solidmechanics::fem::hyperelastic +{ + +namespace material { PlasticMaterial::PlasticMaterial() @@ -112,8 +116,12 @@ void PlasticMaterial::computeStressOnSection(Vec3& Stress, Vec3 Strain, int sect } -int PlasticMaterialClass = core::RegisterObject("Plastic material") -.add< PlasticMaterial >() -; +} // namespace material + +void registerPlasticMaterial(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Plastic material.") + .add< material::PlasticMaterial >()); +} -} // namespace sofa::component::solidmechanics::fem::hyperelastic::material +} // namespace sofa::component::solidmechanics::fem::hyperelastic diff --git a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/HexahedronCompositeFEMForceFieldAndMass.cpp b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/HexahedronCompositeFEMForceFieldAndMass.cpp index f32eb7950ef..7cd06b2985e 100644 --- a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/HexahedronCompositeFEMForceFieldAndMass.cpp +++ b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/HexahedronCompositeFEMForceFieldAndMass.cpp @@ -33,14 +33,12 @@ using namespace sofa::core; namespace sofa::component::solidmechanics::fem::nonuniform { - -// Register in the Factory -int HexahedronCompositeFEMForceFieldAndMassClass = RegisterObject("Non uniform Hexahedral finite elements") - .add< HexahedronCompositeFEMForceFieldAndMass >() - - ; +void registerHexahedronCompositeFEMForceFieldAndMass(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Non uniform Hexahedral finite elements.") + .add< HexahedronCompositeFEMForceFieldAndMass >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_NONUNIFORM_API HexahedronCompositeFEMForceFieldAndMass; - } // namespace sofa::component::solidmechanics::fem::nonuniform diff --git a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/HexahedronCompositeFEMMapping.cpp b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/HexahedronCompositeFEMMapping.cpp index 932f6af7ad6..9e90d561539 100644 --- a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/HexahedronCompositeFEMMapping.cpp +++ b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/HexahedronCompositeFEMMapping.cpp @@ -32,17 +32,12 @@ using namespace defaulttype; using namespace core; using namespace core::behavior; - -// Register in the Factory -int HexahedronCompositeFEMMappingClass = core::RegisterObject("Set the point to the center of mass of the DOFs it is attached to") - .add< HexahedronCompositeFEMMapping< Mapping< Vec3Types, Vec3Types > > >() - -// - - ; +void registerHexahedronCompositeFEMMapping(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Set the point to the center of mass of the DOFs it is attached to.") + .add< HexahedronCompositeFEMMapping< Mapping< Vec3Types, Vec3Types > > >()); +} template class HexahedronCompositeFEMMapping< Mapping< Vec3Types, Vec3Types > >; - - } // namespace sofa::component::solidmechanics::fem::nonuniform diff --git a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedralFEMForceFieldAndMass.cpp b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedralFEMForceFieldAndMass.cpp index 6e6e7cd55d5..82c184871e0 100644 --- a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedralFEMForceFieldAndMass.cpp +++ b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedralFEMForceFieldAndMass.cpp @@ -31,11 +31,11 @@ using namespace sofa::core; namespace sofa::component::solidmechanics::fem::nonuniform { -// Register in the Factory -int NonUniformHexahedralFEMForceFieldAndMassClass = RegisterObject("Non uniform Hexahedral finite elements") - .add< NonUniformHexahedralFEMForceFieldAndMass >() - - ; +void registerNonUniformHexahedralFEMForceFieldAndMass(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Non uniform Hexahedral finite elements.") + .add< NonUniformHexahedralFEMForceFieldAndMass >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_NONUNIFORM_API NonUniformHexahedralFEMForceFieldAndMass; diff --git a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedronFEMForceFieldAndMass.cpp b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedronFEMForceFieldAndMass.cpp index 14b87a58b5c..f318909f1a6 100644 --- a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedronFEMForceFieldAndMass.cpp +++ b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/NonUniformHexahedronFEMForceFieldAndMass.cpp @@ -31,12 +31,11 @@ using namespace sofa::core; namespace sofa::component::solidmechanics::fem::nonuniform { - -// Register in the Factory -int NonUniformHexahedronFEMForceFieldAndMassClass = RegisterObject("Non uniform Hexahedral finite elements") - .add< NonUniformHexahedronFEMForceFieldAndMass >() - - ; +void registerNonUniformHexahedronFEMForceFieldAndMass(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Non uniform Hexahedral finite elements.") + .add< NonUniformHexahedronFEMForceFieldAndMass >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_NONUNIFORM_API NonUniformHexahedronFEMForceFieldAndMass; diff --git a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/init.cpp b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/init.cpp index efa2f9139ed..2c0475c396e 100644 --- a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/init.cpp +++ b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/init.cpp @@ -21,22 +21,26 @@ ******************************************************************************/ #include #include +#include + namespace sofa::component::solidmechanics::fem::nonuniform { - + +extern void registerHexahedronCompositeFEMForceFieldAndMass(sofa::core::ObjectFactory* factory); +extern void registerHexahedronCompositeFEMMapping(sofa::core::ObjectFactory* factory); +extern void registerNonUniformHexahedralFEMForceFieldAndMass(sofa::core::ObjectFactory* factory); +extern void registerNonUniformHexahedronFEMForceFieldAndMass(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() +void init() { - static bool first = true; - if (first) - { - first = false; - } + initExternalModule(); } const char* getModuleName() @@ -49,9 +53,24 @@ const char* getModuleVersion() return MODULE_VERSION; } -void init() +void registerObjects(sofa::core::ObjectFactory* factory) { - initExternalModule(); + registerHexahedronCompositeFEMForceFieldAndMass(factory); + registerHexahedronCompositeFEMMapping(factory); + registerNonUniformHexahedralFEMForceFieldAndMass(factory); + registerNonUniformHexahedronFEMForceFieldAndMass(factory); +} + +void initExternalModule() +{ + 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; + } } } // namespace sofa::component::solidmechanics::fem::nonuniform diff --git a/Sofa/Component/SolidMechanics/FEM/src/sofa/component/solidmechanics/fem/init.cpp b/Sofa/Component/SolidMechanics/FEM/src/sofa/component/solidmechanics/fem/init.cpp index 0508bb21f8e..1b0961245cf 100644 --- a/Sofa/Component/SolidMechanics/FEM/src/sofa/component/solidmechanics/fem/init.cpp +++ b/Sofa/Component/SolidMechanics/FEM/src/sofa/component/solidmechanics/fem/init.cpp @@ -24,6 +24,9 @@ #include #include +#include +#include + namespace sofa::component::solidmechanics::fem { @@ -31,6 +34,7 @@ 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() @@ -48,6 +52,12 @@ const char* getModuleVersion() return MODULE_VERSION; } +void registerObjects(sofa::core::ObjectFactory* factory) +{ + factory->registerObjectsFromPlugin("Sofa.Component.SolidMechanics.FEM.Elastic"); + factory->registerObjectsFromPlugin("Sofa.Component.SolidMechanics.FEM.HyperElastic"); +} + void init() { static bool first = true; @@ -57,6 +67,9 @@ void init() sofa::component::solidmechanics::fem::elastic::init(); sofa::component::solidmechanics::fem::hyperelastic::init(); + // 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/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.cpp index 6fd8b527bef..4839c4e5d56 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.cpp @@ -29,10 +29,11 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; - -int AngularSpringForceFieldClass = core::RegisterObject("Angular springs applied to rotational degrees of freedom of a rigid body or frame") - .add< AngularSpringForceField >() - ; +void registerAngularSpringForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Angular springs applied to rotational degrees of freedom of a rigid body or frame.") + .add< AngularSpringForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API AngularSpringForceField; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.cpp index e1f29e7b01d..e449b4c6334 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.cpp @@ -29,15 +29,13 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; -// Register in the Factory -int FastTriangularBendingSpringsClass = core::RegisterObject("Springs added to a triangular mesh to prevent bending") - .add< FastTriangularBendingSprings >() - - ; +void registerFastTriangularBendingSprings(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Springs added to a triangular mesh to prevent bending.") + .add< FastTriangularBendingSprings >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API FastTriangularBendingSprings; - - } // namespace sofa::component::solidmechanics::spring diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FrameSpringForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FrameSpringForceField.cpp index 7f37374074f..ecca0b2fbcc 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FrameSpringForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FrameSpringForceField.cpp @@ -31,15 +31,12 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; - -// Register in the Factory - -int FrameSpringForceFieldClass = core::RegisterObject ( "Springs for Flexibles" ) - .add< FrameSpringForceField >() - - ; +void registerFrameSpringForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Springs for Flexibles.") + .add< FrameSpringForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API FrameSpringForceField; - } // namespace sofa::component::solidmechanics::spring diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/GearSpringForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/GearSpringForceField.cpp index 5a0acaf73e9..92440e1d25e 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/GearSpringForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/GearSpringForceField.cpp @@ -33,16 +33,14 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; - -// Register in the Factory -int GearSpringForceFieldClass = core::RegisterObject("Gear springs for Rigids") - .add< GearSpringForceField >() - - ; +void registerGearSpringForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Gear springs for Rigids.") + .add< GearSpringForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API GearSpring; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API GearSpringForceField; - } // namespace sofa::component::solidmechanics::spring diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/JointSpringForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/JointSpringForceField.cpp index 99009ac5a19..ae80042b898 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/JointSpringForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/JointSpringForceField.cpp @@ -31,14 +31,11 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; - -// Register in the Factory -int JointSpringForceFieldClass = core::RegisterObject("Springs for Rigids") - .add< JointSpringForceField >() - - ; - +void registerNonUniformHexahedronFEMForceFieldAndMass(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Springs for Rigids.") + .add< JointSpringForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API JointSpringForceField; - } // namespace sofa::component::solidmechanics::spring diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/MeshSpringForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/MeshSpringForceField.cpp index 26b526f8e7b..fb7853c51cd 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/MeshSpringForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/MeshSpringForceField.cpp @@ -30,13 +30,13 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; - -int MeshSpringForceFieldClass = core::RegisterObject("Spring force field acting along the edges of a mesh") +void registerMeshSpringForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Spring force field acting along the edges of a mesh.") .add< MeshSpringForceField >() .add< MeshSpringForceField >() - .add< MeshSpringForceField >() - - ; + .add< MeshSpringForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API MeshSpringForceField; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API MeshSpringForceField; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialRestShapeSpringsForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialRestShapeSpringsForceField.cpp index d3bda42d41c..d5e74109f6c 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialRestShapeSpringsForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialRestShapeSpringsForceField.cpp @@ -33,12 +33,11 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; -SOFA_DECL_CLASS(PolynomialRestShapeSpringsForceField) - - -int PolynomialRestShapeSpringsForceFieldClass = core::RegisterObject("Simple elastic springs applied to given degrees of freedom between their current and rest shape position") - .add< PolynomialRestShapeSpringsForceField >() - ; +void registerPolynomialRestShapeSpringsForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Simple elastic springs applied to given degrees of freedom between their current and rest shape position.") + .add< PolynomialRestShapeSpringsForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API PolynomialRestShapeSpringsForceField; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.cpp index cd9c19afd33..0ae896cec12 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.cpp @@ -33,11 +33,11 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; -SOFA_DECL_CLASS(PolynomialSpringsForceField) - -int PolynomialSpringsForceFieldClass = core::RegisterObject("Simple elastic springs applied to given degrees of freedom between their current and rest shape position") - .add< PolynomialSpringsForceField >() - ; +void registerPolynomialSpringsForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Simple elastic springs applied to given degrees of freedom between their current and rest shape position.") + .add< PolynomialSpringsForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API PolynomialSpringsForceField; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadBendingSprings.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadBendingSprings.cpp index 1f9608facba..4799af2c572 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadBendingSprings.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadBendingSprings.cpp @@ -32,14 +32,12 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; - -// Register in the Factory -int QuadBendingSpringsClass = core::RegisterObject("Springs added to a quad mesh to prevent bending") +void registerQuadBendingSprings(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Springs added to a quad mesh to prevent bending.") .add< QuadBendingSprings >() - .add< QuadBendingSprings >() - - ; - + .add< QuadBendingSprings >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API QuadBendingSprings; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API QuadBendingSprings; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.cpp index c92abac60df..15497310bd3 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.cpp @@ -30,14 +30,12 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; - -// Register in the Factory -int QuadularBendingSpringsClass = core::RegisterObject("Springs added to a quad mesh to prevent bending") - .add< QuadularBendingSprings >() - - ; +void registerQuadularBendingSprings(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Springs added to a quad mesh to prevent bending.") + .add< QuadularBendingSprings >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API QuadularBendingSprings; - } // namespace sofa::component::solidmechanics::spring diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RegularGridSpringForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RegularGridSpringForceField.cpp index c6a34b8d4de..04d744cd4da 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RegularGridSpringForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RegularGridSpringForceField.cpp @@ -30,19 +30,18 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; - -// Register in the Factory -int RegularGridSpringForceFieldClass = core::RegisterObject("Spring acting on the edges and faces of a regular grid") +void registerRegularGridSpringForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Spring acting on the edges and faces of a regular grid.") .add< RegularGridSpringForceField >(true) // default template .add< RegularGridSpringForceField >() .add< RegularGridSpringForceField >() - .add< RegularGridSpringForceField >() + .add< RegularGridSpringForceField >()); +} - ; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API RegularGridSpringForceField; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API RegularGridSpringForceField; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API RegularGridSpringForceField; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API RegularGridSpringForceField; - } // namespace sofa::component::solidmechanics::spring diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RepulsiveSpringForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RepulsiveSpringForceField.cpp index 1e7fc7344ae..7b4c3867393 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RepulsiveSpringForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RepulsiveSpringForceField.cpp @@ -29,13 +29,14 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; -// Register in the Factory -int RepulsiveSpringForceFieldClass = core::RegisterObject("Springs which only repell") +void registerRepulsiveSpringForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Springs which only repel.") .add< RepulsiveSpringForceField >() .add< RepulsiveSpringForceField >() - .add< RepulsiveSpringForceField >() + .add< RepulsiveSpringForceField >()); +} - ; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API RepulsiveSpringForceField; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API RepulsiveSpringForceField; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.cpp index 3ba3ea58fe6..3962e7ab93b 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.cpp @@ -31,19 +31,18 @@ namespace sofa::component::solidmechanics::spring { -using namespace sofa::type; using namespace sofa::defaulttype; -int RestShapeSpringsForceFieldClass = core::RegisterObject("Elastic springs generating forces on degrees of freedom between their current and rest shape position") +void registerRestShapeSpringsForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Elastic springs generating forces on degrees of freedom between their current and rest shape position.") .add< RestShapeSpringsForceField >() .add< RestShapeSpringsForceField >() - .add< RestShapeSpringsForceField >() - - ; + .add< RestShapeSpringsForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API RestShapeSpringsForceField; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API RestShapeSpringsForceField; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API RestShapeSpringsForceField; - } // namespace sofa::component::solidmechanics::spring diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/SpringForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/SpringForceField.cpp index 58796021534..960f5aee3ea 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/SpringForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/SpringForceField.cpp @@ -30,15 +30,15 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; - -//Register in the Factory -int SpringForceFieldClass = core::RegisterObject("Springs") +void registerSpringForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Springs.") .add< SpringForceField >() .add< SpringForceField >() .add< SpringForceField >() .add< SpringForceField >() - .add< SpringForceField >() - ; + .add< SpringForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API SpringForceField; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API SpringForceField; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangleBendingSprings.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangleBendingSprings.cpp index e304d600fe9..0df42ff0b20 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangleBendingSprings.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangleBendingSprings.cpp @@ -31,12 +31,12 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; -// Register in the Factory -int TriangleBendingSpringsClass = core::RegisterObject("Springs added to a traingular mesh to prevent bending") +void registerTriangleBendingSprings(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Springs added to a triangular mesh to prevent bending.") .add< TriangleBendingSprings >() - .add< TriangleBendingSprings >() - - ; + .add< TriangleBendingSprings >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API TriangleBendingSprings; template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API TriangleBendingSprings; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.cpp index 19824999759..e80a2b16e9d 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.cpp @@ -29,15 +29,13 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; -// Register in the Factory -int TriangularBendingSpringsClass = core::RegisterObject("Springs added to a triangular mesh to prevent bending") - .add< TriangularBendingSprings >() - - ; +void registerTriangularBendingSprings(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Springs added to a triangular mesh to prevent bending") + .add< TriangularBendingSprings >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API TriangularBendingSprings; - - } // namespace sofa::component::solidmechanics::spring diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.cpp index cea767ff2cc..58a1f312a5e 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.cpp @@ -30,11 +30,11 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; -// Register in the Factory -int TriangularBiquadraticSpringsForceFieldClass = core::RegisterObject("Biquadratic Springs on a Triangular Mesh") - .add< TriangularBiquadraticSpringsForceField >() - - ; +void registerTriangularBiquadraticSpringsForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Biquadratic Springs on a Triangular Mesh.") + .add< TriangularBiquadraticSpringsForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API TriangularBiquadraticSpringsForceField; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularQuadraticSpringsForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularQuadraticSpringsForceField.cpp index 1bde55078b9..6c344534728 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularQuadraticSpringsForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularQuadraticSpringsForceField.cpp @@ -31,15 +31,12 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; -// Register in the Factory -int TriangularQuadraticSpringsForceFieldClass = core::RegisterObject("Quadratic Springs on a Triangular Mesh") - .add< TriangularQuadraticSpringsForceField >() - - ; +void registerTriangularQuadraticSpringsForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Quadratic Springs on a Triangular Mesh.") + .add< TriangularQuadraticSpringsForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API TriangularQuadraticSpringsForceField; - - - } // namespace sofa::component::solidmechanics::spring diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/VectorSpringForceField.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/VectorSpringForceField.cpp index 7178a771b4e..51c3fac9bf9 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/VectorSpringForceField.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/VectorSpringForceField.cpp @@ -30,13 +30,12 @@ namespace sofa::component::solidmechanics::spring using namespace sofa::defaulttype; -int VectorSpringForceFieldClass = core::RegisterObject("Spring force field acting along the edges of a mesh") - .add< VectorSpringForceField >() - - ; +void registerVectorSpringForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Spring force field acting along the edges of a mesh.") + .add< VectorSpringForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_SPRING_API VectorSpringForceField; - - } // namespace sofa::component::solidmechanics::spring diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/init.cpp b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/init.cpp index eb0545819d8..329e648e6b7 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/init.cpp +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/init.cpp @@ -21,13 +21,36 @@ ******************************************************************************/ #include #include +#include + namespace sofa::component::solidmechanics::spring { - + +extern void registerAngularSpringForceField(sofa::core::ObjectFactory* factory); +extern void registerFastTriangularBendingSprings(sofa::core::ObjectFactory* factory); +extern void registerFrameSpringForceField(sofa::core::ObjectFactory* factory); +extern void registerGearSpringForceField(sofa::core::ObjectFactory* factory); +extern void registerNonUniformHexahedronFEMForceFieldAndMass(sofa::core::ObjectFactory* factory); +extern void registerMeshSpringForceField(sofa::core::ObjectFactory* factory); +extern void registerPolynomialRestShapeSpringsForceField(sofa::core::ObjectFactory* factory); +extern void registerPolynomialSpringsForceField(sofa::core::ObjectFactory* factory); +extern void registerQuadBendingSprings(sofa::core::ObjectFactory* factory); +extern void registerQuadularBendingSprings(sofa::core::ObjectFactory* factory); +extern void registerRegularGridSpringForceField(sofa::core::ObjectFactory* factory); +extern void registerRepulsiveSpringForceField(sofa::core::ObjectFactory* factory); +extern void registerRestShapeSpringsForceField(sofa::core::ObjectFactory* factory); +extern void registerSpringForceField(sofa::core::ObjectFactory* factory); +extern void registerTriangleBendingSprings(sofa::core::ObjectFactory* factory); +extern void registerTriangularBendingSprings(sofa::core::ObjectFactory* factory); +extern void registerTriangularBiquadraticSpringsForceField(sofa::core::ObjectFactory* factory); +extern void registerTriangularQuadraticSpringsForceField(sofa::core::ObjectFactory* factory); +extern void registerVectorSpringForceField(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 +68,37 @@ const char* getModuleVersion() return MODULE_VERSION; } +void registerObjects(sofa::core::ObjectFactory* factory) +{ + registerAngularSpringForceField(factory); + registerFastTriangularBendingSprings(factory); + registerFrameSpringForceField(factory); + registerGearSpringForceField(factory); + registerNonUniformHexahedronFEMForceFieldAndMass(factory); + registerMeshSpringForceField(factory); + registerPolynomialRestShapeSpringsForceField(factory); + registerPolynomialSpringsForceField(factory); + registerQuadBendingSprings(factory); + registerQuadularBendingSprings(factory); + registerRegularGridSpringForceField(factory); + registerRepulsiveSpringForceField(factory); + registerRestShapeSpringsForceField(factory); + registerSpringForceField(factory); + registerTriangleBendingSprings(factory); + registerTriangularBendingSprings(factory); + registerTriangularBiquadraticSpringsForceField(factory); + registerTriangularQuadraticSpringsForceField(factory); + registerVectorSpringForceField(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/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TetrahedralTensorMassForceField.cpp b/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TetrahedralTensorMassForceField.cpp index e674ea9b7c1..6c4126f24a1 100644 --- a/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TetrahedralTensorMassForceField.cpp +++ b/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TetrahedralTensorMassForceField.cpp @@ -31,11 +31,11 @@ namespace sofa::component::solidmechanics::tensormass using namespace sofa::defaulttype; -// Register in the Factory -int TetrahedralTensorMassForceFieldClass = core::RegisterObject("Linear Elastic Tetrahedral Mesh") - .add< TetrahedralTensorMassForceField >() - - ; +void registerTetrahedralTensorMassForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Linear Elastic Tetrahedral Mesh") + .add< TetrahedralTensorMassForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_TENSORMASS_API TetrahedralTensorMassForceField; diff --git a/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TriangularTensorMassForceField.cpp b/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TriangularTensorMassForceField.cpp index cdc9c87d6e3..40e34e44c0c 100644 --- a/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TriangularTensorMassForceField.cpp +++ b/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TriangularTensorMassForceField.cpp @@ -31,14 +31,12 @@ namespace sofa::component::solidmechanics::tensormass using namespace sofa::defaulttype; - -// Register in the Factory -int TriangularTensorMassForceFieldClass = core::RegisterObject("Linear Elastic Membrane on a Triangular Mesh") - .add< TriangularTensorMassForceField >() - - ; +void registerTriangularTensorMassForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Linear Elastic Membrane on a Triangular Mesh") + .add< TriangularTensorMassForceField >()); +} template class SOFA_COMPONENT_SOLIDMECHANICS_TENSORMASS_API TriangularTensorMassForceField; - } // namespace sofa::component::solidmechanics::tensormass diff --git a/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/init.cpp b/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/init.cpp index 616a70834c0..6caab3e3d3b 100644 --- a/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/init.cpp +++ b/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/init.cpp @@ -21,13 +21,19 @@ ******************************************************************************/ #include #include +#include + namespace sofa::component::solidmechanics::tensormass { - + +extern void registerTetrahedralTensorMassForceField(sofa::core::ObjectFactory* factory); +extern void registerTriangularTensorMassForceField(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 +51,20 @@ const char* getModuleVersion() return MODULE_VERSION; } +void registerObjects(sofa::core::ObjectFactory* factory) +{ + registerTetrahedralTensorMassForceField(factory); + registerTriangularTensorMassForceField(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/SolidMechanics/src/sofa/component/solidmechanics/init.cpp b/Sofa/Component/SolidMechanics/src/sofa/component/solidmechanics/init.cpp index 24240906999..a35ec25d9d9 100644 --- a/Sofa/Component/SolidMechanics/src/sofa/component/solidmechanics/init.cpp +++ b/Sofa/Component/SolidMechanics/src/sofa/component/solidmechanics/init.cpp @@ -21,10 +21,13 @@ ******************************************************************************/ #include -#include #include +#include #include +#include +#include + namespace sofa::component::solidmechanics { @@ -32,6 +35,7 @@ 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() @@ -49,16 +53,26 @@ const char* getModuleVersion() return MODULE_VERSION; } +void registerObjects(sofa::core::ObjectFactory* factory) +{ + factory->registerObjectsFromPlugin("Sofa.Component.SolidMechanics.FEM"); + factory->registerObjectsFromPlugin("Sofa.Component.SolidMechanics.Spring"); + factory->registerObjectsFromPlugin("Sofa.Component.SolidMechanics.TensorMass"); +} + void init() { static bool first = true; if (first) { // force dependencies at compile-time - sofa::component::solidmechanics::spring::init(); sofa::component::solidmechanics::fem::init(); + sofa::component::solidmechanics::spring::init(); sofa::component::solidmechanics::tensormass::init(); + // 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/src/sofa/component/init.cpp b/Sofa/Component/src/sofa/component/init.cpp index c9626de10c1..0031dc4c206 100644 --- a/Sofa/Component/src/sofa/component/init.cpp +++ b/Sofa/Component/src/sofa/component/init.cpp @@ -89,6 +89,7 @@ void registerObjects(sofa::core::ObjectFactory* factory) factory->registerObjectsFromPlugin("Sofa.Component.Topology"); factory->registerObjectsFromPlugin("Sofa.Component.LinearSolver"); factory->registerObjectsFromPlugin("Sofa.Component.Engine"); + factory->registerObjectsFromPlugin("Sofa.Component.SolidMechanics"); } void init() From f8d886d1328a09e3bee1890eba9261ee9ea852db Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Thu, 10 Oct 2024 09:20:35 +0900 Subject: [PATCH 2/4] fix unit test --- .../test/ParallelImplementationsRegistry_test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/applications/plugins/MultiThreading/test/ParallelImplementationsRegistry_test.cpp b/applications/plugins/MultiThreading/test/ParallelImplementationsRegistry_test.cpp index 6b8d46adccc..1fdfbca5ab7 100644 --- a/applications/plugins/MultiThreading/test/ParallelImplementationsRegistry_test.cpp +++ b/applications/plugins/MultiThreading/test/ParallelImplementationsRegistry_test.cpp @@ -31,7 +31,9 @@ namespace multithreading TEST(ParallelImplementationsRegistry, existInObjectFactory) { - sofa::simpleapi::importPlugin("Sofa.Component.LinearSolver.Iterative"); // sequential version will be added to the ObjectFactory + // sequential versions will be added to the ObjectFactory + sofa::simpleapi::importPlugin("Sofa.Component.LinearSolver.Iterative"); + sofa::simpleapi::importPlugin("Sofa.Component.SolidMechanics.FEM.Elastic"); const auto implementations = ParallelImplementationsRegistry::getImplementations(); From aa1d0ede7bc13586594d3659ff8223bbaac509e4 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Thu, 10 Oct 2024 09:18:46 +0900 Subject: [PATCH 3/4] adding nonuniform --- .../FEM/src/sofa/component/solidmechanics/fem/init.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sofa/Component/SolidMechanics/FEM/src/sofa/component/solidmechanics/fem/init.cpp b/Sofa/Component/SolidMechanics/FEM/src/sofa/component/solidmechanics/fem/init.cpp index 1b0961245cf..06c8c86b4fd 100644 --- a/Sofa/Component/SolidMechanics/FEM/src/sofa/component/solidmechanics/fem/init.cpp +++ b/Sofa/Component/SolidMechanics/FEM/src/sofa/component/solidmechanics/fem/init.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -56,6 +57,7 @@ void registerObjects(sofa::core::ObjectFactory* factory) { factory->registerObjectsFromPlugin("Sofa.Component.SolidMechanics.FEM.Elastic"); factory->registerObjectsFromPlugin("Sofa.Component.SolidMechanics.FEM.HyperElastic"); + factory->registerObjectsFromPlugin("Sofa.Component.SolidMechanics.FEM.NonUniform"); } void init() @@ -66,6 +68,7 @@ void init() // force dependencies at compile-time sofa::component::solidmechanics::fem::elastic::init(); sofa::component::solidmechanics::fem::hyperelastic::init(); + sofa::component::solidmechanics::fem::nonuniform::init(); // make sure that this plugin is registered into the PluginManager sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME); From 48a9636b076cd2a6a6b5e67c158c5ed25c1dae44 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Fri, 11 Oct 2024 08:26:29 +0900 Subject: [PATCH 4/4] fix meta module mechanism for nonuniform --- .../sofa/component/solidmechanics/fem/nonuniform/init.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/init.cpp b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/init.cpp index 2c0475c396e..422d91d1d43 100644 --- a/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/init.cpp +++ b/Sofa/Component/SolidMechanics/FEM/NonUniform/src/sofa/component/solidmechanics/fem/nonuniform/init.cpp @@ -38,9 +38,9 @@ extern "C" { SOFA_EXPORT_DYNAMIC_LIBRARY void registerObjects(sofa::core::ObjectFactory* factory); } -void init() +void initExternalModule() { - initExternalModule(); + init(); } const char* getModuleName() @@ -61,7 +61,7 @@ void registerObjects(sofa::core::ObjectFactory* factory) registerNonUniformHexahedronFEMForceFieldAndMass(factory); } -void initExternalModule() +void init() { static bool first = true; if (first)