7 #include "imstkNeedleInteraction.h" 8 #include "imstkCollisionDetectionAlgorithm.h" 9 #include "imstkLineMesh.h" 10 #include "imstkNeedle.h" 11 #include "imstkPbdObject.h" 12 #include "imstkPuncturable.h" 13 #include "imstkNeedlePbdCH.h" 17 NeedleInteraction::NeedleInteraction(std::shared_ptr<PbdObject> tissueObj,
18 std::shared_ptr<PbdObject> needleObj,
19 std::shared_ptr<PbdObject> threadObj)
23 CHECK(threadObj !=
nullptr) <<
"NeedleInteraction: Thread object cannot be null";
24 CHECK(tissueObj !=
nullptr) <<
"NeedleInteraction: Tissue object cannot be null";
25 CHECK(needleObj !=
nullptr) <<
"NeedleInteraction: Needle object cannot be null";
27 if (!needleObj->containsComponent<
Needle>())
29 needleObj->addComponent<
Needle>();
30 LOG(INFO) <<
"NeedleInteraction: Needle component added to needle object";
36 LOG(INFO) <<
"NeedleInteraction: Puncturable component added to tissue object";
39 CHECK(std::dynamic_pointer_cast<SurfaceMesh>(tissueObj->getCollidingGeometry()) !=
nullptr) <<
40 "NeedleInteraction only works with SufraceMesh collision geometry on the tissue object";
41 CHECK(std::dynamic_pointer_cast<LineMesh>(needleObj->getCollidingGeometry()) !=
nullptr) <<
42 "NeedleInteraction only works with LineMesh collision geometry on NeedleObject";
44 CHECK(threadObj->getPbdModel() == tissueObj->getPbdModel()
45 && threadObj->getPbdModel() == needleObj->getPbdModel())
46 <<
"Tissue, thread, and needle must share a PbdModel";
49 auto needlePbdCH = std::make_shared<NeedlePbdCH>();
50 needlePbdCH->setInputObjectA(tissueObj);
51 needlePbdCH->setInputObjectB(needleObj);
52 needlePbdCH->setInputCollisionData(getCollisionDetection()->getCollisionData());
53 needlePbdCH->init(threadObj);
54 setCollisionHandlingAB(needlePbdCH);
58 NeedleInteraction::stitch()
60 auto CH = std::dynamic_pointer_cast<
NeedlePbdCH>(this->getCollisionHandlingAB());
64 const NeedlePbdCH::PunctureData&
65 NeedleInteraction::getPunctureData()
67 auto CH = std::dynamic_pointer_cast<
NeedlePbdCH>(this->getCollisionHandlingAB());
68 return CH->getPunctureData();
Place this on an object to make it puncturable by a needle. This allows puncturables to know they've ...
void stitch()
Create stitching constraints on button press for four or more puncture points.
Base for all needles in imstk it supports global puncture state, per object puncture state...
This class defines a collision interaction between two PbdObjects or PbdObject & CollidingObject.
Handles penetration constraints for the needle and the thread by creating a set of puncture points th...