Skip to content
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

Replace pcl_isnan, pcl_isfinite and pcl_isinf by C++11 methods #2798

Merged
merged 5 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ namespace pcl
pcl::eigen33 (covariance_matrix, eigenVectors, eigenValues);

float eigsum = eigenValues.sum ();
if (!pcl_isfinite(eigsum))
if (!std::isfinite(eigsum))
{
PCL_ERROR("Eigen sum is not finite\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace pcl
int NaNs = 0;
for (int i = 0; i < size_feat; i++)
{
if (!pcl_isfinite(shots->points[k].descriptor[i]))
if (!std::isfinite(shots->points[k].descriptor[i]))
NaNs++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ namespace pcl
int j = 0;
for (size_t i = 0; i < out->points.size (); ++i)
{
if (!pcl_isfinite (out->points[i].x) || !pcl_isfinite (out->points[i].y) || !pcl_isfinite (out->points[i].z))
if (!std::isfinite (out->points[i].x) || !std::isfinite (out->points[i].y) || !std::isfinite (out->points[i].z))
continue;

out->points[j] = out->points[i];
Expand Down Expand Up @@ -243,8 +243,8 @@ namespace pcl
int j = 0;
for (size_t i = 0; i < normals->points.size (); ++i)
{
if (!pcl_isfinite (normals->points[i].normal_x) || !pcl_isfinite (normals->points[i].normal_y)
|| !pcl_isfinite (normals->points[i].normal_z))
if (!std::isfinite (normals->points[i].normal_x) || !std::isfinite (normals->points[i].normal_y)
|| !std::isfinite (normals->points[i].normal_z))
continue;

normals->points[j] = normals->points[i];
Expand All @@ -267,8 +267,8 @@ namespace pcl
bool NaNs = false;
for (size_t i = 0; i < normals->points.size (); ++i)
{
if (pcl_isfinite (normals->points[i].normal_x) && pcl_isfinite (normals->points[i].normal_y)
&& pcl_isfinite (normals->points[i].normal_z))
if (std::isfinite (normals->points[i].normal_x) && std::isfinite (normals->points[i].normal_y)
&& std::isfinite (normals->points[i].normal_z))
continue;

NaNs = true;
Expand Down
2 changes: 1 addition & 1 deletion apps/src/ni_agast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class AGASTDemo
{
const PointT &pt = (*cloud)(static_cast<long unsigned int> (keypoints->points[i].u),
static_cast<long unsigned int> (keypoints->points[i].v));
if (!pcl_isfinite (pt.x) || !pcl_isfinite (pt.y) || !pcl_isfinite (pt.z))
if (!std::isfinite (pt.x) || !std::isfinite (pt.y) || !std::isfinite (pt.z))
continue;

keypoints3d.points[j].x = pt.x;
Expand Down
6 changes: 3 additions & 3 deletions apps/src/openni_mobile_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ CopyPointCloudToBuffers (pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr cloud, Poi

const pcl::PointXYZRGBA& point = cloud->points[i];

if (!pcl_isfinite (point.x) ||
!pcl_isfinite (point.y) ||
!pcl_isfinite (point.z))
if (!std::isfinite (point.x) ||
!std::isfinite (point.y) ||
!std::isfinite (point.z))
continue;

if (point.x < bounds_min.x ||
Expand Down
6 changes: 3 additions & 3 deletions apps/src/openni_tracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ class OpenNISegmentTracking
if (!(fabs(point.x) < 0.01 &&
fabs(point.y) < 0.01 &&
fabs(point.z) < 0.01) &&
!pcl_isnan(point.x) &&
!pcl_isnan(point.y) &&
!pcl_isnan(point.z))
!std::isnan(point.x) &&
!std::isnan(point.y) &&
!std::isnan(point.z))
result.points.push_back(point);
}

Expand Down
2 changes: 1 addition & 1 deletion common/include/pcl/common/centroid.h
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ namespace pcl
const T* data_ptr = reinterpret_cast<const T*>(raw_ptr);

// Check if the value is invalid
if (!pcl_isfinite (*data_ptr))
if (!std::isfinite (*data_ptr))
{
f_idx_++;
return;
Expand Down
2 changes: 1 addition & 1 deletion common/include/pcl/common/impl/bivariate_polynomial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pcl::BivariatePolynomialT<real>::findCriticalPoints (std::vector<real>& x_values
(parameters[1]*parameters[1] - real(4)*parameters[0]*parameters[3]),
y = (real(-2)*parameters[0]*x - parameters[2]) / parameters[1];

if (!pcl_isfinite(x) || !pcl_isfinite(y))
if (!std::isfinite(x) || !std::isfinite(y))
return;

int type = 2;
Expand Down
36 changes: 18 additions & 18 deletions common/include/pcl/common/impl/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ pcl::getPointsInBox (const pcl::PointCloud<PointT> &cloud,
for (size_t i = 0; i < cloud.points.size (); ++i)
{
// Check if the point is invalid
if (!pcl_isfinite (cloud.points[i].x) ||
!pcl_isfinite (cloud.points[i].y) ||
!pcl_isfinite (cloud.points[i].z))
if (!std::isfinite (cloud.points[i].x) ||
!std::isfinite (cloud.points[i].y) ||
!std::isfinite (cloud.points[i].z))
continue;
// Check if the point is inside bounds
if (cloud.points[i].x < min_pt[0] || cloud.points[i].y < min_pt[1] || cloud.points[i].z < min_pt[2])
Expand Down Expand Up @@ -168,7 +168,7 @@ pcl::getMaxDistance (const pcl::PointCloud<PointT> &cloud, const Eigen::Vector4f
for (size_t i = 0; i < cloud.points.size (); ++i)
{
// Check if the point is invalid
if (!pcl_isfinite (cloud.points[i].x) || !pcl_isfinite (cloud.points[i].y) || !pcl_isfinite (cloud.points[i].z))
if (!std::isfinite (cloud.points[i].x) || !std::isfinite (cloud.points[i].y) || !std::isfinite (cloud.points[i].z))
continue;
pcl::Vector3fMapConst pt = cloud.points[i].getVector3fMap ();
dist = (pivot_pt3 - pt).norm ();
Expand Down Expand Up @@ -216,9 +216,9 @@ pcl::getMaxDistance (const pcl::PointCloud<PointT> &cloud, const std::vector<int
for (size_t i = 0; i < indices.size (); ++i)
{
// Check if the point is invalid
if (!pcl_isfinite (cloud.points[indices[i]].x) || !pcl_isfinite (cloud.points[indices[i]].y)
if (!std::isfinite (cloud.points[indices[i]].x) || !std::isfinite (cloud.points[indices[i]].y)
||
!pcl_isfinite (cloud.points[indices[i]].z))
!std::isfinite (cloud.points[indices[i]].z))
continue;

pcl::Vector3fMapConst pt = cloud.points[indices[i]].getVector3fMap ();
Expand Down Expand Up @@ -261,9 +261,9 @@ pcl::getMinMax3D (const pcl::PointCloud<PointT> &cloud, PointT &min_pt, PointT &
for (size_t i = 0; i < cloud.points.size (); ++i)
{
// Check if the point is invalid
if (!pcl_isfinite (cloud.points[i].x) ||
!pcl_isfinite (cloud.points[i].y) ||
!pcl_isfinite (cloud.points[i].z))
if (!std::isfinite (cloud.points[i].x) ||
!std::isfinite (cloud.points[i].y) ||
!std::isfinite (cloud.points[i].z))
continue;
pcl::Array4fMapConst pt = cloud.points[i].getArray4fMap ();
min_p = min_p.min (pt);
Expand Down Expand Up @@ -298,9 +298,9 @@ pcl::getMinMax3D (const pcl::PointCloud<PointT> &cloud, Eigen::Vector4f &min_pt,
for (size_t i = 0; i < cloud.points.size (); ++i)
{
// Check if the point is invalid
if (!pcl_isfinite (cloud.points[i].x) ||
!pcl_isfinite (cloud.points[i].y) ||
!pcl_isfinite (cloud.points[i].z))
if (!std::isfinite (cloud.points[i].x) ||
!std::isfinite (cloud.points[i].y) ||
!std::isfinite (cloud.points[i].z))
continue;
pcl::Array4fMapConst pt = cloud.points[i].getArray4fMap ();
min_p = min_p.min (pt);
Expand Down Expand Up @@ -337,9 +337,9 @@ pcl::getMinMax3D (const pcl::PointCloud<PointT> &cloud, const pcl::PointIndices
for (size_t i = 0; i < indices.indices.size (); ++i)
{
// Check if the point is invalid
if (!pcl_isfinite (cloud.points[indices.indices[i]].x) ||
!pcl_isfinite (cloud.points[indices.indices[i]].y) ||
!pcl_isfinite (cloud.points[indices.indices[i]].z))
if (!std::isfinite (cloud.points[indices.indices[i]].x) ||
!std::isfinite (cloud.points[indices.indices[i]].y) ||
!std::isfinite (cloud.points[indices.indices[i]].z))
continue;
pcl::Array4fMapConst pt = cloud.points[indices.indices[i]].getArray4fMap ();
min_p = min_p.min (pt);
Expand Down Expand Up @@ -374,9 +374,9 @@ pcl::getMinMax3D (const pcl::PointCloud<PointT> &cloud, const std::vector<int> &
for (size_t i = 0; i < indices.size (); ++i)
{
// Check if the point is invalid
if (!pcl_isfinite (cloud.points[indices[i]].x) ||
!pcl_isfinite (cloud.points[indices[i]].y) ||
!pcl_isfinite (cloud.points[indices[i]].z))
if (!std::isfinite (cloud.points[indices[i]].x) ||
!std::isfinite (cloud.points[indices[i]].y) ||
!std::isfinite (cloud.points[indices[i]].z))
continue;
pcl::Array4fMapConst pt = cloud.points[indices[i]].getArray4fMap ();
min_pt = min_pt.array ().min (pt);
Expand Down
12 changes: 6 additions & 6 deletions common/include/pcl/common/impl/pca.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ pcl::PCA<PointT>::project (const PointCloud& input, PointCloud& projection)
PointT p;
for (size_t i = 0; i < input.size (); ++i)
{
if (!pcl_isfinite (input[i].x) ||
!pcl_isfinite (input[i].y) ||
!pcl_isfinite (input[i].z))
if (!std::isfinite (input[i].x) ||
!std::isfinite (input[i].y) ||
!std::isfinite (input[i].z))
continue;
project (input[i], p);
projection.push_back (p);
Expand Down Expand Up @@ -228,9 +228,9 @@ pcl::PCA<PointT>::reconstruct (const PointCloud& projection, PointCloud& input)
PointT p;
for (size_t i = 0; i < input.size (); ++i)
{
if (!pcl_isfinite (input[i].x) ||
!pcl_isfinite (input[i].y) ||
!pcl_isfinite (input[i].z))
if (!std::isfinite (input[i].x) ||
!std::isfinite (input[i].y) ||
!std::isfinite (input[i].z))
continue;
reconstruct (projection[i], p);
input.push_back (p);
Expand Down
2 changes: 1 addition & 1 deletion common/include/pcl/common/impl/projection_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pcl::estimateProjectionMatrix (
unsigned xIdx = pointIt.getCurrentPointIndex () % cloud->width;

const PointT& point = *pointIt;
if (pcl_isfinite (point.x))
if (std::isfinite (point.x))
{
Scalar xx = point.x * point.x;
Scalar xy = point.x * point.y;
Expand Down
24 changes: 12 additions & 12 deletions common/include/pcl/common/impl/transforms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ pcl::transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
// otherwise we get errors during the multiplication (?)
for (size_t i = 0; i < cloud_out.points.size (); ++i)
{
if (!pcl_isfinite (cloud_in.points[i].x) ||
!pcl_isfinite (cloud_in.points[i].y) ||
!pcl_isfinite (cloud_in.points[i].z))
if (!std::isfinite (cloud_in.points[i].x) ||
!std::isfinite (cloud_in.points[i].y) ||
!std::isfinite (cloud_in.points[i].z))
continue;
tf.se3 (cloud_in[i].data, cloud_out[i].data);
}
Expand Down Expand Up @@ -292,9 +292,9 @@ pcl::transformPointCloud (const pcl::PointCloud<PointT> &cloud_in,
{
if (copy_all_fields)
cloud_out.points[i] = cloud_in.points[indices[i]];
if (!pcl_isfinite (cloud_in.points[indices[i]].x) ||
!pcl_isfinite (cloud_in.points[indices[i]].y) ||
!pcl_isfinite (cloud_in.points[indices[i]].z))
if (!std::isfinite (cloud_in.points[indices[i]].x) ||
!std::isfinite (cloud_in.points[indices[i]].y) ||
!std::isfinite (cloud_in.points[indices[i]].z))
continue;
tf.se3 (cloud_in[indices[i]].data, cloud_out[i].data);
}
Expand Down Expand Up @@ -339,9 +339,9 @@ pcl::transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
{
for (size_t i = 0; i < cloud_out.points.size (); ++i)
{
if (!pcl_isfinite (cloud_in.points[i].x) ||
!pcl_isfinite (cloud_in.points[i].y) ||
!pcl_isfinite (cloud_in.points[i].z))
if (!std::isfinite (cloud_in.points[i].x) ||
!std::isfinite (cloud_in.points[i].y) ||
!std::isfinite (cloud_in.points[i].z))
continue;
tf.se3 (cloud_in[i].data, cloud_out[i].data);
tf.so3 (cloud_in[i].data_n, cloud_out[i].data_n);
Expand Down Expand Up @@ -389,9 +389,9 @@ pcl::transformPointCloudWithNormals (const pcl::PointCloud<PointT> &cloud_in,
if (copy_all_fields)
cloud_out.points[i] = cloud_in.points[indices[i]];

if (!pcl_isfinite (cloud_in.points[indices[i]].x) ||
!pcl_isfinite (cloud_in.points[indices[i]].y) ||
!pcl_isfinite (cloud_in.points[indices[i]].z))
if (!std::isfinite (cloud_in.points[indices[i]].x) ||
!std::isfinite (cloud_in.points[indices[i]].y) ||
!std::isfinite (cloud_in.points[indices[i]].z))
continue;

tf.se3 (cloud_in[indices[i]].data, cloud_out[i].data);
Expand Down
2 changes: 1 addition & 1 deletion common/include/pcl/common/impl/vector_average.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace pcl

mean_ += (diff)*alpha;

//if (pcl_isnan(covariance_(0,0)))
//if (std::isnan(covariance_(0,0)))
//{
//cout << PVARN(weight);
//exit(0);
Expand Down
60 changes: 27 additions & 33 deletions common/include/pcl/common/point_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace pcl
template <typename PointT> inline bool
isFinite (const PointT &pt)
{
return (pcl_isfinite (pt.x) && pcl_isfinite (pt.y) && pcl_isfinite (pt.z));
return (std::isfinite (pt.x) && std::isfinite (pt.y) && std::isfinite (pt.z));
}

#ifdef _MSC_VER
Expand All @@ -63,48 +63,42 @@ namespace pcl
}
#endif

template<> inline bool isFinite<pcl::RGB> (const pcl::RGB&) { return (true); }
template<> inline bool isFinite<pcl::Label> (const pcl::Label&) { return (true); }
template<> inline bool isFinite<pcl::Axis> (const pcl::Axis&) { return (true); }
template<> inline bool isFinite<pcl::Intensity> (const pcl::Intensity&) { return (true); }
template<> inline bool isFinite<pcl::MomentInvariants> (const pcl::MomentInvariants&) { return (true); }
template<> inline bool isFinite<pcl::PrincipalRadiiRSD> (const pcl::PrincipalRadiiRSD&) { return (true); }
template<> inline bool isFinite<pcl::Boundary> (const pcl::Boundary&) { return (true); }
template<> inline bool isFinite<pcl::PrincipalCurvatures> (const pcl::PrincipalCurvatures&) { return (true); }
template<> inline bool isFinite<pcl::SHOT352> (const pcl::SHOT352&) { return (true); }
template<> inline bool isFinite<pcl::SHOT1344> (const pcl::SHOT1344&) { return (true); }
template<> inline bool isFinite<pcl::ReferenceFrame> (const pcl::ReferenceFrame&) { return (true); }
template<> inline bool isFinite<pcl::ShapeContext1980> (const pcl::ShapeContext1980&) { return (true); }
template<> inline bool isFinite<pcl::UniqueShapeContext1960> (const pcl::UniqueShapeContext1960&) { return (true); }
template<> inline bool isFinite<pcl::PFHSignature125> (const pcl::PFHSignature125&) { return (true); }
template<> inline bool isFinite<pcl::PFHRGBSignature250> (const pcl::PFHRGBSignature250&) { return (true); }
template<> inline bool isFinite<pcl::PPFSignature> (const pcl::PPFSignature&) { return (true); }
template<> inline bool isFinite<pcl::PPFRGBSignature> (const pcl::PPFRGBSignature&) { return (true); }
template<> inline bool isFinite<pcl::NormalBasedSignature12> (const pcl::NormalBasedSignature12&) { return (true); }
template<> inline bool isFinite<pcl::FPFHSignature33> (const pcl::FPFHSignature33&) { return (true); }
template<> inline bool isFinite<pcl::VFHSignature308> (const pcl::VFHSignature308&) { return (true); }
template<> inline bool isFinite<pcl::ESFSignature640> (const pcl::ESFSignature640&) { return (true); }
template<> inline bool isFinite<pcl::IntensityGradient> (const pcl::IntensityGradient&) { return (true); }
template<> inline bool isFinite<pcl::BRISKSignature512> (const pcl::BRISKSignature512&) { return (true); }
template<> inline bool isFinite<pcl::Axis>(const pcl::Axis&) { return (true); }
template<> inline bool isFinite<pcl::BRISKSignature512>(const pcl::BRISKSignature512&) { return (true); }
template<> inline bool isFinite<pcl::BorderDescription>(const pcl::BorderDescription &p) { return true; }
template<> inline bool isFinite<pcl::Boundary>(const pcl::Boundary&) { return (true); }
template<> inline bool isFinite<pcl::ESFSignature640>(const pcl::ESFSignature640&) { return (true); }
template<> inline bool isFinite<pcl::FPFHSignature33>(const pcl::FPFHSignature33&) { return (true); }
template<> inline bool isFinite<pcl::Intensity>(const pcl::Intensity&) { return (true); }
template<> inline bool isFinite<pcl::IntensityGradient>(const pcl::IntensityGradient&) { return (true); }
template<> inline bool isFinite<pcl::Label>(const pcl::Label&) { return (true); }
template<> inline bool isFinite<pcl::MomentInvariants>(const pcl::MomentInvariants&) { return (true); }
template<> inline bool isFinite<pcl::NormalBasedSignature12>(const pcl::NormalBasedSignature12&) { return (true); }
template<> inline bool isFinite<pcl::PFHRGBSignature250>(const pcl::PFHRGBSignature250&) { return (true); }
template<> inline bool isFinite<pcl::PFHSignature125>(const pcl::PFHSignature125&) { return (true); }
template<> inline bool isFinite<pcl::PPFRGBSignature>(const pcl::PPFRGBSignature&) { return (true); }
template<> inline bool isFinite<pcl::PPFSignature>(const pcl::PPFSignature&) { return (true); }
template<> inline bool isFinite<pcl::PrincipalCurvatures>(const pcl::PrincipalCurvatures&) { return (true); }
template<> inline bool isFinite<pcl::PrincipalRadiiRSD>(const pcl::PrincipalRadiiRSD&) { return (true); }
template<> inline bool isFinite<pcl::RGB>(const pcl::RGB&) { return (true); }
template<> inline bool isFinite<pcl::ReferenceFrame>(const pcl::ReferenceFrame&) { return (true); }
template<> inline bool isFinite<pcl::SHOT1344>(const pcl::SHOT1344&) { return (true); }
template<> inline bool isFinite<pcl::SHOT352>(const pcl::SHOT352&) { return (true); }
template<> inline bool isFinite<pcl::ShapeContext1980>(const pcl::ShapeContext1980&) { return (true); }
template<> inline bool isFinite<pcl::UniqueShapeContext1960>(const pcl::UniqueShapeContext1960&) { return (true); }
template<> inline bool isFinite<pcl::VFHSignature308>(const pcl::VFHSignature308&) { return (true); }

// specification for pcl::PointXY
template <> inline bool
isFinite<pcl::PointXY> (const pcl::PointXY &p)
{
return (pcl_isfinite (p.x) && pcl_isfinite (p.y));
}

// specification for pcl::BorderDescription
template <> inline bool
isFinite<pcl::BorderDescription> (const pcl::BorderDescription &p)
{
return (pcl_isfinite (p.x) && pcl_isfinite (p.y));
return (std::isfinite (p.x) && std::isfinite (p.y));
}

// specification for pcl::Normal
template <> inline bool
isFinite<pcl::Normal> (const pcl::Normal &n)
{
return (pcl_isfinite (n.normal_x) && pcl_isfinite (n.normal_y) && pcl_isfinite (n.normal_z));
return (std::isfinite (n.normal_x) && std::isfinite (n.normal_y) && std::isfinite (n.normal_z));
}
}
Loading