gramods
IntersectionVisitor.hh
1 
2 #ifndef GRAMODS_GRAPHICS_INTERSECTIONVISITOR
3 #define GRAMODS_GRAPHICS_INTERSECTIONVISITOR
4 
5 #include <gmGraphics/config.hh>
6 
7 #include <gmGraphics/IntersectionLine.hh>
8 #include <gmGraphics/Node.hh>
9 
10 #include <Eigen/Eigen>
11 #include <vector>
12 
13 BEGIN_NAMESPACE_GMGRAPHICS;
14 
29 
33  struct Intersection {
38  const Eigen::Vector3f local_position;
39 
44  const Eigen::Vector3f position;
45 
52  const std::vector<gmGraphics::Node *> node_path;
53  };
54 
59  IntersectionVisitor(IntersectionLine line) : line(line) {}
60 
64  void apply(gmCore::Object *node) override;
65 
70  std::vector<Intersection> intersections;
71 
72 protected:
73  const IntersectionLine line; //< Line checked against
74  std::vector<gmGraphics::Node *> node_path; //< Current path
75 };
76 
77 END_NAMESPACE_GMGRAPHICS;
78 
79 #endif
Base type for objects in the Gramods package for standardized handling of construction,...
Definition: Object.hh:42
Line for intersection with ray or segment.
Definition: IntersectionLine.hh:15
Data associated with an intersection.
Definition: IntersectionVisitor.hh:33
const std::vector< gmGraphics::Node * > node_path
The path taken through the scene graph to find this intersection.
Definition: IntersectionVisitor.hh:52
const Eigen::Vector3f position
The position of the intersection in the space where the line was defined and the visitor was first ap...
Definition: IntersectionVisitor.hh:44
const Eigen::Vector3f local_position
The position of the intersection in the local space of the node where the intersection was detected.
Definition: IntersectionVisitor.hh:38
Visitor that collects intersections.
Definition: IntersectionVisitor.hh:28
std::vector< Intersection > intersections
This is the list of intersections found by the visitors during traversal.
Definition: IntersectionVisitor.hh:70
IntersectionVisitor(IntersectionLine line)
Create a visitor for checking for intersection against the specified line.
Definition: IntersectionVisitor.hh:59
Base for Visitor:s that need to track the space transform through traversal.
Definition: Node.hh:36