Helios++
Helios software for LiDAR simulations
GroveKDTreeRaycaster.h
1 #pragma once
2 
3 #include <LightKDTreeNode.h>
4 #include <DynObject.h>
5 #include <KDTreeRaycaster.h>
6 #include <RaycasterGroveTree.h>
7 #include <KDTreeFactory.h>
8 #include <adt/custom/PointerVector.h>
9 
19  public RaycasterGroveTree<DynObject>,
20  public KDTreeRaycaster
21 {
22 protected:
23  // *** ATTRIBUTES *** //
24  // ******************** //
28  std::shared_ptr<KDTreeFactory> kdtf;
29 
30  // CACHE ATTRIBUTES
35  std::shared_ptr<PointerVector<Primitive>> cache_prims;
36 
37 public:
38  // *** CONSTRUCTION / DESTRUCTION *** //
39  // ************************************ //
45  std::shared_ptr<LightKDTreeNode> root,
46  std::shared_ptr<KDTreeFactory> kdtf=nullptr,
47  std::shared_ptr<PointerVector<Primitive>> cache_prims=nullptr
48  ) :
50  kdtf(kdtf),
52  {}
58  virtual ~GroveKDTreeRaycaster() = default;
59 
60  // *** RAYCASTING METHODS *** //
61  // **************************** //
65  std::map<double, Primitive*> searchAll(
66  glm::dvec3 rayOrigin,
67  glm::dvec3 rayDir,
68  double tmin,
69  double tmax,
70  bool groundOnly
71  ) override {return KDTreeRaycaster::searchAll(
72  rayOrigin, rayDir, tmin, tmax, groundOnly
73  );}
78  glm::dvec3 rayOrigin,
79  glm::dvec3 rayDir,
80  double tmin,
81  double tmax,
82  bool groundOnly
83  ) override {return KDTreeRaycaster::search(
84  rayOrigin, rayDir, tmin, tmax, groundOnly
85  );}
86 
87  // *** GROVE DYNAMIC TREE METHODS *** //
88  // ************************************ //
94  void update(DynObject &dynObj) override;
95 
106  virtual std::shared_ptr<GroveKDTreeRaycaster> makeTemporalClone() const;
107 
115  std::shared_ptr<PointerVector<Primitive>> sharedCopy(
116  std::vector<Primitive *> const &src
117  ) const;
118 };
Dynamic object base implementation.
Definition: DynObject.h:23
Grove KDTree Raycaster extends KDTreeRaycaster to make it compatible with groves by implementing the ...
Definition: GroveKDTreeRaycaster.h:21
GroveKDTreeRaycaster(std::shared_ptr< LightKDTreeNode > root, std::shared_ptr< KDTreeFactory > kdtf=nullptr, std::shared_ptr< PointerVector< Primitive >> cache_prims=nullptr)
Default Grove KDTree ray caster constructor.
Definition: GroveKDTreeRaycaster.h:44
RaySceneIntersection * search(glm::dvec3 rayOrigin, glm::dvec3 rayDir, double tmin, double tmax, bool groundOnly) override
Definition: GroveKDTreeRaycaster.h:77
virtual std::shared_ptr< GroveKDTreeRaycaster > makeTemporalClone() const
Make a temporal clone of the GroveKDTreeRaycaster.
Definition: GroveKDTreeRaycaster.cpp:27
virtual ~GroveKDTreeRaycaster()=default
The destructor of Grove KDTree must destroy any cache-related resource that doesnt make sense after t...
void update(DynObject &dynObj) override
Method to handle callbacks from updated dynamic objects.
Definition: GroveKDTreeRaycaster.cpp:10
std::shared_ptr< KDTreeFactory > kdtf
The KDTreeFactory to be used to rebuild the KDTree if necessary.
Definition: GroveKDTreeRaycaster.h:28
std::shared_ptr< PointerVector< Primitive > > cache_prims
The cache of primitives defining the last state for the root node of the raycasting process.
Definition: GroveKDTreeRaycaster.h:35
std::shared_ptr< PointerVector< Primitive > > sharedCopy(std::vector< Primitive * > const &src) const
Generate a shared pointer to a copy of the given vector of primitives. Copy implies that primitives a...
Definition: GroveKDTreeRaycaster.cpp:34
std::map< double, Primitive * > searchAll(glm::dvec3 rayOrigin, glm::dvec3 rayDir, double tmin, double tmax, bool groundOnly) override
Definition: GroveKDTreeRaycaster.h:65
Class representing a KDTree ray caster.
Definition: KDTreeRaycaster.h:16
std::map< double, Primitive * > searchAll(glm::dvec3 const rayOrigin, glm::dvec3 const rayDir, double const tmin, double const tmax, bool const groundOnly) override
Definition: KDTreeRaycaster.cpp:6
std::shared_ptr< LightKDTreeNode > root
Shared pointer to the root node of the KDTree.
Definition: KDTreeRaycaster.h:109
RaySceneIntersection * search(glm::dvec3 const rayOrigin, glm::dvec3 const rayDir, double const tmin, double const tmax, bool const groundOnly) override
Definition: KDTreeRaycaster.cpp:29
Wrapper to have a vector of pointers such that when it is destroyed, all the pointers are deleted.
Definition: PointerVector.h:17
Class representing a the intersection of a ray over a scene made of primitives.
Definition: RaySceneIntersection.h:12
Define a Raycaster derived interface to make it compatible with groves.
Definition: RaycasterGroveTree.h:22