iMSTK
Interactive Medical Simulation Toolkit
imstkPickingAlgorithm.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 "imstkGeometryAlgorithm.h"
10 #include "imstkCollisionData.h"
11 
12 namespace imstk
13 {
18 struct PickData
19 {
20  int ids[4] = { -1, -1, -1, -1 };
21  int idCount = 0;
22  CellTypeId cellType = IMSTK_VERTEX;
23  Vec3d pickPoint = Vec3d::Zero();
24  int cellId = -1;
25 };
26 
41 {
42 public:
44  {
45  setNumInputPorts(1);
46  setNumOutputPorts(0);
47  }
48 
49  ~PickingAlgorithm() override = default;
50 
54  const std::vector<PickData>& pick(std::shared_ptr<Geometry> geomToPick)
55  {
56  setInput(geomToPick, 0);
57  m_results.clear();
58  update();
59  return m_results;
60  }
61 
62  const std::vector<PickData>& getPickData() const { return m_results; }
63 
64 protected:
65  std::vector<PickData> m_results;
66 };
67 } // namespace imstk
Abstract functor for picking/selecting of geometry. Differs from collision in that the picking criter...
const std::vector< PickData > & pick(std::shared_ptr< Geometry > geomToPick)
Perform picking on provided geometry.
Compound Geometry.
int idCount
Indicates number of vertices (if 1 a cell or individual vertex)
int cellId
Supplemental cell id (when vertices are provided above and cell id is available)
Vec3d pickPoint
Some pickings may produce specific points on an element.
PickData provides ids to indicate what was picked These may be optionally used to indicate the select...
Abstract base class for geometry algorithms. GeometryAlgorithms take N input geometries and produce N...
CellTypeId cellType
Indicates picked cell type.
int ids[4]
Ids of the cell or vertices.