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