iMSTK
Interactive Medical Simulation Toolkit
imstkPbdConnectiveTissueConstraintGenerator.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 "imstkPbdConstraintFunctor.h"
10 #include "imstkMath.h"
11 
12 #include <unordered_map>
13 
14 namespace imstk
15 {
16 class PbdObject;
17 class PbdConstraintContainer;
18 class PbdBaryPointToPointConstraint;
19 class PbdModel;
20 class ProximitySurfaceSelector;
21 
32 
34 {
35 public:
37  ~PbdConnectiveTissueConstraintGenerator() override = default;
38 
43  void setConnectiveStrandObj(std::shared_ptr<PbdObject> connectiveStrandObj) { m_connectiveStrandObj = connectiveStrandObj; }
44 
51 
57  void setConnectedObjA(std::shared_ptr<PbdObject> objA) { m_objA = objA; }
58 
64  void setConnectedObjB(std::shared_ptr<PbdObject> objB) { m_objB = objB; }
65 
69  void operator()(PbdConstraintContainer& constraints) override;
70 
74  void setDistStiffness(double stiffness) { m_distStiffness = stiffness; }
75  double getDistStiffness() { return m_distStiffness; }
77 
81  void setTolerance(double tolerance) { m_tolerance = tolerance; }
82  double getTolerance() { return m_tolerance; }
84 
85 protected:
86 
92  std::shared_ptr<PbdObject> pbdObj,
93  PbdConstraintContainer& constraints);
94 
100  std::shared_ptr<PbdObject> pbdObj,
101  PbdConstraintContainer& constraints);
102 
103  std::shared_ptr<PbdObject> m_connectiveStrandObj = nullptr;
104  std::shared_ptr<PbdObject> m_objA = nullptr;
105  std::shared_ptr<PbdObject> m_objB = nullptr;
106 
107  double m_distStiffness = 50.0;
108  double m_tolerance = 0.00001;
109 };
110 
116 std::shared_ptr<PbdObject> addConnectiveTissueConstraints(
117  std::shared_ptr<LineMesh> connectiveLineMesh,
118  std::shared_ptr<PbdObject> objA,
119  std::shared_ptr<PbdObject> objB,
120  std::shared_ptr<PbdModel> model,
121  double mass = 0.005,
122  double distStiffness = 10000000000);
123 
143 
144 std::shared_ptr<PbdObject> makeConnectiveTissue(
145  std::shared_ptr<PbdObject> objA,
146  std::shared_ptr<PbdObject> objB,
147  std::shared_ptr<PbdModel> model,
148  double maxDist,
149  double strandsPerFace,
150  int segmentsPerStrand,
151  std::shared_ptr<ProximitySurfaceSelector> selector,
152  double mass,
153  double distStiffness,
154  double allowedAngleDeviation);
155 
156 std::shared_ptr<PbdObject> makeConnectiveTissue(
157  std::shared_ptr<PbdObject> objA,
158  std::shared_ptr<PbdObject> objB,
159  std::shared_ptr<PbdModel> model,
160  double maxDist = 0.0,
161  double strandsPerFace = 1,
162  int segmentsPerStrand = 3,
163  double mass = 0.005,
164  double distStiffness = 1.0e10,
165  double allowedAngleDeviation = PI);
166 } // namespace imstk
void setConnectedObjB(std::shared_ptr< PbdObject > objB)
Sets PBD object to connect to connective straints assumes the surface mesh of ObjB is coincident with...
std::shared_ptr< PbdObject > m_objA
Organ being connected.
Container for pbd constraints.
void connectLineToTetMesh(std::shared_ptr< PbdObject > pbdObj, PbdConstraintContainer &constraints)
Used to generate connecting constraints when the body being attached uses a tet mesh as the physics m...
void setTolerance(double tolerance)
Get/Set Tolerance for checking coincidence of surface to line mesh.
Compound Geometry.
std::shared_ptr< PbdObject > m_objB
Organ being connected.
std::shared_ptr< PbdObject > m_connectiveStrandObj
Connective tissue that is made.
void setConnectiveStrandObj(std::shared_ptr< PbdObject > connectiveStrandObj)
Sets PBD object that represents the connective tissue. This must use a line mesh for the physics mesh...
double m_distStiffness
Stiffness used for distance constraints.
void setDistStiffness(double stiffness)
Get/Set the stiffness for the distance constraint.
void connectLineToSurfMesh(std::shared_ptr< PbdObject > pbdObj, PbdConstraintContainer &constraints)
Used to generate connecting constraints when the body being attached uses a surface mesh as the physi...
void setConnectedObjA(std::shared_ptr< PbdObject > objA)
Sets PBD object to connect to connective strands assumes the surface mesh of ObjA is coincident with ...
void operator()(PbdConstraintContainer &constraints) override
Appends a set of constraint to the container given a geometry & body.
double m_tolerance
Tolerance for checking coincidence of surface to line mesh.
void generateDistanceConstraints()
Creates distance constraints for the connective strands using the default m_distStiffness value...
Abstract PbdConstraintFunctor that assumes usage of a singular body & geometry.