iMSTK
Interactive Medical Simulation Toolkit
imstkPuncture.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 "imstkMath.h"
10 
11 #include <unordered_map>
12 
13 namespace imstk
14 {
21 using PunctureId = std::tuple<int, int, int>;
22 
27 struct Puncture
28 {
29  public:
30  enum class State
31  {
32  REMOVED,
33  TOUCHING,
34  INSERTED
35  };
40  struct UserData
41  {
42  int id = -1;
43  int ids[4];
44  Vec4d weights = Vec4d::Zero();
45  };
46 
47  public:
48  //PunctureId id;
49  State state = State::REMOVED;
50  UserData userData;
51 };
52 
59 {
60  std::size_t operator()(const imstk::PunctureId& k) const
61  {
62  // Swapping 0 and 1 should result in equivalence.
63  return cantor(symCantor(std::get<0>(k), std::get<1>(k)), std::get<2>(k));
64  }
65 };
72 {
73  bool operator()(const imstk::PunctureId& a, const imstk::PunctureId& b) const
74  {
75  std::pair<int, int> a1 = { std::get<0>(a), std::get<1>(a) };
76  if (a1.second < a1.first)
77  {
78  std::swap(a1.first, a1.second);
79  }
80  std::pair<int, int> b1 = { std::get<0>(b), std::get<1>(b) };
81  if (b1.second < b1.first)
82  {
83  std::swap(b1.first, b1.second);
84  }
85  return (a1.first == b1.first) && (a1.second == b1.second) && (std::get<2>(a) == std::get<2>(b));
86  }
87 };
88 
89 using PunctureMap = std::unordered_map<PunctureId, std::shared_ptr<Puncture>, PunctureIdHash, PunctureIdEq>;
90 } // namespace imstk
Compound Geometry.
Accompanying data stored with a puncture. No usage within Needle structure.
Definition: imstkPuncture.h:40
The entity and tissue id should be reversible.
Definition: imstkPuncture.h:71
The puncture itself is composed of a state and extra non-essential user data.
Definition: imstkPuncture.h:27
The entity and tissue id should be reversible.
Definition: imstkPuncture.h:58
std::tuple< int, int, int > PunctureId
Punctures are identified via three ints. The needle id, the puncturable id, and a local id that allow...
Definition: imstkPuncture.h:21