From 851c29c4ea90f6eb3b89213c0ac151e7eb03bfac Mon Sep 17 00:00:00 2001 From: Heiko Thiel Date: Thu, 18 Apr 2019 18:38:47 +0200 Subject: [PATCH] Changes are done by run-clang-tidy -header-filter='.*' -checks='-*,modernize-use-nullptr' -fix --- features/include/pcl/features/3dsc.h | 2 +- .../include/pcl/features/impl/brisk_2d.hpp | 2 +- features/include/pcl/features/impl/crh.hpp | 2 +- features/include/pcl/features/impl/esf.hpp | 2 +- .../features/impl/integral_image_normal.hpp | 8 +- .../impl/range_image_border_extractor.hpp | 10 +-- .../pcl/features/integral_image_normal.h | 8 +- features/include/pcl/features/narf.h | 2 +- .../include/pcl/features/narf_descriptor.h | 4 +- .../features/range_image_border_extractor.h | 6 +- features/src/narf.cpp | 16 ++-- features/src/range_image_border_extractor.cpp | 78 +++++++++---------- 12 files changed, 70 insertions(+), 70 deletions(-) diff --git a/features/include/pcl/features/3dsc.h b/features/include/pcl/features/3dsc.h index 93d4f819c87..09776e8781c 100644 --- a/features/include/pcl/features/3dsc.h +++ b/features/include/pcl/features/3dsc.h @@ -110,7 +110,7 @@ namespace pcl // Create a random number generator object if (random) - rng_->base ().seed (static_cast (std::time(0))); + rng_->base ().seed (static_cast (std::time(nullptr))); else rng_->base ().seed (12345u); } diff --git a/features/include/pcl/features/impl/brisk_2d.hpp b/features/include/pcl/features/impl/brisk_2d.hpp index 9ff27dd847a..255848c9b31 100644 --- a/features/include/pcl/features/impl/brisk_2d.hpp +++ b/features/include/pcl/features/impl/brisk_2d.hpp @@ -47,7 +47,7 @@ pcl::BRISK2DEstimation::BRISK2DEstim , scale_invariance_enabled_ (true) , pattern_scale_ (1.0f) , input_cloud_ (), keypoints_ (), scale_range_ (), pattern_points_ (), points_ () - , n_rot_ (1024), scale_list_ (NULL), size_list_ (NULL) + , n_rot_ (1024), scale_list_ (nullptr), size_list_ (nullptr) , scales_ (64) , scalerange_ (30) , basic_size_ (12.0) diff --git a/features/include/pcl/features/impl/crh.hpp b/features/include/pcl/features/impl/crh.hpp index be71c48fd8a..8787a9ab3dd 100644 --- a/features/include/pcl/features/impl/crh.hpp +++ b/features/include/pcl/features/impl/crh.hpp @@ -113,7 +113,7 @@ pcl::CRHEstimation::computeFeature (PointCloudOut spatial_data[i] /= sum_w; kiss_fft_cpx * freq_data = new kiss_fft_cpx[nbins / 2 + 1]; - kiss_fftr_cfg mycfg = kiss_fftr_alloc (nbins, 0, NULL, NULL); + kiss_fftr_cfg mycfg = kiss_fftr_alloc (nbins, 0, nullptr, nullptr); kiss_fftr (mycfg, spatial_data, freq_data); output.points.resize (1); diff --git a/features/include/pcl/features/impl/esf.hpp b/features/include/pcl/features/impl/esf.hpp index 0af2f6f8a28..408b93c57fe 100644 --- a/features/include/pcl/features/impl/esf.hpp +++ b/features/include/pcl/features/impl/esf.hpp @@ -54,7 +54,7 @@ pcl::ESFEstimation::computeESF ( { const int binsize = 64; unsigned int sample_size = 20000; - srand (static_cast (time (0))); + srand (static_cast (time (nullptr))); int maxindex = static_cast (pc.points.size ()); int index1, index2, index3; diff --git a/features/include/pcl/features/impl/integral_image_normal.hpp b/features/include/pcl/features/impl/integral_image_normal.hpp index f53dfacf560..23390564875 100644 --- a/features/include/pcl/features/impl/integral_image_normal.hpp +++ b/features/include/pcl/features/impl/integral_image_normal.hpp @@ -72,10 +72,10 @@ pcl::IntegralImageNormalEstimation::initData () delete[] diff_y_; delete[] depth_data_; delete[] distance_map_; - diff_x_ = NULL; - diff_y_ = NULL; - depth_data_ = NULL; - distance_map_ = NULL; + diff_x_ = nullptr; + diff_y_ = nullptr; + depth_data_ = nullptr; + distance_map_ = nullptr; if (normal_estimation_method_ == COVARIANCE_MATRIX) initCovarianceMatrixMethod (); diff --git a/features/include/pcl/features/impl/range_image_border_extractor.hpp b/features/include/pcl/features/impl/range_image_border_extractor.hpp index 0dc29835278..055dc41d1b9 100644 --- a/features/include/pcl/features/impl/range_image_border_extractor.hpp +++ b/features/include/pcl/features/impl/range_image_border_extractor.hpp @@ -144,7 +144,7 @@ bool RangeImageBorderExtractor::get3dDirection(const BorderDescription& border_d range_image_->calculate3DPoint(static_cast (x+delta_x), static_cast (y+delta_y), point.range, neighbor_point); //cout << "Neighborhood point is "<getSensorPos(), @@ -166,7 +166,7 @@ void RangeImageBorderExtractor::calculateBorderDirection(int x, int y) { int index = y*range_image_->width + x; Eigen::Vector3f*& border_direction = border_directions_[index]; - border_direction = NULL; + border_direction = nullptr; const BorderDescription& border_description = border_descriptions_->points[index]; const BorderTraits& border_traits = border_description.traits; if (!border_traits[BORDER_TRAIT__OBSTACLE_BORDER]) @@ -175,7 +175,7 @@ void RangeImageBorderExtractor::calculateBorderDirection(int x, int y) if (!get3dDirection(border_description, *border_direction, surface_structure_[index])) { delete border_direction; - border_direction = NULL; + border_direction = nullptr; return; } } @@ -318,7 +318,7 @@ bool RangeImageBorderExtractor::calculateMainPrincipalCurvature(int x, int y, in magnitude = 0.0f; int index = y*range_image_->width+x; LocalSurface* local_surface = surface_structure_[index]; - if (local_surface==NULL) + if (local_surface==nullptr) return false; //const PointWithRange& point = range_image_->getPointNoCheck(x,y); @@ -361,7 +361,7 @@ bool RangeImageBorderExtractor::calculateMainPrincipalCurvature(int x, int y, in //const PointWithRange& point2 = range_image_->getPoint(index2); LocalSurface* local_surface2 = surface_structure_[index2]; - if (local_surface2==NULL) + if (local_surface2==nullptr) continue; Eigen::Vector3f& normal2 = local_surface2->normal_no_jumps; //float distance_squared = squaredEuclideanDistance(point, point2); diff --git a/features/include/pcl/features/integral_image_normal.h b/features/include/pcl/features/integral_image_normal.h index afe36bfb743..732b4a6bc3c 100644 --- a/features/include/pcl/features/integral_image_normal.h +++ b/features/include/pcl/features/integral_image_normal.h @@ -113,10 +113,10 @@ namespace pcl , integral_image_DY_ (false) , integral_image_depth_ (false) , integral_image_XYZ_ (true) - , diff_x_ (NULL) - , diff_y_ (NULL) - , depth_data_ (NULL) - , distance_map_ (NULL) + , diff_x_ (nullptr) + , diff_y_ (nullptr) + , depth_data_ (nullptr) + , distance_map_ (nullptr) , use_depth_dependent_smoothing_ (false) , max_depth_change_factor_ (20.0f*0.001f) , normal_smoothing_size_ (10.0f) diff --git a/features/include/pcl/features/narf.h b/features/include/pcl/features/narf.h index d04d398d108..92d674a0fa3 100644 --- a/features/include/pcl/features/narf.h +++ b/features/include/pcl/features/narf.h @@ -220,7 +220,7 @@ namespace pcl getSurfacePatch () { return surface_patch_;} //! Method to erase the surface patch and free the memory inline void - freeSurfacePatch () { delete[] surface_patch_; surface_patch_=NULL; surface_patch_pixel_size_=0; } + freeSurfacePatch () { delete[] surface_patch_; surface_patch_=nullptr; surface_patch_pixel_size_=0; } // =====SETTERS===== //! Setter for the descriptor diff --git a/features/include/pcl/features/narf_descriptor.h b/features/include/pcl/features/narf_descriptor.h index 5c8bebf095c..257bbb44a76 100644 --- a/features/include/pcl/features/narf_descriptor.h +++ b/features/include/pcl/features/narf_descriptor.h @@ -70,14 +70,14 @@ namespace pcl // =====CONSTRUCTOR & DESTRUCTOR===== /** Constructor */ - NarfDescriptor (const RangeImage* range_image=NULL, const std::vector* indices=NULL); + NarfDescriptor (const RangeImage* range_image=nullptr, const std::vector* indices=nullptr); /** Destructor */ ~NarfDescriptor(); // =====METHODS===== //! Set input data void - setRangeImage (const RangeImage* range_image, const std::vector* indices=NULL); + setRangeImage (const RangeImage* range_image, const std::vector* indices=nullptr); //! Overwrite the compute function of the base class void diff --git a/features/include/pcl/features/range_image_border_extractor.h b/features/include/pcl/features/range_image_border_extractor.h index 00688456f2f..10dc9df7a08 100644 --- a/features/include/pcl/features/range_image_border_extractor.h +++ b/features/include/pcl/features/range_image_border_extractor.h @@ -106,7 +106,7 @@ namespace pcl // =====CONSTRUCTOR & DESTRUCTOR===== /** Constructor */ - RangeImageBorderExtractor (const RangeImage* range_image=NULL); + RangeImageBorderExtractor (const RangeImage* range_image=nullptr); /** Destructor */ ~RangeImageBorderExtractor (); @@ -142,7 +142,7 @@ namespace pcl getParameters () { return (parameters_); } bool - hasRangeImage () const { return range_image_ != NULL; } + hasRangeImage () const { return range_image_ != nullptr; } const RangeImage& getRangeImage () const { return *range_image_; } @@ -322,7 +322,7 @@ namespace pcl */ inline bool get3dDirection (const BorderDescription& border_description, Eigen::Vector3f& direction, - const LocalSurface* local_surface=NULL); + const LocalSurface* local_surface=nullptr); /** \brief Calculate the main principal curvature (the largest eigenvalue and corresponding eigenvector for the * normals in the area) in the given point diff --git a/features/src/narf.cpp b/features/src/narf.cpp index d24ef39e336..7aa8178453a 100644 --- a/features/src/narf.cpp +++ b/features/src/narf.cpp @@ -57,9 +57,9 @@ int Narf::max_no_of_threads = 1; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// Narf::Narf() : - position_ (), transformation_ (), surface_patch_ (NULL), + position_ (), transformation_ (), surface_patch_ (nullptr), surface_patch_pixel_size_ (0), surface_patch_world_size_ (), - surface_patch_rotation_ (), descriptor_ (NULL), descriptor_size_ (0) + surface_patch_rotation_ (), descriptor_ (nullptr), descriptor_size_ (0) { reset(); } @@ -72,9 +72,9 @@ Narf::~Narf() ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// Narf::Narf (const Narf& other) : - position_ (), transformation_ (), surface_patch_ (NULL), + position_ (), transformation_ (), surface_patch_ (nullptr), surface_patch_pixel_size_ (0), surface_patch_world_size_ (), - surface_patch_rotation_ (), descriptor_ (NULL), descriptor_size_ (0) + surface_patch_rotation_ (), descriptor_ (nullptr), descriptor_size_ (0) { deepCopy (other); } @@ -92,10 +92,10 @@ void Narf::reset () { delete[] descriptor_; - descriptor_ = NULL; + descriptor_ = nullptr; descriptor_size_ = 0; delete[] surface_patch_; - surface_patch_ = NULL; + surface_patch_ = nullptr; surface_patch_pixel_size_ = 0; surface_patch_world_size_ = 0.0f; surface_patch_rotation_ = 0.0f; @@ -620,7 +620,7 @@ void NarfDescriptor::setRangeImage (const RangeImage* range_image, const std::vector* indices) { range_image_ = range_image; - if (indices != NULL) + if (indices != nullptr) { IndicesPtr indicesptr (new std::vector (*indices)); setIndices (indicesptr); @@ -635,7 +635,7 @@ NarfDescriptor::computeFeature(NarfDescriptor::PointCloudOut& output) output.points.clear(); - if (range_image_==NULL) + if (range_image_==nullptr) { std::cerr << __PRETTY_FUNCTION__ << ": RangeImage is not set. Sorry, the NARF descriptor calculation works on range images, not on normal point clouds." diff --git a/features/src/range_image_border_extractor.cpp b/features/src/range_image_border_extractor.cpp index 0f9cb9451ba..1143c95b751 100644 --- a/features/src/range_image_border_extractor.cpp +++ b/features/src/range_image_border_extractor.cpp @@ -55,9 +55,9 @@ namespace pcl /////////////////////////////////////////////////////////////////////////////////////////////////////////////// RangeImageBorderExtractor::RangeImageBorderExtractor(const RangeImage* range_image) : BaseClass(), parameters_ (), range_image_(range_image), range_image_size_during_extraction_(0), - border_scores_left_(NULL), border_scores_right_(NULL), border_scores_top_(NULL), border_scores_bottom_(NULL), - surface_structure_(NULL), border_descriptions_(NULL), shadow_border_informations_(NULL), border_directions_(NULL), - surface_change_scores_(NULL), surface_change_directions_(NULL) + border_scores_left_(nullptr), border_scores_right_(nullptr), border_scores_top_(nullptr), border_scores_bottom_(nullptr), + surface_structure_(nullptr), border_descriptions_(nullptr), shadow_border_informations_(nullptr), border_directions_(nullptr), + surface_change_scores_(nullptr), surface_change_directions_(nullptr) { } @@ -79,34 +79,34 @@ RangeImageBorderExtractor::setRangeImage (const RangeImage* range_image) void RangeImageBorderExtractor::clearData () { - delete[] border_scores_left_; border_scores_left_ = NULL; - delete[] border_scores_right_; border_scores_right_ = NULL; - delete[] border_scores_top_; border_scores_top_ = NULL; - delete[] border_scores_bottom_; border_scores_bottom_ = NULL; + delete[] border_scores_left_; border_scores_left_ = nullptr; + delete[] border_scores_right_; border_scores_right_ = nullptr; + delete[] border_scores_top_; border_scores_top_ = nullptr; + delete[] border_scores_bottom_; border_scores_bottom_ = nullptr; //cout << PVARC(range_image_size_during_extraction_)<isValid(index)) continue; local_surface = new LocalSurface; @@ -141,7 +141,7 @@ RangeImageBorderExtractor::extractLocalSurfaceStructure () &local_surface->neighborhood_mean, &local_surface->eigen_values)) { delete local_surface; - local_surface = NULL; + local_surface = nullptr; } //cout << x<<","<normal_no_jumps[0]<<","<normal_no_jumps[1]<<","<normal_no_jumps[2]<<")\n"; @@ -153,7 +153,7 @@ RangeImageBorderExtractor::extractLocalSurfaceStructure () void RangeImageBorderExtractor::extractBorderScoreImages () { - if (border_scores_left_ != NULL) + if (border_scores_left_ != nullptr) return; extractLocalSurfaceStructure(); @@ -175,7 +175,7 @@ RangeImageBorderExtractor::extractBorderScoreImages () float& left=border_scores_left_[index]; float& right=border_scores_right_[index]; float& top=border_scores_top_[index]; float& bottom=border_scores_bottom_[index]; LocalSurface* local_surface_ptr = surface_structure_[index]; - if (local_surface_ptr==NULL) + if (local_surface_ptr==nullptr) { left=right=top=bottom = 0.0f; continue; @@ -227,10 +227,10 @@ RangeImageBorderExtractor::updateScoresAccordingToNeighborValues () void RangeImageBorderExtractor::findAndEvaluateShadowBorders () { - if (shadow_border_informations_ != NULL) + if (shadow_border_informations_ != nullptr) return; - if (border_scores_left_==NULL) + if (border_scores_left_==nullptr) { std::cerr << __PRETTY_FUNCTION__<<": border score images not available!\n"; } @@ -246,27 +246,27 @@ RangeImageBorderExtractor::findAndEvaluateShadowBorders () { int index = y*width+x; ShadowBorderIndices*& shadow_border_indices = shadow_border_informations_[index]; - shadow_border_indices = NULL; + shadow_border_indices = nullptr; int shadow_border_idx; if (changeScoreAccordingToShadowBorderValue(x, y, -1, 0, border_scores_left_, border_scores_right_, shadow_border_idx)) { - shadow_border_indices = (shadow_border_indices==NULL ? new ShadowBorderIndices : shadow_border_indices); + shadow_border_indices = (shadow_border_indices==nullptr ? new ShadowBorderIndices : shadow_border_indices); shadow_border_indices->left = shadow_border_idx; } if (changeScoreAccordingToShadowBorderValue(x, y, 1, 0, border_scores_right_, border_scores_left_, shadow_border_idx)) { - shadow_border_indices = (shadow_border_indices==NULL ? new ShadowBorderIndices : shadow_border_indices); + shadow_border_indices = (shadow_border_indices==nullptr ? new ShadowBorderIndices : shadow_border_indices); shadow_border_indices->right = shadow_border_idx; } if (changeScoreAccordingToShadowBorderValue(x, y, 0, -1, border_scores_top_, border_scores_bottom_, shadow_border_idx)) { - shadow_border_indices = (shadow_border_indices==NULL ? new ShadowBorderIndices : shadow_border_indices); + shadow_border_indices = (shadow_border_indices==nullptr ? new ShadowBorderIndices : shadow_border_indices); shadow_border_indices->top = shadow_border_idx; } if (changeScoreAccordingToShadowBorderValue(x, y, 0, 1, border_scores_bottom_, border_scores_top_, shadow_border_idx)) { - shadow_border_indices = (shadow_border_indices==NULL ? new ShadowBorderIndices : shadow_border_indices); + shadow_border_indices = (shadow_border_indices==nullptr ? new ShadowBorderIndices : shadow_border_indices); shadow_border_indices->bottom = shadow_border_idx; } } @@ -292,7 +292,7 @@ RangeImageBorderExtractor::getAnglesImageForBorderDirections () float& angle = angles_image[index]; angle = -std::numeric_limits::infinity (); const Eigen::Vector3f* border_direction_ptr = border_directions_[index]; - if (border_direction_ptr == NULL) + if (border_direction_ptr == nullptr) continue; const Eigen::Vector3f& border_direction = *border_direction_ptr; const PointWithRange& point = range_image_->getPoint(index); @@ -354,7 +354,7 @@ RangeImageBorderExtractor::getAnglesImageForSurfaceChangeDirections () void RangeImageBorderExtractor::classifyBorders () { - if (border_descriptions_ != NULL) + if (border_descriptions_ != nullptr) return; // Get local plane approximations @@ -392,7 +392,7 @@ RangeImageBorderExtractor::classifyBorders () BorderTraits& border_traits = border_description.traits; ShadowBorderIndices* shadow_border_indices = shadow_border_informations_[index]; - if (shadow_border_indices == NULL) + if (shadow_border_indices == nullptr) continue; int shadow_border_index = shadow_border_indices->left; @@ -461,7 +461,7 @@ RangeImageBorderExtractor::classifyBorders () void RangeImageBorderExtractor::calculateBorderDirections () { - if (border_directions_!=NULL) + if (border_directions_!=nullptr) return; classifyBorders(); @@ -489,9 +489,9 @@ RangeImageBorderExtractor::calculateBorderDirections () { int index = y*width + x; Eigen::Vector3f*& average_border_direction = average_border_directions[index]; - average_border_direction = NULL; + average_border_direction = nullptr; const Eigen::Vector3f* border_direction = border_directions_[index]; - if (border_direction==NULL) + if (border_direction==nullptr) continue; average_border_direction = new Eigen::Vector3f(*border_direction); float weight_sum = 1.0f; @@ -501,7 +501,7 @@ RangeImageBorderExtractor::calculateBorderDirections () { int index2 = y2*width + x2; const Eigen::Vector3f* neighbor_border_direction = border_directions_[index2]; - if (neighbor_border_direction==NULL || index2==index) + if (neighbor_border_direction==nullptr || index2==index) continue; // Opposite directions? @@ -526,7 +526,7 @@ RangeImageBorderExtractor::calculateBorderDirections () if (pcl_lrint (weight_sum) < minimum_weight) { delete average_border_direction; - average_border_direction=NULL; + average_border_direction=nullptr; } else average_border_direction->normalize(); @@ -543,7 +543,7 @@ RangeImageBorderExtractor::calculateBorderDirections () void RangeImageBorderExtractor::calculateSurfaceChanges () { - if (surface_change_scores_!=NULL) + if (surface_change_scores_!=nullptr) return; calculateBorderDirections(); @@ -569,7 +569,7 @@ RangeImageBorderExtractor::calculateSurfaceChanges () const BorderTraits& border_traits = border_descriptions_->points[index].traits; if (border_traits[BORDER_TRAIT__VEIL_POINT] || border_traits[BORDER_TRAIT__SHADOW_BORDER]) continue; - if (border_directions_[index]!=NULL) + if (border_directions_[index]!=nullptr) { surface_change_score = 1.0f; surface_change_direction = *border_directions_[index]; @@ -664,7 +664,7 @@ RangeImageBorderExtractor::computeFeature (PointCloudOut& output) return; } - if (range_image_==NULL) + if (range_image_==nullptr) { std::cerr << __PRETTY_FUNCTION__ << ": RangeImage is not set. Sorry, the border extraction works on range images, not on normal point clouds."