Template Class HashGrid

Inheritance Relationships

Base Type

Derived Type

Class Documentation

template<typename BaseVecT, typename BoxT>
class HashGrid : public lvr2::GridBase

Subclassed by lvr2::PointsetGrid< BaseVecT, BoxT >

Public Types

typedef std::unordered_map<Vector3i, BoxT*> box_map

type alias for box map

typedef std::vector<QueryPoint<BaseVecT>*> qp_list

type alias for list of query points

typedef box_map::iterator box_map_it

Typedef to alias iterators for box maps.

typedef qp_list::iterator query_point_it

Typedef to alias iterators to query points.

Public Functions

HashGrid(float resolution, BoundingBox<BaseVecT> bb, bool isVoxelsize = true, bool extrude = true)

Construct an empty HashGrid object.

Parameters:
  • resolution – if isVoxelsize: voxel size. if not: number of voxels on the longest size of bb.

  • bb – the bounding box of the grid

  • isVoxelsize – see resolution description

  • extrude – add cells around the existing ones

inline HashGrid(std::string file, const BoundingBox<BaseVecT> &boundingBox, float voxelsize)

Construct a new Hash Grid object from a file.

Parameters:
  • file – A file written by saveGrid(file).

  • boundingBox – Bounding box of the grid.

  • voxelsize – The voxel size of the grid.

inline HashGrid(const std::vector<std::string> &files, const BoundingBox<BaseVecT> &boundingBox, float voxelsize)

Construct a new Hash Grid object from multiple files.

Parameters:
  • files – A list of files each written by saveGrid(file).

  • boundingBox – Bounding box of the grid.

  • voxelsize – The voxel size of the grid.

HashGrid(const std::vector<string> &files, const std::vector<BoundingBox<BaseVecT>> &innerBoxes, const BoundingBox<BaseVecT> &boundingBox, float voxelsize)

Construct a new Hash Grid object from multiple files.

Parameters:
  • files – A list of files each written by saveGrid(file).

  • innerBoxes – A list of bounding boxes for each file. Useful for removing overlap.

  • boundingBox – Bounding box of the grid.

  • voxelsize – The voxel size of the grid.

inline HashGrid(PointBufferPtr src, const BoundingBox<BaseVecT> &boundingBox, float voxelsize)

Construct a new Hash Grid object from a PointBuffer.

Parameters:
  • src – A PointBuffer created with toPointBuffer().

  • boundingBox – Bounding box of the grid.

  • voxelsize – The voxel size of the grid.

HashGrid(const std::vector<PointBufferPtr> &chunks, const std::vector<BoundingBox<BaseVecT>> &innerBoxes, const BoundingBox<BaseVecT> &boundingBox, float voxelsize)

Construct a new Hash Grid object from multiple PointBuffers.

Parameters:
  • chunks – A list of PointBuffers each created with toPointBuffer().

  • innerBoxes – A list of bounding boxes for each buffer. Useful for removing overlap.

  • boundingBox – Bounding box of the grid.

  • voxelsize – The voxel size of the grid.

PointBufferPtr toPointBuffer() const

Create a PointBuffer containing the cells and distances.

Can be converted back to a HashGrid with HashGrid(PointBufferPtr, …).

virtual void addLatticePoint(int i, int j, int k, float distance = 0.0) override

Add one cell to the grid. When adding multiple cells, use addLatticePoints()

Note that distances are measured at the Corners of a cell, and the distance parameter is only used to fill remaining corners that aren’t shared with existing cells.

Parameters:
  • i – Discrete x position within the grid.

  • j – Discrete y position within the grid.

  • k – Discrete z position within the grid.

  • distance – Signed distance to the represented surface at the position within the grid.

void addLatticePoints(const std::unordered_set<Vector3i> &indices)

Add many lattice points at once.

Parameters:

indices – the {i,j,k} indices of the lattice points

virtual void saveGrid(std::string file) override

Saves a representation of the grid to the given file.

Parameters:

file – Output file name.

inline size_t getNumberOfCells() const
inline box_map_it firstCell()
Returns:

Returns an iterator to the first box in the cell map.

inline box_map_it lastCell()
Returns:

Returns an iterator to the last box in the cell map.

inline query_point_it firstQueryPoint()
Returns:

Returns an iterator to the first query point

inline query_point_it lastQueryPoint()
inline std::vector<QueryPoint<BaseVecT>> &getQueryPoints()
inline const std::vector<QueryPoint<BaseVecT>> &getQueryPoints() const
inline box_map &getCells()
inline const box_map &getCells() const
virtual ~HashGrid()
inline void setBB(BoundingBox<BaseVecT> &bb)
inline BoundingBox<BaseVecT> &getBoundingBox()
inline const BoundingBox<BaseVecT> &getBoundingBox() const
uint findQueryPoint(int position, const Vector3i &index) const

Searches for a existing shared lattice point in the grid.

Parameters:
  • position – Number of a possible neighbor

  • index – index within the grid

Returns:

Query point index of the found point, INVALID_INDEX otherwise

inline void calcIndex(const BaseVecT &vec, Vector3i &index) const
inline Vector3i calcIndex(const BaseVecT &vec) const
inline void indexToCenter(const Vector3i &index, BaseVecT &center) const
inline BaseVecT indexToCenter(const Vector3i &index) const

Protected Functions

void fillNeighbors()

Fill in the neighbors of all cells.

BoxT *addBox(const Vector3i &index, const BaseVecT &center, float *distances)
inline BoxT *addBox(const BaseVecT &center, float *distances)
inline BoxT *addBox(const Vector3i &index, float *distances)

Protected Attributes

box_map m_cells

Map to handle the boxes in the grid.

float m_voxelsize

The voxelsize used for reconstruction.

std::vector<QueryPoint<BaseVecT>> m_queryPoints

A vector containing the query points for the reconstruction.

BoundingBox<BaseVecT> m_boundingBox

Bounding box of the covered volume.