Skip to content

Commit

Permalink
Use SFINAE instead of relying on macros
Browse files Browse the repository at this point in the history
  • Loading branch information
kunaltyagi committed Mar 11, 2021
1 parent 7eec8f2 commit 94a573c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
16 changes: 9 additions & 7 deletions tracking/include/pcl/tracking/impl/particle_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,11 @@ ParticleFilterTracker<PointInT, StateT>::computeTransformedPointCloudWithoutNorm

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT, typename StateT>
template <typename PointT, pcl::traits::HasNormal<PointT>>
void
ParticleFilterTracker<PointInT, StateT>::computeTransformedPointCloudWithNormal(
#ifdef PCL_TRACKING_NORMAL_SUPPORTED
const StateT& hypothesis, pcl::Indices& indices, PointCloudIn& cloud)
#else
const StateT&, pcl::Indices&, PointCloudIn&)
#endif
{
#ifdef PCL_TRACKING_NORMAL_SUPPORTED
const Eigen::Affine3f trans = toEigenMatrix(hypothesis);
// destructively assigns to cloud
pcl::transformPointCloudWithNormals<PointInT>(*ref_, cloud, trans);
Expand All @@ -318,11 +314,17 @@ ParticleFilterTracker<PointInT, StateT>::computeTransformedPointCloudWithNormal(
if (theta > occlusion_angle_thr_)
indices.push_back(i);
}
#else
}

template <typename PointInT, typename StateT>
template <typename PointT, pcl::traits::HasNoNormal<PointT>>
void
ParticleFilterTracker<PointInT, StateT>::computeTransformedPointCloudWithNormal(
const StateT&, pcl::Indices&, PointCloudIn&)
{
PCL_WARN("[pcl::%s::computeTransformedPointCloudWithoutNormal] "
"use_normal_ == true is not supported in this Point Type.\n",
getClassName().c_str());
#endif
}

template <typename PointInT, typename StateT>
Expand Down
12 changes: 12 additions & 0 deletions tracking/include/pcl/tracking/particle_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <pcl/tracking/tracker.h>
#include <pcl/tracking/tracking.h>
#include <pcl/memory.h>
#include <pcl/point_types.h>

namespace pcl {
namespace tracking {
Expand Down Expand Up @@ -438,6 +439,7 @@ class ParticleFilterTracker : public Tracker<PointInT, StateT> {
pcl::Indices& indices,
PointCloudIn& cloud);

#ifdef DOXYGEN_ONLY
/** \brief Compute a reference pointcloud transformed to the pose that hypothesis
* represents and calculate indices taking occlusion into account.
* \param[in] hypothesis a particle which represents a hypothesis.
Expand All @@ -449,6 +451,16 @@ class ParticleFilterTracker : public Tracker<PointInT, StateT> {
computeTransformedPointCloudWithNormal(const StateT& hypothesis,
pcl::Indices& indices,
PointCloudIn& cloud);
#else
template <typename PointT = PointInT, traits::HasNormal<PointT> = true>
void
computeTransformedPointCloudWithNormal(const StateT& hypothesis,
pcl::Indices& indices,
PointCloudIn& cloud);
template <typename PointT = PointInT, traits::HasNoNormal<PointT> = true>
void
computeTransformedPointCloudWithNormal(const StateT&, pcl::Indices&, PointCloudIn&);
#endif

/** \brief Compute a reference pointcloud transformed to the pose that hypothesis
* represents and calculate indices without taking occlusion into account.
Expand Down
4 changes: 0 additions & 4 deletions tracking/src/kld_adaptive_particle_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#ifndef PCL_NO_PRECOMPILE
#include <pcl/impl/instantiate.hpp>
#include <pcl/point_types.h>
#define PCL_TRACKING_NORMAL_SUPPORTED

// clang-format off
PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterTracker,
Expand All @@ -53,9 +52,6 @@ PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterOMPTracker,
(pcl::PointXYZINormal)
(pcl::PointXYZRGBNormal))
(PCL_STATE_POINT_TYPES))
// clang-format on
#undef PCL_TRACKING_NORMAL_SUPPORTED
// clang-format off
PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterOMPTracker,
((pcl::PointXYZ)
(pcl::PointXYZI)
Expand Down
4 changes: 0 additions & 4 deletions tracking/src/particle_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#ifndef PCL_NO_PRECOMPILE
#include <pcl/impl/instantiate.hpp>
#include <pcl/point_types.h>
#define PCL_TRACKING_NORMAL_SUPPORTED

// clang-format off
PCL_INSTANTIATE_PRODUCT(ParticleFilterTracker,
Expand All @@ -53,9 +52,6 @@ PCL_INSTANTIATE_PRODUCT(ParticleFilterOMPTracker,
(pcl::PointXYZINormal)
(pcl::PointXYZRGBNormal))
(PCL_STATE_POINT_TYPES))
// clang-format on
#undef PCL_TRACKING_NORMAL_SUPPORTED
// clang-format off
PCL_INSTANTIATE_PRODUCT(ParticleFilterTracker,
((pcl::PointXYZ)
(pcl::PointXYZI)
Expand Down

0 comments on commit 94a573c

Please sign in to comment.