Skip to content

Commit

Permalink
Everything working
Browse files Browse the repository at this point in the history
  • Loading branch information
bakpaul committed Apr 8, 2024
1 parent 0b0af48 commit 9e8ef99
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 5 deletions.
105 changes: 105 additions & 0 deletions scenes/iGTLinkMouseInteractor_Lagrange.scn
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0"?>

<Node name="root" dt="0.01" gravity="0 0 0">

<RequiredPlugin pluginName='SofaPreconditioner'/> <!-- Needed to use components [ShewchukPCGLinearSolver, ]-->
<RequiredPlugin pluginName='SofaSparseSolver'/> <!-- Needed to use components [SparseLUSolver, ]-->
<RequiredPlugin pluginName='SofaOpenglVisual'/> <!-- Needed to use components [OglModel, ]-->
<RequiredPlugin name='SofaConstraint'/> <!-- Needed to use components [LinearSolverConstraintCorrection, ]-->
<RequiredPlugin name='SofaGeneralSimpleFem'/> <!-- Needed to use components [BeamFEMForceField, ]-->
<RequiredPlugin name='SofaImplicitOdeSolver'/> <!-- Needed to use components [EulerImplicitSolver, ]-->
<RequiredPlugin name='SofaMiscMapping'/> <!-- Needed to use components [BeamLinearMapping, TubularMapping, ]-->
<RequiredPlugin name='SofaTopologyMapping'/> <!-- Needed to use components [Edge2QuadTopologicalMapping, ]-->
<RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedConstraint] -->
<RequiredPlugin name="Sofa.Component.Engine.Select"/> <!-- Needed to use components [BoxROI] -->
<RequiredPlugin name="Sofa.Component.LinearSolver.Direct"/> <!-- Needed to use components [SparseLDLSolver] -->
<RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMapping] -->
<RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
<RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
<RequiredPlugin name="Sofa.Component.SolidMechanics.FEM.Elastic"/> <!-- Needed to use components [TetrahedronFEMForceField] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [TetrahedronSetTopologyContainer,TetrahedronSetTopologyModifier,TriangleSetTopologyContainer,TriangleSetTopologyModifier] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [RegularGridTopology] -->
<RequiredPlugin name="Sofa.Component.Topology.Mapping"/> <!-- Needed to use components [Hexa2TetraTopologicalMapping,Tetra2TriangleTopologicalMapping] -->
<RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
<RequiredPlugin name="SofaIGTLink"/> <!-- Needed to use components [OglModel] -->


<VisualStyle displayFlags=" showForceFields "/>
<FreeMotionAnimationLoop name="FreeMotionAnimationLoop" parallelODESolving="true" parallelCollisionDetectionAndFreeMotion="true"/>-->
<GenericConstraintSolver maxIterations="10" multithreading='true' tolerance="1.0e-3"/>
<CollisionPipeline name="CollisionPipeline" />
<ParallelBruteForceBroadPhase/>
<ParallelBVHNarrowPhase/>
<CollisionResponse name="ContactManager" response="FrictionContactConstraint" responseParams="mu=0.5" />
<NewProximityIntersection name="Intersection" alarmDistance="0.2" contactDistance="0.02" />



<!-- $$$$$$$$$$$$$$$$$$$$$$ TOPOLOGY 1 $$$$$$$$$$$$$$$$$$$$$$ -->
<Node name="BEAMVOLUME">
<RegularGrid name="HexaTop" n="25 5 5" min="0 0 0" max="0.5 0.1 0.1"/>
<TetrahedronSetTopologyContainer name="Container" position="@HexaTop.position"/>
<TetrahedronSetTopologyModifier name="Modifier"/>
<Hexa2TetraTopologicalMapping input="@HexaTop" output="@Container" swapping="true"/>
</Node>



<Node name="FEM">
<EulerImplicitSolver firstOrder="false" rayleighMass="0.1" rayleighStiffness="0.1"/>
<SparseLDLSolver name="precond" template="CompressedRowSparseMatrixMat3x3" parallelInverseProduct="true" />

<TetrahedronSetTopologyContainer name="Container" position="@../BEAMVOLUME/HexaTop.position"
tetrahedra="@../BEAMVOLUME/Container.tetrahedra"/>
<TetrahedronSetTopologyModifier name="Modifier"/>

<MechanicalObject name="mstate" template="Vec3d" src="@Container"/>
<TetrahedronFEMForceField name="forceField" listening="true" youngModulus="6e4" poissonRatio="0.40" />


<BoxROI name="box" box="-0.01 -0.01 -0.01 0.01 0.11 0.11"/>
<FixedConstraint indices="@box.indices"/>

<UniformMass totalMass="1"/>

<Node name="Surface">
<TriangleSetTopologyContainer name="Container"/>
<TriangleSetTopologyModifier name="Modifier"/>
<Tetra2TriangleTopologicalMapping input="@../Container" output="@Container" flipNormals="false"/>
<MechanicalObject name="dofs" rest_position="@../mstate.rest_position"/>
<TriangleCollisionModel name="Torus8CMT" proximity="0.001" contactStiffness="20" color="0.94117647058824 0.93725490196078 0.89411764705882" />
<Node name="Visual" activated="1">
<TriangleSetTopologyContainer name="Container" src="@../Container"/>
<OglModel color="1.0 0.1 0.2 1.0" name="visualModel"/>
<IdentityMapping name="VisualMapping"/>
</Node>
<IdentityMapping name="SurfaceMapping"/>
</Node>

<Node name="AttachPoint">
<PointSetTopologyContainer name="Container" />
<PointSetTopologyModifier name="Modifier"/>
<MechanicalObject name="mstate" template="Vec3d" position="0.5 0.05 0.05" drawMode="1" showObjectScale="0.01" showColor="0 1 0" showObject="false"/>

<UserInteractionController name="UIC" inStiffness="10000" reactionTime="50" position="@../../AttachPointMessage.points" />
<RestShapeSpringsForceField stiffness='@UIC.outStiffness' external_rest_shape='@../../AttachPoint/mstate' points='0' external_points='0'/>

<BarycentricMapping />
</Node>

<LinearSolverConstraintCorrection linearSolver="@precond"/>
</Node>

<Node name="AttachPoint">
<PointSetTopologyContainer name="Container" />
<PointSetTopologyModifier name="Modifier"/>
<MechanicalObject name="mstate" template="Vec3d" position="0.5 0.05 0.05" drawMode="2" showObjectScale="0.01" showObject="false"/>
<iGTLinkMouseInteractor pickingType="spring" position="0 0 0" reactionTime="20000" destCollisionModel="@../FEM/Surface/Torus8CMT"/>

</Node>

</Node>


Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
<Node name="AttachPoint">
<PointSetTopologyContainer name="Container" />
<PointSetTopologyModifier name="Modifier"/>
<MechanicalObject name="mstate" template="Vec3d" position="0.5 0.05 0.05" drawMode="2" showObjectScale="0.01" showObject="false"/>
<iGTLinkMouseInteractor pickingType="spring" position="0 0 0" reactionTime="2000" destCollisionModel="@../FEM/Surface/Torus8CMT"/>
<MechanicalObject name="mstate" template="Vec3d" drawMode="2" showObjectScale="0.01" showObject="false"/>
<iGTLinkMouseInteractor pickingType="spring" reactionTime="20000" destCollisionModel="@../FEM/Surface/Torus8CMT"/>

</Node>

Expand Down
13 changes: 10 additions & 3 deletions src/sofa/igtlink/utils/iGTLinkMouseInteractor.inl
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ void iGTLinkMouseInteractor::positionChanged()
void iGTLinkMouseInteractor::attachmentChanged()
{
if(m_performer)
{
m_performer->clear();
}
if(d_pickingType.getValue().getSelectedItem() == std::string("constraint"))
{
m_performer.reset(new sofa::gui::component::performer::ConstraintAttachBodyPerformer<defaulttype::Vec3Types>(this));
}
else
{
m_performer.reset(new sofa::gui::component::performer::AttachBodyPerformer<defaulttype::Vec3Types>(this));

}
}


Expand All @@ -72,12 +77,14 @@ void iGTLinkMouseInteractor::startPerformer()
bodyPicked.indexCollisionElement = findCollidingElem(d_positions.getValue()[0]);
bodyPicked.mstate = l_destCollisionModel->getContext()->get<sofa::core::behavior::BaseMechanicalState>();
bodyPicked.point = d_positions.getValue()[0];
// bodyPicked.body = l_destCollisionModel.get();
bodyPicked.body = l_destCollisionModel.get();
this->setBodyPicked(bodyPicked);
this->setMouseAttached(true);

m_performer->start_partial(bodyPicked);

m_performer->getInteractionObject()->init();
m_performer->getInteractionObject()->bwdInit();
m_performer->getInteractionObject()->f_listening.setValue(true);
m_performerStarted = true;
}

Expand Down

0 comments on commit 9e8ef99

Please sign in to comment.