3 Needles have physics approximations in iMSTK. There are currently many examples within iMSTK that do implement needles to check out. Amongst others, `PBDTissueSurfaceNeedleContact`, `PBDTissueVolumeNeedleContact`.
6 <img src="media/needleTissue.gif" alt="pbd needle puncture volume"/>
11 iMSTK currently contains two types of needle definitions.
12 - StraigthNeedle: A single line segment needle.
13 - ArcNeedle: Define with an arc. Also provides a LineMesh for collision.
15 To setup a PBD simulated `StraightNeedle` that is also controlled with a `PbdObjectController` one can do:
18 auto toolObj = std::make_shared<PbdObject>();
20 auto toolGeometry = std::make_shared<LineMesh>();
21 auto verticesPtr = std::make_shared<VecDataArray<double, 3>>(2);
22 (*verticesPtr)[0] = Vec3d(0.0, 0.0, 0.0);
23 (*verticesPtr)[1] = Vec3d(0.0, 0.0, 0.25);
24 auto indicesPtr = std::make_shared<VecDataArray<int, 2>>(1);
25 (*indicesPtr)[0] = Vec2i(0, 1);
26 toolGeometry->initialize(verticesPtr, indicesPtr);
28 toolObj->setVisualGeometry(toolGeometry);
29 toolObj->setCollidingGeometry(toolGeometry);
30 toolObj->setPhysicsGeometry(toolGeometry);
31 toolObj->setDynamicalModel(model);
32 toolObj->getPbdBody()->setRigid(
33 Vec3d(0.0, 1.0, 0.0), // Position
35 Quatd::Identity(), // Orientation
36 Mat3d::Identity() * 10000.0); // Inertia
38 // Add a component for controlling via another device
39 auto controller = toolObj->addComponent<PbdObjectController>();
40 controller->setControlledObject(toolObj);
41 controller->setLinearKs(20000.0);
42 controller->setAngularKs(8000000.0);
43 controller->setUseCritDamping(true);
44 controller->setForceScaling(0.05);
45 controller->setSmoothingKernelSize(15);
46 controller->setUseForceSmoothening(true);
49 Add the needle component:
52 // Add a component for needle puncturing
53 auto needle = toolObj->addComponent<StraightNeedle>();
54 needle->setNeedleGeometry(toolGeometry);
59 Needles work in junction with Puncturables. Puncturable exists to keep track of the punctures on a tissue. To define something as puncturable add the component to the `toolObj`.
62 toolObj->addComponent<Puncturable>();
67 Both Needle and Puncturable contain a PunctureMap which is a map of the objects punctures. It's assumed:
68 - A needle can puncture N different tissues.
69 - A needle can puncture the same tissue multiple times.
70 - A tissue can be punctured by N needles.
71 - A tissue can be punctured multiple times.
75 A puncture is defined as having a state `REMOVED`, `TOUCHING`, or `INSERTED`. This holds true for all needles. Though sometimes instant puncture needles are desirable, in which case `TOUCHING` would not be used. A puncture also contains a `UserData`. This is not used by iMSTK but tends to be useful in user code. It contains the ids of the puncturable, ids of the cell punctured, and barycentric weights. When puncture occurs a `Puncture` is added to both the `Puncturable` and the `Needle`'s `PunctureMap`. This way each can keep track of what punctures it has. ie: `PunctureMap` is not shared, but individual `Puncture`'s are shared.
79 As mentioned `NeedleInteraction` is not yet available in iMSTK but is defined in many iMSTK examples. See [PBDTissueVolumeNeedleContact](Examples/PBDTissueVolumeNeedleContact.md) for one such example. Though the internals differ the user facing API is mostly the same.
82 auto needleInteraction = std::make_shared<NeedleInteraction>(tissueObj, needleToolObj);
84 scene->addSceneObject(needleInteraction);
88 <img src="media/needles.png" alt="pbd needle puncture volume"/>
93 Suturing is not yet in iMSTK but has been prototyped in an example.
95 