Skip to content

Commit

Permalink
Merge pull request #3008 from SunBlack/modernize-use-nullptr_features
Browse files Browse the repository at this point in the history
Use nullptr in module features
  • Loading branch information
SergioRAgostinho authored Apr 22, 2019
2 parents 514ecb4 + 851c29c commit 4330977
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 70 deletions.
2 changes: 1 addition & 1 deletion features/include/pcl/features/3dsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace pcl

// Create a random number generator object
if (random)
rng_->base ().seed (static_cast<unsigned> (std::time(0)));
rng_->base ().seed (static_cast<unsigned> (std::time(nullptr)));
else
rng_->base ().seed (12345u);
}
Expand Down
2 changes: 1 addition & 1 deletion features/include/pcl/features/impl/brisk_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pcl::BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::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)
Expand Down
2 changes: 1 addition & 1 deletion features/include/pcl/features/impl/crh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pcl::CRHEstimation<PointInT, PointNT, PointOutT>::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);
Expand Down
2 changes: 1 addition & 1 deletion features/include/pcl/features/impl/esf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pcl::ESFEstimation<PointInT, PointOutT>::computeESF (
{
const int binsize = 64;
unsigned int sample_size = 20000;
srand (static_cast<unsigned int> (time (0)));
srand (static_cast<unsigned int> (time (nullptr)));
int maxindex = static_cast<int> (pc.points.size ());

int index1, index2, index3;
Expand Down
8 changes: 4 additions & 4 deletions features/include/pcl/features/impl/integral_image_normal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::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 ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ bool RangeImageBorderExtractor::get3dDirection(const BorderDescription& border_d
range_image_->calculate3DPoint(static_cast<float> (x+delta_x), static_cast<float> (y+delta_y), point.range, neighbor_point);
//cout << "Neighborhood point is "<<neighbor_point[0]<<", "<<neighbor_point[1]<<", "<<neighbor_point[2]<<".\n";

if (local_surface!=NULL)
if (local_surface!=nullptr)
{
// Get the point that lies on the local plane approximation
Eigen::Vector3f sensor_pos = range_image_->getSensorPos(),
Expand All @@ -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])
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions features/include/pcl/features/integral_image_normal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion features/include/pcl/features/narf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions features/include/pcl/features/narf_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ namespace pcl

// =====CONSTRUCTOR & DESTRUCTOR=====
/** Constructor */
NarfDescriptor (const RangeImage* range_image=NULL, const std::vector<int>* indices=NULL);
NarfDescriptor (const RangeImage* range_image=nullptr, const std::vector<int>* indices=nullptr);
/** Destructor */
~NarfDescriptor();

// =====METHODS=====
//! Set input data
void
setRangeImage (const RangeImage* range_image, const std::vector<int>* indices=NULL);
setRangeImage (const RangeImage* range_image, const std::vector<int>* indices=nullptr);

//! Overwrite the compute function of the base class
void
Expand Down
6 changes: 3 additions & 3 deletions features/include/pcl/features/range_image_border_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace pcl

// =====CONSTRUCTOR & DESTRUCTOR=====
/** Constructor */
RangeImageBorderExtractor (const RangeImage* range_image=NULL);
RangeImageBorderExtractor (const RangeImage* range_image=nullptr);
/** Destructor */
~RangeImageBorderExtractor ();

Expand Down Expand Up @@ -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_; }
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions features/src/narf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -620,7 +620,7 @@ void
NarfDescriptor::setRangeImage (const RangeImage* range_image, const std::vector<int>* indices)
{
range_image_ = range_image;
if (indices != NULL)
if (indices != nullptr)
{
IndicesPtr indicesptr (new std::vector<int> (*indices));
setIndices (indicesptr);
Expand All @@ -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."
Expand Down
Loading

0 comments on commit 4330977

Please sign in to comment.