iMSTK
Interactive Medical Simulation Toolkit
imstkNeedle.cpp
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 #include "imstkNeedle.h"
8 
9 namespace imstk
10 {
11 void
12 Needle::setPuncture(const PunctureId& id, std::shared_ptr<Puncture> data)
13 {
14  m_punctures[id] = data;
15 }
16 
17 std::shared_ptr<Puncture>
18 Needle::getPuncture(const PunctureId& id)
19 {
20  auto iter = m_punctures.find(id);
21  if (iter == m_punctures.end())
22  {
23  m_punctures[id] = std::make_shared<Puncture>();
24  }
25  return m_punctures[id];
26 }
27 
28 void
29 Needle::setState(const PunctureId& id, const Puncture::State state)
30 {
31  auto iter = m_punctures.find(id);
32  if (iter == m_punctures.end())
33  {
34  m_punctures[id] = std::make_shared<Puncture>();
35  }
36  m_punctures[id]->state = state;
37 }
38 
39 Puncture::State
40 Needle::getState(const PunctureId& id)
41 {
42  return getPuncture(id)->state;
43 }
44 
45 bool
47 {
48  for (auto puncture : m_punctures)
49  {
50  if (puncture.second->state == Puncture::State::INSERTED)
51  {
52  return true;
53  }
54  }
55  return false;
56 }
57 } // namespace imstk
Compound Geometry.
void setPuncture(const PunctureId &id, std::shared_ptr< Puncture > data)
Get/Set puncture data.
Definition: imstkNeedle.cpp:12
void setState(const PunctureId &id, const Puncture::State state)
Get/set puncture state. This can be done through data too but this supports the allocation of new pun...
Definition: imstkNeedle.cpp:29
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
bool getInserted() const
Get if inserted at all.
Definition: imstkNeedle.cpp:46