-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
WIP: Split point_types.hpp part into field_traits.(h|hpp)
#6375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
sumir0
wants to merge
8
commits into
PointCloudLibrary:master
Choose a base branch
from
sumir0:feature/split-impl-point-types-part-into-field-traits
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+347
−180
Draft
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
897032d
Split `point_types.hpp` part into `field_traits.(h|hpp)`
sumir0 8225075
Fix changes according to clang-format
sumir0 84b6e73
Remove blank lines between namespace declarations in `field_traits.hpp`
sumir0 1d5b1d4
Optimize some imports related to `pcl/point_types.h`
sumir0 cca4098
Change license description in `pcl/field_traits.(h|hpp)`
sumir0 90bb25b
Add missing `pcl/point_types.h` includes in `examples`
sumir0 70240a7
Add missing `pcl/point_types.h` includes in some files
sumir0 d2199ca
Add missing `cstring` include in `pcl/common/impl/copy_point.hpp`
sumir0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ | |
|
|
||
| #pragma once | ||
|
|
||
| #include <pcl/field_traits.h> | ||
| #include <pcl/point_types.h> | ||
|
|
||
| #ifdef _MSC_VER | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| /* | ||
| * Software License Agreement (BSD License) | ||
| * | ||
| * Point Cloud Library (PCL) - www.pointclouds.org | ||
| * Copyright (c) 2025-, Open Perception, Inc. | ||
| * | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following | ||
| * disclaimer in the documentation and/or other materials provided | ||
| * with the distribution. | ||
| * * Neither the name of the copyright holder(s) nor the names of its | ||
| * contributors may be used to endorse or promote products derived | ||
| * from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
| * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| */ | ||
sumir0 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #pragma once | ||
|
|
||
| #include <type_traits> // for std::enable_if | ||
|
|
||
| namespace pcl | ||
| { | ||
| namespace traits | ||
| { | ||
|
|
||
| /** \brief Metafunction to check if a given point type has a given field. | ||
| * | ||
| * Example usage at run-time: | ||
| * | ||
| * \code | ||
| * bool curvature_available = pcl::traits::has_field<PointT, pcl::fields::curvature>::value; | ||
| * \endcode | ||
| * | ||
| * Example usage at compile-time: | ||
| * | ||
| * \code | ||
| * BOOST_MPL_ASSERT_MSG ((pcl::traits::has_field<PointT, pcl::fields::label>::value), | ||
| * POINT_TYPE_SHOULD_HAVE_LABEL_FIELD, | ||
| * (PointT)); | ||
| * \endcode | ||
| */ | ||
| template <typename PointT, typename Field> | ||
| struct has_field; | ||
|
|
||
| /** Metafunction to check if a given point type has all given fields. */ | ||
| template <typename PointT, typename Field> | ||
| struct has_all_fields; | ||
|
|
||
| /** Metafunction to check if a given point type has any of the given fields. */ | ||
| template <typename PointT, typename Field> | ||
| struct has_any_field; | ||
|
|
||
| /** \brief Traits defined for ease of use with common fields | ||
| * | ||
| * has_<fields to be detected>: struct with `value` datamember defined at compiletime | ||
| * has_<fields to be detected>_v: constexpr boolean | ||
| * Has<Fields to be detected>: concept modelling name alias for `enable_if` | ||
| */ | ||
|
|
||
| /** Metafunction to check if a given point type has x and y fields. */ | ||
| template <typename PointT> | ||
| struct has_xy; | ||
|
|
||
| template <typename PointT> | ||
| constexpr auto has_xy_v = has_xy<PointT>::value; | ||
|
|
||
| template <typename PointT> | ||
| using HasXY = std::enable_if_t<has_xy_v<PointT>, bool>; | ||
|
|
||
| template <typename PointT> | ||
| using HasNoXY = std::enable_if_t<!has_xy_v<PointT>, bool>; | ||
|
|
||
| /** Metafunction to check if a given point type has x, y, and z fields. */ | ||
| template <typename PointT> | ||
| struct has_xyz; | ||
|
|
||
| template <typename PointT> | ||
| constexpr auto has_xyz_v = has_xyz<PointT>::value; | ||
|
|
||
| template <typename PointT> | ||
| using HasXYZ = std::enable_if_t<has_xyz_v<PointT>, bool>; | ||
|
|
||
| template <typename PointT> | ||
| using HasNoXYZ = std::enable_if_t<!has_xyz_v<PointT>, bool>; | ||
|
|
||
| /** Metafunction to check if a given point type has normal_x, normal_y, and | ||
| * normal_z fields. */ | ||
| template <typename PointT> | ||
| struct has_normal; | ||
|
|
||
| template <typename PointT> | ||
| constexpr auto has_normal_v = has_normal<PointT>::value; | ||
|
|
||
| template <typename PointT> | ||
| using HasNormal = std::enable_if_t<has_normal_v<PointT>, bool>; | ||
|
|
||
| template <typename PointT> | ||
| using HasNoNormal = std::enable_if_t<!has_normal_v<PointT>, bool>; | ||
|
|
||
| /** Metafunction to check if a given point type has curvature field. */ | ||
| template <typename PointT> | ||
| struct has_curvature; | ||
|
|
||
| template <typename PointT> | ||
| constexpr auto has_curvature_v = has_curvature<PointT>::value; | ||
|
|
||
| template <typename PointT> | ||
| using HasCurvature = std::enable_if_t<has_curvature_v<PointT>, bool>; | ||
|
|
||
| template <typename PointT> | ||
| using HasNoCurvature = std::enable_if_t<!has_curvature_v<PointT>, bool>; | ||
|
|
||
| /** Metafunction to check if a given point type has intensity field. */ | ||
| template <typename PointT> | ||
| struct has_intensity; | ||
|
|
||
| template <typename PointT> | ||
| constexpr auto has_intensity_v = has_intensity<PointT>::value; | ||
|
|
||
| template <typename PointT> | ||
| using HasIntensity = std::enable_if_t<has_intensity_v<PointT>, bool>; | ||
|
|
||
| template <typename PointT> | ||
| using HasNoIntensity = std::enable_if_t<!has_intensity_v<PointT>, bool>; | ||
|
|
||
| /** Metafunction to check if a given point type has either rgb or rgba field. */ | ||
| template <typename PointT> | ||
| struct has_color; | ||
|
|
||
| template <typename PointT> | ||
| constexpr auto has_color_v = has_color<PointT>::value; | ||
|
|
||
| template <typename PointT> | ||
| using HasColor = std::enable_if_t<has_color_v<PointT>, bool>; | ||
|
|
||
| template <typename PointT> | ||
| using HasNoColor = std::enable_if_t<!has_color_v<PointT>, bool>; | ||
|
|
||
| /** Metafunction to check if a given point type has label field. */ | ||
| template <typename PointT> | ||
| struct has_label; | ||
|
|
||
| template <typename PointT> | ||
| constexpr auto has_label_v = has_label<PointT>::value; | ||
|
|
||
| template <typename PointT> | ||
| using HasLabel = std::enable_if_t<has_label_v<PointT>, bool>; | ||
|
|
||
| template <typename PointT> | ||
| using HasNoLabel = std::enable_if_t<!has_label_v<PointT>, bool>; | ||
|
|
||
| } // namespace traits | ||
| } // namespace pcl | ||
|
|
||
| #include <pcl/impl/field_traits.hpp> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| /* | ||
| * Software License Agreement (BSD License) | ||
| * | ||
| * Point Cloud Library (PCL) - www.pointclouds.org | ||
| * Copyright (c) 2025-, Open Perception, Inc. | ||
| * | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following | ||
| * disclaimer in the documentation and/or other materials provided | ||
| * with the distribution. | ||
| * * Neither the name of the copyright holder(s) nor the names of its | ||
| * contributors may be used to endorse or promote products derived | ||
| * from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
| * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <pcl/point_struct_traits.h> // for pcl::traits::fieldList | ||
|
|
||
| // Forward declarations of common pcl field types | ||
| namespace pcl | ||
| { | ||
| namespace fields | ||
| { | ||
| struct x; | ||
| struct y; | ||
| struct z; | ||
| struct normal_x; | ||
| struct normal_y; | ||
| struct normal_z; | ||
| struct curvature; | ||
| struct intensity; | ||
| struct rgb; | ||
| struct rgba; | ||
| struct label; | ||
| } // namespace fields | ||
| } // namespace pcl | ||
|
|
||
| #include <boost/mpl/and.hpp> // for boost::mpl::and_ | ||
| #include <boost/mpl/bool.hpp> // for boost::mpl::bool_ | ||
| #include <boost/mpl/contains.hpp> // for boost::mpl::contains | ||
| #include <boost/mpl/fold.hpp> // for boost::mpl::fold | ||
| #include <boost/mpl/or.hpp> // for boost::mpl::or_ | ||
| #include <boost/mpl/placeholders.hpp> // for boost::mpl::_1, boost::mpl::_2 | ||
| #include <boost/mpl/vector.hpp> // for boost::mpl::vector | ||
|
|
||
| namespace pcl | ||
| { | ||
| namespace traits | ||
| { | ||
|
|
||
| template <typename PointT, typename Field> | ||
| struct has_field : boost::mpl::contains<typename pcl::traits::fieldList<PointT>::type, Field>::type | ||
| { }; | ||
|
|
||
| template <typename PointT, typename Field> | ||
| struct has_all_fields : boost::mpl::fold<Field, | ||
| boost::mpl::bool_<true>, | ||
| boost::mpl::and_<boost::mpl::_1, | ||
| has_field<PointT, boost::mpl::_2> > >::type | ||
| { }; | ||
|
|
||
| template <typename PointT, typename Field> | ||
| struct has_any_field : boost::mpl::fold<Field, | ||
| boost::mpl::bool_<false>, | ||
| boost::mpl::or_<boost::mpl::_1, | ||
| has_field<PointT, boost::mpl::_2> > >::type | ||
| { }; | ||
|
|
||
| template <typename PointT> | ||
| struct has_xy : has_all_fields<PointT, boost::mpl::vector<pcl::fields::x, | ||
| pcl::fields::y> > | ||
| { }; | ||
|
|
||
| template <typename PointT> | ||
| struct has_xyz : has_all_fields<PointT, boost::mpl::vector<pcl::fields::x, | ||
| pcl::fields::y, | ||
| pcl::fields::z> > | ||
| { }; | ||
|
|
||
| template <typename PointT> | ||
| struct has_normal : has_all_fields<PointT, boost::mpl::vector<pcl::fields::normal_x, | ||
| pcl::fields::normal_y, | ||
| pcl::fields::normal_z> > | ||
| { }; | ||
|
|
||
| template <typename PointT> | ||
| struct has_curvature : has_field<PointT, pcl::fields::curvature> | ||
| { }; | ||
|
|
||
| template <typename PointT> | ||
| struct has_intensity : has_field<PointT, pcl::fields::intensity> | ||
| { }; | ||
|
|
||
| template <typename PointT> | ||
| struct has_color : has_any_field<PointT, boost::mpl::vector<pcl::fields::rgb, | ||
| pcl::fields::rgba> > | ||
| { }; | ||
|
|
||
| template <typename PointT> | ||
| struct has_label : has_field<PointT, pcl::fields::label> | ||
| { }; | ||
|
|
||
| } // namespace traits | ||
| } // namespace pcl |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.