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

Use nullptr in module segmentation #3023

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
11 changes: 1 addition & 10 deletions segmentation/include/pcl/segmentation/impl/crf_segmentation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,20 @@ pcl::CrfSegmentation<PointT>::~CrfSegmentation ()
template <typename PointT> void
pcl::CrfSegmentation<PointT>::setInputCloud (typename pcl::PointCloud<PointT>::Ptr input_cloud)
{
if (input_cloud_ != NULL)
input_cloud_.reset ();

input_cloud_ = input_cloud;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::CrfSegmentation<PointT>::setAnnotatedCloud (typename pcl::PointCloud<pcl::PointXYZRGBL>::Ptr anno_cloud)
{
if (anno_cloud_ != NULL)
anno_cloud_.reset ();

anno_cloud_ = anno_cloud;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::CrfSegmentation<PointT>::setNormalCloud (typename pcl::PointCloud<pcl::PointNormal>::Ptr normal_cloud)
{
if (normal_cloud_ != NULL)
normal_cloud_.reset ();

normal_cloud_ = normal_cloud;
}

Expand Down Expand Up @@ -329,7 +320,7 @@ pcl::CrfSegmentation<PointT>::createUnaryPotentials (std::vector<float> &unary,
unsigned int n_labels)
{
/* initialize random seed: */
srand ( static_cast<unsigned int> (time (NULL)) );
srand ( static_cast<unsigned int> (time (nullptr)) );
//srand ( time (NULL) );

// Certainty that the groundtruth is correct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ template <typename PointT> void
pcl::EuclideanClusterExtraction<PointT>::extract (std::vector<PointIndices> &clusters)
{
if (!initCompute () ||
(input_ != 0 && input_->points.empty ()) ||
(indices_ != 0 && indices_->empty ()))
(input_ && input_->points.empty ()) ||
(indices_ && indices_->empty ()))
{
clusters.clear ();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ template <typename PointT> void
pcl::LabeledEuclideanClusterExtraction<PointT>::extract (std::vector<std::vector<PointIndices> > &labeled_clusters)
{
if (!initCompute () ||
(input_ != 0 && input_->points.empty ()) ||
(indices_ != 0 && indices_->empty ()))
(input_ && input_->points.empty ()) ||
(indices_ && indices_->empty ()))
{
labeled_clusters.clear ();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,6 @@ pcl::MinCutSegmentation<PointT>::MinCutSegmentation () :
template <typename PointT>
pcl::MinCutSegmentation<PointT>::~MinCutSegmentation ()
{
if (search_ != 0)
search_.reset ();
if (graph_ != 0)
graph_.reset ();
if (capacity_ != 0)
capacity_.reset ();
if (reverse_edges_ != 0)
reverse_edges_.reset ();

foreground_points_.clear ();
background_points_.clear ();
clusters_.clear ();
Expand Down Expand Up @@ -167,9 +158,6 @@ pcl::MinCutSegmentation<PointT>::getSearchMethod () const
template <typename PointT> void
pcl::MinCutSegmentation<PointT>::setSearchMethod (const KdTreePtr& tree)
{
if (search_ != 0)
search_.reset ();

search_ = tree;
}

Expand Down Expand Up @@ -327,7 +315,7 @@ pcl::MinCutSegmentation<PointT>::buildGraph ()
if (input_->points.size () == 0 || number_of_points == 0 || foreground_points_.empty () == true )
return (false);

if (search_ == 0)
if (!search_)
search_.reset (new pcl::search::KdTree<PointT>);

graph_.reset (new mGraph);
Expand Down
17 changes: 3 additions & 14 deletions segmentation/include/pcl/segmentation/impl/region_growing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ pcl::RegionGrowing<PointT, NormalT>::RegionGrowing () :
template <typename PointT, typename NormalT>
pcl::RegionGrowing<PointT, NormalT>::~RegionGrowing ()
{
if (search_ != 0)
search_.reset ();
if (normals_ != 0)
normals_.reset ();

point_neighbours_.clear ();
point_labels_.clear ();
num_pts_in_segment_.clear ();
Expand Down Expand Up @@ -233,9 +228,6 @@ pcl::RegionGrowing<PointT, NormalT>::getSearchMethod () const
template <typename PointT, typename NormalT> void
pcl::RegionGrowing<PointT, NormalT>::setSearchMethod (const KdTreePtr& tree)
{
if (search_ != 0)
search_.reset ();

search_ = tree;
}

Expand All @@ -250,9 +242,6 @@ pcl::RegionGrowing<PointT, NormalT>::getInputNormals () const
template <typename PointT, typename NormalT> void
pcl::RegionGrowing<PointT, NormalT>::setInputNormals (const NormalPtr& norm)
{
if (normals_ != 0)
normals_.reset ();

normals_ = norm;
}

Expand Down Expand Up @@ -312,7 +301,7 @@ pcl::RegionGrowing<PointT, NormalT>::prepareForSegmentation ()
return (false);

// if user forgot to pass normals or the sizes of point and normal cloud are different
if ( normals_ == 0 || input_->points.size () != normals_->points.size () )
if ( !normals_ || input_->points.size () != normals_->points.size () )
return (false);

// if residual test is on then we need to check if all needed parameters were correctly initialized
Expand Down Expand Up @@ -656,7 +645,7 @@ pcl::RegionGrowing<PointT, NormalT>::getColoredCloud ()
{
colored_cloud = (new pcl::PointCloud<pcl::PointXYZRGB>)->makeShared ();

srand (static_cast<unsigned int> (time (0)));
srand (static_cast<unsigned int> (time (nullptr)));
std::vector<unsigned char> colors;
for (size_t i_segment = 0; i_segment < clusters_.size (); i_segment++)
{
Expand Down Expand Up @@ -708,7 +697,7 @@ pcl::RegionGrowing<PointT, NormalT>::getColoredCloudRGBA ()
{
colored_cloud = (new pcl::PointCloud<pcl::PointXYZRGBA>)->makeShared ();

srand (static_cast<unsigned int> (time (0)));
srand (static_cast<unsigned int> (time (nullptr)));
std::vector<unsigned char> colors;
for (size_t i_segment = 0; i_segment < clusters_.size (); i_segment++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pcl::RegionGrowingRGB<PointT, NormalT>::prepareForSegmentation ()
if (normal_flag_)
{
// if user forgot to pass normals or the sizes of point and normal cloud are different
if ( normals_ == 0 || input_->points.size () != normals_->points.size () )
if ( !normals_ || input_->points.size () != normals_->points.size () )
return (false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ void
pcl::SeededHueSegmentation::segment (PointIndices &indices_in, PointIndices &indices_out)
{
if (!initCompute () ||
(input_ != 0 && input_->points.empty ()) ||
(indices_ != 0 && indices_->empty ()))
(input_ && input_->points.empty ()) ||
(indices_ && indices_->empty ()))
{
indices_out.indices.clear ();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ pcl::SupervoxelClustering<PointT>::computeVoxelData ()
{
VoxelData& voxel_data = (*leaf_itr)->getData ();
voxel_data.normal_.normalize ();
voxel_data.owner_ = 0;
voxel_data.owner_ = nullptr;
voxel_data.distance_ = std::numeric_limits<float>::max ();
//Get the number of points in this leaf
int num_points = (*leaf_itr)->getPointCounter ();
Expand Down Expand Up @@ -280,7 +280,7 @@ pcl::SupervoxelClustering<PointT>::computeVoxelData ()
pcl::flipNormalTowardsViewpoint (voxel_centroid_cloud_->points[new_voxel_data.idx_], 0.0f,0.0f,0.0f, new_voxel_data.normal_);
new_voxel_data.normal_[3] = 0.0f;
new_voxel_data.normal_.normalize ();
new_voxel_data.owner_ = 0;
new_voxel_data.owner_ = nullptr;
new_voxel_data.distance_ = std::numeric_limits<float>::max ();
}
}
Expand Down Expand Up @@ -384,7 +384,7 @@ pcl::SupervoxelClustering<PointT>::selectInitialSupervoxelSeeds (std::vector<int
std::vector<float> distance;
closest_index.resize(1,0);
distance.resize(1,0);
if (voxel_kdtree_ == 0)
if (!voxel_kdtree_)
{
voxel_kdtree_.reset (new pcl::search::KdTree<PointT>);
voxel_kdtree_ ->setInputCloud (voxel_centroid_cloud_);
Expand Down Expand Up @@ -781,7 +781,7 @@ pcl::SupervoxelClustering<PointT>::SupervoxelHelper::removeAllLeaves ()
for (auto leaf_itr = leaves_.cbegin (); leaf_itr != leaves_.cend (); ++leaf_itr)
{
VoxelData& voxel = ((*leaf_itr)->getData ());
voxel.owner_ = 0;
voxel.owner_ = nullptr;
voxel.distance_ = std::numeric_limits<float>::max ();
}
leaves_.clear ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ pcl::UnaryClassifier<PointT>::~UnaryClassifier ()
template <typename PointT> void
pcl::UnaryClassifier<PointT>::setInputCloud (typename pcl::PointCloud<PointT>::Ptr input_cloud)
{
if (input_cloud_ != NULL)
input_cloud_.reset ();

input_cloud_ = input_cloud;

pcl::PointCloud <PointT> point;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace pcl
rgb_ (0.0f, 0.0f, 0.0f),
normal_ (0.0f, 0.0f, 0.0f, 0.0f),
curvature_ (0.0f),
owner_ (0)
owner_ (nullptr)
{}

/** \brief Gets the data of in the form of a point
Expand Down