From 397fa9ba7798e1a339c0c6d2de1abdc1080dd30e Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Tue, 24 Dec 2024 10:45:33 +0900 Subject: [PATCH] apply new register mechanism to beamadapter, and refresh, clean --- .../component/BeamInterpolation.cpp | 28 ++- .../component/WireBeamInterpolation.cpp | 24 ++- .../AdaptiveBeamLengthConstraint.cpp | 28 ++- .../AdaptiveBeamSlidingConstraint.cpp | 28 ++- .../controller/AdaptiveBeamController.cpp | 26 ++- .../BeamAdapterActionController.cpp | 17 +- .../InterventionalRadiologyController.cpp | 26 ++- .../component/controller/SutureController.cpp | 24 ++- .../component/engine/SteerableCatheter.cpp | 25 ++- .../component/engine/WireRestShape.cpp | 26 ++- .../AdaptiveBeamForceFieldAndMass.cpp | 25 ++- .../AdaptiveInflatableBeamForceField.cpp | 28 ++- .../component/mapping/AdaptiveBeamMapping.cpp | 29 ++-- .../component/mapping/BeamLengthMapping.cpp | 32 +--- .../BeamProjectionDifferenceMultiMapping.cpp | 12 +- .../BeamProjectionDifferenceMultiMapping.h | 1 - .../mapping/MultiAdaptiveBeamMapping.cpp | 27 ++- .../component/model/RodMeshSection.cpp | 16 +- .../component/model/RodSpireSection.cpp | 16 +- .../component/model/RodStraightSection.cpp | 16 +- src/BeamAdapter/config.h.in | 6 + src/BeamAdapter/initBeamAdapter.cpp | 160 ++++++++++++------ 22 files changed, 306 insertions(+), 314 deletions(-) diff --git a/src/BeamAdapter/component/BeamInterpolation.cpp b/src/BeamAdapter/component/BeamInterpolation.cpp index 2c00c629c..7c0b7f31f 100644 --- a/src/BeamAdapter/component/BeamInterpolation.cpp +++ b/src/BeamAdapter/component/BeamInterpolation.cpp @@ -44,25 +44,17 @@ namespace sofa::component::fem::_beaminterpolation_ { -using namespace sofa::defaulttype; +template class SOFA_BEAMADAPTER_API BeamInterpolation; -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description -static int BeamInterpolationClass = core::RegisterObject("Adaptive Beam Interpolation") -.add< BeamInterpolation >(true) -; +} // namespace sofa::component::fem::_beaminterpolation_ +namespace beamadapter +{ -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// Explicit template instanciation of extern template. -//////////////////////////////////////////////////////////////////////////////////////////////////// -template class SOFA_BEAMADAPTER_API BeamInterpolation; +void registerBeamInterpolation(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive Beam Interpolation") + .add< sofa::component::fem::_beaminterpolation_::BeamInterpolation >()); +} -} // namespace sofa::component::fem::_beaminterpolation_ +} // namespace beamadapter diff --git a/src/BeamAdapter/component/WireBeamInterpolation.cpp b/src/BeamAdapter/component/WireBeamInterpolation.cpp index 0c859c4f9..156ba4983 100644 --- a/src/BeamAdapter/component/WireBeamInterpolation.cpp +++ b/src/BeamAdapter/component/WireBeamInterpolation.cpp @@ -41,22 +41,18 @@ namespace sofa::component::fem::_wirebeaminterpolation_ { -using namespace sofa::defaulttype; -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description -static int WireBeamInterpolationClass = core::RegisterObject("Adaptive Beam Interpolation on Wire rest Shape") -.add< WireBeamInterpolation >(); - -template class SOFA_BEAMADAPTER_API WireBeamInterpolation; +template class SOFA_BEAMADAPTER_API WireBeamInterpolation; } // namespace sofa::component::fem::_wirebeaminterpolation_ +namespace beamadapter +{ + +void registerWireBeamInterpolation(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive Beam Interpolation on Wire rest Shape") + .add< sofa::component::fem::_wirebeaminterpolation_::WireBeamInterpolation >()); +} +} // namespace beamadapter diff --git a/src/BeamAdapter/component/constraint/AdaptiveBeamLengthConstraint.cpp b/src/BeamAdapter/component/constraint/AdaptiveBeamLengthConstraint.cpp index b5abfd832..69bb388a8 100644 --- a/src/BeamAdapter/component/constraint/AdaptiveBeamLengthConstraint.cpp +++ b/src/BeamAdapter/component/constraint/AdaptiveBeamLengthConstraint.cpp @@ -56,25 +56,17 @@ void AdaptiveBeamLengthConstraintResolution::store(int line, SReal* force, bool *m_active = (force[line] != 0); } +template class AdaptiveBeamLengthConstraint; -using namespace sofa::defaulttype; -using namespace sofa::helper; -using core::RegisterObject; - -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// -static int AdaptiveBeamLengthConstraintClass = RegisterObject("Constrain the length of a beam.") - .add< AdaptiveBeamLengthConstraint >(true) // default template - - ; - -template class AdaptiveBeamLengthConstraint; +} // namespace sofa::component::constraintset::_adaptivebeamlengthconstraint_ +namespace beamadapter +{ -} // namespace sofa::component::constraintset::_adaptivebeamlengthconstraint_ +void registerAdaptiveBeamLengthConstraint(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Constrain the length of a beam.") + .add< sofa::component::constraintset::_adaptivebeamlengthconstraint_::AdaptiveBeamLengthConstraint >()); +} +} // namespace beamadapter diff --git a/src/BeamAdapter/component/constraint/AdaptiveBeamSlidingConstraint.cpp b/src/BeamAdapter/component/constraint/AdaptiveBeamSlidingConstraint.cpp index ec5b2ccdc..36c711fd2 100644 --- a/src/BeamAdapter/component/constraint/AdaptiveBeamSlidingConstraint.cpp +++ b/src/BeamAdapter/component/constraint/AdaptiveBeamSlidingConstraint.cpp @@ -37,7 +37,6 @@ using sofa::core::objectmodel::BaseObjectDescription ; using sofa::component::DeprecatedComponent; using sofa::defaulttype::Rigid3Types; using sofa::defaulttype::Rigid3Types; -using sofa::core::RegisterObject; namespace sofa::component::constraintset::_adaptiveBeamSlidingConstraint_ @@ -78,25 +77,20 @@ void AdaptiveBeamSlidingConstraintResolution::store(int line, double* force, boo *m_slidingDisp = force[line+2] * m_slidingW; } - -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -SOFA_DECL_CLASS(AdaptiveBeamSlidingConstraint) - -int AdaptiveBeamSlidingConstraintClass = RegisterObject("Constrain a rigid to be attached to a beam (only in position, not the orientation)") - .add< AdaptiveBeamSlidingConstraint >() - - ; - template class SOFA_BEAMADAPTER_API AdaptiveBeamSlidingConstraint; /////////////////////////////////////////////////////////////////////////////////////////////////// } // namespace sofa::component::constraintset::_adaptiveBeamSlidingConstraint_ + +namespace beamadapter +{ + +void registerAdaptiveBeamSlidingConstraint(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Constrain a rigid to be attached to a beam (only in position, not the orientation).") + .add< sofa::component::constraintset::_adaptiveBeamSlidingConstraint_::AdaptiveBeamSlidingConstraint >()); +} + +} // namespace beamadapter diff --git a/src/BeamAdapter/component/controller/AdaptiveBeamController.cpp b/src/BeamAdapter/component/controller/AdaptiveBeamController.cpp index 1961cc924..dc87a70f1 100644 --- a/src/BeamAdapter/component/controller/AdaptiveBeamController.cpp +++ b/src/BeamAdapter/component/controller/AdaptiveBeamController.cpp @@ -44,25 +44,19 @@ namespace sofa::component::controller::_adaptivebeamcontroller_ { -using sofa::defaulttype::Rigid3Types; -using core::RegisterObject; +template class SOFA_BEAMADAPTER_API AdaptiveBeamController; -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -//TODO(dmarchal 2017-06-01): Il faut remplacer les descriptions dans RegisterObject par un vrai description -int AdaptiveBeamControllerClass = RegisterObject("Adaptive beam controller") -.add< AdaptiveBeamController >() -; +} // namespace sofa::component::controller::_adaptivebeamcontroller_ -template class SOFA_BEAMADAPTER_API AdaptiveBeamController; +namespace beamadapter +{ +void registerAdaptiveBeamController(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive beam controller.") + .add< sofa::component::controller::_adaptivebeamcontroller_::AdaptiveBeamController >()); +} -} // namespace sofa::component::controller::_adaptivebeamcontroller_ +} // namespace beamadapter diff --git a/src/BeamAdapter/component/controller/BeamAdapterActionController.cpp b/src/BeamAdapter/component/controller/BeamAdapterActionController.cpp index 2ba73ecb4..ef116d263 100644 --- a/src/BeamAdapter/component/controller/BeamAdapterActionController.cpp +++ b/src/BeamAdapter/component/controller/BeamAdapterActionController.cpp @@ -31,10 +31,17 @@ namespace sofa::component::controller { -const static int BeamAdapterActionControllerClass = core::RegisterObject("BeamAdapterActionController") - .add< BeamAdapterActionController >() - ; - template class SOFA_BEAMADAPTER_API BeamAdapterActionController; -} // namespace sofa::component::controller +} // namespace + +namespace beamadapter +{ + +void registerBeamAdapterActionController(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("BeamAdapterActionController") + .add< sofa::component::controller::BeamAdapterActionController >()); +} + +} // namespace beamadapter diff --git a/src/BeamAdapter/component/controller/InterventionalRadiologyController.cpp b/src/BeamAdapter/component/controller/InterventionalRadiologyController.cpp index bd2a9ddf8..12f940f8a 100644 --- a/src/BeamAdapter/component/controller/InterventionalRadiologyController.cpp +++ b/src/BeamAdapter/component/controller/InterventionalRadiologyController.cpp @@ -43,23 +43,17 @@ namespace sofa::component::controller::_interventionalradiologycontroller_ { -using namespace sofa::defaulttype; - - -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -static int InterventionalRadiologyControllerClass = core::RegisterObject("Provides a Mouse & Keyboard user control on an EdgeSet Topology.") -.add< InterventionalRadiologyController >(true) -; - -template class SOFA_BEAMADAPTER_API InterventionalRadiologyController; +template class SOFA_BEAMADAPTER_API InterventionalRadiologyController; } // namespace sofa::component::controller::_interventionalradiologycontroller_ +namespace beamadapter +{ + +void registerInterventionalRadiologyController(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Provides a Mouse & Keyboard user control on an EdgeSet Topology.") + .add< sofa::component::controller::_interventionalradiologycontroller_::InterventionalRadiologyController >()); +} +} // namespace beamadapter diff --git a/src/BeamAdapter/component/controller/SutureController.cpp b/src/BeamAdapter/component/controller/SutureController.cpp index f56cea48a..e1d98f3f3 100644 --- a/src/BeamAdapter/component/controller/SutureController.cpp +++ b/src/BeamAdapter/component/controller/SutureController.cpp @@ -42,21 +42,17 @@ namespace sofa::component::controller::_suturecontroller_ { -using namespace sofa::defaulttype; +template class SOFA_BEAMADAPTER_API SutureController; -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// +} // namespace -static int SutureControllerClass = core::RegisterObject("Provides a Mouse & Keyboard user control on an EdgeSet Topology.") -.add< SutureController >(true) - -; +namespace beamadapter +{ -template class SOFA_BEAMADAPTER_API SutureController; +void registerSutureController(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Provides a Mouse & Keyboard user control on an EdgeSet Topology.") + .add< sofa::component::controller::_suturecontroller_::SutureController >()); +} -} // namespace sofa::component::controller::_suturecontroller_ +} // namespace beamadapter diff --git a/src/BeamAdapter/component/engine/SteerableCatheter.cpp b/src/BeamAdapter/component/engine/SteerableCatheter.cpp index cc942a5e4..9c4f44f6f 100644 --- a/src/BeamAdapter/component/engine/SteerableCatheter.cpp +++ b/src/BeamAdapter/component/engine/SteerableCatheter.cpp @@ -41,22 +41,17 @@ namespace sofa::component::engine { -using namespace sofa::defaulttype; +template class SOFA_BEAMADAPTER_API SteerableCatheter; -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description -static int SteerableCatheterClass = core::RegisterObject("") -.add< SteerableCatheter >() +}// namespace sofa::component::engine -; +namespace beamadapter +{ -template class SOFA_BEAMADAPTER_API SteerableCatheter; +void registerSteerableCatheter(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("") + .add< sofa::component::engine::SteerableCatheter >()); +} -}// namespace sofa::component::engine +} // namespace beamadapter diff --git a/src/BeamAdapter/component/engine/WireRestShape.cpp b/src/BeamAdapter/component/engine/WireRestShape.cpp index 5bcbe104e..7617731a9 100644 --- a/src/BeamAdapter/component/engine/WireRestShape.cpp +++ b/src/BeamAdapter/component/engine/WireRestShape.cpp @@ -40,24 +40,18 @@ namespace sofa::component::engine::_wirerestshape_ { -using namespace sofa::defaulttype; - -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -const int WireRestShapeClass = core::RegisterObject("Describe the shape functions on multiple segments using curvilinear abscissa") -.add< WireRestShape >(true) - -; - -template class SOFA_BEAMADAPTER_API WireRestShape; +template class SOFA_BEAMADAPTER_API WireRestShape; } // namespace sofa::component::engine::_wirerestshape_ +namespace beamadapter +{ + +void registerWireRestShape(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Describe the shape functions on multiple segments using curvilinear abscissa") + .add< sofa::component::engine::_wirerestshape_::WireRestShape >()); +} +} // namespace beamadapter diff --git a/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.cpp b/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.cpp index 82eb192c5..52e459dca 100644 --- a/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.cpp +++ b/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.cpp @@ -32,7 +32,6 @@ // #define SOFA_PLUGIN_BEAMADAPTER_ADAPTIVEBEAMFORCEFIELD_CPP -//////////////////////// Inclusion of headers...from wider to narrower/closer ////////////////////// #include #include #include @@ -43,21 +42,17 @@ namespace sofa::component::forcefield::_adaptivebeamforcefieldandmass_ { -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// +template class SOFA_BEAMADAPTER_API AdaptiveBeamForceFieldAndMass; -//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description -const static int AdaptiveBeamForceFieldAndMassClass = sofa::core::RegisterObject("Adaptive Beam finite elements") -.add< AdaptiveBeamForceFieldAndMass >() -; +} // namespace -template class SOFA_BEAMADAPTER_API AdaptiveBeamForceFieldAndMass; +namespace beamadapter +{ -//////////////////////////////////////////////////////////////////////////////////////////////////// +void registerAdaptiveBeamForceFieldAndMass(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive Beam finite elements") + .add< sofa::component::forcefield::_adaptivebeamforcefieldandmass_::AdaptiveBeamForceFieldAndMass >()); +} -} // namespace sofa::component::forcefield::_adaptivebeamforcefieldandmass_ +} // namespace beamadapter diff --git a/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.cpp b/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.cpp index 45b2b1b9f..98119a462 100644 --- a/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.cpp +++ b/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.cpp @@ -42,25 +42,17 @@ namespace sofa::component::forcefield::_AdaptiveInflatableBeamForceField_ { -using sofa::core::RegisterObject ; -using sofa::defaulttype::Rigid3fTypes; -using sofa::defaulttype::Rigid3dTypes; +template class SOFA_BEAMADAPTER_API AdaptiveInflatableBeamForceField; -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description -static int AdaptiveInflatableBeamForceFieldClass = RegisterObject("Adaptive Beam finite elements") -.add< AdaptiveInflatableBeamForceField >() -; +} // namespace sofa::component::forcefield::_AdaptiveInflatableBeamForceField_ -template class SOFA_BEAMADAPTER_API AdaptiveInflatableBeamForceField; +namespace beamadapter +{ -//////////////////////////////////////////////////////////////////////////////////////////////////// +void registerAdaptiveInflatableBeamForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive Beam finite elements") + .add< sofa::component::forcefield::_AdaptiveInflatableBeamForceField_::AdaptiveInflatableBeamForceField >()); +} -} // namespace sofa::component::forcefield::_AdaptiveInflatableBeamForceField_ +} // namespace beamadapter diff --git a/src/BeamAdapter/component/mapping/AdaptiveBeamMapping.cpp b/src/BeamAdapter/component/mapping/AdaptiveBeamMapping.cpp index 670fa3eb6..677c27e3c 100644 --- a/src/BeamAdapter/component/mapping/AdaptiveBeamMapping.cpp +++ b/src/BeamAdapter/component/mapping/AdaptiveBeamMapping.cpp @@ -39,10 +39,11 @@ #include +using namespace sofa::defaulttype; + namespace sofa::component::mapping::_adaptivebeammapping_ { -using namespace defaulttype; using namespace core; using namespace core::behavior; @@ -196,21 +197,19 @@ SOFA_BEAMADAPTER_API void AdaptiveBeamMapping::comput dmsg_info()<<" ********** TEST J-Jt(transposed): ********** \n"< >(true) //default template -.add< AdaptiveBeamMapping >() -; - template class SOFA_BEAMADAPTER_API AdaptiveBeamMapping; template class SOFA_BEAMADAPTER_API AdaptiveBeamMapping; } // namespace sofa::component::mapping::_adaptivebeammapping_ + +namespace beamadapter +{ + +void registerAdaptiveBeamMapping(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Set the positions and velocities of points attached to a beam using linear interpolation between DOFs.") + .add< sofa::component::mapping::_adaptivebeammapping_::AdaptiveBeamMapping >(true) //default template + .add< sofa::component::mapping::_adaptivebeammapping_::AdaptiveBeamMapping >()); +} + +} // namespace beamadapter diff --git a/src/BeamAdapter/component/mapping/BeamLengthMapping.cpp b/src/BeamAdapter/component/mapping/BeamLengthMapping.cpp index 89a9a6ab4..d1184f84a 100644 --- a/src/BeamAdapter/component/mapping/BeamLengthMapping.cpp +++ b/src/BeamAdapter/component/mapping/BeamLengthMapping.cpp @@ -43,34 +43,20 @@ namespace sofa::component::mapping { -//using namespace defaulttype; -using namespace core; -using namespace core::behavior; -using namespace sofa::defaulttype; - - -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// -//SOFA_DECL_CLASS(BeamLengthMapping) - -// Register in the Factory -int BeamLengthMappingClass = core::RegisterObject("computes the lengths of the beams") - .add< BeamLengthMapping >(true) //default template - //.add< BeamLengthMapping >() -; - namespace _beamlengthmapping_ { - template class SOFA_BEAMADAPTER_API BeamLengthMapping; + template class SOFA_BEAMADAPTER_API BeamLengthMapping; } } // namespace sofa::component::mapping +namespace beamadapter +{ +void registerBeamLengthMapping(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Compute the lengths of the beams.") + .add< sofa::component::mapping::BeamLengthMapping >()); +} - +} // namespace beamadapter diff --git a/src/BeamAdapter/component/mapping/BeamProjectionDifferenceMultiMapping.cpp b/src/BeamAdapter/component/mapping/BeamProjectionDifferenceMultiMapping.cpp index ffa54fee6..534cf83c8 100644 --- a/src/BeamAdapter/component/mapping/BeamProjectionDifferenceMultiMapping.cpp +++ b/src/BeamAdapter/component/mapping/BeamProjectionDifferenceMultiMapping.cpp @@ -34,10 +34,12 @@ namespace beamadapter::mapping { -using namespace sofa::defaulttype; +void registerBeamProjectionDifferenceMultiMapping(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Computes the difference between given points and their projection on a beam.") + .add< BeamProjectionDifferenceMultiMapping< sofa::defaulttype::Rigid3Types, sofa::defaulttype::Rigid3Types, sofa::defaulttype::Rigid3Types > >()); +} -// Register in the Factory -int BeamProjectionDifferenceMultiMappingClass = sofa::core::RegisterObject("Computes the difference between given points and their projection on a beam.") - .add< BeamProjectionDifferenceMultiMapping< Rigid3Types, Rigid3Types, Rigid3Types > >(); +template class SOFA_BEAMADAPTER_API BeamProjectionDifferenceMultiMapping< sofa::defaulttype::Rigid3Types, sofa::defaulttype::Rigid3Types, sofa::defaulttype::Rigid3Types >; -} // namespace +} // namespace beamadapter::mapping diff --git a/src/BeamAdapter/component/mapping/BeamProjectionDifferenceMultiMapping.h b/src/BeamAdapter/component/mapping/BeamProjectionDifferenceMultiMapping.h index d79bbd32f..cc2a8b44e 100644 --- a/src/BeamAdapter/component/mapping/BeamProjectionDifferenceMultiMapping.h +++ b/src/BeamAdapter/component/mapping/BeamProjectionDifferenceMultiMapping.h @@ -199,7 +199,6 @@ class SOFA_BEAMADAPTER_API BeamProjectionDifferenceMultiMapping : public sofa::c // Declares template as extern to avoid the code generation of the template for // each compilation unit. see: http://www.stroustrup.com/C++11FAQ.html#extern-templates #if !defined(BEAMADAPTER_MAPPING_BEAMPROJECTIONDIFFERENCEMULTIMAPPING_CPP) -//extern template class BeamProjectionDifferenceMultiMapping< sofa::defaulttype::Vec3Types, sofa::defaulttype::Rigid3Types, sofa::defaulttype::Vec3Types >; extern template class SOFA_BEAMADAPTER_API BeamProjectionDifferenceMultiMapping< sofa::defaulttype::Rigid3Types, sofa::defaulttype::Rigid3Types, sofa::defaulttype::Rigid3Types >; #endif diff --git a/src/BeamAdapter/component/mapping/MultiAdaptiveBeamMapping.cpp b/src/BeamAdapter/component/mapping/MultiAdaptiveBeamMapping.cpp index 09552703a..3e7706002 100644 --- a/src/BeamAdapter/component/mapping/MultiAdaptiveBeamMapping.cpp +++ b/src/BeamAdapter/component/mapping/MultiAdaptiveBeamMapping.cpp @@ -38,24 +38,17 @@ namespace sofa::component::mapping { -using namespace defaulttype; -using namespace core; -using namespace core::behavior; +template class SOFA_BEAMADAPTER_API MultiAdaptiveBeamMapping< sofa::defaulttype::Rigid3Types, sofa::defaulttype::Vec3Types >; -/////////////////////////////////////////// FACTORY //////////////////////////////////////////////// -/// -/// Register the component into the sofa factory. -/// For more details: -/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/ -/// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -// Register in the Factory -static int MultiAdaptiveBeamMappingClass = core::RegisterObject("Set the positions and velocities of points attached to a beam using linear interpolation between DOFs") -.add< MultiAdaptiveBeamMapping< Rigid3Types, Vec3Types > >() +} // namespace sofa::component::mapping -; +namespace beamadapter +{ -template class SOFA_BEAMADAPTER_API MultiAdaptiveBeamMapping< Rigid3Types, Vec3Types >; +void registerMultiAdaptiveBeamMapping(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Set the positions and velocities of points attached to a beam using linear interpolation between DOFs.") + .add< sofa::component::mapping::MultiAdaptiveBeamMapping< sofa::defaulttype::Rigid3Types, sofa::defaulttype::Vec3Types > >()); +} -} // namespace sofa::component::mapping +} // namespace beamadapter diff --git a/src/BeamAdapter/component/model/RodMeshSection.cpp b/src/BeamAdapter/component/model/RodMeshSection.cpp index 1e23ec6f4..1d380d275 100644 --- a/src/BeamAdapter/component/model/RodMeshSection.cpp +++ b/src/BeamAdapter/component/model/RodMeshSection.cpp @@ -29,11 +29,17 @@ namespace sofa::beamadapter { -using namespace sofa::defaulttype; +template class SOFA_BEAMADAPTER_API RodMeshSection; -const int RodMeshSectionClass = core::RegisterObject("Class defining a Rod Section using a MeshLoader and material parameters.") - .add< RodMeshSection >(true); +}// namespace sofa::beamadapter -template class SOFA_BEAMADAPTER_API RodMeshSection; +namespace beamadapter +{ -}// namespace sofa::beamadapter +void registerRodMeshSection(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Class defining a Rod Section using a MeshLoader and material parameters.") + .add< sofa::beamadapter::RodMeshSection >()); +} + +} // namespace beamadapter diff --git a/src/BeamAdapter/component/model/RodSpireSection.cpp b/src/BeamAdapter/component/model/RodSpireSection.cpp index e0dd278db..c2e998fbf 100644 --- a/src/BeamAdapter/component/model/RodSpireSection.cpp +++ b/src/BeamAdapter/component/model/RodSpireSection.cpp @@ -30,11 +30,17 @@ namespace sofa::beamadapter { -using namespace sofa::defaulttype; +template class SOFA_BEAMADAPTER_API RodSpireSection; -const int RodSpireSectionClass = core::RegisterObject("Class defining a rod spire section, defining material and geometry parameters.") - .add< RodSpireSection >(true); +}// namespace sofa::beamadapter -template class SOFA_BEAMADAPTER_API RodSpireSection; +namespace beamadapter +{ -}// namespace sofa::beamadapter +void registerRodSpireSection(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Class defining a rod spire section, defining material and geometry parameters.") + .add< sofa::beamadapter::RodSpireSection >()); +} + +} // namespace beamadapter diff --git a/src/BeamAdapter/component/model/RodStraightSection.cpp b/src/BeamAdapter/component/model/RodStraightSection.cpp index 4a433a145..5894b37bc 100644 --- a/src/BeamAdapter/component/model/RodStraightSection.cpp +++ b/src/BeamAdapter/component/model/RodStraightSection.cpp @@ -31,11 +31,17 @@ namespace sofa::beamadapter { -using namespace sofa::defaulttype; +template class SOFA_BEAMADAPTER_API RodStraightSection; -const int RodStraightSectionClass = core::RegisterObject("Class defining a rod straight section Material, defining material and geometry parameters.") - .add< RodStraightSection >(true); +}// namespace sofa::beamadapter -template class SOFA_BEAMADAPTER_API RodStraightSection; +namespace beamadapter +{ -}// namespace sofa::beamadapter +void registerRodStraightSection(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Class defining a rod straight section Material, defining material and geometry parameters.") + .add< sofa::beamadapter::RodStraightSection >()); +} + +} // namespace beamadapter diff --git a/src/BeamAdapter/config.h.in b/src/BeamAdapter/config.h.in index 96173f6b3..872c0f0a7 100644 --- a/src/BeamAdapter/config.h.in +++ b/src/BeamAdapter/config.h.in @@ -32,3 +32,9 @@ #else # define SOFA_BEAMADAPTER_API SOFA_IMPORT_DYNAMIC_LIBRARY #endif + +namespace beamadapter +{ + constexpr const char* MODULE_NAME = "@PROJECT_NAME@"; + constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@"; +} // namespace beamadapter diff --git a/src/BeamAdapter/initBeamAdapter.cpp b/src/BeamAdapter/initBeamAdapter.cpp index 49c21e604..29e252764 100644 --- a/src/BeamAdapter/initBeamAdapter.cpp +++ b/src/BeamAdapter/initBeamAdapter.cpp @@ -22,65 +22,113 @@ #include #include -using sofa::core::ObjectFactory; +#include -#ifdef SOFA_DEV -#include -#include -#endif // SOFA_DEV +namespace beamadapter +{ + +extern void registerBeamInterpolation(sofa::core::ObjectFactory* factory); +extern void registerWireBeamInterpolation(sofa::core::ObjectFactory* factory); +extern void registerAdaptiveBeamLengthConstraint(sofa::core::ObjectFactory* factory); +extern void registerAdaptiveBeamSlidingConstraint(sofa::core::ObjectFactory* factory); +extern void registerAdaptiveBeamController(sofa::core::ObjectFactory* factory); +extern void registerBeamAdapterActionController(sofa::core::ObjectFactory* factory); +extern void registerInterventionalRadiologyController(sofa::core::ObjectFactory* factory); +extern void registerSutureController(sofa::core::ObjectFactory* factory); +extern void registerSteerableCatheter(sofa::core::ObjectFactory* factory); +extern void registerWireRestShape(sofa::core::ObjectFactory* factory); +extern void registerAdaptiveBeamForceFieldAndMass(sofa::core::ObjectFactory* factory); +extern void registerAdaptiveInflatableBeamForceField(sofa::core::ObjectFactory* factory); +extern void registerAdaptiveBeamMapping(sofa::core::ObjectFactory* factory); +extern void registerBeamLengthMapping(sofa::core::ObjectFactory* factory); +extern void registerMultiAdaptiveBeamMapping(sofa::core::ObjectFactory* factory); +extern void registerRodMeshSection(sofa::core::ObjectFactory* factory); +extern void registerRodSpireSection(sofa::core::ObjectFactory* factory); +extern void registerRodStraightSection(sofa::core::ObjectFactory* factory); + +namespace mapping +{ + +extern void registerBeamProjectionDifferenceMultiMapping(sofa::core::ObjectFactory* factory); + +} // namespace mapping + +} // namespace beamadapter namespace sofa::component { - extern "C" { - SOFA_BEAMADAPTER_API void initExternalModule(); - SOFA_BEAMADAPTER_API const char* getModuleLicense(); - SOFA_BEAMADAPTER_API const char* getModuleName(); - SOFA_BEAMADAPTER_API const char* getModuleVersion(); - SOFA_BEAMADAPTER_API const char* getModuleDescription(); - SOFA_BEAMADAPTER_API const char* getModuleComponentList(); - } - - void initBeamAdapter() - { - static bool first = true; - if (first) - { - first = false; - } - } - - //Here are just several convenient functions to help user to know what contains the plugin - - void initExternalModule() - { - initBeamAdapter(); - } - - const char* getModuleLicense() - { - return "INRIA and Digital-Trainers"; - } - - const char* getModuleName() - { - return sofa_tostring(SOFA_TARGET); - } - - const char* getModuleVersion() - { - return sofa_tostring(BEAMADAPTER_VERSION); - } - - const char* getModuleDescription() - { - return "A dynamic adapter that modulates the DOF repartition of a beam model according to its radius of curvature."; - } - - const char* getModuleComponentList() - { - /// string containing the names of the classes provided by the plugin - static std::string classes = ObjectFactory::getInstance()->listClassesFromTarget(sofa_tostring(SOFA_TARGET)); - return classes.c_str(); - } + +using namespace beamadapter; + +extern "C" { + SOFA_BEAMADAPTER_API void initExternalModule(); + SOFA_BEAMADAPTER_API const char* getModuleLicense(); + SOFA_BEAMADAPTER_API const char* getModuleName(); + SOFA_BEAMADAPTER_API const char* getModuleVersion(); + SOFA_BEAMADAPTER_API const char* getModuleDescription(); + SOFA_BEAMADAPTER_API void registerObjects(sofa::core::ObjectFactory* factory); +} + +void initBeamAdapter() +{ + 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; + } +} + +//Here are just several convenient functions to help user to know what contains the plugin + +void initExternalModule() +{ + initBeamAdapter(); +} + +const char* getModuleLicense() +{ + return "INRIA and Digital-Trainers"; +} + +const char* getModuleName() +{ + return MODULE_NAME; +} + +const char* getModuleVersion() +{ + return MODULE_VERSION; +} + +const char* getModuleDescription() +{ + return "A dynamic adapter that modulates the DOF repartition of a beam model according to its radius of curvature."; +} + +void registerObjects(sofa::core::ObjectFactory* factory) +{ + registerBeamInterpolation(factory); + registerWireBeamInterpolation(factory); + registerAdaptiveBeamLengthConstraint(factory); + registerAdaptiveBeamSlidingConstraint(factory); + registerAdaptiveBeamController(factory); + registerBeamAdapterActionController(factory); + registerInterventionalRadiologyController(factory); + registerSutureController(factory); + registerSteerableCatheter(factory); + registerWireRestShape(factory); + registerAdaptiveBeamForceFieldAndMass(factory); + registerAdaptiveInflatableBeamForceField(factory); + registerAdaptiveBeamMapping(factory); + registerBeamLengthMapping(factory); + registerMultiAdaptiveBeamMapping(factory); + registerRodMeshSection(factory); + registerRodSpireSection(factory); + registerRodStraightSection(factory); + mapping::registerBeamProjectionDifferenceMultiMapping(factory); +} } // namespace sofa::component