Skip to content

Commit 1b8dcaf

Browse files
authored
[Interpolations] Fix init stage (sofa-framework#184)
* fix init stage (removing bwdInit shenanigans and add forgotten super init) * call super init for baseobj
1 parent 968e244 commit 1b8dcaf

5 files changed

Lines changed: 12 additions & 13 deletions

File tree

src/BeamAdapter/component/BaseBeamInterpolation.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject
6161
SOFA_CLASS(SOFA_TEMPLATE(BaseBeamInterpolation, DataTypes) ,
6262
sofa::core::objectmodel::BaseObject);
6363

64+
using Inherit = sofa::core::objectmodel::BaseObject;
65+
6466
using Coord = typename DataTypes::Coord;
6567
using VecCoord = typename DataTypes::VecCoord;
6668
using Real = typename Coord::value_type;
@@ -86,7 +88,7 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject
8688

8789
virtual ~BaseBeamInterpolation() = default;
8890

89-
void bwdInit() override;
91+
void init() override;
9092

9193
static void getControlPointsFromFrame(
9294
const Transform& global_H_local0, const Transform& global_H_local1,

src/BeamAdapter/component/BaseBeamInterpolation.inl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ BaseBeamInterpolation<DataTypes>::BaseBeamInterpolation(/*sofa::component::engin
117117

118118

119119
template<class DataTypes>
120-
void BaseBeamInterpolation<DataTypes>::bwdInit()
120+
void BaseBeamInterpolation<DataTypes>::init()
121121
{
122+
Inherit::init();
123+
122124
BaseContext* context = getContext();
123125

124126
m_mstate = dynamic_cast<sofa::core::behavior::MechanicalState<DataTypes> *> (context->getMechanicalState());

src/BeamAdapter/component/BeamInterpolation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ class BeamInterpolation : public BaseBeamInterpolation<DataTypes>
117117

118118
//////////////////////////////////// Inherited from Base ///////////////////////////////////////
119119
void init() override ;
120-
void bwdInit() override ;
121120
void reinit() override ;
122121
void reset() override ;
123122

src/BeamAdapter/component/BeamInterpolation.inl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,6 @@ void BeamInterpolation<DataTypes>::computeCrossSectionInertiaMatrix()
163163

164164

165165
////////////////////////////////// ADAPTIVE INTERPOLATION //////////////////////////////////////////
166-
template <class DataTypes>
167-
void BeamInterpolation<DataTypes>::init()
168-
{
169-
}
170-
171166
template <class DataTypes>
172167
void BeamInterpolation<DataTypes>::checkDataSize(Real& defaultValue, Data<type::vector<Real>>& dataList, const size_t& nbEdges)
173168
{
@@ -194,10 +189,10 @@ void BeamInterpolation<DataTypes>::checkDataSize(Real& defaultValue, Data<type::
194189
}
195190

196191
template <class DataTypes>
197-
void BeamInterpolation<DataTypes>::bwdInit()
192+
void BeamInterpolation<DataTypes>::init()
198193
{
199194
this->d_componentState.setValue(ComponentState::Loading);
200-
BaseBeamInterpolation<DataTypes>::bwdInit();
195+
BaseBeamInterpolation<DataTypes>::init();
201196

202197
if (this->d_componentState.getValue() == ComponentState::Invalid)
203198
return;
@@ -293,8 +288,7 @@ void BeamInterpolation<DataTypes>::bwdInit()
293288
template<class DataTypes>
294289
void BeamInterpolation<DataTypes>::reinit()
295290
{
296-
init();
297-
bwdInit();
291+
init();
298292
}
299293

300294
template<class DataTypes>
@@ -312,7 +306,7 @@ void BeamInterpolation<DataTypes>::reset()
312306
if(d_componentState.getValue()==ComponentState::Invalid)
313307
return ;
314308

315-
bwdInit();
309+
init();
316310
}
317311

318312
template<class DataTypes>

src/BeamAdapter/component/WireBeamInterpolation.inl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ WireBeamInterpolation<DataTypes>::WireBeamInterpolation(WireRestShape<DataTypes>
5151
template <class DataTypes>
5252
void WireBeamInterpolation<DataTypes>::init()
5353
{
54+
Inherited::init();
55+
5456
if( m_restShape.get() == nullptr )
5557
{
5658
msg_error() << "Missing WireRestShape. The component is thus de-activated" ;

0 commit comments

Comments
 (0)