From c295be985117eeae28bd3e9576b095431409cb92 Mon Sep 17 00:00:00 2001 From: Kino Date: Thu, 18 Jan 2024 03:18:57 +0800 Subject: [PATCH] Enable C++17 filesystem in the future (#5921) * Enable C++17 filesystem * Fix format complaint * Fix ubuntu build error * Fix apps build error * Fix format complaint * Switch Ubuntu 23.04 to C++17 * Revert doc/tutorials and outofcore * Revert examples/outofcore * Revert test/outofcore * Revert recognition * Fix apps/face_detection build error * Address review * Address more review --- .../3d_rec_framework/pc_source/mesh_source.h | 8 ++-- .../pipeline/impl/global_nn_classifier.hpp | 8 ++-- .../impl/global_nn_recognizer_crh.hpp | 8 ++-- .../impl/global_nn_recognizer_cvfh.hpp | 12 ++--- .../pipeline/impl/local_recognizer.hpp | 8 ++-- .../utils/persistence_utils.h | 7 +++ .../tools/local_recognition_mian_dataset.cpp | 24 +++++----- .../src/offline_integration.cpp | 13 ++++-- .../face_detection_apps_utils.h | 16 +++++-- apps/include/pcl/apps/pcd_video_player.h | 8 +++- .../filesystem_face_detection.cpp | 10 ++-- apps/src/openni_grab_frame.cpp | 11 +++-- apps/src/openni_grab_images.cpp | 3 -- apps/src/organized_segmentation_demo.cpp | 3 -- .../src/pcd_video_player/pcd_video_player.cpp | 9 ++-- apps/src/stereo_ground_segmentation.cpp | 12 +++-- common/include/pcl/common/impl/file_io.hpp | 15 ++++-- cuda/apps/src/kinect_planes_cuda.cpp | 8 +++- gpu/kinfu/tools/kinfu_app.cpp | 17 ++++--- .../kinfu_large_scale/screenshot_manager.h | 8 +++- .../src/screenshot_manager.cpp | 4 +- gpu/kinfu_large_scale/tools/kinfuLS_app.cpp | 17 ++++--- .../tools/standalone_texture_mapping.cpp | 13 ++++-- gpu/people/tools/people_app.cpp | 18 +++++--- io/include/pcl/io/impl/auto_io.hpp | 13 ++++-- io/src/ascii_io.cpp | 12 ++++- io/src/auto_io.cpp | 12 ++--- io/src/image_grabber.cpp | 46 +++++++++++-------- io/src/lzf_image_io.cpp | 10 +++- io/src/obj_io.cpp | 18 ++++++-- io/src/openni2_grabber.cpp | 9 +++- io/src/openni_grabber.cpp | 9 +++- io/src/pcd_io.cpp | 23 ++++++++-- io/src/ply_io.cpp | 13 ++++-- test/io/test_grabbers.cpp | 12 ++++- tools/converter.cpp | 23 ++++++---- tools/fast_bilateral_filter.cpp | 16 +++++-- tools/grid_min.cpp | 16 +++++-- tools/image_grabber_saver.cpp | 11 ++++- tools/image_grabber_viewer.cpp | 9 +++- tools/local_max.cpp | 16 +++++-- tools/morph.cpp | 16 +++++-- tools/normal_estimation.cpp | 16 +++++-- tools/passthrough_filter.cpp | 16 +++++-- tools/pcd_grabber_viewer.cpp | 16 +++++-- tools/progressive_morphological_filter.cpp | 16 +++++-- tools/radius_filter.cpp | 16 +++++-- tools/sac_segmentation_plane.cpp | 16 +++++-- tools/tiff2pcd.cpp | 21 ++++++--- tools/unary_classifier_segment.cpp | 15 ++++-- tools/uniform_sampling.cpp | 10 +++- tools/virtual_scanner.cpp | 15 ++++-- visualization/src/interactor_style.cpp | 9 +++- visualization/src/pcl_visualizer.cpp | 36 +++++++++------ 54 files changed, 523 insertions(+), 223 deletions(-) diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/mesh_source.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/mesh_source.h index 6e1713618e2..4b39619f465 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/mesh_source.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/mesh_source.h @@ -81,7 +81,7 @@ class MeshSource : public Source { loadOrGenerate(std::string& dir, std::string& model_path, ModelT& model) { const std::string pathmodel = dir + '/' + model.class_ + '/' + model.id_; - bf::path trained_dir = pathmodel; + pcl_fs::path trained_dir = pathmodel; model.views_.reset(new std::vector::Ptr>); model.poses_.reset( @@ -90,12 +90,12 @@ class MeshSource : public Source { model.assembled_.reset(new pcl::PointCloud); uniform_sampling(model_path, 100000, *model.assembled_, model_scale_); - if (bf::exists(trained_dir)) { + if (pcl_fs::exists(trained_dir)) { // load views, poses and self-occlusions std::vector view_filenames; - for (const auto& dir_entry : bf::directory_iterator(trained_dir)) { + for (const auto& dir_entry : pcl_fs::directory_iterator(trained_dir)) { // check if its a directory, then get models in it - if (!(bf::is_directory(dir_entry))) { + if (!(pcl_fs::is_directory(dir_entry))) { // check that it is a ply file and then add, otherwise ignore.. std::vector strs; std::vector strs_; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_classifier.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_classifier.hpp index 0592be86b93..79929997ab2 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_classifier.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_classifier.hpp @@ -17,7 +17,7 @@ pcl::rec_3d_framework::GlobalNNPipeline:: std::string path = source_->getModelDescriptorDir(models->at(i), training_dir_, descr_name_); - for (const auto& dir_entry : bf::directory_iterator(path)) { + for (const auto& dir_entry : pcl_fs::directory_iterator(path)) { std::string file_name = (dir_entry.path().filename()).string(); std::vector strs; @@ -177,9 +177,9 @@ pcl::rec_3d_framework::GlobalNNPipeline::initializ std::string path = source_->getModelDescriptorDir(models->at(i), training_dir_, descr_name_); - bf::path desc_dir = path; - if (!bf::exists(desc_dir)) - bf::create_directory(desc_dir); + pcl_fs::path desc_dir = path; + if (!pcl_fs::exists(desc_dir)) + pcl_fs::create_directory(desc_dir); const std::string path_view = path + "/view_" + std::to_string(v) + ".pcd"; pcl::io::savePCDFileBinary(path_view, *processed); diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp index bf6607eeae7..af7ab87d642 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp @@ -91,7 +91,7 @@ pcl::rec_3d_framework::GlobalNNCRHRecognizer:: std::string path = source_->getModelDescriptorDir(models->at(i), training_dir_, descr_name_); - for (const auto& dir_entry : bf::directory_iterator(path)) { + for (const auto& dir_entry : pcl_fs::directory_iterator(path)) { std::string file_name = (dir_entry.path().filename()).string(); std::vector strs; @@ -412,9 +412,9 @@ pcl::rec_3d_framework::GlobalNNCRHRecognizer::init std::string path = source_->getModelDescriptorDir(models->at(i), training_dir_, descr_name_); - bf::path desc_dir = path; - if (!bf::exists(desc_dir)) - bf::create_directory(desc_dir); + pcl_fs::path desc_dir = path; + if (!pcl_fs::exists(desc_dir)) + pcl_fs::create_directory(desc_dir); const std::string path_view = path + "/view_" + std::to_string(v) + ".pcd"; pcl::io::savePCDFileBinary(path_view, *processed); diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp index fdd83be86d7..6a583006cd7 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp @@ -51,8 +51,8 @@ pcl::rec_3d_framework::GlobalNNCVFHRecognizer:: const std::string dir = path + "/roll_trans_" + std::to_string(view_id) + '_' + std::to_string(d_id) + ".txt"; - const bf::path file_path = dir; - if (bf::exists(file_path)) { + const pcl_fs::path file_path = dir; + if (pcl_fs::exists(file_path)) { PersistenceUtils::readMatrixFromFile(dir, pose_matrix); return true; } @@ -108,7 +108,7 @@ pcl::rec_3d_framework::GlobalNNCVFHRecognizer:: std::string path = source_->getModelDescriptorDir(models->at(i), training_dir_, descr_name_); - for (const auto& dir_entry : bf::directory_iterator(path)) { + for (const auto& dir_entry : pcl_fs::directory_iterator(path)) { std::string file_name = (dir_entry.path().filename()).string(); std::vector strs; @@ -608,9 +608,9 @@ pcl::rec_3d_framework::GlobalNNCVFHRecognizer::ini std::string path = source_->getModelDescriptorDir(models->at(i), training_dir_, descr_name_); - bf::path desc_dir = path; - if (!bf::exists(desc_dir)) - bf::create_directory(desc_dir); + pcl_fs::path desc_dir = path; + if (!pcl_fs::exists(desc_dir)) + pcl_fs::create_directory(desc_dir); const std::string path_view = path + "/view_" + std::to_string(v) + ".pcd"; pcl::io::savePCDFileBinary(path_view, *processed); diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp index 3561c3036cd..1bf8388f7fe 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp @@ -20,7 +20,7 @@ pcl::rec_3d_framework::LocalRecognitionPipeline:: std::string path = source_->getModelDescriptorDir(models->at(i), training_dir_, descr_name_); - for (const auto& dir_entry : bf::directory_iterator(path)) { + for (const auto& dir_entry : pcl_fs::directory_iterator(path)) { std::string file_name = (dir_entry.path().filename()).string(); std::vector strs; @@ -150,9 +150,9 @@ pcl::rec_3d_framework::LocalRecognitionPipeline:: std::string path = source_->getModelDescriptorDir(models->at(i), training_dir_, descr_name_); - bf::path desc_dir = path; - if (!bf::exists(desc_dir)) - bf::create_directory(desc_dir); + pcl_fs::path desc_dir = path; + if (!pcl_fs::exists(desc_dir)) + pcl_fs::create_directory(desc_dir); const std::string path_view = path = "/view_" + std::to_string(v) + ".pcd"; pcl::io::savePCDFileBinary(path_view, *processed); diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h index a3c5812487e..9415c366fe8 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h @@ -1,7 +1,14 @@ #include #include + +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif #include diff --git a/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp b/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp index 53891821d11..220952347f4 100644 --- a/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp +++ b/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp @@ -22,17 +22,17 @@ #include void -getScenesInDirectory(bf::path& dir, +getScenesInDirectory(pcl_fs::path& dir, std::string& rel_path_so_far, std::vector& relative_paths) { // list models in MODEL_FILES_DIR_ and return list - for (const auto& dir_entry : bf::directory_iterator(dir)) { + for (const auto& dir_entry : pcl_fs::directory_iterator(dir)) { // check if its a directory, then get models in it - if (bf::is_directory(dir_entry)) { + if (pcl_fs::is_directory(dir_entry)) { std::string so_far = rel_path_so_far + (dir_entry.path().filename()).string() + "/"; - bf::path curr_path = dir_entry.path(); + pcl_fs::path curr_path = dir_entry.path(); getScenesInDirectory(curr_path, so_far, relative_paths); } else { @@ -86,7 +86,7 @@ recognizeAndVisualize( { // read mians scenes - bf::path ply_files_dir = scenes_dir; + pcl_fs::path ply_files_dir = scenes_dir; std::vector files; std::string start; getScenesInDirectory(ply_files_dir, start, files); @@ -223,18 +223,18 @@ recognizeAndVisualize( } void -getModelsInDirectory(bf::path& dir, +getModelsInDirectory(pcl_fs::path& dir, std::string& rel_path_so_far, std::vector& relative_paths, std::string& ext) { - for (const auto& dir_entry : bf::directory_iterator(dir)) { + for (const auto& dir_entry : pcl_fs::directory_iterator(dir)) { // check if its a directory, then get models in it - if (bf::is_directory(dir_entry)) { + if (pcl_fs::is_directory(dir_entry)) { std::string so_far = rel_path_so_far + (dir_entry.path().filename()).string() + "/"; - bf::path curr_path = dir_entry.path(); + pcl_fs::path curr_path = dir_entry.path(); getModelsInDirectory(curr_path, so_far, relative_paths, ext); } else { @@ -315,8 +315,8 @@ main(int argc, char** argv) return -1; } - bf::path models_dir_path = path; - if (!bf::exists(models_dir_path)) { + pcl_fs::path models_dir_path = path; + if (!pcl_fs::exists(models_dir_path)) { PCL_ERROR("Models dir path %s does not exist, use -models_dir [dir] option\n", path.c_str()); return -1; @@ -324,7 +324,7 @@ main(int argc, char** argv) std::vector files; std::string start; std::string ext = std::string("ply"); - bf::path dir = models_dir_path; + pcl_fs::path dir = models_dir_path; getModelsInDirectory(dir, start, files, ext); assert(files.size() == 4); diff --git a/apps/in_hand_scanner/src/offline_integration.cpp b/apps/in_hand_scanner/src/offline_integration.cpp index 853232dc7f6..626320a4959 100644 --- a/apps/in_hand_scanner/src/offline_integration.cpp +++ b/apps/in_hand_scanner/src/offline_integration.cpp @@ -45,7 +45,14 @@ #include #include + +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif #include #include @@ -186,14 +193,14 @@ pcl::ihs::OfflineIntegration::getFilesFromDirectory( const std::string& extension, std::vector& files) const { - if (path_dir.empty() || !boost::filesystem::exists(path_dir)) { + if (path_dir.empty() || !pcl_fs::exists(path_dir)) { std::cerr << "ERROR in offline_integration.cpp: Invalid path\n '" << path_dir << "'\n"; return (false); } - boost::filesystem::directory_iterator it_end; - for (boost::filesystem::directory_iterator it(path_dir); it != it_end; ++it) { + pcl_fs::directory_iterator it_end; + for (pcl_fs::directory_iterator it(path_dir); it != it_end; ++it) { if (!is_directory(it->status()) && boost::algorithm::to_upper_copy(it->path().extension().string()) == boost::algorithm::to_upper_copy(extension)) { diff --git a/apps/include/pcl/apps/face_detection/face_detection_apps_utils.h b/apps/include/pcl/apps/face_detection/face_detection_apps_utils.h index b986ea9a6c1..bce884062a0 100644 --- a/apps/include/pcl/apps/face_detection/face_detection_apps_utils.h +++ b/apps/include/pcl/apps/face_detection/face_detection_apps_utils.h @@ -7,6 +7,14 @@ #pragma once +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else +#include +namespace pcl_fs = boost::filesystem; +#endif + namespace face_detection_apps_utils { inline bool @@ -65,18 +73,18 @@ sortFiles(const std::string& file1, const std::string& file2) } inline void -getFilesInDirectory(bf::path& dir, +getFilesInDirectory(pcl_fs::path& dir, std::string& rel_path_so_far, std::vector& relative_paths, std::string& ext) { - for (const auto& dir_entry : bf::directory_iterator(dir)) { + for (const auto& dir_entry : pcl_fs::directory_iterator(dir)) { // check if its a directory, then get models in it - if (bf::is_directory(dir_entry)) { + if (pcl_fs::is_directory(dir_entry)) { std::string so_far = rel_path_so_far + (dir_entry.path().filename()).string() + "/"; - bf::path curr_path = dir_entry.path(); + pcl_fs::path curr_path = dir_entry.path(); getFilesInDirectory(curr_path, so_far, relative_paths, ext); } else { diff --git a/apps/include/pcl/apps/pcd_video_player.h b/apps/include/pcl/apps/pcd_video_player.h index ba177d66f15..657b3626e63 100644 --- a/apps/include/pcl/apps/pcd_video_player.h +++ b/apps/include/pcl/apps/pcd_video_player.h @@ -42,7 +42,13 @@ #include #include +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif #include #include @@ -100,7 +106,7 @@ class PCDVideoPlayer : public QMainWindow { QString dir_; std::vector pcd_files_; - std::vector pcd_paths_; + std::vector pcd_paths_; /** \brief The current displayed frame */ unsigned int current_frame_; diff --git a/apps/src/face_detection/filesystem_face_detection.cpp b/apps/src/face_detection/filesystem_face_detection.cpp index fcb5028b66a..58dbb329329 100644 --- a/apps/src/face_detection/filesystem_face_detection.cpp +++ b/apps/src/face_detection/filesystem_face_detection.cpp @@ -13,9 +13,13 @@ #include // clang-format on +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include - -namespace bf = boost::filesystem; +namespace pcl_fs = boost::filesystem; +#endif bool SHOW_GT = false; bool VIDEO = false; @@ -222,7 +226,7 @@ main(int argc, char** argv) // recognize all files in directory... std::string start; std::string ext = std::string("pcd"); - bf::path dir = test_directory; + pcl_fs::path dir = test_directory; std::vector files; face_detection_apps_utils::getFilesInDirectory(dir, start, files, ext); diff --git a/apps/src/openni_grab_frame.cpp b/apps/src/openni_grab_frame.cpp index fbdc4d42ebf..cc7c454c763 100644 --- a/apps/src/openni_grab_frame.cpp +++ b/apps/src/openni_grab_frame.cpp @@ -45,7 +45,13 @@ #include #include +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif #include @@ -75,7 +81,6 @@ using namespace std::chrono_literals; #endif using namespace pcl::console; -using namespace boost::filesystem; template class OpenNIGrabFrame { @@ -222,7 +227,7 @@ class OpenNIGrabFrame { bool paused, bool visualizer) { - boost::filesystem::path path(filename); + pcl_fs::path path(filename); if (filename.empty()) { dir_name_ = "."; @@ -231,7 +236,7 @@ class OpenNIGrabFrame { else { dir_name_ = path.parent_path().string(); - if (!dir_name_.empty() && !boost::filesystem::exists(path.parent_path())) { + if (!dir_name_.empty() && !pcl_fs::exists(path.parent_path())) { std::cerr << "directory \"" << path.parent_path() << "\" does not exist!\n"; exit(1); } diff --git a/apps/src/openni_grab_images.cpp b/apps/src/openni_grab_images.cpp index edb5d549694..428b083da42 100644 --- a/apps/src/openni_grab_images.cpp +++ b/apps/src/openni_grab_images.cpp @@ -44,12 +44,9 @@ #include #include -#include - #include using namespace pcl::console; -using namespace boost::filesystem; class OpenNIGrabFrame { public: diff --git a/apps/src/organized_segmentation_demo.cpp b/apps/src/organized_segmentation_demo.cpp index 480817345a4..cbf81a72728 100644 --- a/apps/src/organized_segmentation_demo.cpp +++ b/apps/src/organized_segmentation_demo.cpp @@ -15,9 +15,6 @@ #include #include -// #include // for boost::filesystem::directory_iterator -#include // for boost::signals2::connection - void displayPlanarRegions( std::vector, diff --git a/apps/src/pcd_video_player/pcd_video_player.cpp b/apps/src/pcd_video_player/pcd_video_player.cpp index aa6157e3678..66c3d4fa104 100644 --- a/apps/src/pcd_video_player/pcd_video_player.cpp +++ b/apps/src/pcd_video_player/pcd_video_player.cpp @@ -167,11 +167,10 @@ PCDVideoPlayer::selectFolderButtonPressed() QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - boost::filesystem::directory_iterator end_itr; + pcl_fs::directory_iterator end_itr; - if (boost::filesystem::is_directory(dir_.toStdString())) { - for (boost::filesystem::directory_iterator itr(dir_.toStdString()); itr != end_itr; - ++itr) { + if (pcl_fs::is_directory(dir_.toStdString())) { + for (pcl_fs::directory_iterator itr(dir_.toStdString()); itr != end_itr; ++itr) { std::string ext = itr->path().extension().string(); if (ext == ".pcd") { pcd_files_.push_back(itr->path().string()); @@ -211,7 +210,7 @@ void PCDVideoPlayer::selectFilesButtonPressed() { pcd_files_.clear(); // Clear the std::vector - pcd_paths_.clear(); // Clear the boost filesystem paths + pcd_paths_.clear(); // Clear the filesystem paths QStringList qt_pcd_files = QFileDialog::getOpenFileNames( this, "Select one or more PCD files to open", "/home", "PointClouds (*.pcd)"); diff --git a/apps/src/stereo_ground_segmentation.cpp b/apps/src/stereo_ground_segmentation.cpp index 0ef2ed02713..b2b8743b3d1 100755 --- a/apps/src/stereo_ground_segmentation.cpp +++ b/apps/src/stereo_ground_segmentation.cpp @@ -50,7 +50,13 @@ #include #include +#if (__cplusplus >= 201703L) +#include // for directory_iterator +namespace pcl_fs = std::filesystem; +#else #include // for directory_iterator +namespace pcl_fs = boost::filesystem; +#endif #include @@ -541,13 +547,13 @@ main(int argc, char** argv) // Get list of stereo files std::vector left_images; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr(argv[1]); itr != end_itr; ++itr) { + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr(argv[1]); itr != end_itr; ++itr) { left_images.push_back(itr->path().string()); } sort(left_images.begin(), left_images.end()); std::vector right_images; - for (boost::filesystem::directory_iterator itr(argv[2]); itr != end_itr; ++itr) { + for (pcl_fs::directory_iterator itr(argv[2]); itr != end_itr; ++itr) { right_images.push_back(itr->path().string()); } sort(right_images.begin(), right_images.end()); diff --git a/common/include/pcl/common/impl/file_io.hpp b/common/include/pcl/common/impl/file_io.hpp index 1c1fe9ec876..503c34d2437 100644 --- a/common/include/pcl/common/impl/file_io.hpp +++ b/common/include/pcl/common/impl/file_io.hpp @@ -39,7 +39,14 @@ #ifndef PCL_COMMON_FILE_IO_IMPL_HPP_ #define PCL_COMMON_FILE_IO_IMPL_HPP_ +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif + #include #include @@ -53,12 +60,12 @@ namespace pcl void getAllPcdFilesInDirectory(const std::string& directory, std::vector& file_names) { - boost::filesystem::path p(directory); - if(boost::filesystem::is_directory(p)) + pcl_fs::path p(directory); + if(pcl_fs::is_directory(p)) { - for(const auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(p), {})) + for(const auto& entry : boost::make_iterator_range(pcl_fs::directory_iterator(p), {})) { - if (boost::filesystem::is_regular_file(entry)) + if (pcl_fs::is_regular_file(entry)) { if (entry.path().extension() == ".pcd") file_names.emplace_back(entry.path().filename().string()); diff --git a/cuda/apps/src/kinect_planes_cuda.cpp b/cuda/apps/src/kinect_planes_cuda.cpp index c61c03364f2..9282bf68410 100644 --- a/cuda/apps/src/kinect_planes_cuda.cpp +++ b/cuda/apps/src/kinect_planes_cuda.cpp @@ -61,7 +61,13 @@ #include #include +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif #include #include @@ -273,7 +279,7 @@ class MultiRansac //bool repeat = false; //std::string path = "./pcl_logo.pcd"; - //if (path.empty() || !boost::filesystem::exists (path)) + //if (path.empty() || !pcl_fs::exists (path)) //{ // std::cerr << "did not find file" << std::endl; //} diff --git a/gpu/kinfu/tools/kinfu_app.cpp b/gpu/kinfu/tools/kinfu_app.cpp index 3ed2e31e8f9..7feb67f4dbe 100644 --- a/gpu/kinfu/tools/kinfu_app.cpp +++ b/gpu/kinfu/tools/kinfu_app.cpp @@ -43,7 +43,13 @@ #include +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif #include #include @@ -173,19 +179,18 @@ namespace pcl /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// std::vector getPcdFilesInDir(const std::string& directory) { - namespace fs = boost::filesystem; - fs::path dir(directory); + pcl_fs::path dir(directory); std::cout << "path: " << directory << std::endl; - if (directory.empty() || !fs::exists(dir) || !fs::is_directory(dir)) + if (directory.empty() || !pcl_fs::exists(dir) || !pcl_fs::is_directory(dir)) PCL_THROW_EXCEPTION (pcl::IOException, "No valid PCD directory given!\n"); std::vector result; - fs::directory_iterator pos(dir); - fs::directory_iterator end; + pcl_fs::directory_iterator pos(dir); + pcl_fs::directory_iterator end; for(; pos != end ; ++pos) - if (fs::is_regular_file(pos->status()) ) + if (pcl_fs::is_regular_file(pos->status()) ) if (pos->path().extension().string() == ".pcd") { result.push_back (pos->path ().string ()); diff --git a/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/screenshot_manager.h b/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/screenshot_manager.h index 35b0a152925..520877494ae 100644 --- a/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/screenshot_manager.h +++ b/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/screenshot_manager.h @@ -48,8 +48,14 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include -//#include +namespace pcl_fs = boost::filesystem; +#endif #include diff --git a/gpu/kinfu_large_scale/src/screenshot_manager.cpp b/gpu/kinfu_large_scale/src/screenshot_manager.cpp index 15e6a9a8dfd..755fc947130 100644 --- a/gpu/kinfu_large_scale/src/screenshot_manager.cpp +++ b/gpu/kinfu_large_scale/src/screenshot_manager.cpp @@ -48,8 +48,8 @@ namespace pcl { ScreenshotManager::ScreenshotManager() { - boost::filesystem::path p ("KinFuSnapshots"); - boost::filesystem::create_directory (p); + pcl_fs::path p ("KinFuSnapshots"); + pcl_fs::create_directory (p); screenshot_counter = 0; setCameraIntrinsics(); } diff --git a/gpu/kinfu_large_scale/tools/kinfuLS_app.cpp b/gpu/kinfu_large_scale/tools/kinfuLS_app.cpp index bc455e17ca6..b5f92881919 100644 --- a/gpu/kinfu_large_scale/tools/kinfuLS_app.cpp +++ b/gpu/kinfu_large_scale/tools/kinfuLS_app.cpp @@ -55,7 +55,13 @@ Work in progress: patch by Marco (AUG,19th 2012) #include #include +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif #include #include @@ -123,19 +129,18 @@ namespace pcl std::vector getPcdFilesInDir(const std::string& directory) { - namespace fs = boost::filesystem; - fs::path dir(directory); + pcl_fs::path dir(directory); std::cout << "path: " << directory << std::endl; - if (directory.empty() || !fs::exists(dir) || !fs::is_directory(dir)) + if (directory.empty() || !pcl_fs::exists(dir) || !pcl_fs::is_directory(dir)) PCL_THROW_EXCEPTION (pcl::IOException, "No valid PCD directory given!\n"); std::vector result; - fs::directory_iterator pos(dir); - fs::directory_iterator end; + pcl_fs::directory_iterator pos(dir); + pcl_fs::directory_iterator end; for(; pos != end ; ++pos) - if (fs::is_regular_file(pos->status()) ) + if (pcl_fs::is_regular_file(pos->status()) ) if (pos->path().extension().string() == ".pcd") { result.push_back (pos->path ().string ()); diff --git a/gpu/kinfu_large_scale/tools/standalone_texture_mapping.cpp b/gpu/kinfu_large_scale/tools/standalone_texture_mapping.cpp index 6803bba3e3d..a7c58e413d7 100644 --- a/gpu/kinfu_large_scale/tools/standalone_texture_mapping.cpp +++ b/gpu/kinfu_large_scale/tools/standalone_texture_mapping.cpp @@ -36,8 +36,13 @@ * Author: Raphael Favier, Technical University Eindhoven, (r.mysurname tue.nl) */ - +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif #include #include @@ -432,11 +437,11 @@ main (int argc, char** argv) PCL_INFO ("\nLoading textures and camera poses...\n"); pcl::texture_mapping::CameraVector my_cams; - const boost::filesystem::path base_dir ("."); + const pcl_fs::path base_dir ("."); std::string extension (".txt"); - for (boost::filesystem::directory_iterator it (base_dir); it != boost::filesystem::directory_iterator (); ++it) + for (pcl_fs::directory_iterator it (base_dir); it != pcl_fs::directory_iterator (); ++it) { - if(boost::filesystem::is_regular_file (it->status ()) && it->path ().extension ().string () == extension) + if(pcl_fs::is_regular_file (it->status ()) && it->path ().extension ().string () == extension) { pcl::TextureMapping::Camera cam; readCamPoseFile(it->path ().string (), cam); diff --git a/gpu/people/tools/people_app.cpp b/gpu/people/tools/people_app.cpp index 91308e4e263..816188ff13a 100644 --- a/gpu/people/tools/people_app.cpp +++ b/gpu/people/tools/people_app.cpp @@ -54,7 +54,14 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif #include #include @@ -66,18 +73,17 @@ using namespace std::chrono_literals; std::vector getPcdFilesInDir(const std::string& directory) { - namespace fs = boost::filesystem; - fs::path dir(directory); + pcl_fs::path dir(directory); - if (!fs::exists(dir) || !fs::is_directory(dir)) + if (!pcl_fs::exists(dir) || !pcl_fs::is_directory(dir)) PCL_THROW_EXCEPTION(pcl::IOException, "Wrong PCD directory"); std::vector result; - fs::directory_iterator pos(dir); - fs::directory_iterator end; + pcl_fs::directory_iterator pos(dir); + pcl_fs::directory_iterator end; for(; pos != end ; ++pos) - if (fs::is_regular_file(pos->status()) ) + if (pcl_fs::is_regular_file(pos->status()) ) if (pos->path().extension().string() == ".pcd") result.push_back(pos->path().string()); diff --git a/io/include/pcl/io/impl/auto_io.hpp b/io/include/pcl/io/impl/auto_io.hpp index c45f8860c5c..748dd0bc408 100644 --- a/io/include/pcl/io/impl/auto_io.hpp +++ b/io/include/pcl/io/impl/auto_io.hpp @@ -44,7 +44,14 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for path +namespace pcl_fs = std::filesystem; +#else #include // for path +namespace pcl_fs = boost::filesystem; +#endif namespace pcl { @@ -53,7 +60,7 @@ namespace pcl template int load (const std::string& file_name, pcl::PointCloud& cloud) { - boost::filesystem::path p (file_name.c_str ()); + pcl_fs::path p (file_name.c_str ()); std::string extension = p.extension ().string (); int result = -1; if (extension == ".pcd") @@ -75,7 +82,7 @@ namespace pcl template int save (const std::string& file_name, const pcl::PointCloud& cloud) { - boost::filesystem::path p (file_name.c_str ()); + pcl_fs::path p (file_name.c_str ()); std::string extension = p.extension ().string (); int result = -1; if (extension == ".pcd") @@ -94,4 +101,4 @@ namespace pcl } } -#endif //PCL_IO_AUTO_IO_IMPL_H_ \ No newline at end of file +#endif //PCL_IO_AUTO_IO_IMPL_H_ diff --git a/io/src/ascii_io.cpp b/io/src/ascii_io.cpp index 486ef5aba18..1b52d89a168 100644 --- a/io/src/ascii_io.cpp +++ b/io/src/ascii_io.cpp @@ -40,7 +40,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif + #include // for lexical_cast #include // for split #include @@ -88,9 +96,9 @@ pcl::ASCIIReader::readHeader (const std::string& file_name, { pcl::utils::ignore(offset); //offset is not used for ascii file implementation - boost::filesystem::path fpath = file_name; + pcl_fs::path fpath = file_name; - if (!boost::filesystem::exists (fpath)) + if (!pcl_fs::exists (fpath)) { PCL_ERROR ("[%s] File %s does not exist.\n", name_.c_str (), file_name.c_str ()); return (-1); diff --git a/io/src/auto_io.cpp b/io/src/auto_io.cpp index 86a206bef82..e5c09e05549 100644 --- a/io/src/auto_io.cpp +++ b/io/src/auto_io.cpp @@ -46,7 +46,7 @@ int pcl::io::load (const std::string& file_name, pcl::PCLPointCloud2& blob) { - boost::filesystem::path p (file_name.c_str ()); + pcl_fs::path p (file_name.c_str ()); std::string extension = p.extension ().string (); int result = -1; if (extension == ".pcd") @@ -68,7 +68,7 @@ pcl::io::load (const std::string& file_name, pcl::PCLPointCloud2& blob) int pcl::io::load (const std::string& file_name, pcl::PolygonMesh& mesh) { - boost::filesystem::path p (file_name.c_str ()); + pcl_fs::path p (file_name.c_str ()); std::string extension = p.extension ().string (); int result = -1; if (extension == ".ply") @@ -88,7 +88,7 @@ pcl::io::load (const std::string& file_name, pcl::PolygonMesh& mesh) int pcl::io::load (const std::string& file_name, pcl::TextureMesh& mesh) { - boost::filesystem::path p (file_name.c_str ()); + pcl_fs::path p (file_name.c_str ()); std::string extension = p.extension ().string (); int result = -1; if (extension == ".obj") @@ -104,7 +104,7 @@ pcl::io::load (const std::string& file_name, pcl::TextureMesh& mesh) int pcl::io::save (const std::string& file_name, const pcl::PCLPointCloud2& blob, unsigned precision) { - boost::filesystem::path p (file_name.c_str ()); + pcl_fs::path p (file_name.c_str ()); std::string extension = p.extension ().string (); int result = -1; if (extension == ".pcd") @@ -134,7 +134,7 @@ pcl::io::save (const std::string& file_name, const pcl::PCLPointCloud2& blob, un int pcl::io::save (const std::string &file_name, const pcl::TextureMesh &tex_mesh, unsigned precision) { - boost::filesystem::path p (file_name.c_str ()); + pcl_fs::path p (file_name.c_str ()); std::string extension = p.extension ().string (); int result = -1; if (extension == ".obj") @@ -150,7 +150,7 @@ pcl::io::save (const std::string &file_name, const pcl::TextureMesh &tex_mesh, u int pcl::io::save (const std::string &file_name, const pcl::PolygonMesh &poly_mesh, unsigned precision) { - boost::filesystem::path p (file_name.c_str ()); + pcl_fs::path p (file_name.c_str ()); std::string extension = p.extension ().string (); int result = -1; if (extension == ".ply") diff --git a/io/src/image_grabber.cpp b/io/src/image_grabber.cpp index de32f1f20de..e436dd6a8c6 100644 --- a/io/src/image_grabber.cpp +++ b/io/src/image_grabber.cpp @@ -42,7 +42,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for exists, basename, is_directory, ... +namespace pcl_fs = std::filesystem; +#else #include // for exists, basename, is_directory, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy #ifdef PCL_BUILT_WITH_VTK @@ -255,7 +263,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::trigger () void pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string &dir) { - if (!boost::filesystem::exists (dir) || !boost::filesystem::is_directory (dir)) + if (!pcl_fs::exists (dir) || !pcl_fs::is_directory (dir)) { PCL_ERROR ("[pcl::ImageGrabber::loadDepthAndRGBFiles] Error: attempted to instantiate a pcl::ImageGrabber from a path which" " is not a directory: %s\n", dir.c_str ()); @@ -264,13 +272,13 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string std::string pathname; std::string extension; std::string basename; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (dir); itr != end_itr; ++itr) { extension = boost::algorithm::to_upper_copy (itr->path ().extension ().string ()); pathname = itr->path ().string (); basename = itr->path ().stem ().string (); - if (!boost::filesystem::is_directory (itr->status ()) + if (!pcl_fs::is_directory (itr->status ()) && isValidExtension (extension)) { if (basename.find ("rgb") < std::string::npos) @@ -291,13 +299,13 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string void pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string &depth_dir, const std::string &rgb_dir) { - if (!boost::filesystem::exists (depth_dir) || !boost::filesystem::is_directory (depth_dir)) + if (!pcl_fs::exists (depth_dir) || !pcl_fs::is_directory (depth_dir)) { PCL_ERROR ("[pcl::ImageGrabber::loadDepthAndRGBFiles] Error: attempted to instantiate a pcl::ImageGrabber from a path which" " is not a directory: %s\n", depth_dir.c_str ()); return; } - if (!boost::filesystem::exists (rgb_dir) || !boost::filesystem::is_directory (rgb_dir)) + if (!pcl_fs::exists (rgb_dir) || !pcl_fs::is_directory (rgb_dir)) { PCL_ERROR ("[pcl::ImageGrabber::loadDepthAndRGBFiles] Error: attempted to instantiate a pcl::ImageGrabber from a path which" " is not a directory: %s\n", rgb_dir.c_str ()); @@ -306,14 +314,14 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string std::string pathname; std::string extension; std::string basename; - boost::filesystem::directory_iterator end_itr; + pcl_fs::directory_iterator end_itr; // First iterate over depth images - for (boost::filesystem::directory_iterator itr (depth_dir); itr != end_itr; ++itr) + for (pcl_fs::directory_iterator itr (depth_dir); itr != end_itr; ++itr) { extension = boost::algorithm::to_upper_copy (itr->path ().extension ().string ()); pathname = itr->path ().string (); basename = itr->path ().stem ().string (); - if (!boost::filesystem::is_directory (itr->status ()) + if (!pcl_fs::is_directory (itr->status ()) && isValidExtension (extension)) { if (basename.find ("depth") < std::string::npos) @@ -323,12 +331,12 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string } } // Then iterate over RGB images - for (boost::filesystem::directory_iterator itr (rgb_dir); itr != end_itr; ++itr) + for (pcl_fs::directory_iterator itr (rgb_dir); itr != end_itr; ++itr) { extension = boost::algorithm::to_upper_copy (itr->path ().extension ().string ()); pathname = itr->path ().string (); basename = itr->path ().stem ().string (); - if (!boost::filesystem::is_directory (itr->status ()) + if (!pcl_fs::is_directory (itr->status ()) && isValidExtension (extension)) { if (basename.find ("rgb") < std::string::npos) @@ -354,7 +362,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string void pcl::ImageGrabberBase::ImageGrabberImpl::loadPCLZFFiles (const std::string &dir) { - if (!boost::filesystem::exists (dir) || !boost::filesystem::is_directory (dir)) + if (!pcl_fs::exists (dir) || !pcl_fs::is_directory (dir)) { PCL_ERROR ("[pcl::ImageGrabber::loadPCLZFFiles] Error: attempted to instantiate a pcl::ImageGrabber from a path which" " is not a directory: %s\n", dir.c_str ()); @@ -363,13 +371,13 @@ pcl::ImageGrabberBase::ImageGrabberImpl::loadPCLZFFiles (const std::string &dir) std::string pathname; std::string extension; std::string basename; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (dir); itr != end_itr; ++itr) { extension = boost::algorithm::to_upper_copy (itr->path ().extension ().string ()); pathname = itr->path ().string (); basename = itr->path ().stem ().string (); - if (!boost::filesystem::is_directory (itr->status ()) + if (!pcl_fs::is_directory (itr->status ()) && isValidExtension (extension)) { if (basename.find ("rgb") < std::string::npos) @@ -429,7 +437,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getTimestampFromFilepath ( { // For now, we assume the file is of the form frame_[22-char POSIX timestamp]_* char timestamp_str[256]; - int result = std::sscanf (boost::filesystem::path (filepath).stem ().string ().c_str (), + int result = std::sscanf (pcl_fs::path (filepath).stem ().string ().c_str (), "frame_%22s_%*s", timestamp_str); if (result > 0) @@ -971,7 +979,7 @@ pcl::ImageGrabberBase::getCurrentDepthFileName () const pathname = impl_->depth_pclzf_files_[impl_->cur_frame_]; else pathname = impl_->depth_image_files_[impl_->cur_frame_]; - std::string basename = boost::filesystem::path (pathname).stem ().string (); + std::string basename = pcl_fs::path (pathname).stem ().string (); return (basename); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -983,7 +991,7 @@ pcl::ImageGrabberBase::getPrevDepthFileName () const pathname = impl_->depth_pclzf_files_[impl_->cur_frame_-1]; else pathname = impl_->depth_image_files_[impl_->cur_frame_-1]; - std::string basename = boost::filesystem::path (pathname).stem ().string (); + std::string basename = pcl_fs::path (pathname).stem ().string (); return (basename); } @@ -996,7 +1004,7 @@ pcl::ImageGrabberBase::getDepthFileNameAtIndex (std::size_t idx) const pathname = impl_->depth_pclzf_files_[idx]; else pathname = impl_->depth_image_files_[idx]; - std::string basename = boost::filesystem::path (pathname).stem ().string (); + std::string basename = pcl_fs::path (pathname).stem ().string (); return (basename); } diff --git a/io/src/lzf_image_io.cpp b/io/src/lzf_image_io.cpp index ab59a6eeb11..e6104748935 100644 --- a/io/src/lzf_image_io.cpp +++ b/io/src/lzf_image_io.cpp @@ -40,7 +40,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif + #include #include @@ -357,7 +365,7 @@ pcl::io::LZFImageReader::loadImageBlob (const std::string &filename, std::vector &data, std::uint32_t &uncompressed_size) { - if (filename.empty() || !boost::filesystem::exists (filename)) + if (filename.empty() || !pcl_fs::exists (filename)) { PCL_ERROR ("[pcl::io::LZFImageReader::loadImage] Could not find file '%s'.\n", filename.c_str ()); return (false); diff --git a/io/src/obj_io.cpp b/io/src/obj_io.cpp index 4f20368d29c..e77d350fbf6 100644 --- a/io/src/obj_io.cpp +++ b/io/src/obj_io.cpp @@ -42,7 +42,15 @@ #include #include // for lexical_cast + +#if (__cplusplus >= 201703L) +#include // for exists +namespace pcl_fs = std::filesystem; +#else #include // for exists +namespace pcl_fs = boost::filesystem; +#endif + #include // for trim pcl::MTLReader::MTLReader () @@ -152,7 +160,7 @@ pcl::MTLReader::read (const std::string& obj_file_name, return (-1); } - if (!boost::filesystem::exists (obj_file_name)) + if (!pcl_fs::exists (obj_file_name)) { PCL_ERROR ("[pcl::MTLReader::read] Could not find file '%s'!\n", obj_file_name.c_str ()); @@ -165,8 +173,8 @@ pcl::MTLReader::read (const std::string& obj_file_name, return (-1); } - boost::filesystem::path obj_file_path (obj_file_name.c_str ()); - boost::filesystem::path mtl_file_path = obj_file_path.parent_path (); + pcl_fs::path obj_file_path (obj_file_name.c_str ()); + pcl_fs::path mtl_file_path = obj_file_path.parent_path (); mtl_file_path /= mtl_file_name; return (read (mtl_file_path.string ())); } @@ -201,7 +209,7 @@ pcl::MTLReader::read (const std::string& mtl_file_path) std::string line; std::vector st; - boost::filesystem::path parent_path = mtl_file_path.c_str (); + pcl_fs::path parent_path = mtl_file_path.c_str (); parent_path = parent_path.parent_path (); try @@ -322,7 +330,7 @@ pcl::MTLReader::read (const std::string& mtl_file_path) if (st[0] == "map_Kd") { - boost::filesystem::path full_path = parent_path; + pcl_fs::path full_path = parent_path; full_path/= st.back ().c_str (); materials_.back ().tex_file = full_path.string (); continue; diff --git a/io/src/openni2_grabber.cpp b/io/src/openni2_grabber.cpp index 2ce1b603620..68dce0cf1d3 100644 --- a/io/src/openni2_grabber.cpp +++ b/io/src/openni2_grabber.cpp @@ -50,7 +50,14 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for exists +namespace pcl_fs = std::filesystem; +#else #include // for exists +namespace pcl_fs = boost::filesystem; +#endif using namespace pcl::io::openni2; @@ -292,7 +299,7 @@ pcl::io::OpenNI2Grabber::setupDevice (const std::string& device_id, const Mode& try { - if (boost::filesystem::exists (device_id)) + if (pcl_fs::exists (device_id)) { device_ = deviceManager->getFileDevice (device_id); // Treat as file path } diff --git a/io/src/openni_grabber.cpp b/io/src/openni_grabber.cpp index 04d43c765d5..4f577c4a523 100644 --- a/io/src/openni_grabber.cpp +++ b/io/src/openni_grabber.cpp @@ -47,7 +47,14 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for exists +namespace pcl_fs = std::filesystem; +#else #include // for exists +namespace pcl_fs = boost::filesystem; +#endif using namespace std::chrono_literals; @@ -303,7 +310,7 @@ pcl::OpenNIGrabber::setupDevice (const std::string& device_id, const Mode& depth try { - if (boost::filesystem::exists (device_id)) + if (pcl_fs::exists (device_id)) { device_ = driver.createVirtualDevice (device_id, true, true); } diff --git a/io/src/pcd_io.cpp b/io/src/pcd_io.cpp index 0407cc9587c..0bcd3a40fdf 100644 --- a/io/src/pcd_io.cpp +++ b/io/src/pcd_io.cpp @@ -51,7 +51,14 @@ #include #include + +#if (__cplusplus >= 201703L) +#include // for permissions +namespace pcl_fs = std::filesystem; +#else #include // for permissions +namespace pcl_fs = boost::filesystem; +#endif /////////////////////////////////////////////////////////////////////////////////////////// void @@ -69,10 +76,13 @@ pcl::PCDWriter::setLockingPermissions (const std::string &file_name, else PCL_DEBUG ("[pcl::PCDWriter::setLockingPermissions] File %s could not be locked!\n", file_name.c_str ()); - namespace fs = boost::filesystem; try { - fs::permissions (fs::path (file_name), fs::add_perms | fs::set_gid_on_exe); +#if (__cplusplus >= 201703L) + pcl_fs::permissions (pcl_fs::path (file_name), pcl_fs::perms::set_gid, pcl_fs::perm_options::add); +#else + pcl_fs::permissions (pcl_fs::path (file_name), pcl_fs::add_perms | pcl_fs::set_gid_on_exe); +#endif } catch (const std::exception &e) { @@ -90,10 +100,13 @@ pcl::PCDWriter::resetLockingPermissions (const std::string &file_name, pcl::utils::ignore(file_name, lock); #ifndef _WIN32 #ifndef NO_MANDATORY_LOCKING - namespace fs = boost::filesystem; try { - fs::permissions (fs::path (file_name), fs::remove_perms | fs::set_gid_on_exe); +#if (__cplusplus >= 201703L) + pcl_fs::permissions (pcl_fs::path (file_name), pcl_fs::perms::set_gid, pcl_fs::perm_options::remove); +#else + pcl_fs::permissions (pcl_fs::path (file_name), pcl_fs::remove_perms | pcl_fs::set_gid_on_exe); +#endif } catch (const std::exception &e) { @@ -677,7 +690,7 @@ pcl::PCDReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud, return (-1); } - if (!boost::filesystem::exists (file_name)) + if (!pcl_fs::exists (file_name)) { PCL_ERROR ("[pcl::PCDReader::read] Could not find file '%s'.\n", file_name.c_str ()); return (-1); diff --git a/io/src/ply_io.cpp b/io/src/ply_io.cpp index aaedca8f39d..9197eb2f53f 100644 --- a/io/src/ply_io.cpp +++ b/io/src/ply_io.cpp @@ -46,12 +46,17 @@ #include #include +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else // https://www.boost.org/doc/libs/1_70_0/libs/filesystem/doc/index.htm#Coding-guidelines #define BOOST_FILESYSTEM_NO_DEPRECATED #include -#include // for split +namespace pcl_fs = boost::filesystem; +#endif -namespace fs = boost::filesystem; +#include // for split std::tuple, std::function > pcl::PLYReader::elementDefinitionCallback (const std::string& element_name, std::size_t count) @@ -582,7 +587,7 @@ pcl::PLYReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud, int data_type; unsigned int data_idx; - if (!fs::exists (file_name)) + if (!pcl_fs::exists (file_name)) { PCL_ERROR ("[pcl::PLYReader::read] File (%s) not found!\n",file_name.c_str ()); return (-1); @@ -682,7 +687,7 @@ pcl::PLYReader::read (const std::string &file_name, pcl::PolygonMesh &mesh, unsigned int data_idx; polygons_ = &(mesh.polygons); - if (!fs::exists (file_name)) + if (!pcl_fs::exists (file_name)) { PCL_ERROR ("[pcl::PLYReader::read] File (%s) not found!\n",file_name.c_str ()); return (-1); diff --git a/test/io/test_grabbers.cpp b/test/io/test_grabbers.cpp index 09185f9f8d2..81e3e4fb670 100644 --- a/test/io/test_grabbers.cpp +++ b/test/io/test_grabbers.cpp @@ -7,7 +7,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for directory_iterator, extension +namespace pcl_fs = std::filesystem; +#else #include // for directory_iterator, extension +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy using namespace std::chrono_literals; @@ -519,8 +527,8 @@ int pclzf_dir_ = grabber_sequences + "/pclzf"; pcd_dir_ = grabber_sequences + "/pcd"; // Get pcd files - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (pcd_dir_); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (pcd_dir_); itr != end_itr; ++itr) { if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) { diff --git a/tools/converter.cpp b/tools/converter.cpp index dd155ec41c9..68deafdcd95 100644 --- a/tools/converter.cpp +++ b/tools/converter.cpp @@ -52,7 +52,14 @@ #include #include // for pcl::make_shared +#if (__cplusplus >= 201703L) +#include // for std::filesystem::path +namespace pcl_fs = std::filesystem; +#else #include // for boost::filesystem::path +namespace pcl_fs = boost::filesystem; +#endif + #include // for boost::algorithm::ends_with #define ASCII 0 @@ -103,7 +110,7 @@ savePointCloud (const pcl::PCLPointCloud2::Ptr& input, std::string output_file, int output_type) { - if (boost::filesystem::path (output_file).extension () == ".pcd") + if (pcl_fs::path (output_file).extension () == ".pcd") { //TODO Support precision, origin, orientation pcl::PCDWriter w; @@ -126,7 +133,7 @@ savePointCloud (const pcl::PCLPointCloud2::Ptr& input, return (false); } } - else if (boost::filesystem::path (output_file).extension () == ".stl") + else if (pcl_fs::path (output_file).extension () == ".stl") { PCL_ERROR ("STL file format does not support point clouds! Aborting.\n"); return (false); @@ -156,7 +163,7 @@ saveMesh (pcl::PolygonMesh& input, std::string output_file, int output_type) { - if (boost::filesystem::path (output_file).extension () == ".obj") + if (pcl_fs::path (output_file).extension () == ".obj") { if (output_type == BINARY || output_type == BINARY_COMPRESSED) PCL_WARN ("OBJ file format only supports ASCII.\n"); @@ -167,7 +174,7 @@ saveMesh (pcl::PolygonMesh& input, if (pcl::io::saveOBJFile (output_file, input) != 0) return (false); } - else if (boost::filesystem::path (output_file).extension () == ".pcd") + else if (pcl_fs::path (output_file).extension () == ".pcd") { if (!input.polygons.empty ()) PCL_WARN ("PCD file format does not support meshes! Only points be saved.\n"); @@ -180,7 +187,7 @@ saveMesh (pcl::PolygonMesh& input, if (output_type == BINARY_COMPRESSED) PCL_WARN ("PLY, STL and VTK file formats only supports ASCII and binary output file types.\n"); - if (input.polygons.empty() && boost::filesystem::path (output_file).extension () == ".stl") + if (input.polygons.empty() && pcl_fs::path (output_file).extension () == ".stl") { PCL_ERROR ("STL file format does not support point clouds! Aborting.\n"); return (false); @@ -263,7 +270,7 @@ main (int argc, // Try to load as mesh pcl::PolygonMesh mesh; - if (boost::filesystem::path (argv[file_args[0]]).extension () != ".pcd" && + if (pcl_fs::path (argv[file_args[0]]).extension () != ".pcd" && pcl::io::loadPolygonFile (argv[file_args[0]], mesh) != 0) { PCL_INFO ("Loaded a mesh with %d points (total size is %d) and the following channels:\n%s\n", @@ -275,7 +282,7 @@ main (int argc, if (!saveMesh (mesh, argv[file_args[1]], output_type)) return (-1); } - else if (boost::filesystem::path (argv[file_args[0]]).extension () == ".stl") + else if (pcl_fs::path (argv[file_args[0]]).extension () == ".stl") { PCL_ERROR ("Unable to load %s.\n", argv[file_args[0]]); return (-1); @@ -283,7 +290,7 @@ main (int argc, else { // PCD, OBJ, PLY or VTK - if (boost::filesystem::path (argv[file_args[0]]).extension () != ".pcd") + if (pcl_fs::path (argv[file_args[0]]).extension () != ".pcd") PCL_WARN ("Could not load %s as a mesh, trying as a point cloud instead.\n", argv[file_args[0]]); //Eigen::Vector4f origin; // TODO: Support origin/orientation diff --git a/tools/fast_bilateral_filter.cpp b/tools/fast_bilateral_filter.cpp index ff9d49544a3..3c9a6ca0aa1 100644 --- a/tools/fast_bilateral_filter.cpp +++ b/tools/fast_bilateral_filter.cpp @@ -41,7 +41,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for path, exists, ... +namespace pcl_fs = std::filesystem; +#else #include // for path, exists, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy using namespace pcl; @@ -131,7 +139,7 @@ batchProcess (const std::vector &pcd_files, std::string &output_dir compute (cloud, output, sigma_s, sigma_r); // Prepare output file name - std::string filename = boost::filesystem::path(pcd_files[i]).filename().string(); + std::string filename = pcl_fs::path(pcd_files[i]).filename().string(); // Save into the second file const std::string filepath = output_dir + '/' + filename; @@ -203,11 +211,11 @@ main (int argc, char** argv) } else { - if (!input_dir.empty() && boost::filesystem::exists (input_dir)) + if (!input_dir.empty() && pcl_fs::exists (input_dir)) { std::vector pcd_files; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (input_dir); itr != end_itr; ++itr) { // Only add PCD files if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) diff --git a/tools/grid_min.cpp b/tools/grid_min.cpp index 1a5c2fa913a..d3bf263b48b 100644 --- a/tools/grid_min.cpp +++ b/tools/grid_min.cpp @@ -44,7 +44,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for path, exists, ... +namespace pcl_fs = std::filesystem; +#else #include // for path, exists, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy using namespace pcl; @@ -129,7 +137,7 @@ batchProcess (const std::vector &pcd_files, std::string &output_dir compute (cloud, output, resolution); // Prepare output file name - std::string filename = boost::filesystem::path(pcd_file).filename().string(); + std::string filename = pcl_fs::path(pcd_file).filename().string(); // Save into the second file const std::string filepath = output_dir + '/' + filename; @@ -195,11 +203,11 @@ main (int argc, char** argv) } else { - if (!input_dir.empty() && boost::filesystem::exists (input_dir)) + if (!input_dir.empty() && pcl_fs::exists (input_dir)) { std::vector pcd_files; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (input_dir); itr != end_itr; ++itr) { // Only add PCD files if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) diff --git a/tools/image_grabber_saver.cpp b/tools/image_grabber_saver.cpp index 1dab5d9230d..34af68249b1 100644 --- a/tools/image_grabber_saver.cpp +++ b/tools/image_grabber_saver.cpp @@ -40,7 +40,14 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for exists +namespace pcl_fs = std::filesystem; +#else #include // for exists +namespace pcl_fs = boost::filesystem; +#endif using pcl::console::print_error; using pcl::console::print_info; @@ -108,7 +115,7 @@ main (int argc, char** argv) pcl::console::parse_argument (argc, argv, "-out_dir", out_folder); - if (out_folder.empty() || !boost::filesystem::exists (out_folder)) + if (out_folder.empty() || !pcl_fs::exists (out_folder)) { PCL_INFO("No correct directory was given with the -out_dir flag. Setting to current dir\n"); out_folder = "./"; @@ -116,7 +123,7 @@ main (int argc, char** argv) else PCL_INFO("Using %s as output dir", out_folder.c_str()); - if (!rgb_path.empty() && !depth_path.empty() && boost::filesystem::exists (rgb_path) && boost::filesystem::exists (depth_path)) + if (!rgb_path.empty() && !depth_path.empty() && pcl_fs::exists (rgb_path) && pcl_fs::exists (depth_path)) { grabber.reset (new pcl::ImageGrabber (depth_path, rgb_path, frames_per_second, false)); } diff --git a/tools/image_grabber_viewer.cpp b/tools/image_grabber_viewer.cpp index 4cf45843fe1..19b365c3a0e 100644 --- a/tools/image_grabber_viewer.cpp +++ b/tools/image_grabber_viewer.cpp @@ -45,7 +45,14 @@ #include #include + +#if (__cplusplus >= 201703L) +#include // for exists +namespace pcl_fs = std::filesystem; +#else #include // for exists +namespace pcl_fs = boost::filesystem; +#endif using namespace std::chrono_literals; using pcl::console::print_error; @@ -197,7 +204,7 @@ main (int argc, char** argv) std::string path; pcl::console::parse_argument (argc, argv, "-dir", path); std::cout << "path: " << path << std::endl; - if (!path.empty() && boost::filesystem::exists (path)) + if (!path.empty() && pcl_fs::exists (path)) { grabber.reset (new pcl::ImageGrabber (path, frames_per_second, repeat, use_pclzf)); } diff --git a/tools/local_max.cpp b/tools/local_max.cpp index 665aee3759c..18806a8d035 100644 --- a/tools/local_max.cpp +++ b/tools/local_max.cpp @@ -44,7 +44,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for path, exists, ... +namespace pcl_fs = std::filesystem; +#else #include // for path, exists, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy using namespace pcl; @@ -130,7 +138,7 @@ batchProcess (const std::vector &pcd_files, std::string &output_dir compute (cloud, output, radius); // Prepare output file name - std::string filename = boost::filesystem::path(pcd_file).filename().string(); + std::string filename = pcl_fs::path(pcd_file).filename().string(); // Save into the second file const std::string filepath = output_dir + '/' + filename; @@ -196,11 +204,11 @@ main (int argc, char** argv) } else { - if (!input_dir.empty() && boost::filesystem::exists (input_dir)) + if (!input_dir.empty() && pcl_fs::exists (input_dir)) { std::vector pcd_files; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (input_dir); itr != end_itr; ++itr) { // Only add PCD files if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) diff --git a/tools/morph.cpp b/tools/morph.cpp index 7c33cdbd2fa..0f37f006d59 100644 --- a/tools/morph.cpp +++ b/tools/morph.cpp @@ -44,7 +44,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for path, exists, ... +namespace pcl_fs = std::filesystem; +#else #include // for path, exists, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy using namespace pcl; @@ -151,7 +159,7 @@ batchProcess (const std::vector &pcd_files, std::string &output_dir compute (cloud, output, resolution, method); // Prepare output file name - std::string filename = boost::filesystem::path(pcd_file).filename().string(); + std::string filename = pcl_fs::path(pcd_file).filename().string(); // Save into the second file const std::string filepath = output_dir + '/' + filename; @@ -219,11 +227,11 @@ main (int argc, char** argv) } else { - if (!input_dir.empty() && boost::filesystem::exists (input_dir)) + if (!input_dir.empty() && pcl_fs::exists (input_dir)) { std::vector pcd_files; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (input_dir); itr != end_itr; ++itr) { // Only add PCD files if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) diff --git a/tools/normal_estimation.cpp b/tools/normal_estimation.cpp index 149427c3d68..61aae380223 100644 --- a/tools/normal_estimation.cpp +++ b/tools/normal_estimation.cpp @@ -45,7 +45,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for path, exists, ... +namespace pcl_fs = std::filesystem; +#else #include // for path, exists, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy using namespace pcl; @@ -150,7 +158,7 @@ batchProcess (const std::vector &pcd_files, std::string &output_dir compute (cloud, output, k, radius); // Prepare output file name - std::string filename = boost::filesystem::path(pcd_files[i]).filename().string(); + std::string filename = pcl_fs::path(pcd_files[i]).filename().string(); // Save into the second file const std::string filepath = output_dir + '/' + filename; @@ -222,11 +230,11 @@ main (int argc, char** argv) } else { - if (!input_dir.empty() && boost::filesystem::exists (input_dir)) + if (!input_dir.empty() && pcl_fs::exists (input_dir)) { std::vector pcd_files; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (input_dir); itr != end_itr; ++itr) { // Only add PCD files if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) diff --git a/tools/passthrough_filter.cpp b/tools/passthrough_filter.cpp index f79a87f0d63..7a23172df57 100644 --- a/tools/passthrough_filter.cpp +++ b/tools/passthrough_filter.cpp @@ -42,7 +42,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for path, exists, ... +namespace pcl_fs = std::filesystem; +#else #include // for path, exists, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy using namespace pcl; @@ -138,7 +146,7 @@ batchProcess (const std::vector &pcd_files, std::string &output_dir compute (cloud, output, field_name, min, max, inside, keep_organized); // Prepare output file name - std::string filename = boost::filesystem::path(pcd_file).filename().string(); + std::string filename = pcl_fs::path(pcd_file).filename().string(); // Save into the second file const std::string filepath = output_dir + '/' + filename; @@ -211,11 +219,11 @@ main (int argc, char** argv) } else { - if (!input_dir.empty() && boost::filesystem::exists (input_dir)) + if (!input_dir.empty() && pcl_fs::exists (input_dir)) { std::vector pcd_files; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (input_dir); itr != end_itr; ++itr) { // Only add PCD files if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) diff --git a/tools/pcd_grabber_viewer.cpp b/tools/pcd_grabber_viewer.cpp index b8216c3a82a..f68761edb9e 100644 --- a/tools/pcd_grabber_viewer.cpp +++ b/tools/pcd_grabber_viewer.cpp @@ -41,7 +41,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for exists, extension, ... +namespace pcl_fs = std::filesystem; +#else #include // for exists, extension, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy #include #include @@ -179,7 +187,7 @@ main (int argc, char** argv) std::string path; pcl::console::parse_argument (argc, argv, "-file", path); std::cout << "path: " << path << std::endl; - if (!path.empty() && boost::filesystem::exists (path)) + if (!path.empty() && pcl_fs::exists (path)) { grabber.reset (new pcl::PCDGrabber (path, frames_per_second, repeat)); } @@ -188,10 +196,10 @@ main (int argc, char** argv) std::vector pcd_files; pcl::console::parse_argument (argc, argv, "-dir", path); std::cout << "path: " << path << std::endl; - if (!path.empty() && boost::filesystem::exists (path)) + if (!path.empty() && pcl_fs::exists (path)) { - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (path); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (path); itr != end_itr; ++itr) { if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) { diff --git a/tools/progressive_morphological_filter.cpp b/tools/progressive_morphological_filter.cpp index 943d5657c9d..95fc9327eda 100644 --- a/tools/progressive_morphological_filter.cpp +++ b/tools/progressive_morphological_filter.cpp @@ -46,7 +46,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for path, exists, ... +namespace pcl_fs = std::filesystem; +#else #include // for path, exists, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy using namespace pcl; @@ -188,7 +196,7 @@ batchProcess (const std::vector &pcd_files, std::string &output_dir compute (cloud, output, max_window_size, slope, max_distance, initial_distance, cell_size, base, exponential, approximate); // Prepare output file name - std::string filename = boost::filesystem::path(pcd_file).filename().string(); + std::string filename = pcl_fs::path(pcd_file).filename().string(); // Save into the second file const std::string filepath = output_dir + '/' + filename; @@ -297,11 +305,11 @@ main (int argc, char** argv) } else { - if (!input_dir.empty() && boost::filesystem::exists (input_dir)) + if (!input_dir.empty() && pcl_fs::exists (input_dir)) { std::vector pcd_files; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (input_dir); itr != end_itr; ++itr) { // Only add PCD files if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) diff --git a/tools/radius_filter.cpp b/tools/radius_filter.cpp index be5c50dbd8b..1617ffabefc 100644 --- a/tools/radius_filter.cpp +++ b/tools/radius_filter.cpp @@ -40,7 +40,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for path, exists, ... +namespace pcl_fs = std::filesystem; +#else #include // for path, exists, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy @@ -131,7 +139,7 @@ batchProcess (const std::vector &pcd_files, std::string &output_dir compute (cloud, output, radius, inside, keep_organized); // Prepare output file name - std::string filename = boost::filesystem::path(pcd_file).filename().string(); + std::string filename = pcl_fs::path(pcd_file).filename().string(); // Save into the second file const std::string filepath = output_dir + '/' + filename; @@ -201,11 +209,11 @@ main (int argc, char** argv) } else { - if (!input_dir.empty() && boost::filesystem::exists (input_dir)) + if (!input_dir.empty() && pcl_fs::exists (input_dir)) { std::vector pcd_files; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (input_dir); itr != end_itr; ++itr) { // Only add PCD files if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) diff --git a/tools/sac_segmentation_plane.cpp b/tools/sac_segmentation_plane.cpp index 45554684055..cc71f5ffaac 100644 --- a/tools/sac_segmentation_plane.cpp +++ b/tools/sac_segmentation_plane.cpp @@ -43,7 +43,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include // for path, exists, ... +namespace pcl_fs = std::filesystem; +#else #include // for path, exists, ... +namespace pcl_fs = boost::filesystem; +#endif + #include // for to_upper_copy using namespace pcl; @@ -191,7 +199,7 @@ batchProcess (const std::vector &pcd_files, std::string &output_dir compute (cloud, output, max_it, thresh, negative); // Prepare output file name - std::string filename = boost::filesystem::path(pcd_file).filename().string(); + std::string filename = pcl_fs::path(pcd_file).filename().string(); // Save into the second file const std::string filepath = output_dir + '/' + filename; @@ -276,11 +284,11 @@ main (int argc, char** argv) } else { - if (!input_dir.empty() && boost::filesystem::exists (input_dir)) + if (!input_dir.empty() && pcl_fs::exists (input_dir)) { std::vector pcd_files; - boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator itr (input_dir); itr != end_itr; ++itr) + pcl_fs::directory_iterator end_itr; + for (pcl_fs::directory_iterator itr (input_dir); itr != end_itr; ++itr) { // Only add PCD files if (!is_directory (itr->status ()) && boost::algorithm::to_upper_copy (itr->path ().extension ().string ()) == ".PCD" ) diff --git a/tools/tiff2pcd.cpp b/tools/tiff2pcd.cpp index d92eddab469..c181068492c 100644 --- a/tools/tiff2pcd.cpp +++ b/tools/tiff2pcd.cpp @@ -40,7 +40,14 @@ **/ #include + +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif #include #include @@ -235,12 +242,12 @@ int main(int argc, char ** argv) PCL_INFO ("Creating RGB Tiff List\n"); std::vector tiff_rgb_files; - std::vector tiff_rgb_paths; - boost::filesystem::directory_iterator end_itr; + std::vector tiff_rgb_paths; + pcl_fs::directory_iterator end_itr; - if(boost::filesystem::is_directory(rgb_path_)) + if(pcl_fs::is_directory(rgb_path_)) { - for (boost::filesystem::directory_iterator itr(rgb_path_); itr != end_itr; ++itr) + for (pcl_fs::directory_iterator itr(rgb_path_); itr != end_itr; ++itr) { std::string ext = itr->path().extension().string(); if(ext == ".tiff") @@ -278,11 +285,11 @@ int main(int argc, char ** argv) PCL_INFO ("Creating Depth Tiff List\n"); std::vector tiff_depth_files; - std::vector tiff_depth_paths; + std::vector tiff_depth_paths; - if(boost::filesystem::is_directory(depth_path_)) + if(pcl_fs::is_directory(depth_path_)) { - for (boost::filesystem::directory_iterator itr(depth_path_); itr != end_itr; ++itr) + for (pcl_fs::directory_iterator itr(depth_path_); itr != end_itr; ++itr) { std::string ext = itr->path().extension().string(); if(ext == ".tiff") diff --git a/tools/unary_classifier_segment.cpp b/tools/unary_classifier_segment.cpp index cdec686d155..785dc233227 100644 --- a/tools/unary_classifier_segment.cpp +++ b/tools/unary_classifier_segment.cpp @@ -45,7 +45,14 @@ #include // for removeNaNFromPointCloud #include + +#if (__cplusplus >= 201703L) +#include // for path, exists, ... +namespace pcl_fs = std::filesystem; +#else #include // for path, exists, ... +namespace pcl_fs = boost::filesystem; +#endif using namespace pcl; using namespace pcl::io; @@ -76,14 +83,14 @@ printHelp (int, char **argv) bool loadTrainedFeatures (std::vector &out, - const boost::filesystem::path &base_dir) + const pcl_fs::path &base_dir) { - if (!boost::filesystem::exists (base_dir) && !boost::filesystem::is_directory (base_dir)) + if (!pcl_fs::exists (base_dir) && !pcl_fs::is_directory (base_dir)) return false; - for (boost::filesystem::directory_iterator it (base_dir); it != boost::filesystem::directory_iterator (); ++it) + for (pcl_fs::directory_iterator it (base_dir); it != pcl_fs::directory_iterator (); ++it) { - if (!boost::filesystem::is_directory (it->status ()) && + if (!pcl_fs::is_directory (it->status ()) && it->path ().extension ().string () == ".pcd") { const std::string path = it->path ().string (); diff --git a/tools/uniform_sampling.cpp b/tools/uniform_sampling.cpp index 269552b16aa..674971859fa 100644 --- a/tools/uniform_sampling.cpp +++ b/tools/uniform_sampling.cpp @@ -41,7 +41,15 @@ #include #include #include + +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif + #include #include @@ -129,7 +137,7 @@ saveCloud (const std::string &filename, const pcl::PCLPointCloud2 &output) PCDWriter w_pcd; PLYWriter w_ply; - std::string output_ext = boost::filesystem::path (filename).extension ().string (); + std::string output_ext = pcl_fs::path (filename).extension ().string (); std::transform (output_ext.begin (), output_ext.end (), output_ext.begin (), ::tolower); if (output_ext == ".pcd") diff --git a/tools/virtual_scanner.cpp b/tools/virtual_scanner.cpp index d339a88413d..19a854db861 100644 --- a/tools/virtual_scanner.cpp +++ b/tools/virtual_scanner.cpp @@ -64,7 +64,14 @@ #include #include // for boost::is_any_of, boost::split, boost::token_compress_on, boost::trim + +#if (__cplusplus >= 201703L) +#include // for std::filesystem::create_directories, std::filesystem::exists, std::filesystem::path, std::filesystem::path::extension +namespace pcl_fs = std::filesystem; +#else #include // for boost::filesystem::create_directories, boost::filesystem::exists, boost::filesystem::path, boost::filesystem::path::extension +namespace pcl_fs = boost::filesystem; +#endif using namespace pcl; @@ -87,7 +94,7 @@ struct ScanParameters vtkPolyData* loadDataSet (const char* file_name) { - std::string extension = boost::filesystem::path (file_name).extension ().string (); + std::string extension = pcl_fs::path (file_name).extension ().string (); if (extension == ".ply") { vtkPLYReader* reader = vtkPLYReader::New (); @@ -413,10 +420,10 @@ main (int argc, char** argv) const std::string output_dir = st.at (st.size () - 1) + "_output"; - boost::filesystem::path outpath (output_dir); - if (!boost::filesystem::exists (outpath)) + pcl_fs::path outpath (output_dir); + if (!pcl_fs::exists (outpath)) { - if (!boost::filesystem::create_directories (outpath)) + if (!pcl_fs::create_directories (outpath)) { PCL_ERROR ("Error creating directory %s.\n", output_dir.c_str ()); return (-1); diff --git a/visualization/src/interactor_style.cpp b/visualization/src/interactor_style.cpp index 58633fe59d4..91728eb56f8 100644 --- a/visualization/src/interactor_style.cpp +++ b/visualization/src/interactor_style.cpp @@ -69,7 +69,14 @@ #include // for is_any_of #include // for split + +#if (__cplusplus >= 201703L) +#include // for exists +namespace pcl_fs = std::filesystem; +#else #include // for exists +namespace pcl_fs = boost::filesystem; +#endif #define ORIENT_MODE 0 #define SELECT_MODE 1 @@ -610,7 +617,7 @@ pcl::visualization::PCLVisualizerInteractorStyle::OnKeyDown () } else { - if (boost::filesystem::exists (camera_file_)) + if (pcl_fs::exists (camera_file_)) { if (loadCameraParameters (camera_file_)) { diff --git a/visualization/src/pcl_visualizer.cpp b/visualization/src/pcl_visualizer.cpp index c8a189ccd67..cb3f0151f50 100644 --- a/visualization/src/pcl_visualizer.cpp +++ b/visualization/src/pcl_visualizer.cpp @@ -102,7 +102,15 @@ #else #include #endif + +#if (__cplusplus >= 201703L) +#include +namespace pcl_fs = std::filesystem; +#else #include +namespace pcl_fs = boost::filesystem; +#endif + #include // for split #include // pcl::utils::ignore #include @@ -465,7 +473,7 @@ void pcl::visualization::PCLVisualizer::setupCamera (int argc, char **argv) std::string camera_file = getUniqueCameraFile (argc, argv); if (!camera_file.empty ()) { - if (boost::filesystem::exists (camera_file) && style_->loadCameraParameters (camera_file)) + if (pcl_fs::exists (camera_file) && style_->loadCameraParameters (camera_file)) { camera_file_loaded_ = true; } @@ -4451,39 +4459,39 @@ pcl::visualization::PCLVisualizer::textureFromTexMaterial (const pcl::TexMateria return (-1); } - boost::filesystem::path full_path (tex_mat.tex_file.c_str ()); - if (!boost::filesystem::exists (full_path)) + pcl_fs::path full_path (tex_mat.tex_file.c_str ()); + if (!pcl_fs::exists (full_path)) { - boost::filesystem::path parent_dir = full_path.parent_path (); + pcl_fs::path parent_dir = full_path.parent_path (); std::string upper_filename = tex_mat.tex_file; boost::to_upper (upper_filename); std::string real_name; try { - if (!boost::filesystem::exists (parent_dir)) + if (!pcl_fs::exists (parent_dir)) { PCL_WARN ("[PCLVisualizer::textureFromTexMaterial] Parent directory '%s' doesn't exist!\n", parent_dir.string ().c_str ()); return (-1); } - if (!boost::filesystem::is_directory (parent_dir)) + if (!pcl_fs::is_directory (parent_dir)) { PCL_WARN ("[PCLVisualizer::textureFromTexMaterial] Parent '%s' is not a directory !\n", parent_dir.string ().c_str ()); return (-1); } - using paths_vector = std::vector; + using paths_vector = std::vector; paths_vector paths; - std::copy (boost::filesystem::directory_iterator (parent_dir), - boost::filesystem::directory_iterator (), + std::copy (pcl_fs::directory_iterator (parent_dir), + pcl_fs::directory_iterator (), back_inserter (paths)); for (const auto& path : paths) { - if (boost::filesystem::is_regular_file (path)) + if (pcl_fs::is_regular_file (path)) { std::string name = path.string (); boost::to_upper (name); @@ -4502,7 +4510,7 @@ pcl::visualization::PCLVisualizer::textureFromTexMaterial (const pcl::TexMateria return (-1); } } - catch (const boost::filesystem::filesystem_error& ex) + catch (const pcl_fs::filesystem_error& ex) { PCL_WARN ("[PCLVisualizer::textureFromTexMaterial] Error %s when looking for file %s\n!", @@ -4577,10 +4585,10 @@ pcl::visualization::PCLVisualizer::getUniqueCameraFile (int argc, char **argv) // Calculate sha1 using canonical paths for (const int &p_file_index : p_file_indices) { - boost::filesystem::path path (argv[p_file_index]); - if (boost::filesystem::exists (path)) + pcl_fs::path path (argv[p_file_index]); + if (pcl_fs::exists (path)) { - path = boost::filesystem::canonical (path); + path = pcl_fs::canonical (path); const auto pathStr = path.string (); sha1.process_bytes (pathStr.c_str(), pathStr.size()); valid = true;