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 "imstkArcNeedle.h"
9 #include "imstkCollisionDetectionAlgorithm.h"
10 #include "imstkImplicitGeometry.h"
11 #include "imstkLineMesh.h"
12 #include "imstkPuncturable.h"
13 #include "imstkRigidObject2.h"
14 #include "imstkTaskGraph.h"
15 #include "NeedleRigidBodyCH.h"
16 
17 using namespace imstk;
18 
19 NeedleInteraction::NeedleInteraction(std::shared_ptr<CollidingObject> tissueObj,
20  std::shared_ptr<RigidObject2> needleObj,
21  const std::string& collisionName) :
22  RigidObjectCollision(needleObj, tissueObj, collisionName)
23 {
24  CHECK(needleObj->containsComponent<ArcNeedle>())
25  << "NeedleInteraction only works with objects that have a ArcNeedle component";
26  CHECK(tissueObj->containsComponent<Puncturable>())
27  << "NeedleInteraction only works with objects that have a Puncturable component";
28  CHECK(std::dynamic_pointer_cast<ImplicitGeometry>(tissueObj->getCollidingGeometry()) != nullptr)
29  << "NeedleInteraction only works with SDF colliding geometry on colliding tissueObj";
30 
31  // First replace the handlers with our needle subclasses
32 
33  // This handler consumes collision data to resolve the tool from the tissue
34  // except when the needle is inserted
35  auto needleRbdCH = std::make_shared<NeedleRigidBodyCH>();
36  needleRbdCH->setInputRigidObjectA(needleObj);
37  needleRbdCH->setInputCollidingObjectB(tissueObj);
38  needleRbdCH->setInputCollisionData(getCollisionDetection()->getCollisionData());
39  needleRbdCH->setBaumgarteStabilization(0.01);
40  setCollisionHandlingA(needleRbdCH);
41 }
Place this on an object to make it puncturable by a needle. This allows puncturables to know they&#39;ve ...
Compound Geometry.