From 8eed6b38a051e683ab934480ce516ce8176133f3 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 15 Dec 2024 17:15:23 +0100 Subject: [PATCH] Satisfy clang-tidy's modernize-use-auto --- geometry/include/pcl/geometry/mesh_base.h | 6 +++--- io/src/openni2/openni2_device.cpp | 12 ++++++------ io/src/openni2/openni2_timer_filter.cpp | 4 ++-- io/src/openni_camera/openni_driver.cpp | 2 +- octree/include/pcl/octree/impl/octree2buf_base.hpp | 14 ++++++-------- octree/include/pcl/octree/impl/octree_base.hpp | 14 ++++++-------- recognition/src/ransac_based/obj_rec_ransac.cpp | 2 +- registration/include/pcl/registration/impl/lum.hpp | 2 +- segmentation/src/grabcut_segmentation.cpp | 4 ++-- .../pcl/surface/impl/marching_cubes_rbf.hpp | 6 +++--- test/common/test_wrappers.cpp | 8 ++++---- visualization/src/pcl_visualizer.cpp | 2 +- 12 files changed, 36 insertions(+), 40 deletions(-) diff --git a/geometry/include/pcl/geometry/mesh_base.h b/geometry/include/pcl/geometry/mesh_base.h index 20003ce49d6..014b8c862eb 100644 --- a/geometry/include/pcl/geometry/mesh_base.h +++ b/geometry/include/pcl/geometry/mesh_base.h @@ -1804,14 +1804,14 @@ class MeshBase { typename IndexContainerT::value_type()); Index ind_old(0), ind_new(0); - typename ElementContainerT::const_iterator it_e_old = elements.begin(); + auto it_e_old = elements.cbegin(); auto it_e_new = elements.begin(); - typename DataContainerT::const_iterator it_d_old = data_cloud.begin(); + auto it_d_old = data_cloud.cbegin(); auto it_d_new = data_cloud.begin(); auto it_ind_new = new_indices.begin(); - typename IndexContainerT::const_iterator it_ind_new_end = new_indices.end(); + auto it_ind_new_end = new_indices.cend(); while (it_ind_new != it_ind_new_end) { if (!this->isDeleted(ind_old)) { diff --git a/io/src/openni2/openni2_device.cpp b/io/src/openni2/openni2_device.cpp index b7201ac889c..a029e532aa4 100644 --- a/io/src/openni2/openni2_device.cpp +++ b/io/src/openni2/openni2_device.cpp @@ -215,8 +215,8 @@ pcl::io::openni2::OpenNI2Device::isIRVideoModeSupported (const OpenNI2VideoMode& bool supported = false; - std::vector::const_iterator it = ir_video_modes_.begin (); - std::vector::const_iterator it_end = ir_video_modes_.end (); + auto it = ir_video_modes_.cbegin (); + auto it_end = ir_video_modes_.cend (); while (it != it_end && !supported) { @@ -234,8 +234,8 @@ pcl::io::openni2::OpenNI2Device::isColorVideoModeSupported (const OpenNI2VideoMo bool supported = false; - std::vector::const_iterator it = color_video_modes_.begin (); - std::vector::const_iterator it_end = color_video_modes_.end (); + auto it = color_video_modes_.cbegin (); + auto it_end = color_video_modes_.cend (); while (it != it_end && !supported) { @@ -253,8 +253,8 @@ pcl::io::openni2::OpenNI2Device::isDepthVideoModeSupported (const OpenNI2VideoMo bool supported = false; - std::vector::const_iterator it = depth_video_modes_.begin (); - std::vector::const_iterator it_end = depth_video_modes_.end (); + auto it = depth_video_modes_.cbegin (); + auto it_end = depth_video_modes_.cend (); while (it != it_end && !supported) { diff --git a/io/src/openni2/openni2_timer_filter.cpp b/io/src/openni2/openni2_timer_filter.cpp index 932ff0a2a14..538c521196f 100644 --- a/io/src/openni2/openni2_timer_filter.cpp +++ b/io/src/openni2/openni2_timer_filter.cpp @@ -73,8 +73,8 @@ namespace pcl { double sum = 0; - std::deque::const_iterator it = buffer_.begin (); - std::deque::const_iterator it_end = buffer_.end (); + auto it = buffer_.cbegin (); + auto it_end = buffer_.cend (); while (it != it_end) { diff --git a/io/src/openni_camera/openni_driver.cpp b/io/src/openni_camera/openni_driver.cpp index 11e50769a2a..5b58936b127 100644 --- a/io/src/openni_camera/openni_driver.cpp +++ b/io/src/openni_camera/openni_driver.cpp @@ -348,7 +348,7 @@ openni_wrapper::OpenNIDriver::getDeviceInfos () noexcept { libusb_device* device = devices[devIdx]; std::uint8_t busId = libusb_get_bus_number (device); - std::map >::const_iterator busIt = bus_map_.find (busId); + auto busIt = bus_map_.find (busId); if (busIt == bus_map_.end ()) continue; diff --git a/octree/include/pcl/octree/impl/octree2buf_base.hpp b/octree/include/pcl/octree/impl/octree2buf_base.hpp index b91b03baf01..f56fa2d2826 100644 --- a/octree/include/pcl/octree/impl/octree2buf_base.hpp +++ b/octree/include/pcl/octree/impl/octree2buf_base.hpp @@ -279,8 +279,8 @@ Octree2BufBase::deserializeTree( leaf_count_ = 0; // iterator for binary tree structure vector - std::vector::const_iterator binary_tree_in_it = binary_tree_in_arg.begin(); - std::vector::const_iterator binary_tree_in_it_end = binary_tree_in_arg.end(); + auto binary_tree_in_it = binary_tree_in_arg.cbegin(); + auto binary_tree_in_it_end = binary_tree_in_arg.cend(); deserializeTreeRecursive(root_node_, depth_mask_, @@ -307,19 +307,17 @@ Octree2BufBase::deserializeTree( OctreeKey new_key; // set data iterator to first element - typename std::vector::const_iterator leaf_container_vector_it = - leaf_container_vector_arg.begin(); + auto leaf_container_vector_it = leaf_container_vector_arg.cbegin(); // set data iterator to last element - typename std::vector::const_iterator leaf_container_vector_it_end = - leaf_container_vector_arg.end(); + auto leaf_container_vector_it_end = leaf_container_vector_arg.cend(); // we will rebuild an octree -> reset leafCount leaf_count_ = 0; // iterator for binary tree structure vector - std::vector::const_iterator binary_tree_in_it = binary_tree_in_arg.begin(); - std::vector::const_iterator binary_tree_in_it_end = binary_tree_in_arg.end(); + auto binary_tree_in_it = binary_tree_in_arg.cbegin(); + auto binary_tree_in_it_end = binary_tree_in_arg.cend(); deserializeTreeRecursive(root_node_, depth_mask_, diff --git a/octree/include/pcl/octree/impl/octree_base.hpp b/octree/include/pcl/octree/impl/octree_base.hpp index 92b0489ef1e..ab440f67359 100644 --- a/octree/include/pcl/octree/impl/octree_base.hpp +++ b/octree/include/pcl/octree/impl/octree_base.hpp @@ -244,8 +244,8 @@ OctreeBase::deserializeTree( deleteTree(); // iterator for binary tree structure vector - std::vector::const_iterator binary_tree_out_it = binary_tree_out_arg.begin(); - std::vector::const_iterator binary_tree_out_it_end = binary_tree_out_arg.end(); + auto binary_tree_out_it = binary_tree_out_arg.cbegin(); + auto binary_tree_out_it_end = binary_tree_out_arg.cend(); deserializeTreeRecursive(root_node_, depth_mask_, @@ -266,19 +266,17 @@ OctreeBase::deserializeTree( OctreeKey new_key; // set data iterator to first element - typename std::vector::const_iterator leaf_vector_it = - leaf_container_vector_arg.begin(); + auto leaf_vector_it = leaf_container_vector_arg.cbegin(); // set data iterator to last element - typename std::vector::const_iterator leaf_vector_it_end = - leaf_container_vector_arg.end(); + auto leaf_vector_it_end = leaf_container_vector_arg.cend(); // free existing tree before tree rebuild deleteTree(); // iterator for binary tree structure vector - std::vector::const_iterator binary_tree_input_it = binary_tree_in_arg.begin(); - std::vector::const_iterator binary_tree_input_it_end = binary_tree_in_arg.end(); + auto binary_tree_input_it = binary_tree_in_arg.cbegin(); + auto binary_tree_input_it_end = binary_tree_in_arg.cend(); deserializeTreeRecursive(root_node_, depth_mask_, diff --git a/recognition/src/ransac_based/obj_rec_ransac.cpp b/recognition/src/ransac_based/obj_rec_ransac.cpp index a57b2d4bc6f..25aba5c0cb3 100644 --- a/recognition/src/ransac_based/obj_rec_ransac.cpp +++ b/recognition/src/ransac_based/obj_rec_ransac.cpp @@ -420,7 +420,7 @@ pcl::recognition::ObjRecRANSAC::buildGraphOfCloseHypotheses (HypothesisOctree& h i = 0; // Now create the graph connectivity such that each two neighboring rotation spaces are neighbors in the graph - for ( std::vector::const_iterator hypo = hypo_leaves.begin () ; hypo != hypo_leaves.end () ; ++hypo, ++i ) + for ( auto hypo = hypo_leaves.cbegin () ; hypo != hypo_leaves.cend () ; ++hypo, ++i ) { // Compute the fitness of the graph node graph.getNodes ()[i]->setFitness (static_cast ((*hypo)->getData ().explained_pixels_.size ())); diff --git a/registration/include/pcl/registration/impl/lum.hpp b/registration/include/pcl/registration/impl/lum.hpp index 534c4951684..852759ee75c 100644 --- a/registration/include/pcl/registration/impl/lum.hpp +++ b/registration/include/pcl/registration/impl/lum.hpp @@ -268,7 +268,7 @@ LUM::compute() // Update the poses float sum = 0.0; for (int vi = 1; vi != n; ++vi) { - Eigen::Vector6f difference_pose = static_cast( + auto difference_pose = static_cast( -incidenceCorrection(getPose(vi)).inverse() * X.segment(6 * (vi - 1), 6)); sum += difference_pose.norm(); setPose(vi, getPose(vi) + difference_pose); diff --git a/segmentation/src/grabcut_segmentation.cpp b/segmentation/src/grabcut_segmentation.cpp index ea2b75c7704..f15aef82951 100644 --- a/segmentation/src/grabcut_segmentation.cpp +++ b/segmentation/src/grabcut_segmentation.cpp @@ -460,7 +460,7 @@ pcl::segmentation::grabcut::BoykovKolmogorov::adoptOrphans (std::deque& orp if (cut_[jt->first] != tree_label) continue; // check edge capacity - const capacitated_edge::iterator kt = nodes_[jt->first].find (u); + const auto kt = nodes_[jt->first].find (u); if (((tree_label == TARGET) && (jt->second <= 0.0)) || ((tree_label == SOURCE) && (kt->second <= 0.0))) continue; @@ -483,7 +483,7 @@ pcl::segmentation::grabcut::BoykovKolmogorov::adoptOrphans (std::deque& orp // free the orphan subtree and remove it from the active set if (b_free_orphan) { - for (capacitated_edge::const_iterator jt = nodes_[u].begin (); jt != nodes_[u].end (); ++jt) + for (auto jt = nodes_[u].cbegin (); jt != nodes_[u].cend (); ++jt) { if ((cut_[jt->first] == tree_label) && (parents_[jt->first].first == u)) { diff --git a/surface/include/pcl/surface/impl/marching_cubes_rbf.hpp b/surface/include/pcl/surface/impl/marching_cubes_rbf.hpp index 3c8529c978c..3e72a13aac4 100644 --- a/surface/include/pcl/surface/impl/marching_cubes_rbf.hpp +++ b/surface/include/pcl/surface/impl/marching_cubes_rbf.hpp @@ -94,9 +94,9 @@ pcl::MarchingCubesRBF::voxelizeData () const Eigen::Vector3d point = point_f.cast (); double f = 0.0; - std::vector::const_iterator w_it (weights.begin()); - for (std::vector >::const_iterator c_it = centers.begin (); - c_it != centers.end (); ++c_it, ++w_it) + auto w_it (weights.cbegin()); + for (auto c_it = centers.cbegin (); + c_it != centers.cend (); ++c_it, ++w_it) f += *w_it * kernel (*c_it, point); grid_[x * res_y_*res_z_ + y * res_z_ + z] = static_cast(f); diff --git a/test/common/test_wrappers.cpp b/test/common/test_wrappers.cpp index 676f92cdd25..4fd195bb5ea 100644 --- a/test/common/test_wrappers.cpp +++ b/test/common/test_wrappers.cpp @@ -108,8 +108,8 @@ TEST (PointCloud, iterators) cloud.begin ()->getVector3fMap ()); EXPECT_EQ_VECTORS ((--cloud.end ())->getVector3fMap (), (--cloud.end ())->getVector3fMap ()); - PointCloud::const_iterator pit = cloud.begin (); - PointCloud::VectorType::const_iterator pit2 = cloud.begin (); + auto pit = cloud.begin (); + auto pit2 = cloud.begin (); for (; pit < cloud.end (); ++pit2, ++pit) EXPECT_EQ_VECTORS (pit->getVector3fMap (), pit2->getVector3fMap ()); } @@ -125,8 +125,8 @@ TEST (PointCloud, insert_range) EXPECT_EQ (cloud.width, cloud.size ()); EXPECT_EQ (cloud.height, 1); EXPECT_EQ (cloud.width, old_size + cloud2.size ()); - PointCloud::const_iterator pit = cloud.begin (); - PointCloud::const_iterator pit2 = cloud2.begin (); + auto pit = cloud.begin (); + auto pit2 = cloud2.begin (); for (; pit2 < cloud2.end (); ++pit2, ++pit) EXPECT_EQ_VECTORS (pit->getVector3fMap (), pit2->getVector3fMap ()); } diff --git a/visualization/src/pcl_visualizer.cpp b/visualization/src/pcl_visualizer.cpp index 902ee201657..c7f2b4b78a9 100644 --- a/visualization/src/pcl_visualizer.cpp +++ b/visualization/src/pcl_visualizer.cpp @@ -2179,7 +2179,7 @@ void pcl::visualization::PCLVisualizer::resetCameraViewpoint (const std::string &id) { vtkSmartPointer camera_pose; - const CloudActorMap::iterator it = cloud_actor_map_->find(id); + const auto it = cloud_actor_map_->find(id); if (it != cloud_actor_map_->end ()) camera_pose = it->second.viewpoint_transformation_; else