iMSTK
Interactive Medical Simulation Toolkit
imstkPointPicker.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 "imstkPickingAlgorithm.h"
10 
11 namespace imstk
12 {
13 class CollisionDetectionAlgorithm;
14 
23 {
24 public:
25  PointPicker() = default;
26  ~PointPicker() override = default;
27 
28  void requestUpdate() override;
29 
36  void setPickingRay(const Vec3d& rayStart, const Vec3d& rayDir,
37  const double maxDist = -1.0)
38  {
39  m_rayStart = rayStart;
40  m_rayDir = rayDir.normalized();
41  m_maxDist = maxDist;
42  }
43 
44  const Vec3d& getPickRayStart() const { return m_rayStart; }
45  const Vec3d& getPickRayDir() const { return m_rayDir; }
46 
51  void setUseFirstHit(const bool useFirstHit) { m_useFirstHit = useFirstHit; }
52  bool getUseFirstHit() const { return m_useFirstHit; }
54 
55 protected:
56  Vec3d m_rayStart = Vec3d::Zero();
57  Vec3d m_rayDir = Vec3d::Zero();
58  double m_maxDist = -1.0;
59  bool m_useFirstHit = true;
60 };
61 } // namespace imstk
Abstract functor for picking/selecting of geometry. Differs from collision in that the picking criter...
void requestUpdate() override
Users can implement this for the logic to be run.
Compound Geometry.
void setUseFirstHit(const bool useFirstHit)
Get/Set whether only the first hit is used otherwise all intersections are returned.
void setPickingRay(const Vec3d &rayStart, const Vec3d &rayDir, const double maxDist=-1.0)
Set the picking ray.
Picks points on elements of geomToPick via those that that are intersecting the provided ray...