IntersectionQueryEngine2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: IntersectionQueryEngine2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Abstract base class for 2-D intersection test query engine.
6 > Created Time: 2017/10/14
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_INTERSECTION_QUERY_ENGINE2_H
10 #define CUBBYFLOW_INTERSECTION_QUERY_ENGINE2_H
11 
13 #include <Core/Vector/Vector2.h>
14 
15 namespace CubbyFlow
16 {
18  template <typename T>
20  {
21  const T* item = nullptr;
22  double distance = std::numeric_limits<double>::max();
23  };
24 
26  template <typename T>
27  using ClosestIntersectionDistanceFunc2 = std::function<double(const T&, const Vector2D&)>;
28 
30  template <typename T>
31  using BoxIntersectionTestFunc2 = std::function<bool(const T&, const BoundingBox2D&)>;
32 
34  template <typename T>
35  using RayIntersectionTestFunc2 = std::function<bool(const T&, const Ray2D&)>;
36 
38  template <typename T>
39  using GetRayIntersectionFunc2 = std::function<double(const T&, const Ray2D&)>;
40 
42  template <typename T>
43  using IntersectionVisitorFunc2 = std::function<void(const T&)>;
44 
46  template <typename T>
48  {
49  public:
51  virtual bool IsIntersects(
52  const BoundingBox2D& box,
53  const BoxIntersectionTestFunc2<T>& testFunc) const = 0;
54 
56  virtual bool IsIntersects(
57  const Ray2D& ray,
58  const RayIntersectionTestFunc2<T>& testFunc) const = 0;
59 
61  virtual void ForEachIntersectingItem(
62  const BoundingBox2D& box, const BoxIntersectionTestFunc2<T>& testFunc,
63  const IntersectionVisitorFunc2<T>& visitorFunc) const = 0;
64 
66  virtual void ForEachIntersectingItem(
67  const Ray2D& ray, const RayIntersectionTestFunc2<T>& testFunc,
68  const IntersectionVisitorFunc2<T>& visitorFunc) const = 0;
69 
72  const Ray2D& ray, const GetRayIntersectionFunc2<T>& testFunc) const = 0;
73  };
74 }
75 
76 #endif
virtual bool IsIntersects(const BoundingBox2D &box, const BoxIntersectionTestFunc2< T > &testFunc) const =0
Returns true if given box intersects with any of the stored items.
Abstract base class for 2-D intersection test query engine.
Definition: IntersectionQueryEngine2.h:47
Closest intersection query result.
Definition: IntersectionQueryEngine2.h:19
virtual ClosestIntersectionQueryResult2< T > GetClosestIntersection(const Ray2D &ray, const GetRayIntersectionFunc2< T > &testFunc) const =0
Returns the closest intersection for given ray.
Class for 2-D ray.
Definition: Ray2.h:23
const T * item
Definition: IntersectionQueryEngine2.h:21
std::function< bool(const T &, const BoundingBox2D &)> BoxIntersectionTestFunc2
Box-item intersection test function.
Definition: IntersectionQueryEngine2.h:31
2-D axis-aligned bounding box class.
Definition: BoundingBox2.h:44
Definition: pybind11Utils.h:24
std::function< void(const T &)> IntersectionVisitorFunc2
Visitor function which is invoked for each intersecting item.
Definition: IntersectionQueryEngine2.h:43
double distance
Definition: IntersectionQueryEngine2.h:22
virtual void ForEachIntersectingItem(const BoundingBox2D &box, const BoxIntersectionTestFunc2< T > &testFunc, const IntersectionVisitorFunc2< T > &visitorFunc) const =0
Invokes visitorFunc for every intersecting items.
std::function< double(const T &, const Vector2D &)> ClosestIntersectionDistanceFunc2
Closest intersection distance measure function.
Definition: IntersectionQueryEngine2.h:27
std::function< double(const T &, const Ray2D &)> GetRayIntersectionFunc2
Ray-item closest intersection evaluation function.
Definition: IntersectionQueryEngine2.h:39
std::function< bool(const T &, const Ray2D &)> RayIntersectionTestFunc2
Ray-item intersection test function.
Definition: IntersectionQueryEngine2.h:35