iMSTK
Interactive Medical Simulation Toolkit
imstkArcNeedle.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 "imstkNeedle.h"
10 
11 namespace imstk
12 {
13 class LineMesh;
14 
15 class ArcNeedle : public Needle
16 {
17 public:
18  ArcNeedle(const std::string& name = "ArcNeedle") : Needle(name)
19  {
20  const Mat4d rot = mat4dRotation(Rotd(-PI_2, Vec3d(0.0, 1.0, 0.0))) *
21  mat4dRotation(Rotd(-0.6, Vec3d(1.0, 0.0, 0.0)));
22 
23  // Manually setup an arc aligned with the geometry, some sort of needle+arc generator
24  // could be a nice addition to imstk
25  Mat3d arcBasis = Mat3d::Identity();
26  arcBasis.col(0) = Vec3d(0.0, 0.0, -1.0);
27  arcBasis.col(1) = Vec3d(1.0, 0.0, 0.0);
28  arcBasis.col(2) = Vec3d(0.0, 1.0, 0.0);
29  arcBasis = rot.block<3, 3>(0, 0) * arcBasis;
30  const Vec3d arcCenter = (rot * Vec4d(0.0, -0.005455, 0.008839, 1.0)).head<3>();
31  const double arcRadius = 0.010705;
32  setArc(arcCenter, arcBasis, arcRadius, 0.558, 2.583);
33  }
34 
35  ~ArcNeedle() override = default;
36 
37  void setArc(const Vec3d& arcCenter, const Mat3d& arcBasis,
38  double arcRadius, double beginRad, double endRad)
39  {
40  m_arcCenter = arcCenter;
41  m_arcBasis = arcBasis;
42  m_beginRad = beginRad;
43  m_endRad = endRad;
44  m_arcRadius = arcRadius;
45  }
46 
50  const Mat3d& getArcBasis() const { return m_arcBasis; }
51 
55  const Vec3d& getArcCenter() { return m_arcCenter; }
56  const double getBeginRad() const { return m_beginRad; }
57  const double getEndRad() const { return m_endRad; }
58  const double getArcRadius() const { return m_arcRadius; }
59 
60 protected:
61  std::shared_ptr<LineMesh> m_needleGeom;
62 
63  Mat3d m_arcBasis = Mat3d::Identity();
64  Vec3d m_arcCenter = Vec3d::Zero();
65  double m_arcRadius = 1.0;
66  double m_beginRad = 0.0;
67  double m_endRad = PI * 2.0;
68 };
69 } // namespace imstk
Compound Geometry.
Base for all needles in imstk it supports global puncture state, per object puncture state...
Definition: imstkNeedle.h:20
const Mat3d & getArcBasis() const
Get the basis post transformation of the rigid body.
const Vec3d & getArcCenter()
Get the arc center post transformation of the rigid body.