iMSTK
Interactive Medical Simulation Toolkit
InflatableObject.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 "imstkMacros.h"
10 #include "imstkPbdObject.h"
11 
12 namespace imstk
13 {
14 class SurfaceMesh;
15 class TetrahedralMesh;
16 }; // namespace imstk
17 
18 using namespace imstk;
19 
26 {
27 public:
28  enum class InflationType
29  {
30  Linear,
31  Exponential,
32  None
33  };
34 
35  InflatableObject(const std::string& name, const Vec3d& tissueSize, const Vec3i& tissueDim, const Vec3d& tissueCenter);
36 
37 public:
38  IMSTK_TYPE_NAME(InflatableObject)
39 
40 
41  void inject(const Vec3d& toolTip, const double radius, double rate);
44 
48  void switchInflationType();
49 
50  void setInflationRatio(double ratio) { m_inflationRatio = ratio; }
51  void setInflationSize(double sigma) { m_sigma = sigma; }
52 
56  void setUpdateAffectedConstraint();
57 
58  void reset() override;
59 
60 protected:
64  void setSphereTexCoords(const double uvScale);
65 
69  void findAffectedConstraint(const Vec3d& toolTip, const double radius);
70 
74  inline double computeGaussianWeight(double x) { return 10 * exp(-0.5 * x * x / m_sigma / m_sigma) / m_sigma; }
75 
76 protected:
77  std::shared_ptr<TetrahedralMesh> m_objectTetMesh;
78  std::shared_ptr<SurfaceMesh> m_objectSurfMesh;
79 
80  std::vector<std::pair<int, double>> m_constraintIDandWeight;
81 
82  bool m_affectedAreaUpdated = false;
83 
84  double m_inflationRatio = 1.0;
85  double m_sigma = 1.0;
86 
87  InflationType m_inflationType = InflationType::Linear;
88 };
Compound Geometry.
Inflatable object based on PBD, with inflatable volume and distance constraints.
double computeGaussianWeight(double x)
Compute weight Gaussian distribution.
Represents a set of tetrahedrons & vertices via an array of Vec3d double vertices & Vec4i integer ind...
Base class for scene objects that move and/or deform under position based dynamics formulation...
Represents a set of triangles & vertices via an array of Vec3d double vertices & Vec3i integer indice...