@@ -97,7 +97,8 @@ void BaseBeamInterpolation<DataTypes>::RotateFrameForAlignNormalizedX(const Quat
9797
9898template <class DataTypes >
9999BaseBeamInterpolation<DataTypes>::BaseBeamInterpolation()
100- : m_StateNodes(sofa::core::objectmodel::New< sofa::component::statecontainer::MechanicalObject<StateDataTypes> >())
100+ : Inherit()
101+ , m_StateNodes(sofa::core::objectmodel::New< sofa::component::statecontainer::MechanicalObject<StateDataTypes> >())
101102 , d_edgeList(initData(&d_edgeList, " edgeList" , " list of the edge in the topology that are concerned by the Interpolation" ))
102103 , d_lengthList(initData(&d_lengthList, " lengthList" , " list of the length of each beam" ))
103104 , d_DOF0TransformNode0(initData(&d_DOF0TransformNode0, " DOF0TransformNode0" , " Optional rigid transformation between the degree of Freedom and the first node of the beam" ))
@@ -107,41 +108,21 @@ BaseBeamInterpolation<DataTypes>::BaseBeamInterpolation()
107108 , d_dofsAndBeamsAligned(initData(&d_dofsAndBeamsAligned, true , " dofsAndBeamsAligned" ,
108109 " if false, a transformation for each beam is computed between the DOF and the beam nodes" ))
109110 , l_topology(initLink(" topology" , " link to the topology (must contain edges)" ))
110- , l_mstate(initLink(" mstate" , " link to the mechanical container" ))
111111{
112112
113-
114113 m_StateNodes->setName (" bezierNodes" );
115- addSlave (m_StateNodes);
114+ this -> addSlave (m_StateNodes);
116115}
117116
118117
119118template <class DataTypes >
120119void BaseBeamInterpolation<DataTypes>::init()
121120{
122121 Inherit::init ();
123-
124- BaseContext* context = getContext ();
125-
126- if (!l_mstate)
127- {
128- auto mstate = dynamic_cast <sofa::core::behavior::MechanicalState<DataTypes> *> (context->getMechanicalState ());
129- l_mstate.set (mstate);
130- }
131- if (l_mstate)
132- {
133- msg_info () << " Found mechanical object named " << l_mstate->getName () ;
134- }
135- else
136- {
137- msg_error () << " Cannot find the mechanical object. Please specify the link to the topology or insert one in the same node." ;
138- this ->d_componentState .setValue (sofa::core::objectmodel::ComponentState::Invalid);
139- return ;
140- }
141-
122+
142123 if (!l_topology)
143124 {
144- l_topology.set (this ->getContext ()->getMeshTopologyLink ());
125+ l_topology.set (this ->getMState ()-> getContext ()->getMeshTopologyLink ());
145126 }
146127
147128 if (l_topology)
@@ -151,14 +132,14 @@ void BaseBeamInterpolation<DataTypes>::init()
151132 else
152133 {
153134 msg_error () << " Cannot find a topology container. Please specify the link to the topology or insert one in the same node." ;
154- this ->d_componentState .setValue (sofa::core::objectmodel:: ComponentState::Invalid);
135+ this ->d_componentState .setValue (ComponentState::Invalid);
155136 return ;
156137 }
157138
158139 if (l_topology->getNbEdges () == 0 )
159140 {
160141 msg_error () << " Found a topology but it is empty (no edges). Component is de-activated" ;
161- d_componentState.setValue (ComponentState::Invalid);
142+ this -> d_componentState .setValue (ComponentState::Invalid);
162143 return ;
163144 }
164145
@@ -280,7 +261,7 @@ void BaseBeamInterpolation<DataTypes>::getBeamAtCurvAbs(const Real x_input, unsi
280261 // / LTotal = length sum of the beams that are "out"
281262 Real LTotal = 0.0 ;
282263
283- const unsigned int edgeListSize = this ->d_edgeList .getValue ().size ();
264+ const sofa::Size edgeListSize = static_cast <sofa::Size>( this ->d_edgeList .getValue ().size () );
284265
285266 // / we find the length of the beam that is "out"
286267 for (unsigned int e = start; e < edgeListSize; e++)
@@ -374,7 +355,7 @@ void BaseBeamInterpolation<DataTypes>::getDOFtoLocalTransformInGlobalFrame(const
374355template <class DataTypes >
375356void BaseBeamInterpolation<DataTypes>::setTransformBetweenDofAndNode(const sofa::Index beam, const Transform& DOF_H_Node, unsigned int zeroORone)
376357{
377- if (beam > int (d_DOF0TransformNode0.getValue ().size () - 1 ) || beam > int (d_DOF1TransformNode1.getValue ().size () - 1 ))
358+ if (beam > (d_DOF0TransformNode0.getValue ().size () - 1 ) || beam > (d_DOF1TransformNode1.getValue ().size () - 1 ))
378359 {
379360 msg_error () << " WARNING setTransformBetweenDofAndNode on non existing beam" ;
380361 return ;
@@ -458,7 +439,7 @@ unsigned int BaseBeamInterpolation<DataTypes>::getStateSize() const
458439 }
459440 else
460441 {
461- return l_mstate ->getSize ();
442+ return this -> getMState () ->getSize ();
462443 }
463444}
464445
@@ -596,22 +577,24 @@ void BaseBeamInterpolation<DataTypes>::computeStrechAndTwist(const EdgeID edgeIn
596577
597578// /vId_Out provides the id of the multiVecId which stores the position of the Bezier Points
598579template <class DataTypes >
599- void BaseBeamInterpolation<DataTypes>::updateBezierPoints(const VecCoord& x, sofa::core::VecCoordId& vId_Out) {
580+ void BaseBeamInterpolation<DataTypes>::updateBezierPoints(const VecCoord& x, sofa::core::VecCoordId& vId_Out)
581+ {
582+ const sofa::Size edgeListSize = static_cast <sofa::Size>(d_edgeList.getValue ().size ());
600583 // /Mechanical Object to stock Bezier points.
601- m_StateNodes->resize (d_edgeList. getValue (). size () * 4 );
584+ m_StateNodes->resize (edgeListSize * 4 );
602585 auto bezierPosVec = sofa::helper::getWriteOnlyAccessor (*m_StateNodes->write (vId_Out));
603- bezierPosVec.resize (d_edgeList. getValue (). size () * 4 );
586+ bezierPosVec.resize (edgeListSize * 4 );
604587
605- for (unsigned int i = 0 ; i < d_edgeList. getValue (). size () ; i++) {
588+ for (unsigned int i = 0 ; i < edgeListSize ; i++) {
606589 updateBezierPoints (x, i, bezierPosVec.wref ());
607590
608591 }
609592}
610593
611594template <class DataTypes >
612595void BaseBeamInterpolation<DataTypes>::updateBezierPoints(const VecCoord& x, unsigned int index,
613- VectorVec3& bezierPosVec) {
614- // / <<" interpolatePointUsingSpline : "<< edgeInList<<" xbary="<<baryCoord<<" localPos"<<localPos<<std::endl;
596+ VectorVec3& bezierPosVec)
597+ {
615598 const Real _L = d_lengthList.getValue ()[index];
616599
617600 // / \todo remove call to
0 commit comments