9 #include "imstkMacros.h" 10 #include "imstkPbdCollisionHandling.h" 11 #include "imstkPbdPointTriangleConstraint.h" 12 #include "imstkSurfaceMesh.h" 14 #include "imstkSurfaceInsertionConstraint.h" 15 #include "imstkThreadInsertionConstraint.h" 47 Vec3i triVertIds = { -1, -1, -1 };
49 Vec3d baryCoords = { 0.0, 0.0, 0.0 };
56 std::vector<PuncturePoint> thread;
57 std::vector<PuncturePoint> needle;
58 std::vector<std::vector<PuncturePoint>> stitch;
64 void init(std::shared_ptr<PbdObject> threadObj);
75 const std::vector<CollisionElement>& elementsA,
76 const std::vector<CollisionElement>& elementsB)
override;
78 void generateNewPunctureData();
79 void addPunctureConstraints();
81 void setNeedleToSurfaceStiffness(
double stiffness) { m_needleToSurfaceStiffness = stiffness; }
82 double getNeedleToSurfaceStiffness() {
return m_needleToSurfaceStiffness; }
84 void setSurfaceToNeedleStiffness(
double stiffness) { m_surfaceToNeedleStiffness = stiffness; }
85 double getSurfaceToNeedleStiffness() {
return m_surfaceToNeedleStiffness; }
87 void setThreadToSurfaceStiffness(
double stiffness) { m_needleToSurfaceStiffness = stiffness; }
88 double getThreadToSurfaceStiffness() {
return m_needleToSurfaceStiffness; }
90 void setSurfaceToThreadStiffness(
double stiffness) { m_surfaceToThreadStiffness = stiffness; }
91 double getSurfaceToThreadStiffness() {
return m_surfaceToThreadStiffness; }
93 void setPunctureDotThreshold(
double threshold) { m_threshold = threshold; }
94 double getPunctureDotThreshold() {
return m_threshold; }
102 std::vector<bool> m_isThreadPunctured;
105 std::vector<std::shared_ptr<SurfaceInsertionConstraint>> pointTriangleConstraints;
108 std::vector<std::shared_ptr<PbdBaryPointToPointConstraint>> m_stitchConstraints;
111 std::vector<std::shared_ptr<PbdConstraint>> m_constraints;
112 std::vector<PbdConstraint*> m_solverConstraints;
118 bool m_stitch =
false;
121 std::vector<Vec3d> m_stitchPoints;
124 std::shared_ptr<PbdObject> m_threadObj;
125 std::shared_ptr<LineMesh> m_threadMesh;
128 std::shared_ptr<PbdObject> m_pbdTissueObj;
129 std::shared_ptr<SurfaceMesh> m_tissueSurfMesh;
131 std::shared_ptr<PbdObject> m_needleObj;
132 std::shared_ptr<LineMesh> m_needleMesh;
137 double m_needleToSurfaceStiffness = 0.2;
138 double m_surfaceToNeedleStiffness = 0.2;
139 double m_threadToSurfaceStiffness = 0.2;
140 double m_surfaceToThreadStiffness = 0.2;
142 bool m_needlePunctured =
false;
143 bool m_threadPunctured =
false;
146 double m_threshold = 0.8;
150 std::vector<PbdParticleId> m_particles;
151 std::vector<std::shared_ptr<PbdConstraint>> m_threadConstraints;
153 bool didPuncture(
const std::vector<CollisionElement>& elementsA,
const std::vector<CollisionElement>& elementsB);
void handle(const std::vector< CollisionElement > &elementsA, const std::vector< CollisionElement > &elementsB) override
Handles puncture constraints for both the needle and the thread.
Implements PBD based collision handling. Given an input PbdObject and CollisionData it creates & adds...
Represents a set of tetrahedrons & vertices via an array of Vec3d double vertices & Vec4i integer ind...
Base class for all volume mesh types.
void init(std::shared_ptr< PbdObject > threadObj)
Initialize interaction data.
Base class for scene objects that move and/or deform under position based dynamics formulation...
Constrains two points from two separate cells/elements given via barycentric coordinates to be coinci...
Handles penetration constraints for the needle and the thread by creating a set of puncture points th...