Skip to content

Commit 97a728c

Browse files
hugtalbotepernod
authored andcommitted
Merge pull request sofa-framework#162 from fredroy/register_beamadapter_and_refresh
Apply new factory registration mechanism + refresh
1 parent 08d033f commit 97a728c

23 files changed

+309
-315
lines changed

BeamAdapter_test/component/controller/AdaptiveBeamController_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/******************************************************************************
1+
/******************************************************************************
22
* BeamAdapter plugin *
33
* (c) 2006 Inria, University of Lille, CNRS *
44
* *
@@ -26,6 +26,8 @@
2626

2727
TEST(AdaptiveBeamController, target)
2828
{
29+
sofa::simpleapi::importPlugin("BeamAdapter");
30+
2931
const auto node = sofa::simpleapi::createNode("node");
3032
const auto controller = sofa::simpleapi::createObject(node, "AdaptiveBeamController");
3133

src/BeamAdapter/component/BeamInterpolation.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,17 @@
4444
namespace sofa::component::fem::_beaminterpolation_
4545
{
4646

47-
using namespace sofa::defaulttype;
47+
template class SOFA_BEAMADAPTER_API BeamInterpolation<sofa::defaulttype::Rigid3Types>;
4848

49-
/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
50-
///
51-
/// Register the component into the sofa factory.
52-
/// For more details:
53-
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
54-
///
55-
////////////////////////////////////////////////////////////////////////////////////////////////////
56-
57-
//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description
58-
static int BeamInterpolationClass = core::RegisterObject("Adaptive Beam Interpolation")
59-
.add< BeamInterpolation<Rigid3Types> >(true)
60-
;
49+
} // namespace sofa::component::fem::_beaminterpolation_
6150

51+
namespace beamadapter
52+
{
6253

63-
////////////////////////////////////////////////////////////////////////////////////////////////////
64-
/// Explicit template instanciation of extern template.
65-
////////////////////////////////////////////////////////////////////////////////////////////////////
66-
template class SOFA_BEAMADAPTER_API BeamInterpolation<Rigid3Types>;
54+
void registerBeamInterpolation(sofa::core::ObjectFactory* factory)
55+
{
56+
factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive Beam Interpolation")
57+
.add< sofa::component::fem::_beaminterpolation_::BeamInterpolation<sofa::defaulttype::Rigid3Types> >());
58+
}
6759

68-
} // namespace sofa::component::fem::_beaminterpolation_
60+
} // namespace beamadapter

src/BeamAdapter/component/WireBeamInterpolation.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,18 @@
4141

4242
namespace sofa::component::fem::_wirebeaminterpolation_
4343
{
44-
using namespace sofa::defaulttype;
4544

46-
/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
47-
///
48-
/// Register the component into the sofa factory.
49-
/// For more details:
50-
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
51-
///
52-
////////////////////////////////////////////////////////////////////////////////////////////////////
53-
54-
//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description
55-
static int WireBeamInterpolationClass = core::RegisterObject("Adaptive Beam Interpolation on Wire rest Shape")
56-
.add< WireBeamInterpolation<Rigid3Types> >();
57-
58-
template class SOFA_BEAMADAPTER_API WireBeamInterpolation<Rigid3Types>;
45+
template class SOFA_BEAMADAPTER_API WireBeamInterpolation<sofa::defaulttype::Rigid3Types>;
5946

6047
} // namespace sofa::component::fem::_wirebeaminterpolation_
6148

49+
namespace beamadapter
50+
{
51+
52+
void registerWireBeamInterpolation(sofa::core::ObjectFactory* factory)
53+
{
54+
factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive Beam Interpolation on Wire rest Shape")
55+
.add< sofa::component::fem::_wirebeaminterpolation_::WireBeamInterpolation<sofa::defaulttype::Rigid3Types> >());
56+
}
6257

58+
} // namespace beamadapter

src/BeamAdapter/component/constraint/AdaptiveBeamLengthConstraint.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,17 @@ void AdaptiveBeamLengthConstraintResolution::store(int line, SReal* force, bool
5656
*m_active = (force[line] != 0);
5757
}
5858

59+
template class AdaptiveBeamLengthConstraint<sofa::defaulttype::Rigid3Types>;
5960

60-
using namespace sofa::defaulttype;
61-
using namespace sofa::helper;
62-
using core::RegisterObject;
63-
64-
/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
65-
///
66-
/// Register the component into the sofa factory.
67-
/// For more details:
68-
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
69-
///
70-
////////////////////////////////////////////////////////////////////////////////////////////////////
71-
static int AdaptiveBeamLengthConstraintClass = RegisterObject("Constrain the length of a beam.")
72-
.add< AdaptiveBeamLengthConstraint<Rigid3Types> >(true) // default template
73-
74-
;
75-
76-
template class AdaptiveBeamLengthConstraint<Rigid3Types>;
61+
} // namespace sofa::component::constraintset::_adaptivebeamlengthconstraint_
7762

63+
namespace beamadapter
64+
{
7865

79-
} // namespace sofa::component::constraintset::_adaptivebeamlengthconstraint_
66+
void registerAdaptiveBeamLengthConstraint(sofa::core::ObjectFactory* factory)
67+
{
68+
factory->registerObjects(sofa::core::ObjectRegistrationData("Constrain the length of a beam.")
69+
.add< sofa::component::constraintset::_adaptivebeamlengthconstraint_::AdaptiveBeamLengthConstraint<sofa::defaulttype::Rigid3Types> >());
70+
}
8071

72+
} // namespace beamadapter

src/BeamAdapter/component/constraint/AdaptiveBeamSlidingConstraint.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ using sofa::core::objectmodel::BaseObjectDescription ;
3737
using sofa::component::DeprecatedComponent;
3838
using sofa::defaulttype::Rigid3Types;
3939
using sofa::defaulttype::Rigid3Types;
40-
using sofa::core::RegisterObject;
4140

4241

4342
namespace sofa::component::constraintset::_adaptiveBeamSlidingConstraint_
@@ -78,25 +77,20 @@ void AdaptiveBeamSlidingConstraintResolution::store(int line, double* force, boo
7877
*m_slidingDisp = force[line+2] * m_slidingW;
7978
}
8079

81-
82-
/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
83-
///
84-
/// Register the component into the sofa factory.
85-
/// For more details:
86-
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
87-
///
88-
////////////////////////////////////////////////////////////////////////////////////////////////////
89-
90-
SOFA_DECL_CLASS(AdaptiveBeamSlidingConstraint)
91-
92-
int AdaptiveBeamSlidingConstraintClass = RegisterObject("Constrain a rigid to be attached to a beam (only in position, not the orientation)")
93-
.add< AdaptiveBeamSlidingConstraint<Rigid3Types> >()
94-
95-
;
96-
9780
template class SOFA_BEAMADAPTER_API AdaptiveBeamSlidingConstraint<Rigid3Types>;
9881

9982

10083
///////////////////////////////////////////////////////////////////////////////////////////////////
10184

10285
} // namespace sofa::component::constraintset::_adaptiveBeamSlidingConstraint_
86+
87+
namespace beamadapter
88+
{
89+
90+
void registerAdaptiveBeamSlidingConstraint(sofa::core::ObjectFactory* factory)
91+
{
92+
factory->registerObjects(sofa::core::ObjectRegistrationData("Constrain a rigid to be attached to a beam (only in position, not the orientation).")
93+
.add< sofa::component::constraintset::_adaptiveBeamSlidingConstraint_::AdaptiveBeamSlidingConstraint<Rigid3Types> >());
94+
}
95+
96+
} // namespace beamadapter

src/BeamAdapter/component/controller/AdaptiveBeamController.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,19 @@
4444
namespace sofa::component::controller::_adaptivebeamcontroller_
4545
{
4646

47-
using sofa::defaulttype::Rigid3Types;
48-
using core::RegisterObject;
47+
template class SOFA_BEAMADAPTER_API AdaptiveBeamController<sofa::defaulttype::Rigid3Types>;
4948

50-
/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
51-
///
52-
/// Register the component into the sofa factory.
53-
/// For more details:
54-
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
55-
///
56-
////////////////////////////////////////////////////////////////////////////////////////////////////
57-
58-
//TODO(dmarchal 2017-06-01): Il faut remplacer les descriptions dans RegisterObject par un vrai description
59-
int AdaptiveBeamControllerClass = RegisterObject("Adaptive beam controller")
60-
.add< AdaptiveBeamController<Rigid3Types> >()
61-
;
49+
} // namespace sofa::component::controller::_adaptivebeamcontroller_
6250

63-
template class SOFA_BEAMADAPTER_API AdaptiveBeamController<Rigid3Types>;
51+
namespace beamadapter
52+
{
6453

54+
void registerAdaptiveBeamController(sofa::core::ObjectFactory* factory)
55+
{
56+
factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive beam controller.")
57+
.add< sofa::component::controller::_adaptivebeamcontroller_::AdaptiveBeamController<sofa::defaulttype::Rigid3Types> >());
58+
}
6559

66-
} // namespace sofa::component::controller::_adaptivebeamcontroller_
60+
} // namespace beamadapter
6761

6862

src/BeamAdapter/component/controller/BeamAdapterActionController.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@
3131
namespace sofa::component::controller
3232
{
3333

34-
const static int BeamAdapterActionControllerClass = core::RegisterObject("BeamAdapterActionController")
35-
.add< BeamAdapterActionController<sofa::defaulttype::Rigid3Types> >()
36-
;
37-
3834
template class SOFA_BEAMADAPTER_API BeamAdapterActionController<sofa::defaulttype::Rigid3Types>;
3935

40-
} // namespace sofa::component::controller
36+
} // namespace
37+
38+
namespace beamadapter
39+
{
40+
41+
void registerBeamAdapterActionController(sofa::core::ObjectFactory* factory)
42+
{
43+
factory->registerObjects(sofa::core::ObjectRegistrationData("BeamAdapterActionController")
44+
.add< sofa::component::controller::BeamAdapterActionController<sofa::defaulttype::Rigid3Types> >());
45+
}
46+
47+
} // namespace beamadapter

src/BeamAdapter/component/controller/InterventionalRadiologyController.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,17 @@
4343
namespace sofa::component::controller::_interventionalradiologycontroller_
4444
{
4545

46-
using namespace sofa::defaulttype;
47-
48-
49-
/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
50-
///
51-
/// Register the component into the sofa factory.
52-
/// For more details:
53-
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
54-
///
55-
////////////////////////////////////////////////////////////////////////////////////////////////////
56-
57-
static int InterventionalRadiologyControllerClass = core::RegisterObject("Provides a Mouse & Keyboard user control on an EdgeSet Topology.")
58-
.add< InterventionalRadiologyController<Rigid3Types> >(true)
59-
;
60-
61-
template class SOFA_BEAMADAPTER_API InterventionalRadiologyController<Rigid3Types>;
46+
template class SOFA_BEAMADAPTER_API InterventionalRadiologyController<sofa::defaulttype::Rigid3Types>;
6247

6348
} // namespace sofa::component::controller::_interventionalradiologycontroller_
6449

50+
namespace beamadapter
51+
{
52+
53+
void registerInterventionalRadiologyController(sofa::core::ObjectFactory* factory)
54+
{
55+
factory->registerObjects(sofa::core::ObjectRegistrationData("Provides a Mouse & Keyboard user control on an EdgeSet Topology.")
56+
.add< sofa::component::controller::_interventionalradiologycontroller_::InterventionalRadiologyController<sofa::defaulttype::Rigid3Types> >());
57+
}
6558

59+
} // namespace beamadapter

src/BeamAdapter/component/controller/SutureController.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,17 @@
4242
namespace sofa::component::controller::_suturecontroller_
4343
{
4444

45-
using namespace sofa::defaulttype;
45+
template class SOFA_BEAMADAPTER_API SutureController<sofa::defaulttype::Rigid3Types>;
4646

47-
/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
48-
///
49-
/// Register the component into the sofa factory.
50-
/// For more details:
51-
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
52-
///
53-
////////////////////////////////////////////////////////////////////////////////////////////////////
47+
} // namespace
5448

55-
static int SutureControllerClass = core::RegisterObject("Provides a Mouse & Keyboard user control on an EdgeSet Topology.")
56-
.add< SutureController<Rigid3Types> >(true)
57-
58-
;
49+
namespace beamadapter
50+
{
5951

60-
template class SOFA_BEAMADAPTER_API SutureController<Rigid3Types>;
52+
void registerSutureController(sofa::core::ObjectFactory* factory)
53+
{
54+
factory->registerObjects(sofa::core::ObjectRegistrationData("Provides a Mouse & Keyboard user control on an EdgeSet Topology.")
55+
.add< sofa::component::controller::_suturecontroller_::SutureController<sofa::defaulttype::Rigid3Types> >());
56+
}
6157

62-
} // namespace sofa::component::controller::_suturecontroller_
58+
} // namespace beamadapter

src/BeamAdapter/component/engine/SteerableCatheter.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,17 @@
4141
namespace sofa::component::engine
4242
{
4343

44-
using namespace sofa::defaulttype;
44+
template class SOFA_BEAMADAPTER_API SteerableCatheter<sofa::defaulttype::Rigid3Types>;
4545

46-
/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
47-
///
48-
/// Register the component into the sofa factory.
49-
/// For more details:
50-
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
51-
///
52-
////////////////////////////////////////////////////////////////////////////////////////////////////
53-
54-
//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description
55-
static int SteerableCatheterClass = core::RegisterObject("")
56-
.add< SteerableCatheter<Rigid3Types> >()
46+
}// namespace sofa::component::engine
5747

58-
;
48+
namespace beamadapter
49+
{
5950

60-
template class SOFA_BEAMADAPTER_API SteerableCatheter<Rigid3Types>;
51+
void registerSteerableCatheter(sofa::core::ObjectFactory* factory)
52+
{
53+
factory->registerObjects(sofa::core::ObjectRegistrationData("Catheter object with a flexible tip based on WireRestShape")
54+
.add< sofa::component::engine::SteerableCatheter<sofa::defaulttype::Rigid3Types> >());
55+
}
6156

62-
}// namespace sofa::component::engine
57+
} // namespace beamadapter

0 commit comments

Comments
 (0)