diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 28a403462c6..9e2341b0fab 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -32,6 +32,7 @@ set(range_image_srcs set(srcs src/point_types.cpp + src/feature_types.cpp src/pcl_base.cpp src/PCLPointCloud2.cpp src/io.cpp @@ -63,7 +64,9 @@ set(incs include/pcl/type_traits.h include/pcl/point_types_conversion.h include/pcl/point_representation.h + include/pcl/descriptor_size.h include/pcl/point_types.h + include/pcl/feature_types.h include/pcl/for_each_type.h include/pcl/pcl_tests.h include/pcl/cloud_iterator.h @@ -150,6 +153,7 @@ set(impl_incs include/pcl/impl/pcl_base.hpp include/pcl/impl/instantiate.hpp include/pcl/impl/point_types.hpp + include/pcl/impl/feature_types.hpp include/pcl/impl/cloud_iterator.hpp ) diff --git a/common/include/pcl/descriptor_size.h b/common/include/pcl/descriptor_size.h new file mode 100644 index 00000000000..f43dcb3a60b --- /dev/null +++ b/common/include/pcl/descriptor_size.h @@ -0,0 +1,23 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2026-, Open Perception Inc. + * * All rights reserved + */ + +#pragma once + +namespace pcl +{ + namespace detail + { + namespace traits + { + template struct descriptorSize {}; + + + template + static constexpr int descriptorSize_v = descriptorSize::value; + } + } +} diff --git a/common/include/pcl/feature_types.h b/common/include/pcl/feature_types.h new file mode 100644 index 00000000000..16eba70b2fc --- /dev/null +++ b/common/include/pcl/feature_types.h @@ -0,0 +1,82 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2026-, Open Perception Inc. + * * All rights reserved + */ + +#pragma once + + +/** + * \file pcl/feature_types.h + * Defines all the PCL implemented PointT feature type structures + * \ingroup common + */ + +/** @{*/ +namespace pcl +{ + /** \brief Members: float j1, j2, j3 + * \ingroup common + */ + struct MomentInvariants; + + /** \brief Members: float r_min, r_max + * \ingroup common + */ + struct PrincipalRadiiRSD; + + /** \brief Members: std::uint8_t boundary_point + * \ingroup common + */ + struct Boundary; + + /** \brief Members: float principal_curvature[3], pc1, pc2 + * \ingroup common + */ + struct PrincipalCurvatures; + + /** \brief Members: float descriptor[352], rf[9] + * \ingroup common + */ + struct SHOT352; + + /** \brief Members: float descriptor[1344], rf[9] + * \ingroup common + */ + struct SHOT1344; + + /** \brief Members: Axis x_axis, y_axis, z_axis + * \ingroup common + */ + struct ReferenceFrame; + + /** \brief Members: float descriptor[1980], rf[9] + * \ingroup common + */ + struct ShapeContext1980; + + /** \brief Members: float descriptor[1960], rf[9] + * \ingroup common + */ + struct UniqueShapeContext1960; + + /** \brief Members: float pfh[125] + * \ingroup common + */ + struct PFHSignature125; + + /** \brief Members: float pfhrgb[250] + * \ingroup common + */ + struct PFHRGBSignature250; + + /** \brief Members: float f1, f2, f3, f4, alpha_m + * \ingroup common + */ + struct PPFSignature; +} // namespace pcl +/** @} */ + +#include diff --git a/common/include/pcl/impl/feature_types.hpp b/common/include/pcl/impl/feature_types.hpp new file mode 100644 index 00000000000..ef95b4e637b --- /dev/null +++ b/common/include/pcl/impl/feature_types.hpp @@ -0,0 +1,337 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2026-, Open Perception Inc. + * * All rights reserved + */ + +#pragma once + +#include // for descriptorSize_v +#include // for PCL_MAKE_ALIGNED_OPERATOR_NEW +#include // implementee +#include // for PCL_EXPORTS +#include // for POINT_CLOUD_REGISTER_POINT_STRUCT +#include // for asEnum which is used internally in POINT_CLOUD_REGISTER_POINT_STRUCT + +#include // for ostream, operator<< + +namespace pcl +{ + namespace detail + { + namespace traits + { + template<> struct descriptorSize { static constexpr const int value = 352; }; + template<> struct descriptorSize { static constexpr const int value = 1344; }; + template<> struct descriptorSize { static constexpr const int value = 1980; }; + template<> struct descriptorSize { static constexpr const int value = 1960; }; + template<> struct descriptorSize { static constexpr const int value = 125; }; + template<> struct descriptorSize { static constexpr const int value = 250; }; + } + } + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const MomentInvariants& p); + /** \brief A point structure representing the three moment invariants. + * \ingroup common + */ + struct MomentInvariants + { + float j1 = 0.f, j2 = 0.f, j3 = 0.f; + + inline constexpr MomentInvariants () = default; + + inline constexpr MomentInvariants (float _j1, float _j2, float _j3): j1 (_j1), j2 (_j2), j3 (_j3) {} + + friend std::ostream& operator << (std::ostream& os, const MomentInvariants& p); + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PrincipalRadiiRSD& p); + /** \brief A point structure representing the minimum and maximum surface radii (in meters) computed using RSD. + * \ingroup common + */ + struct PrincipalRadiiRSD + { + float r_min = 0.f, r_max = 0.f; + + inline constexpr PrincipalRadiiRSD () = default; + + inline constexpr PrincipalRadiiRSD (float _r_min, float _r_max): r_min (_r_min), r_max (_r_max) {} + + friend std::ostream& operator << (std::ostream& os, const PrincipalRadiiRSD& p); + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const Boundary& p); + /** \brief A point structure representing a description of whether a point is lying on a surface boundary or not. + * \ingroup common + */ + struct Boundary + { + std::uint8_t boundary_point = 0; + +#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION <= 1101 + constexpr operator unsigned char() const + { + return boundary_point; + } +#endif + + inline constexpr Boundary (std::uint8_t _boundary = 0): boundary_point (_boundary) {} + + friend std::ostream& operator << (std::ostream& os, const Boundary& p); + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PrincipalCurvatures& p); + /** \brief A point structure representing the principal curvatures and their magnitudes. + * \ingroup common + */ + struct PrincipalCurvatures + { + union + { + float principal_curvature[3]; + struct + { + float principal_curvature_x; + float principal_curvature_y; + float principal_curvature_z; + }; + }; + float pc1 = 0.f; + float pc2 = 0.f; + + inline constexpr PrincipalCurvatures (): PrincipalCurvatures (0.f, 0.f) {} + + inline constexpr PrincipalCurvatures (float _pc1, float _pc2): PrincipalCurvatures (0.f, 0.f, 0.f, _pc1, _pc2) {} + + inline constexpr PrincipalCurvatures (float _x, float _y, float _z): PrincipalCurvatures (_x, _y, _z, 0.f, 0.f) {} + + inline constexpr PrincipalCurvatures (float _x, float _y, float _z, float _pc1, float _pc2): + principal_curvature_x (_x), principal_curvature_y (_y), principal_curvature_z (_z), pc1 (_pc1), pc2 (_pc2) {} + + friend std::ostream& operator << (std::ostream& os, const PrincipalCurvatures& p); + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const SHOT352& p); + /** \brief A point structure representing the generic Signature of Histograms of OrienTations (SHOT) - shape only. + * \ingroup common + */ + struct SHOT352 + { + float descriptor[352] = {0.f}; + float rf[9] = {0.f}; + static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } + + inline constexpr SHOT352 () = default; + + friend std::ostream& operator << (std::ostream& os, const SHOT352& p); + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const SHOT1344& p); + /** \brief A point structure representing the generic Signature of Histograms of OrienTations (SHOT) - shape+color. + * \ingroup common + */ + struct SHOT1344 + { + float descriptor[1344] = {0.f}; + float rf[9] = {0.f}; + static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } + + inline constexpr SHOT1344 () = default; + + friend std::ostream& operator << (std::ostream& os, const SHOT1344& p); + }; + + /** \brief A structure representing the Local Reference Frame of a point. + * \ingroup common + */ + struct EIGEN_ALIGN16 _ReferenceFrame + { + union + { + float rf[9]; + struct + { + float x_axis[3]; + float y_axis[3]; + float z_axis[3]; + }; + }; + + inline Eigen::Map getXAxisVector3fMap () { return (Eigen::Vector3f::Map (x_axis)); } + inline const Eigen::Map getXAxisVector3fMap () const { return (Eigen::Vector3f::Map (x_axis)); } + inline Eigen::Map getYAxisVector3fMap () { return (Eigen::Vector3f::Map (y_axis)); } + inline const Eigen::Map getYAxisVector3fMap () const { return (Eigen::Vector3f::Map (y_axis)); } + inline Eigen::Map getZAxisVector3fMap () { return (Eigen::Vector3f::Map (z_axis)); } + inline const Eigen::Map getZAxisVector3fMap () const { return (Eigen::Vector3f::Map (z_axis)); } + inline Eigen::Map getMatrix3fMap () { return (Eigen::Matrix3f::Map (rf)); } + inline const Eigen::Map getMatrix3fMap () const { return (Eigen::Matrix3f::Map (rf)); } + + PCL_MAKE_ALIGNED_OPERATOR_NEW + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const ReferenceFrame& p); + struct EIGEN_ALIGN16 ReferenceFrame : public _ReferenceFrame + { + inline constexpr ReferenceFrame (const _ReferenceFrame &p) : + ReferenceFrame{p.rf} + { + //std::copy_n(p.rf, 9, rf); // this algorithm is constexpr starting from C++20 + } + + inline constexpr ReferenceFrame () : + _ReferenceFrame{ {{0.0f}} } + { + // this algorithm is constexpr starting from C++20 + /*std::fill_n(x_axis, 3, 0.f); + std::fill_n(y_axis, 3, 0.f); + std::fill_n(z_axis, 3, 0.f);*/ + } + + inline constexpr ReferenceFrame (const float (&_rf)[9]) : + _ReferenceFrame{ {{_rf[0], _rf[1], _rf[2], _rf[3], _rf[4], _rf[5], _rf[6], _rf[7], _rf[8]}} } {} + + friend std::ostream& operator << (std::ostream& os, const ReferenceFrame& p); + PCL_MAKE_ALIGNED_OPERATOR_NEW + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const ShapeContext1980& p); + /** \brief A point structure representing a Shape Context. + * \ingroup common + */ + struct ShapeContext1980 + { + float descriptor[1980] = {0.f}; + float rf[9] = {0.f}; + static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } + + inline constexpr ShapeContext1980 () = default; + + friend std::ostream& operator << (std::ostream& os, const ShapeContext1980& p); + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const UniqueShapeContext1960& p); + /** \brief A point structure representing a Unique Shape Context. + * \ingroup common + */ + struct UniqueShapeContext1960 + { + float descriptor[1960] = {0.f}; + float rf[9] = {0.f}; + static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } + + inline constexpr UniqueShapeContext1960 () = default; + + friend std::ostream& operator << (std::ostream& os, const UniqueShapeContext1960& p); + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PFHSignature125& p); + /** \brief A point structure representing the Point Feature Histogram (PFH). + * \ingroup common + */ + struct PFHSignature125 + { + float histogram[125] = {0.f}; + static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } + + inline constexpr PFHSignature125 () = default; + + friend std::ostream& operator << (std::ostream& os, const PFHSignature125& p); + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PFHRGBSignature250& p); + /** \brief A point structure representing the Point Feature Histogram with colors (PFHRGB). + * \ingroup common + */ + struct PFHRGBSignature250 + { + float histogram[250] = {0.f}; + static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } + + inline constexpr PFHRGBSignature250 () = default; + + friend std::ostream& operator << (std::ostream& os, const PFHRGBSignature250& p); + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PPFSignature& p); + /** \brief A point structure for storing the Point Pair Feature (PPF) values + * \ingroup common + */ + struct PPFSignature + { + float f1 = 0.f, f2 = 0.f, f3 = 0.f, f4 = 0.f; + float alpha_m = 0.f; + + inline constexpr PPFSignature (float _alpha = 0.f): PPFSignature (0.f, 0.f, 0.f, 0.f, _alpha) {} + + inline constexpr PPFSignature (float _f1, float _f2, float _f3, float _f4, float _alpha = 0.f): + f1 (_f1), f2 (_f2), f3 (_f3), f4 (_f4), alpha_m (_alpha) {} + + friend std::ostream& operator << (std::ostream& os, const PPFSignature& p); + }; +} // namespace pcl + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::MomentInvariants, + (float, j1, j1) + (float, j2, j2) + (float, j3, j3) +) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PrincipalRadiiRSD, + (float, r_min, r_min) + (float, r_max, r_max) +) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Boundary, + (std::uint8_t, boundary_point, boundary_point) +) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PrincipalCurvatures, + (float, principal_curvature_x, principal_curvature_x) + (float, principal_curvature_y, principal_curvature_y) + (float, principal_curvature_z, principal_curvature_z) + (float, pc1, pc1) + (float, pc2, pc2) +) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::SHOT352, + (float[352], descriptor, shot) + (float[9], rf, rf) +) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::SHOT1344, + (float[1344], descriptor, shot) + (float[9], rf, rf) +) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_ReferenceFrame, + (float[3], x_axis, x_axis) + (float[3], y_axis, y_axis) + (float[3], z_axis, z_axis) +) +POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::ReferenceFrame, pcl::_ReferenceFrame) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::ShapeContext1980, + (float[1980], descriptor, shape_context) + (float[9], rf, rf) +) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::UniqueShapeContext1960, + (float[1960], descriptor, shape_context) + (float[9], rf, rf) +) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PFHSignature125, + (float[125], histogram, pfh) +) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PFHRGBSignature250, + (float[250], histogram, pfhrgb) +) + +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PPFSignature, + (float, f1, f1) + (float, f2, f2) + (float, f3, f3) + (float, f4, f4) + (float, alpha_m, alpha_m) +) diff --git a/common/include/pcl/impl/point_types.hpp b/common/include/pcl/impl/point_types.hpp index 0f626f03652..fcabe8aa777 100644 --- a/common/include/pcl/impl/point_types.hpp +++ b/common/include/pcl/impl/point_types.hpp @@ -38,11 +38,13 @@ #pragma once +#include // for descriptorSize_v #include // for PCL_MAKE_ALIGNED_OPERATOR_NEW #include // for PCL_XYZ_POINT_TYPES, PCL_NORMAL_POINT_TYPES #include // for PCL_EXPORTS #include // for PCLPointField #include // implementee +#include // for feature types #include // for POINT_CLOUD_REGISTER_POINT_STRUCT, POINT_CLOUD_REGISTER_POINT_WRAPPER #include // for MatrixMap @@ -155,14 +157,6 @@ namespace pcl { namespace traits { - template struct descriptorSize {}; - - template<> struct descriptorSize { static constexpr const int value = 125; }; - template<> struct descriptorSize { static constexpr const int value = 250; }; - template<> struct descriptorSize { static constexpr const int value = 1980; }; - template<> struct descriptorSize { static constexpr const int value = 1960; }; - template<> struct descriptorSize { static constexpr const int value = 352; }; - template<> struct descriptorSize { static constexpr const int value = 1344; }; template<> struct descriptorSize { static constexpr const int value = 33; }; template<> struct descriptorSize { static constexpr const int value = 308; }; template<> struct descriptorSize { static constexpr const int value = 21; }; @@ -175,10 +169,6 @@ namespace pcl template<> struct descriptorSize { static constexpr const int value = 36; }; template<> struct descriptorSize { static constexpr const int value = 12; }; template struct descriptorSize> { static constexpr const int value = N; }; - - - template - static constexpr int descriptorSize_v = descriptorSize::value; } } @@ -1093,133 +1083,6 @@ namespace pcl friend std::ostream& operator << (std::ostream& os, const PointWithViewpoint& p); }; - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const MomentInvariants& p); - /** \brief A point structure representing the three moment invariants. - * \ingroup common - */ - struct MomentInvariants - { - float j1 = 0.f, j2 = 0.f, j3 = 0.f; - - inline constexpr MomentInvariants () = default; - - inline constexpr MomentInvariants (float _j1, float _j2, float _j3): j1 (_j1), j2 (_j2), j3 (_j3) {} - - friend std::ostream& operator << (std::ostream& os, const MomentInvariants& p); - }; - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PrincipalRadiiRSD& p); - /** \brief A point structure representing the minimum and maximum surface radii (in meters) computed using RSD. - * \ingroup common - */ - struct PrincipalRadiiRSD - { - float r_min = 0.f, r_max = 0.f; - - inline constexpr PrincipalRadiiRSD () = default; - - inline constexpr PrincipalRadiiRSD (float _r_min, float _r_max): r_min (_r_min), r_max (_r_max) {} - - friend std::ostream& operator << (std::ostream& os, const PrincipalRadiiRSD& p); - }; - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const Boundary& p); - /** \brief A point structure representing a description of whether a point is lying on a surface boundary or not. - * \ingroup common - */ - struct Boundary - { - std::uint8_t boundary_point = 0; - -#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION <= 1101 - constexpr operator unsigned char() const - { - return boundary_point; - } -#endif - - inline constexpr Boundary (std::uint8_t _boundary = 0): boundary_point (_boundary) {} - - friend std::ostream& operator << (std::ostream& os, const Boundary& p); - }; - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PrincipalCurvatures& p); - /** \brief A point structure representing the principal curvatures and their magnitudes. - * \ingroup common - */ - struct PrincipalCurvatures - { - union - { - float principal_curvature[3]; - struct - { - float principal_curvature_x; - float principal_curvature_y; - float principal_curvature_z; - }; - }; - float pc1 = 0.f; - float pc2 = 0.f; - - inline constexpr PrincipalCurvatures (): PrincipalCurvatures (0.f, 0.f) {} - - inline constexpr PrincipalCurvatures (float _pc1, float _pc2): PrincipalCurvatures (0.f, 0.f, 0.f, _pc1, _pc2) {} - - inline constexpr PrincipalCurvatures (float _x, float _y, float _z): PrincipalCurvatures (_x, _y, _z, 0.f, 0.f) {} - - inline constexpr PrincipalCurvatures (float _x, float _y, float _z, float _pc1, float _pc2): - principal_curvature_x (_x), principal_curvature_y (_y), principal_curvature_z (_z), pc1 (_pc1), pc2 (_pc2) {} - - friend std::ostream& operator << (std::ostream& os, const PrincipalCurvatures& p); - }; - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PFHSignature125& p); - /** \brief A point structure representing the Point Feature Histogram (PFH). - * \ingroup common - */ - struct PFHSignature125 - { - float histogram[125] = {0.f}; - static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } - - inline constexpr PFHSignature125 () = default; - - friend std::ostream& operator << (std::ostream& os, const PFHSignature125& p); - }; - - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PFHRGBSignature250& p); - /** \brief A point structure representing the Point Feature Histogram with colors (PFHRGB). - * \ingroup common - */ - struct PFHRGBSignature250 - { - float histogram[250] = {0.f}; - static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } - - inline constexpr PFHRGBSignature250 () = default; - - friend std::ostream& operator << (std::ostream& os, const PFHRGBSignature250& p); - }; - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PPFSignature& p); - /** \brief A point structure for storing the Point Pair Feature (PPF) values - * \ingroup common - */ - struct PPFSignature - { - float f1 = 0.f, f2 = 0.f, f3 = 0.f, f4 = 0.f; - float alpha_m = 0.f; - - inline constexpr PPFSignature (float _alpha = 0.f): PPFSignature (0.f, 0.f, 0.f, 0.f, _alpha) {} - - inline constexpr PPFSignature (float _f1, float _f2, float _f3, float _f4, float _alpha = 0.f): - f1 (_f1), f2 (_f2), f3 (_f3), f4 (_f4), alpha_m (_alpha) {} - - friend std::ostream& operator << (std::ostream& os, const PPFSignature& p); - }; - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const CPPFSignature& p); /** \brief A point structure for storing the Point Pair Feature (CPPF) values * \ingroup common @@ -1275,122 +1138,6 @@ namespace pcl friend std::ostream& operator << (std::ostream& os, const NormalBasedSignature12& p); }; - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const ShapeContext1980& p); - /** \brief A point structure representing a Shape Context. - * \ingroup common - */ - struct ShapeContext1980 - { - float descriptor[1980] = {0.f}; - float rf[9] = {0.f}; - static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } - - inline constexpr ShapeContext1980 () = default; - - friend std::ostream& operator << (std::ostream& os, const ShapeContext1980& p); - }; - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const UniqueShapeContext1960& p); - /** \brief A point structure representing a Unique Shape Context. - * \ingroup common - */ - struct UniqueShapeContext1960 - { - float descriptor[1960] = {0.f}; - float rf[9] = {0.f}; - static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } - - inline constexpr UniqueShapeContext1960 () = default; - - friend std::ostream& operator << (std::ostream& os, const UniqueShapeContext1960& p); - }; - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const SHOT352& p); - /** \brief A point structure representing the generic Signature of Histograms of OrienTations (SHOT) - shape only. - * \ingroup common - */ - struct SHOT352 - { - float descriptor[352] = {0.f}; - float rf[9] = {0.f}; - static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } - - inline constexpr SHOT352 () = default; - - friend std::ostream& operator << (std::ostream& os, const SHOT352& p); - }; - - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const SHOT1344& p); - /** \brief A point structure representing the generic Signature of Histograms of OrienTations (SHOT) - shape+color. - * \ingroup common - */ - struct SHOT1344 - { - float descriptor[1344] = {0.f}; - float rf[9] = {0.f}; - static constexpr int descriptorSize () { return detail::traits::descriptorSize_v; } - - inline constexpr SHOT1344 () = default; - - friend std::ostream& operator << (std::ostream& os, const SHOT1344& p); - }; - - - /** \brief A structure representing the Local Reference Frame of a point. - * \ingroup common - */ - struct EIGEN_ALIGN16 _ReferenceFrame - { - union - { - float rf[9]; - struct - { - float x_axis[3]; - float y_axis[3]; - float z_axis[3]; - }; - }; - - inline Eigen::Map getXAxisVector3fMap () { return (Eigen::Vector3f::Map (x_axis)); } - inline const Eigen::Map getXAxisVector3fMap () const { return (Eigen::Vector3f::Map (x_axis)); } - inline Eigen::Map getYAxisVector3fMap () { return (Eigen::Vector3f::Map (y_axis)); } - inline const Eigen::Map getYAxisVector3fMap () const { return (Eigen::Vector3f::Map (y_axis)); } - inline Eigen::Map getZAxisVector3fMap () { return (Eigen::Vector3f::Map (z_axis)); } - inline const Eigen::Map getZAxisVector3fMap () const { return (Eigen::Vector3f::Map (z_axis)); } - inline Eigen::Map getMatrix3fMap () { return (Eigen::Matrix3f::Map (rf)); } - inline const Eigen::Map getMatrix3fMap () const { return (Eigen::Matrix3f::Map (rf)); } - - PCL_MAKE_ALIGNED_OPERATOR_NEW - }; - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const ReferenceFrame& p); - struct EIGEN_ALIGN16 ReferenceFrame : public _ReferenceFrame - { - inline constexpr ReferenceFrame (const _ReferenceFrame &p) : - ReferenceFrame{p.rf} - { - //std::copy_n(p.rf, 9, rf); // this algorithm is constexpr starting from C++20 - } - - inline constexpr ReferenceFrame () : - _ReferenceFrame{ {{0.0f}} } - { - // this algorithm is constexpr starting from C++20 - /*std::fill_n(x_axis, 3, 0.f); - std::fill_n(y_axis, 3, 0.f); - std::fill_n(z_axis, 3, 0.f);*/ - } - - inline constexpr ReferenceFrame (const float (&_rf)[9]) : - _ReferenceFrame{ {{_rf[0], _rf[1], _rf[2], _rf[3], _rf[4], _rf[5], _rf[6], _rf[7], _rf[8]}} } {} - - friend std::ostream& operator << (std::ostream& os, const ReferenceFrame& p); - PCL_MAKE_ALIGNED_OPERATOR_NEW - }; - - PCL_EXPORTS std::ostream& operator << (std::ostream& os, const FPFHSignature33& p); /** \brief A point structure representing the Fast Point Feature Histogram (FPFH). * \ingroup common @@ -1902,45 +1649,6 @@ POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointWithViewpoint, ) POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointWithViewpoint, pcl::_PointWithViewpoint) -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::MomentInvariants, - (float, j1, j1) - (float, j2, j2) - (float, j3, j3) -) - -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PrincipalRadiiRSD, - (float, r_min, r_min) - (float, r_max, r_max) -) - -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Boundary, - (std::uint8_t, boundary_point, boundary_point) -) - -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PrincipalCurvatures, - (float, principal_curvature_x, principal_curvature_x) - (float, principal_curvature_y, principal_curvature_y) - (float, principal_curvature_z, principal_curvature_z) - (float, pc1, pc1) - (float, pc2, pc2) -) - -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PFHSignature125, - (float[125], histogram, pfh) -) - -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PFHRGBSignature250, - (float[250], histogram, pfhrgb) -) - -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PPFSignature, - (float, f1, f1) - (float, f2, f2) - (float, f3, f3) - (float, f4, f4) - (float, alpha_m, alpha_m) -) - POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::CPPFSignature, (float, f1, f1) (float, f2, f2) @@ -1970,26 +1678,6 @@ POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::NormalBasedSignature12, (float[12], values, values) ) -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::ShapeContext1980, - (float[1980], descriptor, shape_context) - (float[9], rf, rf) -) - -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::UniqueShapeContext1960, - (float[1960], descriptor, shape_context) - (float[9], rf, rf) -) - -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::SHOT352, - (float[352], descriptor, shot) - (float[9], rf, rf) -) - -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::SHOT1344, - (float[1344], descriptor, shot) - (float[9], rf, rf) -) - POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::FPFHSignature33, (float[33], histogram, fpfh) ) @@ -2058,13 +1746,6 @@ POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::PointSurfel, (float, curvature, curvature) ) -POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_ReferenceFrame, - (float[3], x_axis, x_axis) - (float[3], y_axis, y_axis) - (float[3], z_axis, z_axis) -) -POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::ReferenceFrame, pcl::_ReferenceFrame) - POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointDEM, (float, x, x) (float, y, y) diff --git a/common/include/pcl/point_types.h b/common/include/pcl/point_types.h index df95b97eaa2..f91269571b8 100644 --- a/common/include/pcl/point_types.h +++ b/common/include/pcl/point_types.h @@ -44,6 +44,8 @@ #include #endif +#include // feature types are point types too + #include @@ -182,66 +184,6 @@ namespace pcl */ struct PointWithViewpoint; - /** \brief Members: float j1, j2, j3 - * \ingroup common - */ - struct MomentInvariants; - - /** \brief Members: float r_min, r_max - * \ingroup common - */ - struct PrincipalRadiiRSD; - - /** \brief Members: std::uint8_t boundary_point - * \ingroup common - */ - struct Boundary; - - /** \brief Members: float principal_curvature[3], pc1, pc2 - * \ingroup common - */ - struct PrincipalCurvatures; - - /** \brief Members: float descriptor[352], rf[9] - * \ingroup common - */ - struct SHOT352; - - /** \brief Members: float descriptor[1344], rf[9] - * \ingroup common - */ - struct SHOT1344; - - /** \brief Members: Axis x_axis, y_axis, z_axis - * \ingroup common - */ - struct ReferenceFrame; - - /** \brief Members: float descriptor[1980], rf[9] - * \ingroup common - */ - struct ShapeContext1980; - - /** \brief Members: float descriptor[1960], rf[9] - * \ingroup common - */ - struct UniqueShapeContext1960; - - /** \brief Members: float pfh[125] - * \ingroup common - */ - struct PFHSignature125; - - /** \brief Members: float pfhrgb[250] - * \ingroup common - */ - struct PFHRGBSignature250; - - /** \brief Members: float f1, f2, f3, f4, alpha_m - * \ingroup common - */ - struct PPFSignature; - /** \brief Members: float f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, alpha_m * \ingroup common */ diff --git a/common/src/feature_types.cpp b/common/src/feature_types.cpp new file mode 100644 index 00000000000..dded31511db --- /dev/null +++ b/common/src/feature_types.cpp @@ -0,0 +1,112 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2026-, Open Perception Inc. + * * All rights reserved + */ + +#include + +namespace pcl +{ + std::ostream& + operator << (std::ostream& os, const MomentInvariants& p) + { + os << "(" << p.j1 << "," << p.j2 << "," << p.j3 << ")"; + return (os); + } + + std::ostream& + operator << (std::ostream& os, const PrincipalRadiiRSD& p) + { + os << "(" << p.r_min << "," << p.r_max << ")"; + return (os); + } + + std::ostream& + operator << (std::ostream& os, const Boundary& p) + { + os << p.boundary_point; + return (os); + } + + std::ostream& + operator << (std::ostream& os, const PrincipalCurvatures& p) + { + os << "(" << p.principal_curvature[0] << "," << p.principal_curvature[1] << "," << p.principal_curvature[2] << " - " << p.pc1 << "," << p.pc2 << ")"; + return (os); + } + + std::ostream& + operator << (std::ostream& os, const SHOT352& p) + { + for (int i = 0; i < 9; ++i) + os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); + for (std::size_t i = 0; i < 352; ++i) + os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 351 ? ", " : ")"); + return (os); + } + + std::ostream& + operator << (std::ostream& os, const SHOT1344& p) + { + for (int i = 0; i < 9; ++i) + os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); + for (std::size_t i = 0; i < 1344; ++i) + os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 1343 ? ", " : ")"); + return (os); + } + + std::ostream& + operator << (std::ostream& os, const ReferenceFrame& p) + { + os << "(" + << p.x_axis[0] << " " << p.x_axis[1] << " " << p.x_axis[2] << "," + << p.y_axis[0] << " " << p.y_axis[1] << " " << p.y_axis[2] << "," + << p.z_axis[0] << " " << p.z_axis[1] << " " << p.z_axis[2] << ")"; + return (os); + } + + std::ostream& + operator << (std::ostream& os, const ShapeContext1980& p) + { + for (int i = 0; i < 9; ++i) + os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); + for (std::size_t i = 0; i < 1980; ++i) + os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 1979 ? ", " : ")"); + return (os); + } + + std::ostream& + operator << (std::ostream& os, const UniqueShapeContext1960& p) + { + for (int i = 0; i < 9; ++i) + os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); + for (std::size_t i = 0; i < 1960; ++i) + os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 1959 ? ", " : ")"); + return (os); + } + + std::ostream& + operator << (std::ostream& os, const PFHSignature125& p) + { + for (int i = 0; i < 125; ++i) + os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 124 ? ", " : ")"); + return (os); + } + + std::ostream& + operator << (std::ostream& os, const PFHRGBSignature250& p) + { + for (int i = 0; i < 250; ++i) + os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 249 ? ", " : ")"); + return (os); + } + + std::ostream& + operator << (std::ostream& os, const PPFSignature& p) + { + os << "(" << p.f1 << ", " << p.f2 << ", " << p.f3 << ", " << p.f4 << ", " << p.alpha_m << ")"; + return (os); + } +} // namespace pcl diff --git a/common/src/point_types.cpp b/common/src/point_types.cpp index e3ab796fa79..bbe0de9e215 100644 --- a/common/src/point_types.cpp +++ b/common/src/point_types.cpp @@ -232,57 +232,6 @@ namespace pcl return (os); } - std::ostream& - operator << (std::ostream& os, const MomentInvariants& p) - { - os << "(" << p.j1 << "," << p.j2 << "," << p.j3 << ")"; - return (os); - } - - std::ostream& - operator << (std::ostream& os, const PrincipalRadiiRSD& p) - { - os << "(" << p.r_min << "," << p.r_max << ")"; - return (os); - } - - std::ostream& - operator << (std::ostream& os, const Boundary& p) - { - os << p.boundary_point; - return (os); - } - - std::ostream& - operator << (std::ostream& os, const PrincipalCurvatures& p) - { - os << "(" << p.principal_curvature[0] << "," << p.principal_curvature[1] << "," << p.principal_curvature[2] << " - " << p.pc1 << "," << p.pc2 << ")"; - return (os); - } - - std::ostream& - operator << (std::ostream& os, const PFHSignature125& p) - { - for (int i = 0; i < 125; ++i) - os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 124 ? ", " : ")"); - return (os); - } - - std::ostream& - operator << (std::ostream& os, const PFHRGBSignature250& p) - { - for (int i = 0; i < 250; ++i) - os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 249 ? ", " : ")"); - return (os); - } - - std::ostream& - operator << (std::ostream& os, const PPFSignature& p) - { - os << "(" << p.f1 << ", " << p.f2 << ", " << p.f3 << ", " << p.f4 << ", " << p.alpha_m << ")"; - return (os); - } - std::ostream& operator << (std::ostream& os, const CPPFSignature& p) { @@ -306,56 +255,6 @@ namespace pcl return (os); } - std::ostream& - operator << (std::ostream& os, const ShapeContext1980& p) - { - for (int i = 0; i < 9; ++i) - os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); - for (std::size_t i = 0; i < 1980; ++i) - os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 1979 ? ", " : ")"); - return (os); - } - - std::ostream& - operator << (std::ostream& os, const UniqueShapeContext1960& p) - { - for (int i = 0; i < 9; ++i) - os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); - for (std::size_t i = 0; i < 1960; ++i) - os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 1959 ? ", " : ")"); - return (os); - } - - std::ostream& - operator << (std::ostream& os, const SHOT352& p) - { - for (int i = 0; i < 9; ++i) - os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); - for (std::size_t i = 0; i < 352; ++i) - os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 351 ? ", " : ")"); - return (os); - } - - std::ostream& - operator << (std::ostream& os, const SHOT1344& p) - { - for (int i = 0; i < 9; ++i) - os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); - for (std::size_t i = 0; i < 1344; ++i) - os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 1343 ? ", " : ")"); - return (os); - } - - std::ostream& - operator << (std::ostream& os, const ReferenceFrame& p) - { - os << "(" - << p.x_axis[0] << " " << p.x_axis[1] << " " << p.x_axis[2] << "," - << p.y_axis[0] << " " << p.y_axis[1] << " " << p.y_axis[2] << "," - << p.z_axis[0] << " " << p.z_axis[1] << " " << p.z_axis[2] << ")"; - return (os); - } - std::ostream& operator << (std::ostream& os, const FPFHSignature33& p) { diff --git a/features/include/pcl/features/3dsc.h b/features/include/pcl/features/3dsc.h index 65bac7c1cf3..a8a194bd398 100644 --- a/features/include/pcl/features/3dsc.h +++ b/features/include/pcl/features/3dsc.h @@ -42,7 +42,7 @@ #include -#include +#include #include namespace pcl diff --git a/features/include/pcl/features/board.h b/features/include/pcl/features/board.h index 2debbf0f24b..7d6542f9c60 100644 --- a/features/include/pcl/features/board.h +++ b/features/include/pcl/features/board.h @@ -39,7 +39,7 @@ #pragma once -#include +#include #include namespace pcl diff --git a/features/include/pcl/features/flare.h b/features/include/pcl/features/flare.h index d03acd3b845..51f2e5c7fe6 100644 --- a/features/include/pcl/features/flare.h +++ b/features/include/pcl/features/flare.h @@ -38,7 +38,7 @@ #pragma once -#include +#include #include #include diff --git a/features/include/pcl/features/pfh.h b/features/include/pcl/features/pfh.h index d8f3eecfef7..4ca9e9a6250 100644 --- a/features/include/pcl/features/pfh.h +++ b/features/include/pcl/features/pfh.h @@ -40,7 +40,7 @@ #pragma once -#include +#include #include #include #include // for std::queue diff --git a/features/include/pcl/features/pfhrgb.h b/features/include/pcl/features/pfhrgb.h index de87ce6bd94..d3d1b9ca898 100644 --- a/features/include/pcl/features/pfhrgb.h +++ b/features/include/pcl/features/pfhrgb.h @@ -39,6 +39,7 @@ #pragma once +#include #include namespace pcl diff --git a/features/include/pcl/features/shot.h b/features/include/pcl/features/shot.h index d278076b29f..df9b3a177dc 100644 --- a/features/include/pcl/features/shot.h +++ b/features/include/pcl/features/shot.h @@ -39,7 +39,7 @@ #pragma once -#include +#include #include #include // for sRGB_LUT, sXYZ_LUT diff --git a/features/include/pcl/features/shot_lrf.h b/features/include/pcl/features/shot_lrf.h index 9a122e2db2f..5b1f1f2f782 100644 --- a/features/include/pcl/features/shot_lrf.h +++ b/features/include/pcl/features/shot_lrf.h @@ -39,7 +39,7 @@ #pragma once -#include +#include #include namespace pcl diff --git a/features/include/pcl/features/shot_lrf_omp.h b/features/include/pcl/features/shot_lrf_omp.h index 1c32ccffea9..6addc0a0623 100644 --- a/features/include/pcl/features/shot_lrf_omp.h +++ b/features/include/pcl/features/shot_lrf_omp.h @@ -39,7 +39,7 @@ #pragma once -#include +#include #include #include diff --git a/features/include/pcl/features/shot_omp.h b/features/include/pcl/features/shot_omp.h index 50fefdf9a2c..01b016f4ce6 100644 --- a/features/include/pcl/features/shot_omp.h +++ b/features/include/pcl/features/shot_omp.h @@ -39,7 +39,7 @@ #pragma once -#include +#include #include #include diff --git a/features/include/pcl/features/usc.h b/features/include/pcl/features/usc.h index 0ad9cd2089c..a65cc4e84f7 100644 --- a/features/include/pcl/features/usc.h +++ b/features/include/pcl/features/usc.h @@ -40,7 +40,7 @@ #pragma once -#include +#include #include namespace pcl diff --git a/recognition/include/pcl/recognition/cg/hough_3d.h b/recognition/include/pcl/recognition/cg/hough_3d.h index 2a736805e3c..ed7eee26389 100644 --- a/recognition/include/pcl/recognition/cg/hough_3d.h +++ b/recognition/include/pcl/recognition/cg/hough_3d.h @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include