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

Apply new registration mechanism #141

Merged
Merged
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ sofa_find_package(SoftRobots QUIET)
if(SoftRobots_FOUND)
message("-- Found dependency : 'SoftRobots' plugin .")

set(COSSERAT_USES_SOFTROBOTS ON)
list(APPEND HEADER_FILES
${SRC_ROOT_DIR}/constraint/CosseratActuatorConstraint.h
${SRC_ROOT_DIR}/constraint/CosseratActuatorConstraint.inl
Expand Down
6 changes: 5 additions & 1 deletion src/Cosserat/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@

/** \mainpage
This is the plugin for the Discret Cosserat Plugin
*/
**/
#cmakedefine COSSERAT_USES_SOFTROBOTS

namespace Cosserat
{
SOFA_COSSERAT_API void init();
constexpr const char *MODULE_NAME = "@PROJECT_NAME@";
constexpr const char *MODULE_VERSION = "@PROJECT_VERSION@";



}
32 changes: 9 additions & 23 deletions src/Cosserat/constraint/CosseratActuatorConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,22 @@
* *
******************************************************************************/


#include "CosseratActuatorConstraint.inl"
#include <Cosserat/constraint/CosseratActuatorConstraint.inl>
#include <Cosserat/config.h>
#include <sofa/core/ObjectFactory.h>

namespace sofa::component::constraintset
template class SOFA_COSSERAT_API sofa::component::constraintset::CosseratActuatorConstraint<sofa::defaulttype::Vec3Types>;

namespace Cosserat
{

//////////////////////////////////////CosseratActuatorConstraintConstraintResolution1Dof/////////////////////////////////////////////
using namespace sofa::defaulttype;
using namespace sofa::helper;
using namespace sofa::core;

//////////////////////////////////////////// FACTORY //////////////////////////////////////////////
// Registering the component
// see: http://wiki.sofa-framework.org/wiki/ObjectFactory
// 1-RegisterObject("description") + .add<> : Register the component
// 2-.add<>(true) : Set default template

int CosseratActuatorConstraintClass = RegisterObject("Simulate cable actuation.")
.add< CosseratActuatorConstraint<Vec3Types> >(true)

;
////////////////////////////////////////////////////////////////////////////////////////////////////////

// Force template specialization for the most common sofa type.
// This goes with the extern template declaration in the .h. Declaring extern template
// avoid the code generation of the template for each compilation unit.
// see: http://www.stroustrup.com/C++11FAQ.html#extern-templates
//template class CosseratActuatorConstraint<Vec3Types>;
void registerCosseratActuatorConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Simulate cable actuation.")
.add< sofa::component::constraintset::CosseratActuatorConstraint<Vec3Types> >(true));
}

} // namespace sofa

27 changes: 9 additions & 18 deletions src/Cosserat/constraint/CosseratNeedleSlidingConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,18 @@
#include<sofa/defaulttype/VecTypes.h>
#include <Cosserat/config.h>
#include <sofa/core/ObjectFactory.h>
#include "CosseratNeedleSlidingConstraint.inl"
#include <Cosserat/constraint/CosseratNeedleSlidingConstraint.inl>

template class SOFA_COSSERAT_API sofa::component::constraintset::CosseratNeedleSlidingConstraint<sofa::defaulttype::Vec3Types>;


namespace sofa::component::constraintset
namespace Cosserat
{

using sofa::defaulttype::Rigid3Types;
using namespace sofa::helper;
using namespace sofa::core;

//////////////////////////////////////////// FACTORY //////////////////////////////////////////////
// Registering the component
// see: http://wiki.sofa-framework.org/wiki/ObjectFactory
// 1-RegisterObject("description") + .add<> : Register the component
// 2-.add<>(true) : Set default template

int CosseratNeedleSlidingConstraintClass = RegisterObject("Simulate sliding contraints for needle insertion.")
.add< CosseratNeedleSlidingConstraint<sofa::defaulttype::Vec3Types> >(true)
;

} // namespace sofa
void registerCosseratNeedleSlidingConstraint(sofa::core::ObjectFactory *factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Simulate sliding constraints for needle insertion.")
.add<sofa::component::constraintset::CosseratNeedleSlidingConstraint<sofa::defaulttype::Vec3Types>>(true));

}

}
2 changes: 0 additions & 2 deletions src/Cosserat/constraint/CosseratNeedleSlidingConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ namespace sofa::component::constraintset
using sofa::core::behavior::Constraint;
using sofa::core::objectmodel::Data;
using sofa::core::visual::VisualParams;
using sofa::defaulttype::Vec3dTypes;
using sofa::defaulttype::Vec3fTypes;
using sofa::helper::ReadAccessor;
using sofa::linearalgebra::BaseVector;
using sofa::core::MultiVecDerivId ;
Expand Down
17 changes: 10 additions & 7 deletions src/Cosserat/constraint/CosseratSlidingConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@
* Contact information: [email protected] *
******************************************************************************/
#define SOFA_COSSERAT_CPP_CosseratSlidingConstraint
#include "CosseratSlidingConstraint.inl"
#include <Cosserat/constraint/CosseratSlidingConstraint.inl>

#include <sofa/defaulttype/VecTypes.h>
#include <sofa/core/ObjectFactory.h>
#include <sofa/component/statecontainer/MechanicalObject.h>

namespace sofa::component::constraintset
template class SOFA_COSSERAT_API sofa::component::constraintset::CosseratSlidingConstraint<sofa::defaulttype::Vec3Types>;


namespace Cosserat
{

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

int CosseratSlidingConstraintClass = core::RegisterObject("TODO-CosseratSlidingConstraint")
.add< CosseratSlidingConstraint<Vec3Types> >(true);
void registerCosseratSlidingConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("TODO-CosseratSlidingConstraint")
.add< sofa::component::constraintset::CosseratSlidingConstraint<Vec3Types> >(true));
}

template class CosseratSlidingConstraint<Vec3dTypes>;
}
31 changes: 11 additions & 20 deletions src/Cosserat/constraint/QPSlidingConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
#include <Cosserat/config.h>
#include <sofa/core/ObjectFactory.h>
#include <iostream>
#include "QPSlidingConstraint.inl"

#include <Cosserat/constraint/QPSlidingConstraint.inl>


//#define SOFTROBOTS_CONSTRAINT_QPSLIDINGCONSTRAINT_NOEXTERN
Expand Down Expand Up @@ -79,26 +78,18 @@ void SlidingForceConstraintResolution::resolution(int line, double** w, double*
lambda[line] = m_imposedForce;
}

template class SOFA_COSSERAT_API QPSlidingConstraint<sofa::defaulttype::Vec3Types>;
}

//////////////////////////////////////////// FACTORY //////////////////////////////////////////////
// Registering the component
// see: http://wiki.sofa-framework.org/wiki/ObjectFactory
// 1-RegisterObject("description") + .add<> : Register the component
// 2-.add<>(true) : Set default template

int QPSlidingConstraintClass = RegisterObject("Simulate cable actuation.")
.add< QPSlidingConstraint<sofa::defaulttype::Vec3Types> >(true)

;
////////////////////////////////////////////////////////////////////////////////////////////////////////

// Force template specialization for the most common sofa type.
// This goes with the extern template declaration in the .h. Declaring extern template
// avoid the code generation of the template for each compilation unit.
// see: http://www.stroustrup.com/C++11FAQ.html#extern-templates
//template class QPSlidingConstraint<sofa::defaulttype::Vec3Types>;
namespace Cosserat
{

void registerQPSlidingConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Simulate cable actuation.")
.add< sofa::component::constraintset::QPSlidingConstraint<sofa::defaulttype::Vec3Types> >(true));
}

} // namespace sofa
} // namespace Cosserat


2 changes: 0 additions & 2 deletions src/Cosserat/constraint/QPSlidingConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ namespace sofa::component::constraintset

using sofa::core::visual::VisualParams ;
using sofa::core::objectmodel::Data ;
using sofa::defaulttype::Vec3dTypes ;
using sofa::defaulttype::Vec3fTypes ;
using sofa::linearalgebra::BaseVector ;
using sofa::core::ConstraintParams ;
using sofa::helper::ReadAccessor ;
Expand Down
44 changes: 30 additions & 14 deletions src/Cosserat/engine/PointsManager.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@

#include "PointsManager.inl"
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture, development version *
* (c) 2006-2019 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: [email protected] *
******************************************************************************/
#include <Cosserat/engine/PointsManager.inl>
#include <sofa/core/ObjectFactory.h>
#include <sofa/core/visual/VisualParams.h>
#include <math.h>
#include <assert.h> /* assert */

namespace sofa::core::behavior
namespace Cosserat
{

using namespace sofa::defaulttype;

SOFA_DECL_CLASS(PointsManager)

int PointsManagerClass = core::RegisterObject("add and remove "
"points from the state will taking into account the changes inside the modifier and the container")
.add<PointsManager>();
void registerPointsManager(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("add and remove "
"points from the state will taking into account the changes inside the modifier and the container")
.add<sofa::core::behavior::PointsManager>());
}

} // namespace sofa
} // namespace Cosserat
18 changes: 12 additions & 6 deletions src/Cosserat/engine/ProjectionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,25 @@
#include <sofa/core/ObjectFactory.h>


namespace sofa::component::constraintset
namespace Cosserat
{

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

int ProjectionEngineClass = core::RegisterObject("TODO-ProjectionEngine")
.add< ProjectionEngine<Vec3Types> >(true);
void registerProjectionEngine(sofa::core::ObjectFactory *factory) {
factory->registerObjects(
sofa::core::ObjectRegistrationData("TODO-ProjectionEngine")
.add<sofa::component::constraintset::ProjectionEngine<Vec3Types>>(
true));
}

template class ProjectionEngine<Vec3dTypes>;
}

namespace sofa::component::constraintset
{
template class SOFA_COSSERAT_API ProjectionEngine<defaulttype::Vec3Types>;
}

} // namespace sofa::component::constraintset



Expand Down
31 changes: 14 additions & 17 deletions src/Cosserat/forcefield/BeamHookeLawForceField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,26 +170,23 @@ void BeamHookeLawForceField<defaulttype::Vec6Types>::addKToMatrix(const Mechanic
}
}

//////////////////////////////////////////// FACTORY //////////////////////////////////////////////
// Registering the component
// see: http://wiki.sofa-framework.org/wiki/ObjectFactory
// 1-RegisterObject("description") + .add<> : Register the component
// 2-.add<>(true) : Set default template
using namespace sofa::defaulttype;

int BeamHookeLawForceFieldClass = core::RegisterObject("This component is used to compute internal stress for torsion (along x) and bending (y and z)")
.add<BeamHookeLawForceField<Vec3Types> >(true)
.add<BeamHookeLawForceField<Vec6Types> >()
template class SOFA_COSSERAT_API BeamHookeLawForceField<Vec3Types>;
template class SOFA_COSSERAT_API BeamHookeLawForceField<Vec6Types>;

;
//////////////////////////////////////////////////////////////////////////////////////////////////////
}

// Force template specialization for the most common sofa floating point related type.
// This goes with the extern template declaration in the .h. Declaring extern template
// avoid the code generation of the template for each compilation unit.
// see: http://www.stroustrup.com/C++11FAQ.html#extern-templates
namespace Cosserat
{

template class BeamHookeLawForceField<Vec3Types>;
template class BeamHookeLawForceField<Vec6Types>;
void registerBeamHookeLawForceField(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(
sofa::core::ObjectRegistrationData(
"This component is used to compute internal stress for torsion (along x) and bending (y and z)")
.add<sofa::component::forcefield::BeamHookeLawForceField<sofa::defaulttype::Vec3Types>>(true)
.add<sofa::component::forcefield::BeamHookeLawForceField<sofa::defaulttype::Vec6Types>>());
}

} // forcefield
}
34 changes: 13 additions & 21 deletions src/Cosserat/forcefield/BeamHookeLawForceFieldRigid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,22 @@

using namespace sofa::defaulttype;

namespace sofa::component::forcefield
namespace Cosserat
{

void registerBeamHookeLawForceFieldRigid(sofa::core::ObjectFactory *factory) {
factory->registerObjects(
sofa::core::ObjectRegistrationData(
"This component is used to compute internal stress for torsion "
"(along x) and bending (y and z)")
.add<sofa::component::forcefield::BeamHookeLawForceFieldRigid<
Vec6Types>>());
}

//////////////////////////////////////////// FACTORY //////////////////////////////////////////////
// Registering the component
// see: http://wiki.sofa-framework.org/wiki/ObjectFactory
// 1-RegisterObject("description") + .add<> : Register the component
// 2-.add<>(true) : Set default template


int BeamHookeLawForceFieldRigidClass = core::RegisterObject("This component is used to compute internal stress for torsion "
"(along x) and bending (y and z)")
.add<BeamHookeLawForceFieldRigid<Vec6Types> >()
;
//////////////////////////////////////////////////////////////////////////////////////////////////////

// Force template specialization for the most common sofa floating point related type.
// This goes with the extern template declaration in the .h. Declaring extern template
// avoid the code generation of the template for each compilation unit.
// see: http://www.stroustrup.com/C++11FAQ.html#extern-templates

template class SOFA_COSSERAT_API BeamHookeLawForceFieldRigid<Vec6Types>;

}

namespace sofa::component::forcefield
{
template class SOFA_COSSERAT_API BeamHookeLawForceFieldRigid<Vec6Types>;

} // sofa::component::forcefield
Loading
Loading