VoxelGrid.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Rainer Kartmann (rainer dot kartmann at student dot kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 #include <vector>
27 
28 #include <Eigen/Geometry>
29 
30 #include "VoxelGridStructure.h"
31 #include "exceptions.h"
32 
33 namespace visionx::voxelgrid
34 {
35 
36  /**
37  * @brief A 3D grid of voxels of type _VoxelT.
38  *
39  * A `VoxelGrid` three-dimensional regular grid of cuboids, called voxels.
40  * Its geometric structure is defined by a `VoxelGridStructure`.
41  * In addition, it stores voxel data of type _VoxelT (one per voxel).
42  *
43  * This is a generic implementation made to hold hold arbitrary data.
44  * As such, there is no concept of "free/occupied" voxels".
45  *
46  * @see VoxelGridStructure
47  */
48  template <typename _VoxelT>
49  class VoxelGrid
50  {
51  public:
52  /// The voxel type.
53  using VoxelT = _VoxelT;
54 
55 
56  public:
57  /// Construct a voxel grid with 0 voxels of size 1.0.
58  VoxelGrid();
59 
60  /// Construct a voxel grid with the given structure and voxels with given value.
61  VoxelGrid(const VoxelGridStructure& structure, const VoxelT& value = {});
62 
63  /**
64  * @brief Construct a voxel grid with the given structure and data.
65  * The size of `voxelData` must match the grid size of `structure`.
66  * @throw error::InvalidVoxelDataSize If the size does not match.
67  */
68  VoxelGrid(const VoxelGridStructure& structure,
69  const std::vector<VoxelGrid::VoxelT>& voxelData);
70 
71  /// Construct a voxel grid with the same structure as other.
72  template <typename OtherVoxelT>
73  VoxelGrid(const VoxelGrid<OtherVoxelT>& other);
74 
75  /// Ordinary copy constructor for voxel grid with same VoxelT.
76  VoxelGrid(const VoxelGrid<VoxelT>& other) = default;
77 
78  /// Reset the voxel data by `numVoxels()` voxels with given value.
79  void
80  reset(const VoxelT& value = {})
81  {
82  _voxels.assign(numVoxels(), value);
83  }
84 
85  /// Get the voxel grid structure.
87  getStructure() const
88  {
89  return _struct;
90  }
91 
92  /// Set the voxel grid structure and reset voxel data.
93  void
95  {
96  this->_struct = structure;
97  reset();
98  }
99 
100  /// Get the voxel with the given index. @see `operator[]`
101  VoxelT&
102  getVoxel(std::size_t index)
103  {
104  return _voxels.at(index);
105  }
106 
107  const VoxelT&
108  getVoxel(std::size_t index) const
109  {
110  return _voxels.at(index);
111  }
112 
113  /// Get the voxel with the given grid index. @see `operator[]`
114  VoxelT&
115  getVoxel(int x, int y, int z)
116  {
117  return getVoxel(getVoxelFlatIndex(x, y, z));
118  }
119 
120  const VoxelT&
121  getVoxel(int x, int y, int z) const
122  {
123  return getVoxel(getVoxelFlatIndex(x, y, z));
124  }
125 
126  /// Get the voxel with the given grid index. @see `operator[]`
127  VoxelT&
128  getVoxel(const Eigen::Vector3i& index)
129  {
131  }
132 
133  const VoxelT&
134  getVoxel(const Eigen::Vector3i& index) const
135  {
137  }
138 
139  /// Get the voxel closest to the given point.
140  /// @param local If false (default), the point is transformed to local coordinate system.
141  VoxelT&
142  getVoxel(const Eigen::Vector3f& point, bool local = false)
143  {
144  return getVoxel(getVoxelGridIndex(point, local));
145  }
146 
147  const VoxelT&
148  getVoxel(const Eigen::Vector3f& point, bool local = false) const
149  {
150  return getVoxel(getVoxelGridIndex(point, local));
151  }
152 
153  /// Get the voxels.
154  /// @note `VoxelGrid` provides begin()/end() pairs, so it can be iterated over directly.
155  const std::vector<VoxelT>&
156  getVoxels() const
157  {
158  return _voxels;
159  }
160 
161  /// Set the voxels. (Size must match `numVoxels()`).
162  /// @throw error::InvalidVoxelDataSize If the size does not match.
163  void
164  setVoxels(const std::vector<VoxelT>& voxels)
165  {
166  if (voxels.size() != numVoxels())
167  {
168  throw error::InvalidVoxelDataSize(voxels.size(), numVoxels());
169  }
170  this->_voxels = voxels;
171  }
172 
173  /// Get the number of voxels in the grid.
174  std::size_t
175  numVoxels() const
176  {
177  return getNumVoxels();
178  }
179 
180  /// Get the number of voxels in the grid.
181  std::size_t
182  getNumVoxels() const
183  {
184  return _struct.getNumVoxels();
185  }
186 
187  /// Get the grid size.
188  Eigen::Vector3i
189  getGridSizes() const
190  {
191  return _struct.getGridSize();
192  }
193 
194  /// Set the grid size for a cubic grid. Resets the grid data.
195  void
196  setGridSizes(float gridSizes)
197  {
198  _struct.setGridSize(gridSizes);
199  }
200 
201  /// Set the grid size. This resets the grid data.
202  void
203  setGridSizes(const Eigen::Vector3i& gridSizes)
204  {
205  _struct.setGridSize(gridSizes);
206  reset();
207  }
208 
209  /// Get the voxel size.
210  Eigen::Vector3f
212  {
213  return _struct.getVoxelSize();
214  }
215 
216  /// Set the voxel size of cubic voxels. The grid data is not updated.
217  void
218  setVoxelSizes(float voxelSize)
219  {
220  _struct.setVoxelSize(voxelSize);
221  }
222 
223  /// Set the voxel size. The grid data is not updated.
224  void
225  setVoxelSizes(const Eigen::Vector3f& voxelSizes)
226  {
227  _struct.setVoxelSize(voxelSizes);
228  }
229 
230  /// Get the flat index of the voxel with given grid index.
231  std::size_t
232  getVoxelFlatIndex(int x, int y, int z) const
233  {
234  return _struct.getFlatIndex(x, y, z);
235  }
236 
237  /// Get the flat index of the voxel with given grid index.
238  std::size_t
239  getVoxelFlatIndex(const Eigen::Vector3i& index) const
240  {
241  return _struct.getFlatIndex(index);
242  }
243 
244  /// Get the flat index of the voxel closest to `point`.
245  std::size_t
246  getVoxelFlatIndex(const Eigen::Vector3f& point, bool local = false) const
247  {
248  return _struct.getFlatIndex(point, local);
249  }
250 
251  /// Get the grid index of the voxel with the given flat index.
252  Eigen::Vector3i
253  getVoxelGridIndex(size_t index) const
254  {
255  return _struct.getGridIndex(index);
256  }
257 
258  /// Get the grid index of the voxel closest to point.
259  /// @param local If false (default), the point is transformed to local coordinate system.
260  Eigen::Vector3i
261  getVoxelGridIndex(const Eigen::Vector3f& point, bool local = false) const
262  {
263  return _struct.getGridIndex(point, local);
264  }
265 
266  /// Get the minimal (along each axis) voxel grid index.
267  Eigen::Vector3i
269  {
270  return _struct.getGridIndexMin();
271  }
272 
273  /// Get the maximal (along each axis) voxel grid index.
274  Eigen::Vector3i
276  {
277  return _struct.getGridIndexMax();
278  }
279 
280  /// Get the center of the voxel with the given index.
281  Eigen::Vector3f
282  getVoxelCenter(std::size_t index, bool local = false) const
283  {
284  return _struct.getVoxelCenter(index, local);
285  }
286 
287  /// Get the center of the voxel with the given index.
288  Eigen::Vector3f
289  getVoxelCenter(int x, int y, int z, bool local = false) const
290  {
291  return _struct.getVoxelCenter(x, y, z, local);
292  }
293 
294  /// Get the center of the voxel with the given index.
295  Eigen::Vector3f
296  getVoxelCenter(const Eigen::Vector3i& index, bool local = false) const
297  {
298  return _struct.getVoxelCenter(index, local);
299  }
300 
301  /// Get the grid origin in the world frame (center of voxel [0 0 0]).
302  /// Note that this differs from the geometric center for even grid sizes.
303  /// @see getCenter()
304  Eigen::Vector3f
305  getOrigin() const
306  {
307  return _struct.getOrigin();
308  }
309 
310  /// Set the grid origin the world frame (center of voxel [0 0 0]).
311  /// Note that this differs from the geometric center for even grid sizes.
312  /// @see setCenter()
313  void
314  setOrigin(const Eigen::Vector3f& value)
315  {
317  }
318 
319  /// Get the grid orienation in the world frame.
322  {
323  return _struct.getOrientation();
324  }
325 
326  /// Set the grid orienation in the world frame.
327  void
329  {
331  }
332 
333  /**
334  * @brief Get the geometric center of the grid the world frame
335  * (which differs from the origin for even grid sizes).
336  */
337  Eigen::Vector3f
338  getCenter() const
339  {
340  return _struct.getCenter();
341  }
342 
343  /**
344  * @brief Set the geometric center of the grid the world frame
345  * (which differs from the origin for even grid sizes).
346  *
347  * @note This computes the origin from the given center using the
348  * current orientation. If you want to set grid center and orientation,
349  * set the orientation first, or (equivalently), use `setCenterPose()`.
350  *
351  * @see setPoseGridCenter()
352  */
353  void
354  setCenter(const Eigen::Vector3f& value)
355  {
357  }
358 
359  /// Get the grid pose in the world frame.
360  /// Note that this differs from the geometric center for even grid sizes.
361  /// @see getCenterPose()
363  getPose() const
364  {
365  return _struct.getPose();
366  }
367 
368  /// Get the grid pose in the world frame.
369  /// Note that this differs from the geometric center for even grid sizes.
370  /// @see setCenterPose()
371  void
373  {
375  }
376 
377  /// Get the grid pose positioned at the grid center in the world frame.
380  {
381  return _struct.getCenterPose();
382  }
383 
384  /// Set the grid pose so that the grid center is the position of the
385  /// given pose under the given orientation.
386  void
388  {
390  }
391 
392  /// Get extent of the grid along each axis (encompassing the whole voxels).
393  Eigen::Vector3f
394  getExtents() const
395  {
396  return _struct.getExtent();
397  }
398 
399  /// Get extent of the grid along each axis (encompassing only voxel centers).
400  Eigen::Vector3f
402  {
403  return _struct.getExtentOfCenters();
404  }
405 
406  /// Get the local axis aligned bounding box of the grid (minimal/maximal values in columns).
409  {
410  return _struct.getLocalBoundingBox();
411  }
412 
413  /// Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns).
416  {
418  }
419 
420  /// Indicate whether the given point is inside the voxel.
421  bool
422  isInside(const Eigen::Vector3i& index) const
423  {
424  return _struct.isInside(index);
425  }
426 
427  /// Indicate whether the given point is inside the voxel.
428  bool
429  isInside(const Eigen::Vector3f& point, bool local = false) const
430  {
431  return _struct.isInside(point, local);
432  }
433 
434  /// Assert that the given index is a valid grid index.
435  void
436  checkIsInside(const Eigen::Vector3i& index) const
437  {
438  return _struct.checkIsInside(index);
439  }
440 
441  /// Get the voxel with given flat index. @see `getVoxel(std::size_t)`
442  VoxelT&
443  operator[](std::size_t index)
444  {
445  return getVoxel(index);
446  }
447 
448  const VoxelT&
449  operator[](std::size_t index) const
450  {
451  return getVoxel(index);
452  }
453 
454  /// Get the voxel with given grid index. @see `getVoxel(const Eigen::Vector3i&)`
455  VoxelT&
456  operator[](const Eigen::Vector3i& index)
457  {
458  return getVoxel(index);
459  }
460 
461  const VoxelT&
462  operator[](const Eigen::Vector3i& index) const
463  {
464  return getVoxel(index);
465  }
466 
467  /// Get an iterator to the first voxel.
468  typename std::vector<VoxelT>::iterator
470  {
471  return _voxels.begin();
472  }
473 
474  /// Get an iterator to the first voxel.
475  typename std::vector<VoxelT>::const_iterator
476  begin() const
477  {
478  return _voxels.begin();
479  }
480 
481  /// Get an iterator to the first voxel.
482  typename std::vector<VoxelT>::const_iterator
483  cbegin() const
484  {
485  return _voxels.begin();
486  }
487 
488  /// Get an iterator to the element following the last voxel.
489  typename std::vector<VoxelT>::iterator
490  end()
491  {
492  return _voxels.end();
493  }
494 
495  /// Get an iterator to the element following the last voxel.
496  typename std::vector<VoxelT>::const_iterator
497  end() const
498  {
499  return _voxels.end();
500  }
501 
502  /// Get an iterator to the element following the last voxel.
503  typename std::vector<VoxelT>::const_iterator
504  cend() const
505  {
506  return _voxels.end();
507  }
508 
509 
510  /// Stream a human-readable description of the grid's structure.
511  template <class VoxelType>
512  friend std::ostream& operator<<(std::ostream& os, const VoxelGrid<VoxelType>& grid);
513 
514 
515  protected:
516  /// The geometric structure.
518 
519  /// The voxel data.
520  std::vector<VoxelT> _voxels;
521  };
522 
523  template <typename VT>
525  {
526  }
527 
528  template <typename VT>
530  VoxelGrid(structure, std::vector<VoxelT>(structure.getNumVoxels(), value))
531  {
532  }
533 
534  template <typename VT>
536  const std::vector<VoxelGrid::VoxelT>& voxelData) :
537  _struct(structure)
538  {
539  if (voxelData.size() != structure.getNumVoxels())
540  {
541  throw error::InvalidVoxelDataSize(voxelData.size(), structure.getNumVoxels());
542  }
543  _voxels = voxelData;
544  }
545 
546  template <typename VT>
547  template <typename OtherVoxelT>
548  VoxelGrid<VT>::VoxelGrid(const VoxelGrid<OtherVoxelT>& other) : VoxelGrid(other.getStructure())
549  {
550  }
551 
552  template <typename VT>
553  std::ostream&
554  operator<<(std::ostream& os, const VoxelGrid<VT>& grid)
555  {
556  os << "VoxelGrid " << grid._struct;
557  return os;
558  }
559 
560 } // namespace visionx::voxelgrid
visionx::voxelgrid::VoxelGrid::cbegin
std::vector< VoxelT >::const_iterator cbegin() const
Get an iterator to the first voxel.
Definition: VoxelGrid.hpp:483
exceptions.h
visionx::voxelgrid::VoxelGridStructure::getGridIndexMin
Eigen::Vector3i getGridIndexMin() const
Get the minimal (along each axis) grid index.
Definition: VoxelGridStructure.cpp:175
visionx::voxelgrid::VoxelGrid::setVoxels
void setVoxels(const std::vector< VoxelT > &voxels)
Set the voxels.
Definition: VoxelGrid.hpp:164
visionx::voxelgrid::VoxelGridStructure::getGridIndexMax
Eigen::Vector3i getGridIndexMax() const
Get the maximal (along each axis) grid index.
Definition: VoxelGridStructure.cpp:185
visionx::voxelgrid::VoxelGrid::setGridSizes
void setGridSizes(float gridSizes)
Set the grid size for a cubic grid. Resets the grid data.
Definition: VoxelGrid.hpp:196
visionx::voxelgrid::VoxelGrid::begin
std::vector< VoxelT >::iterator begin()
Get an iterator to the first voxel.
Definition: VoxelGrid.hpp:469
visionx::voxelgrid::VoxelGrid::getVoxel
const VoxelT & getVoxel(int x, int y, int z) const
Definition: VoxelGrid.hpp:121
visionx::voxelgrid::VoxelGrid::getVoxelFlatIndex
std::size_t getVoxelFlatIndex(int x, int y, int z) const
Get the flat index of the voxel with given grid index.
Definition: VoxelGrid.hpp:232
visionx::voxelgrid::VoxelGrid
A 3D grid of voxels of type _VoxelT.
Definition: VoxelGrid.hpp:49
visionx::voxelgrid::VoxelGrid::end
std::vector< VoxelT >::iterator end()
Get an iterator to the element following the last voxel.
Definition: VoxelGrid.hpp:490
visionx::voxelgrid::VoxelGrid::setCenterPose
void setCenterPose(const Eigen::Matrix4f &value)
Set the grid pose so that the grid center is the position of the given pose under the given orientati...
Definition: VoxelGrid.hpp:387
index
uint8_t index
Definition: EtherCATFrame.h:59
visionx::voxelgrid::VoxelGrid::reset
void reset(const VoxelT &value={})
Reset the voxel data by numVoxels() voxels with given value.
Definition: VoxelGrid.hpp:80
visionx::voxelgrid::VoxelGrid::VoxelGrid
VoxelGrid()
Construct a voxel grid with 0 voxels of size 1.0.
Definition: VoxelGrid.hpp:524
visionx::voxelgrid::VoxelGrid::getVoxelSizes
Eigen::Vector3f getVoxelSizes() const
Get the voxel size.
Definition: VoxelGrid.hpp:211
visionx::voxelgrid::VoxelGridStructure::getFlatIndex
std::size_t getFlatIndex(int x, int y, int z) const
Get the flat index for the given grid indices.
Definition: VoxelGridStructure.cpp:113
visionx::voxelgrid::VoxelGrid::_voxels
std::vector< VoxelT > _voxels
The voxel data.
Definition: VoxelGrid.hpp:520
visionx::voxelgrid::VoxelGridStructure::getVoxelSize
Eigen::Vector3f getVoxelSize() const
Get the voxel size.
Definition: VoxelGridStructure.cpp:89
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
visionx::voxelgrid::VoxelGridStructure::setGridSize
void setGridSize(int gridSize)
Set the grid size for a cubic grid.
Definition: VoxelGridStructure.cpp:77
visionx::voxelgrid::VoxelGrid::getPose
Eigen::Matrix4f getPose() const
Get the grid pose in the world frame.
Definition: VoxelGrid.hpp:363
visionx::voxelgrid::VoxelGridStructure::getOrientation
Eigen::Quaternionf getOrientation() const
Get the grid orienation in the world frame.
Definition: VoxelGridStructure.cpp:235
visionx::voxelgrid::VoxelGrid::setVoxelSizes
void setVoxelSizes(const Eigen::Vector3f &voxelSizes)
Set the voxel size. The grid data is not updated.
Definition: VoxelGrid.hpp:225
VoxelGridStructure.h
visionx::voxelgrid::VoxelGrid::operator[]
VoxelT & operator[](std::size_t index)
Get the voxel with given flat index.
Definition: VoxelGrid.hpp:443
visionx::voxelgrid::VoxelGrid::setGridSizes
void setGridSizes(const Eigen::Vector3i &gridSizes)
Set the grid size. This resets the grid data.
Definition: VoxelGrid.hpp:203
visionx::voxelgrid::VoxelGrid::resetStructure
void resetStructure(const VoxelGridStructure &structure)
Set the voxel grid structure and reset voxel data.
Definition: VoxelGrid.hpp:94
visionx::voxelgrid::VoxelGridStructure::setPose
void setPose(const Eigen::Matrix4f &pose)
Get the grid pose in the world frame.
Definition: VoxelGridStructure.cpp:265
visionx::voxelgrid::VoxelGrid< VoxelT >::VoxelT
VoxelT VoxelT
The voxel type.
Definition: VoxelGrid.hpp:53
visionx::voxelgrid::operator<<
std::ostream & operator<<(std::ostream &os, const VoxelGrid< VT > &grid)
Definition: VoxelGrid.hpp:554
visionx::voxelgrid::VoxelGrid::setOrientation
void setOrientation(const Eigen::Quaternionf &value)
Set the grid orienation in the world frame.
Definition: VoxelGrid.hpp:328
visionx::voxelgrid::VoxelGrid::getVoxelFlatIndex
std::size_t getVoxelFlatIndex(const Eigen::Vector3i &index) const
Get the flat index of the voxel with given grid index.
Definition: VoxelGrid.hpp:239
visionx::voxelgrid::VoxelGridStructure::getPose
Eigen::Matrix4f getPose() const
Get the grid pose in the world frame.
Definition: VoxelGridStructure.cpp:259
visionx::voxelgrid::VoxelGrid::setCenter
void setCenter(const Eigen::Vector3f &value)
Set the geometric center of the grid the world frame (which differs from the origin for even grid siz...
Definition: VoxelGrid.hpp:354
visionx::voxelgrid::VoxelGridStructure::getExtentOfCenters
Eigen::Vector3f getExtentOfCenters() const
Get extent of the grid along each axis (encompassing only voxel centers).
Definition: VoxelGridStructure.cpp:291
visionx::voxelgrid::error::InvalidVoxelDataSize
Indicates that voxel data with an invalid number of voxels has been passed to a VoxelGrid.
Definition: exceptions.h:26
visionx::voxelgrid::VoxelGrid::cend
std::vector< VoxelT >::const_iterator cend() const
Get an iterator to the element following the last voxel.
Definition: VoxelGrid.hpp:504
visionx::voxelgrid::VoxelGrid::getStructure
VoxelGridStructure getStructure() const
Get the voxel grid structure.
Definition: VoxelGrid.hpp:87
visionx::voxelgrid::VoxelGridStructure::getExtent
Eigen::Vector3f getExtent() const
Get extent of the grid along each axis (encompassing the whole voxels).
Definition: VoxelGridStructure.cpp:285
visionx::voxelgrid
Definition: exceptions.cpp:7
visionx::voxelgrid::VoxelGrid::getVoxel
VoxelT & getVoxel(int x, int y, int z)
Get the voxel with the given grid index.
Definition: VoxelGrid.hpp:115
visionx::voxelgrid::VoxelGrid::getVoxel
const VoxelT & getVoxel(std::size_t index) const
Definition: VoxelGrid.hpp:108
visionx::voxelgrid::VoxelGrid::operator[]
VoxelT & operator[](const Eigen::Vector3i &index)
Get the voxel with given grid index.
Definition: VoxelGrid.hpp:456
visionx::voxelgrid::VoxelGrid::getVoxel
VoxelT & getVoxel(std::size_t index)
Get the voxel with the given index.
Definition: VoxelGrid.hpp:102
visionx::voxelgrid::VoxelGridStructure::getLocalBoundingBoxOfCenters
Eigen::Matrix32f getLocalBoundingBoxOfCenters() const
Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns).
Definition: VoxelGridStructure.cpp:306
visionx::voxelgrid::VoxelGrid::isInside
bool isInside(const Eigen::Vector3f &point, bool local=false) const
Indicate whether the given point is inside the voxel.
Definition: VoxelGrid.hpp:429
visionx::voxelgrid::VoxelGridStructure::isInside
bool isInside(const Eigen::Vector3i &indices) const
Indicate whether the given point is inside the voxel.
Definition: VoxelGridStructure.cpp:315
visionx::voxelgrid::VoxelGrid::numVoxels
std::size_t numVoxels() const
Get the number of voxels in the grid.
Definition: VoxelGrid.hpp:175
visionx::voxelgrid::VoxelGridStructure
Geometric structure of a 3D voxel grid.
Definition: VoxelGridStructure.h:94
visionx::voxelgrid::VoxelGrid::end
std::vector< VoxelT >::const_iterator end() const
Get an iterator to the element following the last voxel.
Definition: VoxelGrid.hpp:497
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
visionx::voxelgrid::VoxelGridStructure::getGridSize
Eigen::Vector3i getGridSize() const
Get the grid size.
Definition: VoxelGridStructure.cpp:71
visionx::voxelgrid::VoxelGrid::getVoxelCenter
Eigen::Vector3f getVoxelCenter(const Eigen::Vector3i &index, bool local=false) const
Get the center of the voxel with the given index.
Definition: VoxelGrid.hpp:296
visionx::voxelgrid::VoxelGrid::begin
std::vector< VoxelT >::const_iterator begin() const
Get an iterator to the first voxel.
Definition: VoxelGrid.hpp:476
visionx::voxelgrid::VoxelGridStructure::setCenter
void setCenter(const Eigen::Vector3f &center)
Set the geometric center of the grid the world frame (which differs from the origin for even grid siz...
Definition: VoxelGridStructure.cpp:253
visionx::voxelgrid::VoxelGridStructure::setOrigin
void setOrigin(const Eigen::Vector3f &value)
Set the grid origin the world frame (center of voxel [0 0 0]).
Definition: VoxelGridStructure.cpp:229
visionx::voxelgrid::VoxelGridStructure::setOrientation
void setOrientation(const Eigen::Quaternionf &value)
Set the grid orienation in the world frame.
Definition: VoxelGridStructure.cpp:241
visionx::voxelgrid::VoxelGridStructure::getCenterPose
Eigen::Matrix4f getCenterPose() const
Get the grid pose positioned at the grid center in the world frame.
Definition: VoxelGridStructure.cpp:272
visionx::voxelgrid::VoxelGrid::setOrigin
void setOrigin(const Eigen::Vector3f &value)
Set the grid origin the world frame (center of voxel [0 0 0]).
Definition: VoxelGrid.hpp:314
visionx::voxelgrid::VoxelGrid::getVoxelGridIndex
Eigen::Vector3i getVoxelGridIndex(size_t index) const
Get the grid index of the voxel with the given flat index.
Definition: VoxelGrid.hpp:253
visionx::voxelgrid::VoxelGrid::getVoxel
VoxelT & getVoxel(const Eigen::Vector3f &point, bool local=false)
Get the voxel closest to the given point.
Definition: VoxelGrid.hpp:142
visionx::voxelgrid::VoxelGrid::operator<<
friend std::ostream & operator<<(std::ostream &os, const VoxelGrid< VoxelType > &grid)
Stream a human-readable description of the grid's structure.
visionx::voxelgrid::VoxelGrid::getVoxelGridIndexMax
Eigen::Vector3i getVoxelGridIndexMax() const
Get the maximal (along each axis) voxel grid index.
Definition: VoxelGrid.hpp:275
visionx::voxelgrid::VoxelGrid::getOrientation
Eigen::Quaternionf getOrientation() const
Get the grid orienation in the world frame.
Definition: VoxelGrid.hpp:321
visionx::voxelgrid::VoxelGrid::getVoxelGridIndex
Eigen::Vector3i getVoxelGridIndex(const Eigen::Vector3f &point, bool local=false) const
Get the grid index of the voxel closest to point.
Definition: VoxelGrid.hpp:261
visionx::voxelgrid::VoxelGrid::getExtents
Eigen::Vector3f getExtents() const
Get extent of the grid along each axis (encompassing the whole voxels).
Definition: VoxelGrid.hpp:394
visionx::voxelgrid::VoxelGridStructure::getVoxelCenter
Eigen::Vector3f getVoxelCenter(std::size_t index, bool local=false) const
Get the center of the voxel with the given indices.
Definition: VoxelGridStructure.cpp:196
visionx::voxelgrid::VoxelGrid::getNumVoxels
std::size_t getNumVoxels() const
Get the number of voxels in the grid.
Definition: VoxelGrid.hpp:182
visionx::voxelgrid::VoxelGrid::getOrigin
Eigen::Vector3f getOrigin() const
Get the grid origin in the world frame (center of voxel [0 0 0]).
Definition: VoxelGrid.hpp:305
visionx::voxelgrid::VoxelGrid::getCenter
Eigen::Vector3f getCenter() const
Get the geometric center of the grid the world frame (which differs from the origin for even grid siz...
Definition: VoxelGrid.hpp:338
visionx::voxelgrid::VoxelGrid::operator[]
const VoxelT & operator[](std::size_t index) const
Definition: VoxelGrid.hpp:449
visionx::voxelgrid::VoxelGridStructure::getNumVoxels
std::size_t getNumVoxels() const
Get the number of voxels contained in the structure.
Definition: VoxelGridStructure.cpp:107
std
Definition: Application.h:66
armarx::Quaternion< float, 0 >
visionx::voxelgrid::VoxelGrid::getCenterPose
Eigen::Matrix4f getCenterPose() const
Get the grid pose positioned at the grid center in the world frame.
Definition: VoxelGrid.hpp:379
visionx::voxelgrid::VoxelGridStructure::setVoxelSize
void setVoxelSize(float voxelSize)
Set the voxel size for cubic voxels.
Definition: VoxelGridStructure.cpp:95
visionx::voxelgrid::VoxelGrid::getVoxel
const VoxelT & getVoxel(const Eigen::Vector3f &point, bool local=false) const
Definition: VoxelGrid.hpp:148
visionx::voxelgrid::VoxelGridStructure::checkIsInside
void checkIsInside(const Eigen::Vector3i &indices) const
Assert that the given indices are valid grid indices.
Definition: VoxelGridStructure.cpp:337
visionx::voxelgrid::VoxelGrid::setVoxelSizes
void setVoxelSizes(float voxelSize)
Set the voxel size of cubic voxels. The grid data is not updated.
Definition: VoxelGrid.hpp:218
visionx::voxelgrid::VoxelGrid::getVoxels
const std::vector< VoxelT > & getVoxels() const
Get the voxels.
Definition: VoxelGrid.hpp:156
visionx::voxelgrid::VoxelGrid::getGridSizes
Eigen::Vector3i getGridSizes() const
Get the grid size.
Definition: VoxelGrid.hpp:189
Eigen::Matrix
Definition: EigenForwardDeclarations.h:27
visionx::voxelgrid::VoxelGrid::getVoxelCenter
Eigen::Vector3f getVoxelCenter(std::size_t index, bool local=false) const
Get the center of the voxel with the given index.
Definition: VoxelGrid.hpp:282
visionx::voxelgrid::VoxelGridStructure::getCenter
Eigen::Vector3f getCenter() const
Get the geometric center of the grid the world frame (which differs from the origin for even grid siz...
Definition: VoxelGridStructure.cpp:247
visionx::voxelgrid::VoxelGrid::getVoxelCenter
Eigen::Vector3f getVoxelCenter(int x, int y, int z, bool local=false) const
Get the center of the voxel with the given index.
Definition: VoxelGrid.hpp:289
visionx::voxelgrid::VoxelGrid::isInside
bool isInside(const Eigen::Vector3i &index) const
Indicate whether the given point is inside the voxel.
Definition: VoxelGrid.hpp:422
visionx::voxelgrid::VoxelGrid::getVoxel
const VoxelT & getVoxel(const Eigen::Vector3i &index) const
Definition: VoxelGrid.hpp:134
visionx::voxelgrid::VoxelGrid::setPose
void setPose(const Eigen::Matrix4f &value)
Get the grid pose in the world frame.
Definition: VoxelGrid.hpp:372
visionx::VoxelGrid
voxelgrid::VoxelGrid< VoxelT > VoxelGrid
Definition: VoxelGridCore.h:34
visionx::voxelgrid::VoxelGrid::getLocalBoundingBox
Eigen::Matrix32f getLocalBoundingBox() const
Get the local axis aligned bounding box of the grid (minimal/maximal values in columns).
Definition: VoxelGrid.hpp:408
visionx::voxelgrid::VoxelGrid::getExtentsOfCenters
Eigen::Vector3f getExtentsOfCenters() const
Get extent of the grid along each axis (encompassing only voxel centers).
Definition: VoxelGrid.hpp:401
visionx::voxelgrid::VoxelGridStructure::getOrigin
Eigen::Vector3f getOrigin() const
Get the grid origin in the world frame (center of voxel [0 0 0]).
Definition: VoxelGridStructure.cpp:223
visionx::voxelgrid::VoxelGrid::getVoxel
VoxelT & getVoxel(const Eigen::Vector3i &index)
Get the voxel with the given grid index.
Definition: VoxelGrid.hpp:128
visionx::voxelgrid::VoxelGridStructure::getGridIndex
Eigen::Vector3i getGridIndex(size_t index) const
Get the voxel indices of the voxel with the given index.
Definition: VoxelGridStructure.cpp:141
visionx::voxelgrid::VoxelGrid::checkIsInside
void checkIsInside(const Eigen::Vector3i &index) const
Assert that the given index is a valid grid index.
Definition: VoxelGrid.hpp:436
visionx::voxelgrid::VoxelGridStructure::getLocalBoundingBox
Eigen::Matrix32f getLocalBoundingBox() const
Get the local axis aligned bounding box of the grid (minimal/maximal values in columns).
Definition: VoxelGridStructure.cpp:297
visionx::voxelgrid::VoxelGrid::getVoxelGridIndexMin
Eigen::Vector3i getVoxelGridIndexMin() const
Get the minimal (along each axis) voxel grid index.
Definition: VoxelGrid.hpp:268
visionx::voxelgrid::VoxelGrid::_struct
VoxelGridStructure _struct
The geometric structure.
Definition: VoxelGrid.hpp:517
visionx::voxelgrid::VoxelGrid::getLocalBoundingBoxOfCenters
Eigen::Matrix32f getLocalBoundingBoxOfCenters() const
Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns).
Definition: VoxelGrid.hpp:415
visionx::voxelgrid::VoxelGrid::getVoxelFlatIndex
std::size_t getVoxelFlatIndex(const Eigen::Vector3f &point, bool local=false) const
Get the flat index of the voxel closest to point.
Definition: VoxelGrid.hpp:246
visionx::voxelgrid::VoxelGridStructure::setCenterPose
void setCenterPose(const Eigen::Matrix4f &pose)
Set the grid pose so that the grid center is the position of the given pose under the given orientati...
Definition: VoxelGridStructure.cpp:278
visionx::voxelgrid::VoxelGrid::operator[]
const VoxelT & operator[](const Eigen::Vector3i &index) const
Definition: VoxelGrid.hpp:462