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 examples/3instruments.scn
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
ymin='0' ymax='0'
zmin='1' zmax='1'
/>
<MechanicalObject template='Rigid3d' name='DOFs' showIndices='0' ry='-90'/>
<MechanicalObject template='Rigid3d' name='DOFs' showIndices='0' />

<WireBeamInterpolation name='InterpolCatheter' WireRestShape='@../topoLines_cath/catheterRestShape'/>
<AdaptiveBeamForceFieldAndMass name='CatheterForceField' interpolation='@InterpolCatheter'/>
Expand Down
4 changes: 2 additions & 2 deletions examples/SingleBeamDeployment.scn
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
<RegularGridTopology name="MeshLines" nx="36" ny="1" nz="1"
xmax="0.0" xmin="0.0" ymin="0" ymax="0" zmax="0" zmin="0"
p0="0 0 0" drawEdges="1"/>
<MechanicalObject template="Rigid3d" name="DOFs Container" ry="-90" />
<MechanicalObject template="Rigid3d" name="DOFs Container" />

<WireBeamInterpolation name="BeamInterpolation" WireRestShape="@../EdgeTopology/BeamRestShape" />
<AdaptiveBeamForceFieldAndMass name="BeamForceField" interpolation="@BeamInterpolation"/>
<InterventionalRadiologyController name="DeployController" template="Rigid3d" instruments="BeamInterpolation"
topology="@MeshLines" startingPos="0 0 0 0 0 0 1" xtip="0" printLog="1"
topology="@MeshLines" startingPos="0 0 0 0 -0.7071068 0 0.7071068" xtip="0" printLog="1"
rotationInstrument="0" step="0.5" speed="0.5"
listening="1" controlledInstrument="0"/>
<FixedProjectiveConstraint name="FixedConstraint" indices="0" />
Expand Down
4 changes: 2 additions & 2 deletions examples/SingleBeamDeploymentCollision.scn
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
<RegularGridTopology name="MeshLines" nx="61" ny="1" nz="1"
xmax="0.0" xmin="0.0" ymin="0" ymax="0" zmax="0" zmin="0"
p0="0 0 0" drawEdges="1"/>
<MechanicalObject template="Rigid3d" name="DOFs Container" ry="-90" />
<MechanicalObject template="Rigid3d" name="DOFs Container" ry="-90"/>

<WireBeamInterpolation name="BeamInterpolation" WireRestShape="@../EdgeTopology/BeamRestShape"/>
<AdaptiveBeamForceFieldAndMass name="BeamForceField" interpolation="@BeamInterpolation"/>
<InterventionalRadiologyController name="DeployController" template="Rigid3d" instruments="BeamInterpolation"
topology="@MeshLines" startingPos="0 0 0 0 0 0 1" xtip="0" printLog="1"
topology="@MeshLines" startingPos="0 0 0 0 -0.7071068 0 0.7071068" xtip="0" printLog="1"
rotationInstrument="0" step="5" speed="5"
listening="1" controlledInstrument="0"/>
<LinearSolverConstraintCorrection wire_optimization="true" printLog="0" />
Expand Down
4 changes: 2 additions & 2 deletions examples/python3/SingleBeamDeployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def createScene(rootNode):
nx=61, ny=1, nz=1,
xmax=0.0, xmin=0.0, ymin=0, ymax=0, zmax=0, zmin=0,
p0=[0,0,0])
BeamMechanics.addObject('MechanicalObject', showIndices=False, name='DOFs Container', template='Rigid3d', ry=-90)
BeamMechanics.addObject('MechanicalObject', showIndices=False, name='DOFs Container', template='Rigid3d')
BeamMechanics.addObject('WireBeamInterpolation', name='BeamInterpolation', WireRestShape='@../EdgeTopology/BeamRestShape', printLog=False)
BeamMechanics.addObject('AdaptiveBeamForceFieldAndMass', name='BeamForceField', massDensity=0.00000155, interpolation='@BeamInterpolation')
BeamMechanics.addObject('InterventionalRadiologyController', name='DeployController', template='Rigid3d', instruments='BeamInterpolation',
topology="@MeshLines", startingPos=[0, 0, 0, 0, 0, 0, 1], xtip=[0], printLog=True,
topology="@MeshLines", startingPos=[0, 0, 0, 0, -0.7071068, 0, 0.7071068], xtip=[0], printLog=True,
rotationInstrument=[0], step=0.5, speed=0.5,
listening=True, controlledInstrument=0)
BeamMechanics.addObject('FixedProjectiveConstraint', indices=0, name='FixedConstraint')
Expand Down
4 changes: 2 additions & 2 deletions examples/python3/SingleBeamDeploymentCollision.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def createScene(rootNode):
nx=61, ny=1, nz=1,
xmax=0.0, xmin=0.0, ymin=0, ymax=0, zmax=0, zmin=0,
p0=[0,0,0])
BeamMechanics.addObject('MechanicalObject', showIndices=False, name='DOFs', template='Rigid3d', ry=-90)
BeamMechanics.addObject('MechanicalObject', showIndices=False, name='DOFs', template='Rigid3d')
BeamMechanics.addObject('WireBeamInterpolation', name='BeamInterpolation', WireRestShape='@../EdgeTopology/BeamRestShape', printLog=False)
BeamMechanics.addObject('AdaptiveBeamForceFieldAndMass', name='BeamForceField', massDensity=0.00000155, interpolation='@BeamInterpolation')
BeamMechanics.addObject('InterventionalRadiologyController', name='DeployController', template='Rigid3d', instruments='BeamInterpolation',
topology="@MeshLines", startingPos=[0, 0, 0, 0, 0, 0, 1], xtip=[0], printLog=True,
topology="@MeshLines", startingPos=[0, 0, 0, 0, -0.7071068, 0, 0.7071068], xtip=[0], printLog=True,
rotationInstrument=[0], step=5., speed=5.,
listening=True, controlledInstrument=0)
BeamMechanics.addObject('LinearSolverConstraintCorrection', wire_optimization='true', printLog=False)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,13 @@ void InterventionalRadiologyController<DataTypes>::init()
}

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

applyInterventionalRadiologyController();

Expand Down Expand Up @@ -1117,14 +1122,19 @@ template <class DataTypes>
void InterventionalRadiologyController<DataTypes>::fixFirstNodesWithUntil(unsigned int firstSimulatedNode)
{
WriteAccessor<Data<VecCoord> > xMstate = *getMechanicalState()->write(sofa::core::vec_id::write_access::position);
WriteAccessor<Data<VecCoord> > xrestMstate = *getMechanicalState()->write(sofa::core::vec_id::write_access::restPosition);
WriteAccessor<Data<VecDeriv> > vMstate = *getMechanicalState()->write(sofa::core::vec_id::write_access::velocity);

// set the position to startingPos for all the nodes that are not simulated
const auto& startPos = d_startingPos.getValue();
// and add a fixedConstraint
l_fixedConstraint->clearConstraints();
for(unsigned int i=0; i<firstSimulatedNode-1 ; i++)
{
xMstate[i]=d_startingPos.getValue();
xMstate[i] = startPos;
// Overwriting the rest position avoids a jump of released DoFs, trying to reach their rest position when released
// This remains safe since BeamFEMForceField uses the interpolation object to compute transformation without using the rest shape
xrestMstate[i] = startPos;
vMstate[i].clear();
l_fixedConstraint->addConstraint(i);
}
Expand Down
Loading