diff --git a/src/SofaSphFluid/OglFluidModel.cpp b/src/SofaSphFluid/OglFluidModel.cpp index 5e5c07f..75cd300 100755 --- a/src/SofaSphFluid/OglFluidModel.cpp +++ b/src/SofaSphFluid/OglFluidModel.cpp @@ -8,8 +8,11 @@ namespace sofa::component::visualmodel SOFA_DECL_CLASS(OglFluidModel) -int OglFluidModelClass = sofa::core::RegisterObject("Particle model for OpenGL display, using glsl") -.add< OglFluidModel >(); +void registerOglFluidModel(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Particle model for OpenGL display, using glsl.") + .add< OglFluidModel >()); +} template class SOFA_SPH_FLUID_API OglFluidModel; diff --git a/src/SofaSphFluid/ParticleSink.cpp b/src/SofaSphFluid/ParticleSink.cpp index 1efe5b3..dd83f67 100644 --- a/src/SofaSphFluid/ParticleSink.cpp +++ b/src/SofaSphFluid/ParticleSink.cpp @@ -28,10 +28,12 @@ namespace sofa::component::misc { -int ParticleSinkClass = core::RegisterObject("Parametrable particle generator") - .add< ParticleSink >() - .add< ParticleSink >() - ; +void registerParticleSink(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Parametrable particle generator.") + .add< ParticleSink >() + .add< ParticleSink >()); +} template class SOFA_SPH_FLUID_API ParticleSink; template class SOFA_SPH_FLUID_API ParticleSink; diff --git a/src/SofaSphFluid/ParticleSource.cpp b/src/SofaSphFluid/ParticleSource.cpp index c57302a..19dd288 100644 --- a/src/SofaSphFluid/ParticleSource.cpp +++ b/src/SofaSphFluid/ParticleSource.cpp @@ -28,16 +28,17 @@ namespace sofa::component::misc { -int ParticleSourceClass = core::RegisterObject("Parametrable particle generator") - .add< ParticleSource >() - .add< ParticleSource >() +void registerParticleSource(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Parametrable particle generator.") + .add< ParticleSource >() + .add< ParticleSource >()); +} - ; template class SOFA_SPH_FLUID_API ParticleSource; template class SOFA_SPH_FLUID_API ParticleSource; - } diff --git a/src/SofaSphFluid/ParticlesRepulsionForceField.cpp b/src/SofaSphFluid/ParticlesRepulsionForceField.cpp index 24edf6e..a682eb0 100644 --- a/src/SofaSphFluid/ParticlesRepulsionForceField.cpp +++ b/src/SofaSphFluid/ParticlesRepulsionForceField.cpp @@ -32,17 +32,16 @@ namespace sofa::component::forcefield using namespace sofa::defaulttype; using namespace core::behavior; - -int ParticlesRepulsionForceFieldClass = core::RegisterObject("ForceField using SpatialGridContainer to compute repulsion forces in a set of spheres") - .add< ParticlesRepulsionForceField >() - .add< ParticlesRepulsionForceField >() - - ; +void registerParticlesRepulsionForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("ForceField using SpatialGridContainer to compute repulsion forces in a set of spheres.") + .add< ParticlesRepulsionForceField >() + .add< ParticlesRepulsionForceField >()); +} template class SOFA_SPH_FLUID_API ParticlesRepulsionForceField; template class SOFA_SPH_FLUID_API ParticlesRepulsionForceField; - } // namespace sofa::component::forcefield diff --git a/src/SofaSphFluid/SPHFluidForceField.cpp b/src/SofaSphFluid/SPHFluidForceField.cpp index 7d3ac11..746bb2b 100644 --- a/src/SofaSphFluid/SPHFluidForceField.cpp +++ b/src/SofaSphFluid/SPHFluidForceField.cpp @@ -32,17 +32,15 @@ namespace sofa::component::forcefield using namespace sofa::defaulttype; using namespace core::behavior; - -int SPHFluidForceFieldClass = core::RegisterObject("Smooth Particle Hydrodynamics") - .add< SPHFluidForceField >() -//.add< SPHFluidForceField >() - - ; +void registerSPHFluidForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Smooth Particle Hydrodynamics.") + .add< SPHFluidForceField >()); +} template class SOFA_SPH_FLUID_API SPHFluidForceField; template class SOFA_SPH_FLUID_API SPHFluidForceField; - } // namespace sofa::component::forcefield diff --git a/src/SofaSphFluid/SPHFluidSurfaceMapping.cpp b/src/SofaSphFluid/SPHFluidSurfaceMapping.cpp index f3f2c59..c580fb1 100644 --- a/src/SofaSphFluid/SPHFluidSurfaceMapping.cpp +++ b/src/SofaSphFluid/SPHFluidSurfaceMapping.cpp @@ -31,10 +31,11 @@ namespace sofa::component::mapping using namespace sofa::defaulttype; // Register in the Factory -int SPHFluidSurfaceMappingClass = core::RegisterObject("SPHFluidSurfaceMappingClass") - .addAlias("MarchingCubeMapping") - .add< SPHFluidSurfaceMapping< Vec3Types, Vec3Types > >() - ; +void registerSPHFluidSurfaceMapping(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Mapping the surface of a Smooth Particle Hydrodynamics model.") + .add< SPHFluidSurfaceMapping< Vec3Types, Vec3Types > >()); +} template class SOFA_SPH_FLUID_API SPHFluidSurfaceMapping< Vec3Types, Vec3Types >; diff --git a/src/SofaSphFluid/SpatialGridContainer.cpp b/src/SofaSphFluid/SpatialGridContainer.cpp index 6c7f4f9..a811538 100644 --- a/src/SofaSphFluid/SpatialGridContainer.cpp +++ b/src/SofaSphFluid/SpatialGridContainer.cpp @@ -30,15 +30,15 @@ namespace sofa::component::container using namespace sofa::defaulttype; using namespace core::behavior; - -int SpatialGridContainerClass = core::RegisterObject("Hashing spatial grid container, used for SPH fluids for instance.") - .add< SpatialGridContainer >() - ; +void registerSpatialGridContainer(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Hashing spatial grid container, used for SPH fluids for instance.") + .add< SpatialGridContainer >()); +} template class SOFA_SPH_FLUID_API SpatialGridContainer< Vec3Types >; template class SOFA_SPH_FLUID_API SpatialGrid< SpatialGridTypes< Vec3Types > >; - } // namespace sofa::component::container diff --git a/src/SofaSphFluid/SpatialGridPointModel.cpp b/src/SofaSphFluid/SpatialGridPointModel.cpp index d60c97b..5d1c017 100644 --- a/src/SofaSphFluid/SpatialGridPointModel.cpp +++ b/src/SofaSphFluid/SpatialGridPointModel.cpp @@ -31,9 +31,11 @@ namespace sofa::component::collision using namespace sofa::component::collision::geometry; -int SpatialGridPointModelClass = core::RegisterObject("Collision model which represents a set of points, spatially grouped using a SpatialGridContainer") - .add< SpatialGridPointModel >() - ; +void registerSpatialGridPointModel(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Collision model which represents a set of points, spatially grouped using a SpatialGridContainer.") + .add< SpatialGridPointModel >()); +} SpatialGridPointModel::SpatialGridPointModel() : d_leafScale(initData(&d_leafScale,0,"leafScale","at which level should the first cube layer be constructed.\nNote that this must not be greater than GRIDDIM_LOG2")) diff --git a/src/SofaSphFluid/config.h.in b/src/SofaSphFluid/config.h.in index fd5c42c..f46dc69 100644 --- a/src/SofaSphFluid/config.h.in +++ b/src/SofaSphFluid/config.h.in @@ -19,8 +19,7 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#ifndef SOFASPHFLUID_CONFIG_H -#define SOFASPHFLUID_CONFIG_H +#pragma once #include @@ -33,4 +32,8 @@ # define SOFA_SPH_FLUID_API SOFA_IMPORT_DYNAMIC_LIBRARY #endif -#endif +namespace sofasphfluid +{ + constexpr const char* MODULE_NAME = "@PROJECT_NAME@"; + constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@"; +} // namespace sofasphfluid diff --git a/src/SofaSphFluid/initSPHFluid.cpp b/src/SofaSphFluid/initSPHFluid.cpp index 7bd8ae8..0c146b3 100644 --- a/src/SofaSphFluid/initSPHFluid.cpp +++ b/src/SofaSphFluid/initSPHFluid.cpp @@ -21,8 +21,39 @@ ******************************************************************************/ #include +#include +#include -namespace sofa::component + +namespace sofa::component::misc +{ + extern void registerParticleSink(sofa::core::ObjectFactory* factory); + extern void registerParticleSource(sofa::core::ObjectFactory* factory); +} +namespace sofa::component::collision +{ + extern void registerSpatialGridPointModel(sofa::core::ObjectFactory* factory); +} +namespace sofa::component::container +{ + extern void registerSpatialGridContainer(sofa::core::ObjectFactory* factory); +} +namespace sofa::component::forcefield +{ + extern void registerParticlesRepulsionForceField(sofa::core::ObjectFactory* factory); + extern void registerSPHFluidForceField(sofa::core::ObjectFactory* factory); +} +namespace sofa::component::mapping +{ + extern void registerSPHFluidSurfaceMapping(sofa::core::ObjectFactory* factory); +} +namespace sofa::component::visualmodel +{ + extern void registerOglFluidModel(sofa::core::ObjectFactory* factory); +} + + +namespace sofasphfluid { extern "C" { @@ -31,7 +62,7 @@ SOFA_SPH_FLUID_API const char* getModuleName(); SOFA_SPH_FLUID_API const char* getModuleVersion(); SOFA_SPH_FLUID_API const char* getModuleLicense(); SOFA_SPH_FLUID_API const char* getModuleDescription(); -SOFA_SPH_FLUID_API const char* getModuleComponentList(); +SOFA_SPH_FLUID_API void registerObjects(sofa::core::ObjectFactory* factory); } void initExternalModule() @@ -39,18 +70,21 @@ 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; } } const char* getModuleName() { - return "SofaSphFluid"; + return MODULE_NAME; } const char* getModuleVersion() { - return "1.0"; + return MODULE_VERSION; } const char* getModuleLicense() @@ -63,13 +97,18 @@ const char* getModuleDescription() return "This plugin contains fluids simulation based on the SPH method."; } -const char* getModuleComponentList() +void registerObjects(sofa::core::ObjectFactory* factory) { - return "SpatialGridContainer SPHFluidForceField SPHFluidSurfaceMapping" - " ParticleSink ParticuleSource ParticlesRepulsionForceField"; + sofa::component::misc::registerParticleSink(factory); + sofa::component::misc::registerParticleSource( factory); + sofa::component::collision::registerSpatialGridPointModel(factory); + sofa::component::container::registerSpatialGridContainer(factory); + sofa::component::forcefield::registerParticlesRepulsionForceField(factory); + sofa::component::forcefield::registerSPHFluidForceField(factory); + sofa::component::mapping::registerSPHFluidSurfaceMapping(factory); + sofa::component::visualmodel::registerOglFluidModel(factory); } - -} // namespace sofa::component +} // namespace sofasphfluid