AABB.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <pcl/point_cloud.h>
4 #include <pcl/PointIndices.h>
5 
6 #include <VisionX/interface/core/DataTypes.h>
7 
8 #include <SimoxUtility/shapes/AxisAlignedBoundingBox.h>
9 
10 
11 namespace visionx::tools
12 {
13 
14  BoundingBox3D toBoundingBox3D(const Eigen::Vector3f& min, const Eigen::Vector3f& max);
15  BoundingBox3D toBoundingBox3D(const simox::AxisAlignedBoundingBox& aabb);
16 
17  simox::AxisAlignedBoundingBox toAABB(const BoundingBox3D& boundingBox);
18 
19 
20  /**
21  * @brief Get the axis-aligned bounding-box of the given point cloud.
22  * @param pointCloud The point cloud.
23  * @param indices If not empty, only the specified point indices are used.
24  * @return The AABB in a 3x2 matrix, where with min's in col(0) and max'x in col(1).
25  */
26  template <typename PointCloudT>
28  const pcl::PointIndices& indices = {})
29  {
31  Eigen::Vector3f::Constant(std::numeric_limits<float>::max()),
32  Eigen::Vector3f::Constant(std::numeric_limits<float>::min()));
33 
34  if (indices.indices.empty())
35  {
36  // Consider whole point cloud.
37  for (const auto& p : pointCloud)
38  {
39  aabb.expand_to(p);
40  }
41  }
42  else
43  {
44  // Consider only indices.
45  for (int i : indices.indices)
46  {
47  aabb.expand_to(pointCloud.at(static_cast<std::size_t>(i)));
48  }
49  }
50 
51  return aabb;
52  }
53 
54  template <class PointCloudT>
56  const pcl::PointIndices::Ptr& indices)
57  {
58  return getAABB(pointCloud, indices ? *indices : pcl::PointIndices());
59  }
60 
61 }
visionx::tools
Definition: PCLUtilities.cpp:4
visionx::tools::toBoundingBox3D
BoundingBox3D toBoundingBox3D(const Eigen::Vector3f &min, const Eigen::Vector3f &max)
Definition: AABB.cpp:6
armarx::aron::simox::arondto::AxisAlignedBoundingBox
::simox::arondto::AxisAlignedBoundingBox AxisAlignedBoundingBox
Definition: simox.h:14
pcl::graph::indices
pcl::PointIndices::Ptr indices(const PCG &g)
Retrieve the indices of the points of the point cloud stored in a point cloud graph that actually bel...
Definition: point_cloud_graph.h:737
max
T max(T t1, T t2)
Definition: gdiam.h:48
armarx::PointCloudT
pcl::PointCloud< PointT > PointCloudT
Definition: Common.h:30
visionx::tools::getAABB
simox::AxisAlignedBoundingBox getAABB(const PointCloudT &pointCloud, const pcl::PointIndices &indices={})
Get the axis-aligned bounding-box of the given point cloud.
Definition: AABB.h:27
min
T min(T t1, T t2)
Definition: gdiam.h:42
visionx::tools::toAABB
simox::AxisAlignedBoundingBox toAABB(const BoundingBox3D &boundingBox)
Definition: AABB.cpp:23