iMSTK
Interactive Medical Simulation Toolkit
NeedleInteraction.cpp
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #include "NeedleInteraction.h"
8 #include "imstkCollidingObject.h"
9 #include "imstkCollisionDetectionAlgorithm.h"
10 #include "imstkLineMesh.h"
11 #include "imstkPuncturable.h"
12 #include "imstkRigidObject2.h"
13 #include "imstkSignedDistanceField.h"
14 #include "imstkStraightNeedle.h"
15 #include "imstkTaskGraph.h"
16 #include "NeedleRigidBodyCH.h"
17 
18 using namespace imstk;
19 
20 NeedleInteraction::NeedleInteraction(std::shared_ptr<CollidingObject> tissueObj,
21  std::shared_ptr<RigidObject2> needleObj,
22  const std::string& collisionName) :
23  RigidObjectCollision(needleObj, tissueObj, collisionName)
24 {
25  CHECK(needleObj->containsComponent<StraightNeedle>())
26  << "NeedleInteraction only works with StraightNeedle component";
27  CHECK(tissueObj->containsComponent<Puncturable>())
28  << "NeedleInteraction only works with Puncturable component";
29  CHECK(std::dynamic_pointer_cast<ImplicitGeometry>(tissueObj->getCollidingGeometry()) != nullptr)
30  << "NeedleInteraction only works with SDF colliding geometry on colliding tissueObj";
31 
32  // First replace the handlers with our needle subclasses
33 
34  // This handler consumes collision data to resolve the tool from the tissue
35  // except when the needle is inserted
36  auto needleRbdCH = std::make_shared<NeedleRigidBodyCH>();
37  needleRbdCH->setInputRigidObjectA(needleObj);
38  needleRbdCH->setInputCollidingObjectB(tissueObj);
39  needleRbdCH->setInputCollisionData(getCollisionDetection()->getCollisionData());
40  needleRbdCH->setBaumgarteStabilization(0.001);
41  setCollisionHandlingA(needleRbdCH);
42 }
Place this on an object to make it puncturable by a needle. This allows puncturables to know they&#39;ve ...
Compound Geometry.
Definition of straight, single segment needle.
void setCollisionHandlingA(std::shared_ptr< CollisionHandling > colHandlingA)
Set the Collision Handling for object A.