iMSTK
Interactive Medical Simulation Toolkit
NeedleInteraction.h
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 #pragma once
8 
9 #include "imstkPbdRigidObjectCollision.h"
10 #include "imstkRigidObject2.h"
11 #include "imstkStraightNeedle.h"
12 #include "NeedlePbdCH.h"
13 #include "NeedleRigidBodyCH.h"
14 
15 using namespace imstk;
16 
23 {
24 public:
25  NeedleInteraction(std::shared_ptr<PbdObject> tissueObj,
26  std::shared_ptr<RigidObject2> needleObj,
27  const std::string& collisionName = "") : PbdRigidObjectCollision(tissueObj, needleObj, collisionName)
28  {
29  CHECK(needleObj->containsComponent<StraightNeedle>())
30  << "NeedleInteraction only works with objects that have a StraightNeedle component";
31  CHECK(tissueObj->containsComponent<Puncturable>())
32  << "NeedleInteraction only works with objects that have a Puncturable component";
33 
34  auto needleRbdCH = std::make_shared<NeedleRigidBodyCH>();
35  needleRbdCH->setInputRigidObjectA(needleObj);
36  needleRbdCH->setInputCollidingObjectB(tissueObj);
37  needleRbdCH->setInputCollisionData(getCollisionDetection()->getCollisionData());
38  needleRbdCH->setBaumgarteStabilization(0.001);
39  setCollisionHandlingB(needleRbdCH);
40 
41  auto needlePbdCH = std::make_shared<NeedlePbdCH>();
42  needlePbdCH->setInputObjectA(tissueObj);
43  needlePbdCH->setInputObjectB(needleObj);
44  needlePbdCH->setInputCollisionData(getCollisionDetection()->getCollisionData());
45  // These two can control compliance
46  needlePbdCH->setDeformableStiffnessA(1.0);
47  needlePbdCH->setDeformableStiffnessB(0.01);
48  setCollisionHandlingA(needlePbdCH);
49  }
50 
51  ~NeedleInteraction() override = default;
52 };
This class defines a collision interaction between a first order PbdObject and second order RigidObje...
Defines interaction between NeedleObject and PbdObject.
void setCollisionHandlingB(std::shared_ptr< CollisionHandling > colHandlingB)
Set the Collision Handling for object B.
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.