Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Constraint] Apply new factory registration mechanism #5052

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ void GenericConstraintCorrection::applyPredictiveConstraintForce(const Constrain

void GenericConstraintCorrection::resetContactForce(){}

int GenericConstraintCorrectionClass = RegisterObject("")
.add< GenericConstraintCorrection >();
void registerGenericConstraintCorrection(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Generic Constraint Correction.")
.add< GenericConstraintCorrection >());
}

} //namespace sofa::component::constraint::lagrangian::correction
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@

namespace sofa::component::constraint::lagrangian::correction
{

using namespace sofa::defaulttype;

int LinearSolverContactCorrectionClass = core::RegisterObject("")
void registerLinearSolverConstraintCorrection(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Constraint Correction for Linear Solvers.")
.add< LinearSolverConstraintCorrection<Vec3Types> >()
.add< LinearSolverConstraintCorrection<Vec2Types> >()
.add< LinearSolverConstraintCorrection<Vec1Types> >()
.add< LinearSolverConstraintCorrection<Rigid3Types> >()
.add< LinearSolverConstraintCorrection<Rigid3Types> >());
}

;
template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API LinearSolverConstraintCorrection<Vec3Types>;
template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API LinearSolverConstraintCorrection<Vec2Types>;
template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API LinearSolverConstraintCorrection<Vec1Types>;
template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API LinearSolverConstraintCorrection<Rigid3Types>;



} //namespace sofa::component::constraint::lagrangian::correction
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,15 @@ SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API void PrecomputedConstraintCo
{
}




using namespace sofa::defaulttype;

int PrecomputedConstraintCorrectionClass = core::RegisterObject("Component computing constraint forces within a simulated body using the compliance method.")
void registerPrecomputedConstraintCorrection(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Component precomputing constraint forces within a simulated body using the compliance method.")
.add< PrecomputedConstraintCorrection<Vec3Types> >()
.add< PrecomputedConstraintCorrection<Vec1Types> >()
.add< PrecomputedConstraintCorrection<Rigid3Types> >()

;
.add< PrecomputedConstraintCorrection<Rigid3Types> >());
}

template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API PrecomputedConstraintCorrection<Vec3Types>;
template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API PrecomputedConstraintCorrection<Vec1Types>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,14 @@ SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API void UncoupledConstraintCorr
}
}


int UncoupledConstraintCorrectionClass = core::RegisterObject("Component computing constraint forces within a simulated body using the compliance method.")
void registerUncoupledConstraintCorrection(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Component computing constraint forces within a simulated body using the compliance method.")
.add< UncoupledConstraintCorrection< Vec1Types > >()
.add< UncoupledConstraintCorrection< Vec2Types > >()
.add< UncoupledConstraintCorrection< Vec3Types > >()
.add< UncoupledConstraintCorrection< Rigid3Types > >()
;
.add< UncoupledConstraintCorrection< Rigid3Types > >());
}

template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API UncoupledConstraintCorrection< Vec1Types >;
template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API UncoupledConstraintCorrection< Vec2Types >;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@
******************************************************************************/
#include <sofa/component/constraint/lagrangian/correction/init.h>
#include <sofa/core/ObjectFactory.h>
#include <sofa/helper/system/PluginManager.h>

namespace sofa::component::constraint::lagrangian::correction
{

extern void registerGenericConstraintCorrection(sofa::core::ObjectFactory* factory);
extern void registerLinearSolverConstraintCorrection(sofa::core::ObjectFactory* factory);
extern void registerPrecomputedConstraintCorrection(sofa::core::ObjectFactory* factory);
extern void registerUncoupledConstraintCorrection(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()
Expand All @@ -45,11 +53,22 @@ const char* getModuleVersion()
return MODULE_VERSION;
}

void registerObjects(sofa::core::ObjectFactory* factory)
{
registerGenericConstraintCorrection(factory);
registerLinearSolverConstraintCorrection(factory);
registerPrecomputedConstraintCorrection(factory);
registerUncoupledConstraintCorrection(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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ void BilateralLagrangianConstraint<defaulttype::Rigid3Types>::addContact(Deriv n
id, localid) ;
}



int BilateralLagrangianConstraintClass = core::RegisterObject("BilateralLagrangianConstraint defining an holonomic equality constraint (attachment)")
void registerBilateralLagrangianConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("BilateralLagrangianConstraint defining an holonomic equality constraint (attachment).")
.add< BilateralLagrangianConstraint<Vec3Types> >()
.add< BilateralLagrangianConstraint<Rigid3Types> >()
;
.add< BilateralLagrangianConstraint<Rigid3Types> >());
}

template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralLagrangianConstraint<Vec3Types>;
template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralLagrangianConstraint<Rigid3Types>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,15 @@ void FixedLagrangianConstraint<Rigid3Types>::doGetSingleConstraintResolution(std
offset += 3;
}



int FixedLagrangianConstraintClass = core::RegisterObject("Lagrangian-based fixation of DOFs of the model")
void registerFixedLagrangianConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Lagrangian-based fixation of DOFs of the model.")
.add< FixedLagrangianConstraint<Vec6Types> >()
.add< FixedLagrangianConstraint<Vec3Types> >()
.add< FixedLagrangianConstraint<Vec2Types> >()
.add< FixedLagrangianConstraint<Vec1Types> >()
.add< FixedLagrangianConstraint<Rigid3Types> >();
.add< FixedLagrangianConstraint<Rigid3Types> >());
}

template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API FixedLagrangianConstraint<Vec6Types>;
template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API FixedLagrangianConstraint<Vec3Types>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ namespace sofa::component::constraint::lagrangian::model
{

using namespace sofa::defaulttype;
using namespace sofa::helper;

int SlidingLagrangianConstraintClass = core::RegisterObject("TODO-SlidingLagrangianConstraint")
.add< SlidingLagrangianConstraint<Vec3Types> >(true);
void registerSlidingLagrangianConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Lagrangian-based partial fixation of DOFs of the model, along an axis.")
.add< SlidingLagrangianConstraint<Vec3Types> >());
}

template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API SlidingLagrangianConstraint<Vec3Types>;


} //namespace sofa::component::constraint::lagrangian::model
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ namespace sofa::component::constraint::lagrangian::model
{

using namespace sofa::defaulttype;
using namespace sofa::helper;

int StopperLagrangianConstraintClass = core::RegisterObject("TODO-StopperLagrangianConstraint")
.add< StopperLagrangianConstraint<Vec1Types> >()

;
void registerStopperLagrangianConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Lagrangian-based constraint forcing a 1D DoF to be inside a given range.")
.add< StopperLagrangianConstraint<Vec1Types> >());
}

template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API StopperLagrangianConstraint<Vec1Types>;


} //namespace sofa::component::constraint::lagrangian::model
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
namespace sofa::component::constraint::lagrangian::model
{

int UniformLagrangianConstraintClass = sofa::core::RegisterObject("A constraint equation applied on all dofs.")
.add< UniformLagrangianConstraint<sofa::defaulttype::Vec1Types> >()
;
void registerUniformLagrangianConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("A constraint equation applied on all dofs.")
.add< UniformLagrangianConstraint<sofa::defaulttype::Vec1Types> >());
}

template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UniformLagrangianConstraint<sofa::defaulttype::Vec1Types>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ namespace sofa::component::constraint::lagrangian::model
{

using namespace sofa::defaulttype;
using namespace sofa::helper;

//TODO(dmarchal) What does this TODO mean ?
int UnilateralLagrangianConstraintClass = core::RegisterObject("TODO-UnilateralLagrangianConstraint")
.add< UnilateralLagrangianConstraint<Vec3Types> >()

;

void registerUnilateralLagrangianConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Lagrangian-based inequality constraint")
.add< UnilateralLagrangianConstraint<Vec3Types> >());
}

template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralLagrangianConstraint<Vec3Types>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@
******************************************************************************/
#include <sofa/component/constraint/lagrangian/model/init.h>
#include <sofa/core/ObjectFactory.h>
#include <sofa/helper/system/PluginManager.h>

namespace sofa::component::constraint::lagrangian::model
{

extern void registerBilateralLagrangianConstraint(sofa::core::ObjectFactory* factory);
extern void registerFixedLagrangianConstraint(sofa::core::ObjectFactory* factory);
extern void registerSlidingLagrangianConstraint(sofa::core::ObjectFactory* factory);
extern void registerStopperLagrangianConstraint(sofa::core::ObjectFactory* factory);
extern void registerUniformLagrangianConstraint(sofa::core::ObjectFactory* factory);
extern void registerUnilateralLagrangianConstraint(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()
Expand All @@ -45,11 +55,24 @@ const char* getModuleVersion()
return MODULE_VERSION;
}

void registerObjects(sofa::core::ObjectFactory* factory)
{
registerBilateralLagrangianConstraint(factory);
registerFixedLagrangianConstraint(factory);
registerSlidingLagrangianConstraint(factory);
registerStopperLagrangianConstraint(factory);
registerUniformLagrangianConstraint(factory);
registerUnilateralLagrangianConstraint(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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,10 @@ sofa::core::MultiVecDerivId GenericConstraintSolver::getDx() const
return m_dxId;
}


int GenericConstraintSolverClass = core::RegisterObject("A Generic Constraint Solver using the Linear Complementarity Problem formulation to solve Constraint based components")
.add< GenericConstraintSolver >();
void registerGenericConstraintSolver(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("A Generic Constraint Solver using the Linear Complementarity Problem formulation to solve Constraint based components")
.add< GenericConstraintSolver >());
}

} //namespace sofa::component::constraint::lagrangian::solver
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,10 @@ void LCPConstraintSolver::draw(const core::visual::VisualParams* vparams)

}

int LCPConstraintSolverClass = core::RegisterObject("A Constraint Solver using the Linear Complementarity Problem formulation to solve BaseConstraint based components")
.add< LCPConstraintSolver >();
void registerLCPConstraintSolver(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("A Constraint Solver using the Linear Complementarity Problem formulation to solve BaseConstraint based components.")
.add< LCPConstraintSolver >());
}

} //namespace sofa::component::constraint::lagrangian::solver
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
******************************************************************************/
#include <sofa/component/constraint/lagrangian/solver/init.h>
#include <sofa/core/ObjectFactory.h>
#include <sofa/helper/system/PluginManager.h>

namespace sofa::component::constraint::lagrangian::solver
{

extern void registerGenericConstraintSolver(sofa::core::ObjectFactory* factory);
extern void registerLCPConstraintSolver(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()
Expand All @@ -46,11 +51,20 @@ const char* getModuleVersion()
return MODULE_VERSION;
}

void registerObjects(sofa::core::ObjectFactory* factory)
{
registerGenericConstraintSolver(factory);
registerLCPConstraintSolver(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;
}
}
Expand Down
Loading
Loading