Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WireRestShape] Introduce use of RodSectionMaterial #65

Merged
merged 23 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fbdc1f0
[WireRestShape] Remove optiond releaseWire or brokenIn2
epernod Jun 29, 2023
dfab80d
Remove use of Edge2QuadTopologicalMapping
epernod Jun 27, 2023
dece380
[WireRestShape] Remove code related to releaseWire, brokenIn2 and Edg…
epernod Oct 19, 2023
27fa7d4
Fix tests
epernod Oct 19, 2023
626b5b1
[doc] Add some comments
epernod Oct 4, 2022
8277457
Update WireREstShape to use the new WireMaterialSection links
epernod Sep 23, 2022
13bda92
Add check on BeamMAterial section
epernod Sep 26, 2022
dfebce3
[src] Move numEdges and numEdgesCollision into WireSectionMaterial
epernod Oct 1, 2022
5d0fbb1
[src] Update WireRestShape to use a vector of Links instead of hardco…
epernod Oct 4, 2022
d6a1b6c
[WireRestShape] Fix Collision edges sampling
epernod Oct 5, 2022
d55b3e2
[WRShape] Add epsilon on get youngModulus and interpolation
epernod Oct 11, 2022
895fa0d
[WireSection] Update WireSectionMaterial to be templated
epernod Jun 27, 2023
43a1e4f
backup work on moving loader to material
epernod Oct 19, 2023
6243a0d
Update WireRestShape to only use RodSectionMaterials
epernod Jun 29, 2023
1a38c89
Clean and doc Rod section classes and WireRestShape
epernod Jun 30, 2023
d9c7cc0
Fix bad cherry pick
epernod Oct 19, 2023
3c61d51
[scenes] Update all scenes with new rod section components
epernod Oct 19, 2023
f7d71f3
Fix more tests
epernod Oct 20, 2023
0137003
restore epsilon value
epernod Oct 20, 2023
8a3860f
Merge branch 'master' into BeamMaterial
epernod Nov 28, 2023
0c6ba1e
Update scenes behavior and add recorded motion to fully test the 3 in…
epernod Nov 28, 2023
71eaf13
Update scenes regression references
epernod Nov 28, 2023
72ac95b
Update scenes regression references
epernod Nov 28, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ void InterventionalRadiologyController_test::testDefaultInit()
"<?xml version='1.0'?> "
"<Node name='Root' gravity='0 -9.81 0' dt='0.01'> "
" <Node name='BeamTopology'> "
" <WireRestShape name='BeamRestShape'/> "
" <RodStraightSection name='StraightSection'/> "
" <WireRestShape name='BeamRestShape' wireMaterials='@StraightSection'/> "
" <EdgeSetTopologyContainer name='meshLinesBeam'/> "
" <EdgeSetTopologyModifier /> "
" </Node> "
Expand Down
69 changes: 39 additions & 30 deletions BeamAdapter_test/component/model/WireRestShape_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,14 @@ void WireRestShape_test::testDefaultInit()
{
std::string scene =
"<?xml version='1.0'?>"
"<Node name='Root' gravity='0 -9.81 0' dt='0.01'> "
" <Node name='BeamTopology'> "
" <WireRestShape name='BeamRestShape'/> "
" <EdgeSetTopologyContainer name='meshLinesBeam'/> "
" <EdgeSetTopologyModifier /> "
" </Node> "
"</Node> ";
"<Node name='Root' gravity='0 -9.81 0' dt='0.01'> "
" <Node name='BeamTopology'> "
" <RodStraightSection name='StraightSection'/> "
" <WireRestShape name='BeamRestShape' wireMaterials='@StraightSection' /> "
" <EdgeSetTopologyContainer name='meshLinesBeam'/> "
" <EdgeSetTopologyModifier /> "
" </Node> "
"</Node> ";

loadScene(scene);

Expand All @@ -141,28 +142,31 @@ void WireRestShape_test::testParameterInit()
{
std::string scene =
"<?xml version='1.0'?>"
"<Node name='Root' gravity='0 -9.81 0' dt='0.01'> "
" <Node name='BeamTopology'> "
" <WireRestShape name='BeamRestShape' length='100.0' "
" straightLength='95.0'/> "
" <EdgeSetTopologyContainer name='meshLinesBeam'/> "
" <EdgeSetTopologyModifier /> "
" </Node> "
"</Node> ";

"<Node name='Root' gravity='0 -9.81 0' dt='0.01'> "
" <Node name='BeamTopology'> "
" <RodStraightSection name='StraightSection' length='95.0' nbEdgesCollis='50' /> "
" <RodStraightSection name='StraightSection2' length='5.0' nbEdgesCollis='10' /> "
" <WireRestShape name='BeamRestShape' wireMaterials='@StraightSection "
" @StraightSection2'/> "
" <EdgeSetTopologyContainer name='meshLinesBeam'/> "
" <EdgeSetTopologyModifier /> "
" </Node> "
"</Node> ";

loadScene(scene);

WireRestShapeRig3::SPtr wireRShape = this->m_root->get< WireRestShapeRig3 >(sofa::core::objectmodel::BaseContext::SearchDown);
WireRestShapeRig3* wire = wireRShape.get();
EXPECT_NE(wire, nullptr);

Real fullLength = wire->getLength();
Real straightLength = 95.0;
EXPECT_EQ(fullLength, 100.0);

Real straightLength = 95.0;
int nbrE0 = 50;
int nbrE1 = 10;
vector<Real> keysPoints, keysPoints_ref = { 0, straightLength, fullLength };
Real ratio = straightLength / fullLength;
vector<int> nbP_density, nbP_density_ref = { int(floor(5.0 * ratio)), int(floor(20.0 * (1 - ratio))) };
vector<int> nbP_density, nbP_density_ref = { nbrE0, nbrE1 };

wire->getSamplingParameters(keysPoints, nbP_density);
EXPECT_EQ(keysPoints.size(), 3);
Expand All @@ -175,9 +179,9 @@ void WireRestShape_test::testParameterInit()
wire->getCollisionSampling(dx1, 0.0);
wire->getCollisionSampling(dx2, fullLength);
wire->getCollisionSampling(dx3, 90.0);
EXPECT_EQ(dx1, straightLength / nbEdgesCol_ref);
EXPECT_EQ(dx2, (fullLength - straightLength) / nbEdgesCol_ref);
EXPECT_EQ(dx3, straightLength / nbEdgesCol_ref);
EXPECT_EQ(dx1, straightLength / nbrE0);
EXPECT_EQ(dx2, (fullLength - straightLength) / nbrE1);
EXPECT_EQ(dx3, straightLength / nbrE0);
}


Expand All @@ -187,8 +191,10 @@ void WireRestShape_test::testTopologyInit()
"<?xml version='1.0'?>"
"<Node name='Root' gravity='0 -9.81 0' dt='0.01'> "
" <Node name='BeamTopology'> "
" <WireRestShape name='BeamRestShape' length='100.0' "
" straightLength='95.0' numEdges='30'/> "
" <RodStraightSection name='StraightSection' length='95.0' nbEdgesVisu='20' /> "
" <RodStraightSection name='StraightSection2' length='5.0' nbEdgesVisu='10' /> "
" <WireRestShape name='BeamRestShape' wireMaterials='@StraightSection "
" @StraightSection2'/> "
" <EdgeSetTopologyContainer name='meshLinesBeam'/> "
" <EdgeSetTopologyModifier /> "
" </Node> "
Expand All @@ -205,11 +211,12 @@ void WireRestShape_test::testTopologyInit()
EXPECT_NE(topo, nullptr);

// checking topo created by WireRestShape
int numbEdgesVisu = 30;
EXPECT_EQ(topo->getNbPoints(), numbEdgesVisu + 1);
EXPECT_EQ(topo->getNbEdges(), numbEdgesVisu);
int numbEdgesVisu0 = 20;
int numbEdgesVisu1 = 10;
EXPECT_EQ(topo->getNbPoints(), numbEdgesVisu0 + numbEdgesVisu1 + 1);
EXPECT_EQ(topo->getNbEdges(), numbEdgesVisu0 + numbEdgesVisu1);

Real dx = 100.0 / Real(numbEdgesVisu);
Real dx = 95.0 / Real(numbEdgesVisu0);

EXPECT_EQ(topo->getPX(0), 0.0);
EXPECT_EQ(topo->getPX(1), dx);
Expand All @@ -227,8 +234,10 @@ void WireRestShape_test::testTransformMethods()
"<?xml version='1.0'?>"
"<Node name='Root' gravity='0 -9.81 0' dt='0.01'> "
" <Node name='BeamTopology'> "
" <WireRestShape name='BeamRestShape' length='100.0' "
" straightLength='95.0' numEdges='30'/> "
" <RodStraightSection name='StraightSection' length='95.0' /> "
" <RodSpireSection name='StraightSection2' length='5.0' /> "
" <WireRestShape name='BeamRestShape' wireMaterials='@StraightSection "
" @StraightSection2'/> "
" <EdgeSetTopologyContainer name='meshLinesBeam'/> "
" <EdgeSetTopologyModifier /> "
" </Node> "
Expand Down
15 changes: 9 additions & 6 deletions examples/3instruments.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<div id="orangeText">Instruments control</div>
<br>
<div align="controler">
You can use the keyboard to control the instrument.
<i>Recorded motion has been recorded to demonstrate the 3 intruments behavior.</i>
<br>
<br>To manually test it, set the component <b>BeamAdapterActionController writeMode</b> to true.
<br>Then you can use the keyboard to control the instrument:
<ul>
<li>To change instrument
<ul>
Expand All @@ -18,16 +21,16 @@
<li><b> ctrl + 2</b>
</ul>
</li>
<li>To progress instrument
<li>To move the instrument forward/backward
<ul>
<li><b> ctrl + +</b>
<li><b> ctrl + -</b>
<li><b> ctrl + UP key</b>
<li><b> ctrl + DOWN key</b>
</ul>
</li>
<li>To turn instrument
<ul>
<li><b> ctrl + A</b>
<li><b> ctrl + E</b>
<li><b> ctrl + LEFT key</b>
<li><b> ctrl + RIGHT key</b>
</ul>
</li>
</ul>
Expand Down
44 changes: 28 additions & 16 deletions examples/3instruments.scn
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,41 @@
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
<VisualStyle displayFlags='showVisualModels showBehaviorModels showCollisionModels hideMappings hideForceFields' />


<DefaultAnimationLoop />
<DefaultVisualManagerLoop/>



<!-- ------------------------- INTERVENTIONAL RADIOLOGY INSTRUMENTS (catheter, guidewire, coil) ------------------------------ -->

<Node name='topoLines_cath'>
<WireRestShape template='Rigid3d' printLog='0' name='catheterRestShape' length='1000.0' straightLength='600' spireDiameter='4000.0' spireHeight='0.0'
densityOfBeams='40 10' numEdges='200' numEdgesCollis='40 20' youngModulus='10000' youngModulusExtremity='10000'/> <!-- silicone -->
<RodStraightSection name="StraightSection" youngModulus="10000" nbEdgesCollis="40" nbEdgesVisu="120" length="600.0"/>
<RodSpireSection name="SpireSection" youngModulus="10000" nbEdgesCollis="20" nbEdgesVisu="80" length="400.0" spireDiameter="4000.0" spireHeight="0.0"/>

<WireRestShape template="Rigid3d" name="catheterRestShape" wireMaterials="@StraightSection @SpireSection"/>

<EdgeSetTopologyContainer name='meshLinesCath' />
<EdgeSetTopologyModifier name='Modifier' />
<EdgeSetGeometryAlgorithms name='GeomAlgo' template='Rigid3d' />
<MechanicalObject template='Rigid3d' name='dofTopo1' />
</Node>
<Node name='topoLines_guide'>
<WireRestShape template='Rigid3d' printLog='0' name='GuideRestShape' length='1000.0' straightLength='980.0' spireDiameter='25' spireHeight='0.0'
densityOfBeams='30 5' numEdges='200' numEdgesCollis='50 10' youngModulus='10000' youngModulusExtremity='10000'/>
<RodStraightSection name="StraightSection" youngModulus="10000" nbEdgesCollis="50" nbEdgesVisu="196" length="980.0"/>
<RodSpireSection name="SpireSection" youngModulus="10000" nbEdgesCollis="10" nbEdgesVisu="4" length="20.0" spireDiameter="25" spireHeight="0.0"/>

<WireRestShape template="Rigid3d" name="GuideRestShape" wireMaterials="@StraightSection @SpireSection"/>

<EdgeSetTopologyContainer name='meshLinesGuide' />
<EdgeSetTopologyModifier name='Modifier' />
<EdgeSetGeometryAlgorithms name='GeomAlgo' template='Rigid3d' />
<MechanicalObject template='Rigid3d' name='dofTopo2' />
</Node>
<Node name='topoLines_coils'>
<WireRestShape template='Rigid3d' printLog='0' name='CoilRestShape' length='600.0' straightLength='540.0' spireDiameter='7' spireHeight='5.0'
densityOfBeams='40 20' numEdges='400' numEdgesCollis='30 30' youngModulus='168000' youngModulusExtremity='168000'/>
<EdgeSetTopologyContainer name='meshLinesCoils' />
<RodStraightSection name="StraightSection" youngModulus="168000" nbEdgesCollis="30" nbEdgesVisu="360" length="540.0"/>
<RodSpireSection name="SpireSection" youngModulus="168000" nbEdgesCollis="30" nbEdgesVisu="40" length="60.0" spireDiameter="7" spireHeight="5.0"/>

<WireRestShape template="Rigid3d" name="CoilRestShape" wireMaterials="@StraightSection @SpireSection"/>

<EdgeSetTopologyContainer name='meshLinesCoils' />
<EdgeSetTopologyModifier name='Modifier' />
<EdgeSetGeometryAlgorithms name='GeomAlgo' template='Rigid3d' />
<MechanicalObject template='Rigid3d' name='dofTopo3' />
Expand All @@ -53,10 +60,10 @@
<EulerImplicitSolver rayleighStiffness='0.2' rayleighMass='0.1' printLog='false' />
<BTDLinearSolver subpartSolve='0' verification='0' verbose='0'/>
<RegularGridTopology name='meshLinesCombined'
nx='60' ny='1' nz='1'
xmin='0.0' xmax='1.0'
ymin='0' ymax='0'
zmin='1' zmax='1'
nx='180' ny='1' nz='1'
xmin='0.0' xmax='1.0'
ymin='0' ymax='0'
zmin='1' zmax='1'
/>
<MechanicalObject template='Rigid3d' name='DOFs' showIndices='0' ry='-90'/>

Expand All @@ -69,11 +76,16 @@
<WireBeamInterpolation name='InterpolCoils' WireRestShape='@../topoLines_coils/CoilRestShape' radius='0.1' printLog='0'/>
<AdaptiveBeamForceFieldAndMass name='CoilsForceField' interpolation='@InterpolCoils' massDensity='0.000021'/> <!-- platine E = 168000 MPa // 21000 Kg/m3-->

<InterventionalRadiologyController template='Rigid3d' name='m_ircontroller' printLog='0' xtip='1 0 0' step='3' rotationInstrument='0 0 0'
controlledInstrument='0' startingPos='0 0 0 0 -0.7071068 0 0.7071068' speed='2' instruments='InterpolCatheter InterpolGuide InterpolCoils' />
<BeamAdapterActionController name="AController" interventionController="@IRController" writeMode="0"
timeSteps="9.1 17.1 17.55 18.05 18.6 19.05 19.55 20.05 20.5 21 21.45 21.9 22.65 23.1 23.55 24.05 24.55 25 25.45 25.95 26.4 27.1 27.55 28.05 28.55 29 29.5 29.95 30.4 30.9 31.4 31.85 32.35 33.05 33.5 34 34.45 34.9 35.4 35.85 36.35 36.8 37.25 37.7 38.2 38.65 39.4 39.85 40.3 40.7 41.2 41.65 42.1 42.55 43 43.4 44.1 44.55 45 45.45 45.9 46.3 46.75 47.2 47.65 48.1 48.55 49 49.65 50.1 50.5 50.9 51.35 51.75 52.2 52.6 53.05 53.5 53.95 54.4 54.85 55.5 55.9 59.1 66.15 66.6 67.05 67.45 67.9 68.35 68.8 69.25 69.65 70.1 70.55 71.2 71.6 72.05 72.5 72.95 73.4 77.6 81.9 87.4 87.75 88.1 88.45 88.75 89.1 89.45 89.75 90.1 90.6 90.9 91.25 91.6 91.95 92.3 92.6 92.95 93.25 93.6 93.95 94.25 94.6 94.95 95.4 95.75 96.1 96.4 96.75 97.05 97.35 97.7 98.05 98.4 98.7 99.15 99.5 99.8 100.15 100.45 100.75 101.1 101.4 101.75 102.05 102.55 102.85 103.2 103.5 103.8 104.1 104.4 104.75 105.05 105.4 105.7 106 106.45 106.75 107.1 107.4 107.7 108 108.35 108.65 108.95 109.25 109.55 110 110.3 110.6 110.9 111.2 111.45 111.75 112.05 112.35 112.65 113.1 113.35 113.65 113.95 114.2 114.5 114.8 115.1 115.35 115.65 116.1 116.35 125.8 128.2 131.6 131.8 132 132.25 132.45 132.65 132.85 133.05 133.3 133.5 133.8 134 134.2 134.4 134.6 134.8 135 135.2 135.4 135.6 135.8 136 136.3 136.5 136.75 136.95 137.15 137.35 137.5 137.7 137.9 138.15 138.3 138.6 138.85 139 139.2 139.4 139.6 139.8 140 140.15 140.35 140.55 140.75 140.95 141.25 141.45 141.65 141.85 142.05 142.25 142.45 142.65 142.85 143.05 143.25 143.45 143.65 143.85 144.15 144.3 144.5 144.7 144.9 145.1 145.3 145.45 145.65 145.95 146.1 146.3 146.5 146.7 146.9 147.1 147.25 147.45 147.65 147.85 148.05 148.25 148.4 148.7 148.9 149.1 149.25 149.45 149.65 149.85 150 150.2 150.35 150.55 150.75 150.9 151.05 151.3 151.45 151.6 151.8 151.95 152.1 152.25 152.4 152.65 152.8 153 153.15 153.3 153.45 153.6 153.75 153.9 154.1 154.25 154.4 154.6 154.75 154.9 155.1 155.25 155.4 155.55 155.7 155.85 156 156.15 156.4 156.55 156.7 156.85 157 157.15 157.3 157.45 157.6 157.75 157.9 158.05 159 160.9 163.4 163.55 163.7 163.85 164.1 164.25 164.4 164.55 164.75 164.9 165.05 165.2 165.35 165.5 165.65 165.8 165.95 166.15 166.35 166.5 166.7 166.85 167 167.15 167.3 167.45 167.65 167.8 167.95 168.1 168.25 168.45 168.6 168.8 169 169.15 169.3 169.45 169.6 169.8 169.95 170.1 170.25 170.4 170.55 170.7 170.95 171.1 171.25 171.4 171.55 171.75 171.9 172.05 172.2 172.45 172.6 172.75 172.9 173.1 173.25 185.8"
actions="1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1"
/>

<InterventionalRadiologyController template='Rigid3d' name='IRController' printLog='0' xtip='1 0 0' step='3' rotationInstrument='0 0 0'
controlledInstrument='0' startingPos='0 0 0 0 -0.7071068 0 0.7071068' speed='2' instruments='InterpolCatheter InterpolGuide InterpolCoils' />

<FixedConstraint name='FixedConstraint' indices='0' />
<RestShapeSpringsForceField points='@m_ircontroller.indexFirstNode' stiffness='1e8' angularStiffness='1e8' />
<RestShapeSpringsForceField points='@IRController.indexFirstNode' stiffness='1e8' angularStiffness='1e8' />

<Node name='VisuCatheter' activated='true'>
<MechanicalObject name='Quads' />
Expand Down
46 changes: 38 additions & 8 deletions examples/3instruments_collis.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
<html>
<head>
<link href="../../../../examples/Objects/sofa_white.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Scene controls</h1>
After launching the simulation ("Animate" button), clic on the viewport to give it the focus.<br>
<b>Ctrl+[UP/DOWN key]</b> move the tool forward/backward.<br>
<b>Ctrl+[LEFT/RIGHT key]</b> rotate the tool.<br>
<b>Ctrl+[0/1/2]</b> switch tool.<br>

<div id="contenu">
<center><h3>Beam Adapter 3 instruments interventional radiology </h3></center>
<br>
<div id="orangeText">Instruments control</div>
<br>
<div align="controler">
<i>Recorded motion has been recorded to demonstrate the 3 intruments behavior.</i>
<br>
<br>To manually test it, set the component <b>BeamAdapterActionController writeMode</b> to true.
<br>Then you can use the keyboard to control the instrument:
<ul>
<li>To change instrument
<ul>
<li><b> ctrl + 0</b>
<li><b> ctrl + 1</b>
<li><b> ctrl + 2</b>
</ul>
</li>
<li>To move the instrument forward/backward
<ul>
<li><b> ctrl + UP key</b>
<li><b> ctrl + DOWN key</b>
</ul>
</li>
<li>To turn instrument
<ul>
<li><b> ctrl + LEFT key</b>
<li><b> ctrl + RIGHT key</b>
</ul>
</li>
</ul>
<br>

</div>
</div>
</body>


</html>
Loading
Loading