Program Listing for File BigGridKdTree.hpp

Return to documentation for file (include/lvr2/reconstruction/BigGridKdTree.hpp)

/*
 * BigGridKdTree.hpp
 *
 *  Created on: Aug 30, 2017
 *      Author: Isaak Mitschke
 */

#ifndef LAS_VEGAS_BIGGRIDKDTREE_H
#define LAS_VEGAS_BIGGRIDKDTREE_H
#include "BigGrid.hpp"
#include "lvr2/geometry/BoundingBox.hpp"

#include <memory>
#include <vector>

namespace lvr2
{

template <typename BaseVecT>
class BigGridKdTree
{
  public:
    BigGridKdTree(BoundingBox<BaseVecT>& bb,
                  size_t maxNodePoints,
                  BigGrid<BaseVecT>* grid,
                  float voxelsize,
                  size_t numPoints = 0);
    virtual ~BigGridKdTree();

    void insert(size_t numPoints, BaseVecT pos);
    static std::vector<BigGridKdTree*> getLeafs();
    static std::vector<BigGridKdTree*> getNodes() { return s_nodes; }
    inline size_t getNumPoints() { return m_numPoints; }
    inline BoundingBox<BaseVecT>& getBB() { return m_bb; }

  private:
    BoundingBox<BaseVecT> m_bb;

    size_t m_numPoints;

    std::vector<BigGridKdTree*> m_children;

    BigGridKdTree(BoundingBox<BaseVecT>& bb, size_t numPoints = 0);

    static std::vector<BigGridKdTree*> s_nodes;

    static float s_voxelsize;

    static size_t s_maxNodePoints;

    static BigGrid<BaseVecT>* m_grid;

    inline bool fitsInBox(BaseVecT& pos)
    {
        return pos.x > m_bb.getMin().x && pos.y > m_bb.getMin().y && pos.z > m_bb.getMin().z &&
               pos.x < m_bb.getMax().x && pos.y < m_bb.getMax().y && pos.z < m_bb.getMax().z;
    }
};

} // namespace lvr2

#include "lvr2/reconstruction/BigGridKdTree.tcc"

#endif // LAS_VEGAS_BIGGRIDKDTREE_H