Skip to content
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
2 changes: 1 addition & 1 deletion src/BeamAdapter/component/BeamInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class BeamInterpolation : public BaseBeamInterpolation<DataTypes>
void getMechanicalSampling(Real& dx, const Real x_localcurv_abs) override;
void getCollisionSampling(Real &dx, const Real x_localcurv_abs) override;
void getNumberOfCollisionSegment(Real &dx, unsigned int &numLines) override;

void setTransformBetweenDofAndNode(const sofa::Index beam, const Transform &DOF_H_Node, unsigned int zeroORone );
void getSplineRestTransform(const EdgeID edgeInList, Transform &local_H_local0_rest, Transform &local_H_local1_rest) override;

Expand Down
1 change: 0 additions & 1 deletion src/BeamAdapter/component/BeamInterpolation.inl
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ void BeamInterpolation<DataTypes>::getNumberOfCollisionSegment(Real &dx, unsigne
dx = getRestTotalLength()/numLines;
}


template<class DataTypes>
void BeamInterpolation<DataTypes>::getInterpolationParameters(sofa::Index beamId, Real& _L, Real& _A, Real& _Iy,
Real& _Iz, Real& _Asy, Real& _Asz, Real& _J)
Expand Down
6 changes: 6 additions & 0 deletions src/BeamAdapter/component/WireBeamInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ class WireBeamInterpolation : public BaseBeamInterpolation<DataTypes>
{
this->m_restShape->getNumberOfCollisionSegment(dx,numLines);
}

// this is the number of beams which can be simulated according to the rest shape (and its sections)
sofa::Size getTotalNumberOfPossibleBeams() const
{
return this->m_restShape->getTotalNumberOfBeams();
}


virtual void getRestTransform(const EdgeID edgeInList, Transform &local0_H_local1_rest);
Expand Down
2 changes: 1 addition & 1 deletion src/BeamAdapter/component/WireBeamInterpolation.inl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void WireBeamInterpolation<DataTypes>::init()
this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
return;
}

type::vector<Real> xP_noticeable;
type::vector<sofa::Size> nbP_density;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,27 +223,35 @@ void InterventionalRadiologyController<DataTypes>::bwdInit()
stPos.getOrientation().normalize();
d_startingPos.setValue(stPos);

if (!this->mState) {
if (!this->mState)
{
msg_error() << "No MechanicalState found. The component can not work and will be set to Invalid.";
sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
return;
}

// check if the provided mechanical state and topology can manage our tools
sofa::Size requiredNumberOfEdges = 0;
for (const auto* instrument : m_instrumentsList)
{
requiredNumberOfEdges += instrument->getTotalNumberOfPossibleBeams();
}

if(requiredNumberOfEdges + 1 > this->mState->getSize())
{
msg_warning() << "The associated Mechanical Object does not contain enough nodes (" << this->mState->getSize()
<< ") whereas the provided tool(s) need(s) at least " << requiredNumberOfEdges + 1 << " nodes.";
}
if(requiredNumberOfEdges > this->l_mechanicalTopology->getNbEdges())
{
msg_warning() << "The associated Topology does not contain enough edges (" << this->l_mechanicalTopology->getNbEdges()
<< ") whereas the provided tool(s) need(s) at least " << requiredNumberOfEdges << " edges.";
}

WriteAccessor<Data<VecCoord> > x = *this->mState->write(sofa::core::vec_id::write_access::position);
for(unsigned int i=0; i<x.size(); i++)
x[i] = d_startingPos.getValue();

sofa::Size nbrBeam = 0;
for (unsigned int i = 0; i < m_instrumentsList.size(); i++)
{
type::vector<Real> xP_noticeable_I;
type::vector<sofa::Size> density_I;
m_instrumentsList[i]->getSamplingParameters(xP_noticeable_I, density_I);

for (auto nb : density_I)
nbrBeam += nb;
}

applyInterventionalRadiologyController();

sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Valid);
Expand Down
2 changes: 2 additions & 0 deletions src/BeamAdapter/component/engine/WireRestShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class WireRestShape : public core::objectmodel::BaseObject
void getMechanicalSampling(Real& dx, const Real x_localcurv_abs);
void getCollisionSampling(Real &dx, const Real x_curv);
void getNumberOfCollisionSegment(Real &dx, sofa::Size& numLines);
sofa::Size getTotalNumberOfBeams() const;


/////////////////////////// Deprecated Methods //////////////////////////////////////////

Expand Down
11 changes: 11 additions & 0 deletions src/BeamAdapter/component/engine/WireRestShape.inl
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ void WireRestShape<DataTypes>::getNumberOfCollisionSegment(Real &dx, sofa::Size&
dx = getLength() / numLines;
}

template <class DataTypes>
sofa::Size WireRestShape<DataTypes>::getTotalNumberOfBeams() const
{
sofa::Size numBeams = 0;
for (sofa::Size i = 0; i < l_sectionMaterials.size(); ++i)
{
numBeams += l_sectionMaterials.get(i)->getNbBeams();
}

return numBeams;
}

template <class DataTypes>
void WireRestShape<DataTypes>::getRestTransformOnX(Transform &global_H_local, const Real x)
Expand Down
Loading