diff --git a/src/ShapeMatchingPlugin/ShapeMatchingForceField.cpp b/src/ShapeMatchingPlugin/ShapeMatchingForceField.cpp index 681f3ad..0957bad 100644 --- a/src/ShapeMatchingPlugin/ShapeMatchingForceField.cpp +++ b/src/ShapeMatchingPlugin/ShapeMatchingForceField.cpp @@ -25,15 +25,17 @@ #include #include -namespace sofa::component::forcefield +namespace shapematchingplugin { using namespace sofa::defaulttype; -int ShapeMatchingForceFieldClass = core::RegisterObject("Meshless deformations based on shape matching") -.add< ShapeMatchingForceField >() -; +void registerShapeMatchingForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Meshless deformations based on shape matching") + .add< ShapeMatchingForceField >()); +} template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingForceField; -} // namespace sofa::component::forcefield +} // namespace shapematchingplugin diff --git a/src/ShapeMatchingPlugin/ShapeMatchingForceField.h b/src/ShapeMatchingPlugin/ShapeMatchingForceField.h index df03096..5a11147 100644 --- a/src/ShapeMatchingPlugin/ShapeMatchingForceField.h +++ b/src/ShapeMatchingPlugin/ShapeMatchingForceField.h @@ -30,7 +30,7 @@ #include -namespace sofa::component::forcefield +namespace shapematchingplugin { /// Meshless deformations based on shape matching @@ -57,7 +57,7 @@ class ShapeMatchingForceField : public core::behavior::ForceField ShapeMatchingForceField(); public: - SingleLink, container::ShapeMatchingRotationFinder, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_rotationFinder; + SingleLink, ShapeMatchingRotationFinder, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_rotationFinder; Data d_stiffness; void init() override; @@ -74,4 +74,4 @@ class ShapeMatchingForceField : public core::behavior::ForceField extern template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingForceField; #endif // !defined(SOFA_COMPONENT_FORCEFIELD_SHAPEMATCHINGFORCEFIELD_CPP) -} // namespace sofa::component::forcefield +} // namespace shapematchingplugin diff --git a/src/ShapeMatchingPlugin/ShapeMatchingForceField.inl b/src/ShapeMatchingPlugin/ShapeMatchingForceField.inl index ef75632..7a035f6 100644 --- a/src/ShapeMatchingPlugin/ShapeMatchingForceField.inl +++ b/src/ShapeMatchingPlugin/ShapeMatchingForceField.inl @@ -28,7 +28,7 @@ #include #include -namespace sofa::component::forcefield +namespace shapematchingplugin { template @@ -47,7 +47,7 @@ void ShapeMatchingForceField::init() if (!l_rotationFinder.get()) { - sofa::core::sptr< container::ShapeMatchingRotationFinder> rotationFinder; + sofa::core::sptr< ShapeMatchingRotationFinder> rotationFinder; this->getContext()->get(rotationFinder); if (!rotationFinder) { @@ -148,4 +148,4 @@ void ShapeMatchingForceField::draw(const core::visual::VisualParams* } -} // namespace sofa::component::forcefield +} // namespace shapematchingplugin diff --git a/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.cpp b/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.cpp index 04fa8e4..ab08324 100644 --- a/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.cpp +++ b/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.cpp @@ -32,17 +32,19 @@ #include #include -namespace sofa::component::container +namespace shapematchingplugin { using namespace sofa::defaulttype; // Register in the Factory -int ShapeMatchingRotationFinderClass = core::RegisterObject("ShapeMatchingRotationFinder") -.add< ShapeMatchingRotationFinder< Vec3Types > >() -.addAlias("RotationFinder") -; +void registerShapeMatchingRotationFinder(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("ShapeMatchingRotationFinder") + .add< ShapeMatchingRotationFinder< Vec3Types > >() + .addAlias("RotationFinder")); +} template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingRotationFinder< defaulttype::Vec3Types >; -} // namespace sofa::component::container +} // namespace shapematchingplugin diff --git a/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.h b/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.h index 1f994bd..745069d 100644 --- a/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.h +++ b/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.h @@ -36,7 +36,7 @@ * "Meshless Deformations Based on Shape Matching" (Muller, Heidelberger, Teschner and Gross) * */ -namespace sofa::component::container +namespace shapematchingplugin { template @@ -120,4 +120,4 @@ class ShapeMatchingRotationFinder : public sofa::core::behavior::RotationFinder< extern template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingRotationFinder< defaulttype::Vec3Types >; #endif -} // namespace sofa::component::container +} // namespace shapematchingplugin diff --git a/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.inl b/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.inl index 70c578b..abc869a 100644 --- a/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.inl +++ b/src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.inl @@ -31,7 +31,7 @@ #include -namespace sofa::component::container +namespace shapematchingplugin { using namespace sofa::core::topology; @@ -619,4 +619,4 @@ void ShapeMatchingRotationFinder::draw(const core::visual::VisualPara vparams->drawTool()->restoreLastState(); } -} // namespace sofa::component::container +} // namespace shapematchingplugin diff --git a/src/ShapeMatchingPlugin/config.h.in b/src/ShapeMatchingPlugin/config.h.in index cbcde01..fbf7003 100644 --- a/src/ShapeMatchingPlugin/config.h.in +++ b/src/ShapeMatchingPlugin/config.h.in @@ -24,6 +24,8 @@ #include #include +using namespace sofa; + #define SHAPEMATCHINGPLUGIN_VERSION @PROJECT_VERSION@ #ifdef SOFA_BUILD_SHAPEMATCHINGPLUGIN @@ -33,7 +35,7 @@ # define SOFA_SHAPEMATCHINGPLUGIN_API SOFA_IMPORT_DYNAMIC_LIBRARY #endif -namespace shapematching +namespace shapematchingplugin { constexpr const char* MODULE_NAME = "@PROJECT_NAME@"; constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@"; diff --git a/src/ShapeMatchingPlugin/initShapeMatchingPlugin.cpp b/src/ShapeMatchingPlugin/initShapeMatchingPlugin.cpp index 623ccfd..c528840 100644 --- a/src/ShapeMatchingPlugin/initShapeMatchingPlugin.cpp +++ b/src/ShapeMatchingPlugin/initShapeMatchingPlugin.cpp @@ -24,17 +24,21 @@ ******************************************************************************/ #include #include +#include -namespace sofa::component +namespace shapematchingplugin { + extern void registerShapeMatchingForceField(sofa::core::ObjectFactory* factory); + extern void registerShapeMatchingRotationFinder(sofa::core::ObjectFactory* factory); + extern "C" { SOFA_SHAPEMATCHINGPLUGIN_API void initExternalModule(); SOFA_SHAPEMATCHINGPLUGIN_API const char* getModuleName(); SOFA_SHAPEMATCHINGPLUGIN_API const char* getModuleVersion(); SOFA_SHAPEMATCHINGPLUGIN_API const char* getModuleLicense(); SOFA_SHAPEMATCHINGPLUGIN_API const char* getModuleDescription(); - SOFA_SHAPEMATCHINGPLUGIN_API const char* getModuleComponentList(); + SOFA_SHAPEMATCHINGPLUGIN_API void registerObjects(sofa::core::ObjectFactory* factory); } void initShapeMatchingPlugin() @@ -44,6 +48,9 @@ namespace sofa::component void initExternalModule() { + // make sure that this plugin is registered into the PluginManager + sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME); + static bool first = true; if (first) { @@ -53,12 +60,12 @@ namespace sofa::component const char* getModuleName() { - return shapematching::MODULE_NAME; + return MODULE_NAME; } const char* getModuleVersion() { - return shapematching::MODULE_VERSION; + return MODULE_VERSION; } const char* getModuleLicense() @@ -71,11 +78,10 @@ namespace sofa::component return "Plugin with ShapeMatchingPlugin"; } - const char* getModuleComponentList() + void registerObjects(sofa::core::ObjectFactory* factory) { - /// string containing the names of the classes provided by the plugin - static std::string classes = sofa::core::ObjectFactory::getInstance()->listClassesFromTarget(sofa_tostring(SOFA_TARGET)); - return classes.c_str(); + registerShapeMatchingForceField(factory); + registerShapeMatchingRotationFinder(factory); } -} // namespace sofa::component +} // namespace shapematchingplugin diff --git a/src/ShapeMatchingPlugin/initShapeMatchingPlugin.h b/src/ShapeMatchingPlugin/initShapeMatchingPlugin.h index 812345c..925ee08 100644 --- a/src/ShapeMatchingPlugin/initShapeMatchingPlugin.h +++ b/src/ShapeMatchingPlugin/initShapeMatchingPlugin.h @@ -24,9 +24,9 @@ ******************************************************************************/ #include -namespace sofa::component +namespace shapematchingplugin { void SOFA_SHAPEMATCHINGPLUGIN_API initShapeMatchingPlugin(); -} // namespace sofa::component +} // namespace shapematchingplugin