diff --git a/.clang-tidy b/.clang-tidy index 5b0383fadf9..d475e97d587 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,7 +1,11 @@ --- Checks: > -*, + bugprone-assert-side-effect, bugprone-copy-constructor-init, + bugprone-dangling-handle, + bugprone-forward-declaration-namespace, + bugprone-inaccurate-erase, bugprone-macro-parentheses, bugprone-unhandled-self-assignment, bugprone-unused-raii, diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 59fc4071c26..1b49eecb99f 100755 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -17,6 +17,7 @@ jobs: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_COMPILER=/usr/bin/clang-18 -DCMAKE_C_COMPILER=/usr/bin/clang-18 . \ -DBUILD_benchmarks=ON \ -DBUILD_examples=ON \ + -DBUILD_surface_on_nurbs=ON \ -DBUILD_simulation=ON \ -DBUILD_global_tests=ON diff --git a/apps/3d_rec_framework/CMakeLists.txt b/apps/3d_rec_framework/CMakeLists.txt index a75d17047a1..57015b61634 100644 --- a/apps/3d_rec_framework/CMakeLists.txt +++ b/apps/3d_rec_framework/CMakeLists.txt @@ -16,6 +16,8 @@ if(NOT build) return() endif() +include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") + set(incs_fw "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/feature_wrapper/normal_estimator.h" ) @@ -89,7 +91,7 @@ PCL_ADD_INCLUDES("${SUBSUBSYS_NAME}" "${SUBSYS_NAME}/${SUBSUBSYS_NAME}/pipeline/ set(LIB_NAME "pcl_${SUBSUBSYS_NAME}") PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSUBSYS_NAME} SOURCES ${srcs} ${impl_incs_pipeline} ${incs_utils} ${incs_fw} ${incs_fw_global} ${incs_fw_local} ${incc_tools_framework} ${incs_pipelines} ${incs_pc_source}) -target_link_libraries("${LIB_NAME}" pcl_apps pcl_common pcl_io pcl_filters pcl_keypoints pcl_recognition pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search pcl_registration) +target_link_libraries("${LIB_NAME}" pcl_apps pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search pcl_registration) if(WITH_OPENNI) target_link_libraries("${LIB_NAME}" ${OPENNI_LIBRARIES}) diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h index 7a92ebbee43..e777aeab1c6 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -87,8 +86,11 @@ class UniformSamplingExtractor : public KeypointExtractor { pcl::PointCloud filtered_keypoints; // create a search object typename pcl::search::Search::Ptr tree; - tree.reset(pcl::search::autoSelectMethod( - input, false, pcl::search::Purpose::radius_search)); + if (input->isOrganized()) + tree.reset(new pcl::search::OrganizedNeighbor()); + else + tree.reset(new pcl::search::KdTree(false)); + tree->setInputCloud(input); neighborhood_indices_.reset(new std::vector); neighborhood_indices_->resize(keypoints_cloud->size()); diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h index bd21f8cc34b..64ec3e95abe 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h @@ -12,9 +12,8 @@ #include #include #include -#include // for KdTree -#include // for pcl::make_shared -#include // for pcl::index_t +#include // for pcl::make_shared +#include // for pcl::index_t namespace pcl { namespace rec_3d_framework { diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index ff551b13bb8..b501bac85c5 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -15,40 +15,16 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) -list(APPEND CMAKE_AUTOUIC_SEARCH_PATHS "src") - -if(VTK_FOUND) - set(incs "include/pcl/${SUBSYS_NAME}/render_views_tesselated_sphere.h") - set(srcs "src/render_views_tesselated_sphere.cpp") -endif() - -if(QHULL_FOUND) - set(incs - "include/pcl/${SUBSYS_NAME}/dominant_plane_segmentation.h" - "include/pcl/${SUBSYS_NAME}/timer.h" - ${incs} - ) - set(impl_incs "include/pcl/${SUBSYS_NAME}/impl/dominant_plane_segmentation.hpp") - set(srcs "src/dominant_plane_segmentation.cpp" ${srcs}) -endif() - -set(LIB_NAME "pcl_${SUBSYS_NAME}") -PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME} SOURCES ${srcs} ${impl_incs} ${incs}) -target_link_libraries("${LIB_NAME}" pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search) -PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC}) -# Install include files -PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}" ${incs}) -PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/impl" ${impl_incs}) - # to be filled with all targets the apps subsystem set(PCL_APPS_ALL_TARGETS) +include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") + PCL_ADD_EXECUTABLE(pcl_test_search_speed COMPONENT ${SUBSYS_NAME} SOURCES src/test_search.cpp) target_link_libraries(pcl_test_search_speed pcl_common pcl_io pcl_search pcl_kdtree pcl_visualization) PCL_ADD_EXECUTABLE(pcl_nn_classification_example COMPONENT ${SUBSYS_NAME} SOURCES src/nn_classification_example.cpp) target_link_libraries(pcl_nn_classification_example pcl_common pcl_io pcl_features pcl_kdtree) -target_include_directories(pcl_nn_classification_example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_pyramid_surface_matching COMPONENT ${SUBSYS_NAME} SOURCES src/pyramid_surface_matching.cpp) target_link_libraries(pcl_pyramid_surface_matching pcl_common pcl_io pcl_features pcl_registration pcl_filters) @@ -62,6 +38,9 @@ if(LIBUSB_FOUND) endif() if(VTK_FOUND) + set(incs "include/pcl/${SUBSYS_NAME}/render_views_tesselated_sphere.h") + set(srcs "src/render_views_tesselated_sphere.cpp") + PCL_ADD_EXECUTABLE(pcl_ppf_object_recognition COMPONENT ${SUBSYS_NAME} SOURCES src/ppf_object_recognition.cpp) target_link_libraries(pcl_ppf_object_recognition pcl_common pcl_io pcl_filters pcl_features pcl_registration pcl_visualization pcl_sample_consensus pcl_segmentation) @@ -91,9 +70,8 @@ if(VTK_FOUND) PCL_ADD_EXECUTABLE(pcl_face_trainer COMPONENT ${SUBSYS_NAME} SOURCES src/face_detection/face_trainer.cpp) target_link_libraries(pcl_face_trainer pcl_features pcl_recognition pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_surface pcl_keypoints pcl_ml pcl_search pcl_kdtree) - PCL_ADD_EXECUTABLE(pcl_fs_face_detector COMPONENT ${SUBSYS_NAME} SOURCES src/face_detection/filesystem_face_detection.cpp BUNDLE) + PCL_ADD_EXECUTABLE(pcl_fs_face_detector COMPONENT ${SUBSYS_NAME} SOURCES src/face_detection//filesystem_face_detection.cpp BUNDLE) target_link_libraries(pcl_fs_face_detector pcl_features pcl_recognition pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_surface pcl_keypoints pcl_ml pcl_search pcl_kdtree) - target_include_directories(pcl_fs_face_detector PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_stereo_ground_segmentation COMPONENT ${SUBSYS_NAME} SOURCES src/stereo_ground_segmentation.cpp) target_link_libraries(pcl_stereo_ground_segmentation pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_features pcl_stereo) @@ -113,7 +91,6 @@ if(VTK_FOUND) BUNDLE) target_link_libraries(pcl_manual_registration pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface pcl_registration ${QTX}::Widgets) - target_include_directories(pcl_manual_registration PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_pcd_video_player COMPONENT @@ -124,8 +101,7 @@ if(VTK_FOUND) src/pcd_video_player/pcd_video_player.ui BUNDLE) - target_link_libraries(pcl_pcd_video_player pcl_common pcl_io pcl_registration pcl_visualization pcl_segmentation pcl_features pcl_surface ${QTX}::Widgets) - target_include_directories(pcl_pcd_video_player PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + target_link_libraries(pcl_pcd_video_player pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface ${QTX}::Widgets) endif() if(WITH_OPENNI) @@ -178,7 +154,6 @@ if(VTK_FOUND) PCL_ADD_EXECUTABLE(pcl_openni_face_detector COMPONENT ${SUBSYS_NAME} SOURCES src/face_detection//openni_face_detection.cpp src/face_detection//openni_frame_source.cpp BUNDLE) target_link_libraries(pcl_openni_face_detector pcl_features pcl_recognition pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_surface pcl_keypoints pcl_ml pcl_search pcl_kdtree) - target_include_directories(pcl_openni_face_detector PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) if(QT_FOUND AND HAVE_QVTK) # OpenNI Passthrough application demo @@ -186,13 +161,13 @@ if(VTK_FOUND) COMPONENT ${SUBSYS_NAME} SOURCES - include/pcl/apps/openni_passthrough_qt.h include/pcl/apps/openni_passthrough.h src/openni_passthrough.cpp src/openni_passthrough.ui) target_link_libraries(pcl_openni_passthrough pcl_common pcl_io pcl_filters pcl_visualization ${QTX}::Widgets) - target_include_directories(pcl_openni_passthrough PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + + list(APPEND CMAKE_AUTOUIC_SEARCH_PATHS "src") # OpenNI Organized Connected Component application demo PCL_ADD_EXECUTABLE(pcl_organized_segmentation_demo @@ -205,51 +180,48 @@ if(VTK_FOUND) src/organized_segmentation_demo.ui BUNDLE) target_link_libraries(pcl_organized_segmentation_demo pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface ${QTX}::Widgets) - target_include_directories(pcl_organized_segmentation_demo PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) endif() if(QHULL_FOUND) - PCL_ADD_EXECUTABLE(pcl_openni_3d_convex_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_3d_convex_hull.cpp BUNDLE) - target_link_libraries(pcl_openni_3d_convex_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface) - - PCL_ADD_EXECUTABLE(pcl_openni_3d_concave_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_3d_concave_hull.cpp BUNDLE) - target_link_libraries(pcl_openni_3d_concave_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface) - - PCL_ADD_EXECUTABLE(pcl_openni_tracking COMPONENT ${SUBSYS_NAME} SOURCES src/openni_tracking.cpp BUNDLE) - target_link_libraries(pcl_openni_tracking pcl_common pcl_io pcl_surface pcl_visualization pcl_filters pcl_features pcl_segmentation pcl_tracking pcl_search) - - PCL_ADD_EXECUTABLE(pcl_openni_planar_convex_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_planar_convex_hull.cpp BUNDLE) - target_link_libraries(pcl_openni_planar_convex_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_surface) - - PCL_ADD_EXECUTABLE(pcl_ni_linemod COMPONENT ${SUBSYS_NAME} SOURCES src/ni_linemod.cpp BUNDLE) - target_link_libraries(pcl_ni_linemod pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface pcl_search) - target_include_directories(pcl_ni_linemod PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + PCL_ADD_EXECUTABLE(pcl_openni_3d_convex_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_3d_convex_hull.cpp BUNDLE) + target_link_libraries(pcl_openni_3d_convex_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface) + + PCL_ADD_EXECUTABLE(pcl_openni_3d_concave_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_3d_concave_hull.cpp BUNDLE) + target_link_libraries(pcl_openni_3d_concave_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface) + + PCL_ADD_EXECUTABLE(pcl_openni_tracking COMPONENT ${SUBSYS_NAME} SOURCES src/openni_tracking.cpp BUNDLE) + target_link_libraries(pcl_openni_tracking pcl_common pcl_io pcl_surface pcl_visualization pcl_filters pcl_features pcl_segmentation pcl_tracking pcl_search) + + PCL_ADD_EXECUTABLE(pcl_openni_planar_convex_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_planar_convex_hull.cpp BUNDLE) + target_link_libraries(pcl_openni_planar_convex_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_surface) + + PCL_ADD_EXECUTABLE(pcl_ni_linemod COMPONENT ${SUBSYS_NAME} SOURCES src/ni_linemod.cpp BUNDLE) + target_link_libraries(pcl_ni_linemod pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface pcl_search) endif() # QHULL_FOUND PCL_ADD_EXECUTABLE(pcl_ni_agast COMPONENT ${SUBSYS_NAME} SOURCES src/ni_agast.cpp BUNDLE) target_link_libraries(pcl_ni_agast pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_keypoints pcl_surface pcl_search) - target_include_directories(pcl_ni_agast PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_ni_brisk COMPONENT ${SUBSYS_NAME} SOURCES src/ni_brisk.cpp BUNDLE) target_link_libraries(pcl_ni_brisk pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_keypoints pcl_surface pcl_search) - target_include_directories(pcl_ni_brisk PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_ni_susan COMPONENT ${SUBSYS_NAME} SOURCES src/ni_susan.cpp BUNDLE) target_link_libraries(pcl_ni_susan pcl_common pcl_visualization pcl_features pcl_keypoints pcl_search) - target_include_directories(pcl_ni_susan PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_ni_trajkovic COMPONENT ${SUBSYS_NAME} SOURCES src/ni_trajkovic.cpp BUNDLE) target_link_libraries(pcl_ni_trajkovic pcl_common pcl_visualization pcl_features pcl_keypoints pcl_search) - target_include_directories(pcl_ni_trajkovic PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_openni_klt COMPONENT ${SUBSYS_NAME} SOURCES src/openni_klt.cpp BUNDLE) - target_link_libraries(pcl_openni_klt pcl_common pcl_io pcl_keypoints pcl_visualization pcl_tracking) + target_link_libraries(pcl_openni_klt pcl_common pcl_io pcl_visualization pcl_tracking) endif() # WITH_OPENNI endif() # VTK_FOUND # OpenGL and GLUT if(OPENGL_FOUND AND GLUT_FOUND) + if(NOT WIN32) + include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}") + endif() PCL_ADD_EXECUTABLE(pcl_grabcut_2d COMPONENT ${SUBSYS_NAME} SOURCES src/grabcut_2d.cpp BUNDLE) if(APPLE) set(_glut_target ${GLUT_glut_LIBRARY}) @@ -264,9 +236,27 @@ set(PCL_APPS_MODULES_NAMES_UNSORTED ${PCL_APPS_MODULES_NAMES}) topological_sort(PCL_APPS_MODULES_NAMES PCL_APPS_ _DEPENDS) sort_relative(PCL_APPS_MODULES_NAMES_UNSORTED PCL_APPS_MODULES_NAMES PCL_APPS_MODULES_DIRS) foreach(subdir ${PCL_APPS_MODULES_DIRS}) - add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/${subdir}") +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/${subdir}") endforeach() +if(QHULL_FOUND) + set(incs + "include/pcl/${SUBSYS_NAME}/dominant_plane_segmentation.h" + "include/pcl/${SUBSYS_NAME}/timer.h" + ${incs} + ) + set(impl_incs "include/pcl/${SUBSYS_NAME}/impl/dominant_plane_segmentation.hpp") + set(srcs "src/dominant_plane_segmentation.cpp" ${srcs}) +endif() + +set(LIB_NAME "pcl_${SUBSYS_NAME}") +PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME} SOURCES ${srcs} ${impl_incs} ${incs}) +target_link_libraries("${LIB_NAME}" pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search) +PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC}) +# Install include files +PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}" ${incs}) +PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/impl" ${impl_incs}) + if(CMAKE_GENERATOR_IS_IDE) set(SUBSYS_TARGET_NAME APPS_BUILD) else() diff --git a/apps/cloud_composer/CMakeLists.txt b/apps/cloud_composer/CMakeLists.txt index 47668e169a4..3e2629fa1c8 100644 --- a/apps/cloud_composer/CMakeLists.txt +++ b/apps/cloud_composer/CMakeLists.txt @@ -5,7 +5,7 @@ set(SUBSUBSYS_NAME cloud_composer) set(SUBSUBSYS_DESC "Cloud Composer - Application for Manipulating Point Clouds") -set(SUBSUBSYS_DEPS common io visualization features filters apps) +set(SUBSUBSYS_DEPS common io visualization filters apps) set(SUBSUBSYS_EXT_DEPS vtk ${QTX}) set(REASON "") set(DEFAULT OFF) @@ -28,6 +28,8 @@ if(NOT build) return() endif() +include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") + #Create subdirectory for plugin libs set(CLOUD_COMPOSER_PLUGIN_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cloud_composer_plugins") make_directory("${CLOUD_COMPOSER_PLUGIN_DIR}") @@ -71,7 +73,7 @@ set(PCL_LIB_TYPE STATIC) PCL_ADD_LIBRARY(pcl_cc_tool_interface COMPONENT ${SUBSUBSYS_NAME} SOURCES ${INTERFACE_HEADERS} ${INTERFACE_SOURCES}) -target_link_libraries(pcl_cc_tool_interface pcl_common pcl_features pcl_filters pcl_search pcl_visualization ${QTX}::Widgets) +target_link_libraries(pcl_cc_tool_interface pcl_common pcl_filters pcl_search pcl_visualization ${QTX}::Widgets) set(PCL_LIB_TYPE ${PCL_LIB_TYPE_ORIGIN}) diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h index 973ca0015e1..c5e8c7d691b 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h @@ -42,35 +42,40 @@ class QItemSelectionModel; -namespace pcl { -namespace cloud_composer { -/** \brief View class for displaying project composition - * \author Jeremie Papon - * \ingroup cloud_composer - */ -class ProjectModel; -class CloudBrowser : public QTreeView { - Q_OBJECT -public: - CloudBrowser(QWidget* parent = nullptr); - - void - setModel(QAbstractItemModel* new_model) override; - -private: - ProjectModel* current_project_model_; -}; - -class BackgroundDelegate : public QStyledItemDelegate { -public: - explicit BackgroundDelegate(QObject* parent = nullptr) : QStyledItemDelegate(parent) - {} - - void - paint(QPainter* painter, - const QStyleOptionViewItem& option, - const QModelIndex& index) const override; -}; - -} // namespace cloud_composer -} // namespace pcl +namespace pcl +{ + namespace cloud_composer + { + /** \brief View class for displaying project composition + * \author Jeremie Papon + * \ingroup cloud_composer + */ + class ProjectModel; + class CloudBrowser : public QTreeView + { + Q_OBJECT + public: + CloudBrowser (QWidget* parent = nullptr); + + void + setModel (QAbstractItemModel* new_model) override; + + private: + ProjectModel* current_project_model_; + + }; + + class BackgroundDelegate : public QStyledItemDelegate + { + public: + explicit + BackgroundDelegate (QObject *parent = nullptr) + : QStyledItemDelegate(parent) {} + + void + paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + + }; + + } +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h index 1da2fb7158a..9fbfdcc5b17 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h @@ -37,7 +37,7 @@ #pragma once -// PCL +//PCL #include #include @@ -45,122 +45,125 @@ class QTreeView; -namespace pcl { -namespace cloud_composer { -class ProjectModel; -class CloudViewer; -class CloudCommand; -class ToolFactory; -class ToolBoxModel; -class SignalMultiplexer; - -/** \brief MainWindow of cloud_composer application - * \author Jeremie Papon - * \ingroup cloud_composer - * The following member objects are defined in the ui file and can be manipulated: - * * cloud_viewer_ is the view which contains the PCLVisualizer & QVTKWidget - * * cloud_browser_ is the tree view in the left dock - * * item_inspector_ is the details view in the left dock - * * tool_box_view_ is the tool box in right dock - * * tool_parameter_view_ shows adjustable parameters for currently selected tool - * * undo_view_ is the undo stack view in the right dock - */ -class ComposerMainWindow : public QMainWindow, private Ui::ComposerMainWindow { - Q_OBJECT -public: - explicit ComposerMainWindow(QWidget* parent = nullptr); - ~ComposerMainWindow(); - -Q_SIGNALS: - /** \brief Signal emitted when the active project is switched - ie a different project - * tab is selected */ - void - activeProjectChanged(ProjectModel* new_model, ProjectModel* previous_model); - - /** \brief This signal tells the current project to insert a cloud using a file dialog - * box */ - void - insertNewCloudFromFile(); - - /** \brief This signal tells the current project to insert a cloud from and RGB and - * Depth image using a file dialog box */ - void - insertNewCloudFromRGBandDepth(); - - /** \brief This signal tells the current project to save currently selected cloud to - * file */ - void - saveSelectedCloudToFile(); - -public Q_SLOTS: - // Slots for File Menu Actions - void on_action_new_project__triggered(/*QString name = "unsaved project"*/); - void - on_action_open_cloud_as_new_project__triggered(); - void - on_action_open_project__triggered(); - void - on_action_save_project__triggered(); - void - on_action_save_project_as__triggered(); - void - on_action_save_selected_cloud__triggered(); - void - on_action_exit__triggered(); - - // Slots for Edit Menu Actions - void - on_action_insert_from_file__triggered(); - void - on_action_insert_from_openNi_source__triggered(); - void - on_action_insert_from_rgb_depth__triggered(); - - void - setCurrentModel(ProjectModel* model); - - void - setMouseStyleAction(interactor_styles::INTERACTOR_STYLES selected_style); - - void - enqueueToolAction(AbstractTool* tool); - -private: - void - connectFileActions(); - void - connectEditActions(); - - void - connectViewActions(); - - void - initializeCloudBrowser(); - void - initializeCloudViewer(); - void - initializeItemInspector(); - - void - initializeToolBox(); - void - initializePlugins(); - - /** \brief Pointer to the model which is currently being viewed */ - ProjectModel* current_model_; - QItemSelectionModel* current_selection_model_; - - QMap name_model_map_; - - QUndoGroup* undo_group_; - - QItemSelectionModel* tool_selection_model_; - ToolBoxModel* tool_box_model_; - - SignalMultiplexer* multiplexer_; - - QActionGroup* mouse_style_group_; -}; - -} // namespace cloud_composer -} // namespace pcl +namespace pcl +{ + namespace cloud_composer + { + class ProjectModel; + class CloudViewer; + class CloudCommand; + class ToolFactory; + class ToolBoxModel; + class SignalMultiplexer; + + /** \brief MainWindow of cloud_composer application + * \author Jeremie Papon + * \ingroup cloud_composer + * The following member objects are defined in the ui file and can be manipulated: + * * cloud_viewer_ is the view which contains the PCLVisualizer & QVTKWidget + * * cloud_browser_ is the tree view in the left dock + * * item_inspector_ is the details view in the left dock + * * tool_box_view_ is the tool box in right dock + * * tool_parameter_view_ shows adjustable parameters for currently selected tool + * * undo_view_ is the undo stack view in the right dock + */ + class ComposerMainWindow : public QMainWindow, private Ui::ComposerMainWindow + { + Q_OBJECT + public: + explicit ComposerMainWindow (QWidget *parent = nullptr); + ~ComposerMainWindow (); + + Q_SIGNALS: + /** \brief Signal emitted when the active project is switched - ie a different project tab is selected */ + void + activeProjectChanged (ProjectModel* new_model, ProjectModel* previous_model); + + /** \brief This signal tells the current project to insert a cloud using a file dialog box */ + void + insertNewCloudFromFile (); + + /** \brief This signal tells the current project to insert a cloud from and RGB and Depth image using a file dialog box */ + void + insertNewCloudFromRGBandDepth (); + + /** \brief This signal tells the current project to save currently selected cloud to file */ + void + saveSelectedCloudToFile (); + + public Q_SLOTS: + //Slots for File Menu Actions + void + on_action_new_project__triggered (/*QString name = "unsaved project"*/); + void + on_action_open_cloud_as_new_project__triggered (); + void + on_action_open_project__triggered (); + void + on_action_save_project__triggered (); + void + on_action_save_project_as__triggered (); + void + on_action_save_selected_cloud__triggered (); + void + on_action_exit__triggered (); + + //Slots for Edit Menu Actions + void + on_action_insert_from_file__triggered (); + void + on_action_insert_from_openNi_source__triggered (); + void + on_action_insert_from_rgb_depth__triggered (); + + + + void + setCurrentModel (ProjectModel* model); + + void + setMouseStyleAction (interactor_styles::INTERACTOR_STYLES selected_style); + + void + enqueueToolAction (AbstractTool* tool); + + private: + void + connectFileActions (); + void + connectEditActions (); + + void + connectViewActions (); + + void + initializeCloudBrowser (); + void + initializeCloudViewer (); + void + initializeItemInspector (); + + void + initializeToolBox (); + void + initializePlugins (); + + + /** \brief Pointer to the model which is currently being viewed */ + ProjectModel* current_model_; + QItemSelectionModel* current_selection_model_; + + QMap name_model_map_; + + QUndoGroup *undo_group_; + + QItemSelectionModel* tool_selection_model_; + ToolBoxModel* tool_box_model_; + + SignalMultiplexer* multiplexer_; + + QActionGroup* mouse_style_group_; + }; + + } +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h index 09723d2beff..27780fa5ebf 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h @@ -37,138 +37,130 @@ #pragma once -#include +#include + +#include + #include #include +#include -#include -#include -#include -#include #include +#include +#include #include class QItemSelection; class QStandardItem; -namespace pcl { -namespace cloud_composer { -class ProjectModel; -/** \brief View class for displaying ProjectModel data using PCLVisualizer - * \author Jeremie Papon - * \ingroup cloud_composer - */ -class CloudView : public QWidget { - Q_OBJECT - -public: - CloudView(QWidget* parent = nullptr); - CloudView(const CloudView& to_copy); - CloudView(ProjectModel* model, QWidget* parent = nullptr); - - void - setModel(ProjectModel* new_model); - - ProjectModel* - getModel() const - { - return model_; - } - - PCLQVTKWidget* - getQVTK() const - { - return qvtk_; - } - - pcl::visualization::PCLVisualizer::Ptr - getPCLVisualizer() const +namespace pcl +{ + namespace cloud_composer { - return vis_; + class ProjectModel; + /** \brief View class for displaying ProjectModel data using PCLVisualizer + * \author Jeremie Papon + * \ingroup cloud_composer + */ + class CloudView : public QWidget + { + Q_OBJECT + + public: + CloudView (QWidget* parent = nullptr); + CloudView (const CloudView& to_copy); + CloudView (ProjectModel* model, QWidget* parent = nullptr); + + void + setModel (ProjectModel* new_model); + + ProjectModel* + getModel () const { return model_; } + + PCLQVTKWidget* + getQVTK() const { return qvtk_; } + + pcl::visualization::PCLVisualizer::Ptr + getPCLVisualizer () const { return vis_; } + + void + setAxisVisibility (bool visible); + + void + setInteractorStyle (interactor_styles::INTERACTOR_STYLES style); + public Q_SLOTS: + void + refresh (); + + /** \brief Slot called when the item selected in cloud browser changes */ + void + selectedItemChanged (const QItemSelection & selected, const QItemSelection & deselected); + + /** \brief Slot called when the data in model changes */ + void + dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); + + protected Q_SLOTS: + /** \brief Slot called when an item in the model changes + * \param topLeft + * \param bottomRight + */ + void + itemChanged (QStandardItem* item); + + /** \brief Slot called when rows inserted to model + * \param start Start of new rows (inclusive) + * \param end End of new rows (inclusive) + */ + void + rowsInserted (const QModelIndex& parent, int start, int end); + + void + rowsAboutToBeRemoved (const QModelIndex& parent, int start, int end); + + void + selectionCompleted (vtkObject* caller, unsigned long event_id, void* client_data, void* call_data); + + void + manipulationCompleted (vtkObject* caller, unsigned long event_id, void* client_data, void* call_data); + + protected: + void + paintEvent (QPaintEvent* event) override; + void + resizeEvent (QResizeEvent* event) override; + // void scrollContentsBy (int dx, int dy); + + + + private: + void + connectSignalsAndSlots (); + + /** \brief Internal function for setting up the style_switch_ */ + void + initializeInteractorSwitch (); + + void + addOrientationMarkerWidgetAxes (); + void + removeOrientationMarkerWidgetAxes (); + + pcl::visualization::PCLVisualizer::Ptr vis_; + ProjectModel* model_; + + PCLQVTKWidget* qvtk_; + + vtkSmartPointer style_switch_; + + vtkSmartPointer axes_widget_; + vtkSmartPointer axes_; + + /** \brief Manages VTK events by connecting them to QT slots */ + vtkSmartPointer connections_; + }; } +} - void - setAxisVisibility(bool visible); - - void - setInteractorStyle(interactor_styles::INTERACTOR_STYLES style); -public Q_SLOTS: - void - refresh(); - - /** \brief Slot called when the item selected in cloud browser changes */ - void - selectedItemChanged(const QItemSelection& selected, const QItemSelection& deselected); - - /** \brief Slot called when the data in model changes */ - void - dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); - -protected Q_SLOTS: - /** \brief Slot called when an item in the model changes - * \param topLeft - * \param bottomRight - */ - void - itemChanged(QStandardItem* item); - - /** \brief Slot called when rows inserted to model - * \param start Start of new rows (inclusive) - * \param end End of new rows (inclusive) - */ - void - rowsInserted(const QModelIndex& parent, int start, int end); - - void - rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end); - - void - selectionCompleted(vtkObject* caller, - unsigned long event_id, - void* client_data, - void* call_data); - - void - manipulationCompleted(vtkObject* caller, - unsigned long event_id, - void* client_data, - void* call_data); - -protected: - void - paintEvent(QPaintEvent* event) override; - void - resizeEvent(QResizeEvent* event) override; - // void scrollContentsBy (int dx, int dy); - -private: - void - connectSignalsAndSlots(); - - /** \brief Internal function for setting up the style_switch_ */ - void - initializeInteractorSwitch(); - - void - addOrientationMarkerWidgetAxes(); - void - removeOrientationMarkerWidgetAxes(); - - pcl::visualization::PCLVisualizer::Ptr vis_; - ProjectModel* model_; - - PCLQVTKWidget* qvtk_; - - vtkSmartPointer style_switch_; - - vtkSmartPointer axes_widget_; - vtkSmartPointer axes_; - - /** \brief Manages VTK events by connecting them to QT slots */ - vtkSmartPointer connections_; -}; -} // namespace cloud_composer -} // namespace pcl - -Q_DECLARE_METATYPE(pcl::cloud_composer::CloudView); +Q_DECLARE_METATYPE (pcl::cloud_composer::CloudView); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h index 3e6489fc5f2..df10dc1f09f 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h @@ -37,44 +37,48 @@ #pragma once -#include -#include -#include - #include -namespace pcl { -namespace cloud_composer { - -/** \brief Tabbed widget for containing CloudView widgets - * \author Jeremie Papon - * \ingroup cloud_composer - */ -class CloudViewer : public QTabWidget { - Q_OBJECT - -public: - CloudViewer(QWidget* parent = nullptr); - ProjectModel* - getModel() const; - -public Q_SLOTS: - void - addModel(ProjectModel* new_model); +#include +#include +#include - void - modelChanged(int index); +namespace pcl +{ + namespace cloud_composer + { + + /** \brief Tabbed widget for containing CloudView widgets + * \author Jeremie Papon + * \ingroup cloud_composer + */ + class CloudViewer : public QTabWidget + { + Q_OBJECT - void - addNewProject(ProjectModel* new_model); + public: + + CloudViewer (QWidget* parent = nullptr); + ProjectModel* getModel () const; -Q_SIGNALS: - void - newModelSelected(ProjectModel* new_model); + public Q_SLOTS: + void + addModel (ProjectModel* new_model); + + void + modelChanged (int index); + + void + addNewProject (ProjectModel* new_model); + + Q_SIGNALS: + void + newModelSelected (ProjectModel *new_model); -private: - pcl::visualization::PCLVisualizer::Ptr vis_; - QMap model_view_map_; -}; -} // namespace cloud_composer -} // namespace pcl + private: + + pcl::visualization::PCLVisualizer::Ptr vis_; + QMap model_view_map_; + }; + } +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h index e47c399b2e2..5186af6a8d3 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h @@ -41,171 +41,180 @@ #include -namespace pcl { -namespace cloud_composer { -class AbstractTool; -class ProjectModel; -struct OutputPair { - QList input_items_; - QList output_items_; -}; - -class CloudCommand : public QUndoCommand { -public: - CloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - ~CloudCommand(); - - virtual bool - runCommand(AbstractTool* tool) = 0; - - void - undo() override = 0; - - void - redo() override = 0; - - // QList - // executeToolOnTemplateCloud (AbstractTool* tool, ConstItemList &input_data); - - void - setProjectModel(ProjectModel* model); - - inline void - setInputData(ConstItemList input_data) - { - original_data_ = std::move(input_data); - } - -protected: - /** \brief Removes the original item(s) from the model and replaces with the - * replacement(s) Replacements are only inserted once, original items must have same - * parent This stores the removed items in removed_items_ - */ - bool - replaceOriginalWithNew(const QList& originals, - const QList& new_items); - - /** \brief This removes new_items from the model and restores originals */ - bool - restoreOriginalRemoveNew(const QList& originals, - const QList& new_items); - - ConstItemList original_data_; - - QMap removed_to_parent_map_; - QList output_data_; - ProjectModel* project_model_; - - /** \brief This determines if we delete original items or not on destruction - * If the command is being deleted because stack is at limit, then we want - * to only delete the originals, since the command is staying for good (new items - * shouldn't be deleted) On the other hand, if we destruct after an undo, then we want - * to delete the new items (but not the originals) - */ - bool last_was_undo_; - - /** \brief This is used to check if a templated version of a tool can be used - * For this to return true, all items must be clouds, and must have the same template - * type - */ - bool - canUseTemplates(ConstItemList& input_data); - - bool can_use_templates_; - int template_type_; -}; - -class ModifyItemCommand : public CloudCommand { -public: - ModifyItemCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand(AbstractTool* tool) override; - - void - undo() override; - - void - redo() override; - -private: -}; - -class NewItemCloudCommand : public CloudCommand { -public: - NewItemCloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand(AbstractTool* tool) override; - - void - undo() override; - - void - redo() override; -}; - -class SplitCloudCommand : public CloudCommand { -public: - SplitCloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand(AbstractTool* tool) override; - - void - undo() override; - - void - redo() override; - -private: -}; - -class DeleteItemCommand : public CloudCommand { -public: - DeleteItemCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand(AbstractTool* tool) override; - - void - undo() override; - - void - redo() override; - -private: -}; - -class MergeCloudCommand : public CloudCommand { -public: - /** \brief Construct for a merge command - * \param[in] input_data Input list of CloudItem s from the project model which will - * be merged \param[in] temporary_clouds Input list of CloudItems which - */ - MergeCloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand(AbstractTool* tool) override; - - void - undo() override; - - void - redo() override; - - inline void - setSelectedIndicesMap( - const QMap& selected_item_index_map) +namespace pcl +{ + namespace cloud_composer { - selected_item_index_map_ = selected_item_index_map; + class AbstractTool; + class ProjectModel; + struct OutputPair + { + QList input_items_; + QList output_items_; + }; + + + + class CloudCommand : public QUndoCommand + { + public: + CloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + + ~CloudCommand (); + + virtual bool + runCommand (AbstractTool* tool) = 0; + + void + undo () override = 0; + + void + redo () override = 0; + + //QList + // executeToolOnTemplateCloud (AbstractTool* tool, ConstItemList &input_data); + + void + setProjectModel (ProjectModel* model); + + inline void + setInputData (ConstItemList input_data) + { + original_data_ = std::move(input_data); + } + protected: + /** \brief Removes the original item(s) from the model and replaces with the replacement(s) + * Replacements are only inserted once, original items must have same parent + * This stores the removed items in removed_items_ + */ + bool + replaceOriginalWithNew (const QList & originals, const QList & new_items); + + /** \brief This removes new_items from the model and restores originals */ + bool + restoreOriginalRemoveNew (const QList & originals, const QList & new_items); + + ConstItemList original_data_; + + QMap removed_to_parent_map_; + QList output_data_; + ProjectModel* project_model_; + + /** \brief This determines if we delete original items or not on destruction + * If the command is being deleted because stack is at limit, then we want + * to only delete the originals, since the command is staying for good (new items shouldn't be deleted) + * On the other hand, if we destruct after an undo, then we want to delete the new items (but not the originals) + */ + bool last_was_undo_; + + /** \brief This is used to check if a templated version of a tool can be used + * For this to return true, all items must be clouds, and must have the same template type + */ + bool + canUseTemplates (ConstItemList &input_data); + + bool can_use_templates_; + int template_type_; + }; + + class ModifyItemCommand : public CloudCommand + { + public: + ModifyItemCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand (AbstractTool* tool) override; + + void + undo () override; + + void + redo () override; + private: + + + + }; + + class NewItemCloudCommand : public CloudCommand + { + public: + NewItemCloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand (AbstractTool* tool) override; + + void + undo () override; + + void + redo () override; + + }; + + + class SplitCloudCommand : public CloudCommand + { + public: + SplitCloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand (AbstractTool* tool) override; + + void + undo () override; + + void + redo () override; + private: + + }; + + class DeleteItemCommand : public CloudCommand + { + public: + DeleteItemCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand (AbstractTool* tool) override; + + void + undo () override; + + void + redo () override; + private: + }; + + class MergeCloudCommand : public CloudCommand + { + public: + /** \brief Construct for a merge command + * \param[in] input_data Input list of CloudItem s from the project model which will be merged + * \param[in] temporary_clouds Input list of CloudItems which + */ + MergeCloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand (AbstractTool* tool) override; + + void + undo () override; + + void + redo () override; + + inline void + setSelectedIndicesMap( const QMap & selected_item_index_map) + { + selected_item_index_map_ = selected_item_index_map; + } + + private: + QMap selected_item_index_map_; + }; } +} -private: - QMap selected_item_index_map_; -}; -} // namespace cloud_composer -} // namespace pcl - -Q_DECLARE_METATYPE(ConstItemList); +Q_DECLARE_METATYPE (ConstItemList); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp index 6c78b82d46f..6689967c065 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp @@ -1,4 +1,4 @@ -/* + /* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org @@ -39,48 +39,45 @@ #define IMPL_CLOUD_ITEM_H_ #include -#include -#include // for pcl::make_shared +#include // for pcl::make_shared #include +#include -template -void -pcl::cloud_composer::CloudItem::printNumPoints() const +template void +pcl::cloud_composer::CloudItem::printNumPoints () const { - QVariant variant = this->data(ItemDataRole::CLOUD_TEMPLATED); + QVariant variant = this->data (ItemDataRole::CLOUD_TEMPLATED); typename PointCloud::Ptr cloud; - if (variant.canConvert::Ptr>()) { - cloud = variant.value::Ptr>(); + if ( variant.canConvert ::Ptr> () ) + { + cloud = variant.value ::Ptr> (); } - else { - qWarning() - << "Attempted to cast to template type which does not exist in this item!"; + else + { + qWarning () << "Attempted to cast to template type which does not exist in this item!"; return; } - qDebug() << "CLOUD HAS WIDTH = " << cloud->width; + qDebug () << "CLOUD HAS WIDTH = "<< cloud->width; + } -template -pcl::cloud_composer::CloudItem* -pcl::cloud_composer::CloudItem::createCloudItemFromTemplate( - const QString& name, typename PointCloud::Ptr cloud_ptr) + + +template pcl::cloud_composer::CloudItem* +pcl::cloud_composer::CloudItem::createCloudItemFromTemplate (const QString& name, typename PointCloud::Ptr cloud_ptr) { - pcl::PCLPointCloud2::Ptr cloud_blob = pcl::make_shared(); - toPCLPointCloud2(*cloud_ptr, *cloud_blob); - CloudItem* cloud_item = - new CloudItem(name, cloud_blob, Eigen::Vector4f(), Eigen::Quaternionf(), false); - cloud_item->setData(QVariant::fromValue(cloud_ptr), ItemDataRole::CLOUD_TEMPLATED); - cloud_item->setPointType(); + pcl::PCLPointCloud2::Ptr cloud_blob = pcl::make_shared (); + toPCLPointCloud2 (*cloud_ptr, *cloud_blob); + CloudItem* cloud_item = new CloudItem ( name, cloud_blob, Eigen::Vector4f (), Eigen::Quaternionf (), false); + cloud_item->setData (QVariant::fromValue(cloud_ptr), ItemDataRole::CLOUD_TEMPLATED); + cloud_item->setPointType (); return cloud_item; } -#define PCL_INSTANTIATE_createCloudItemFromTemplate(T) \ - template pcl::cloud_composer::CloudItem* \ - pcl::cloud_composer::CloudItem::createCloudItemFromTemplate( \ - const QString, typename PointCloud::Ptr); -#define PCL_INSTANTIATE_printNumPoints(T) \ - template void pcl::cloud_composer::CloudItem::getNumPoints(); +#define PCL_INSTANTIATE_createCloudItemFromTemplate(T) template pcl::cloud_composer::CloudItem* pcl::cloud_composer::CloudItem::createCloudItemFromTemplate(const QString, typename PointCloud::Ptr); + +#define PCL_INSTANTIATE_printNumPoints(T) template void pcl::cloud_composer::CloudItem::getNumPoints(); #endif diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp index bb913d2581e..9574b738433 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp @@ -1,4 +1,4 @@ -/* + /* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org @@ -38,85 +38,81 @@ #ifndef IMPL_MERGE_SELECTION_H_ #define IMPL_MERGE_SELECTION_H_ -#include #include -#include #include +#include -template -QList -pcl::cloud_composer::MergeSelection::performTemplatedAction( - const QList& input_data) +template QList +pcl::cloud_composer::MergeSelection::performTemplatedAction (const QList & input_data) { - QList output; - - foreach (const CloudComposerItem* input_item, input_data) { - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - if (!variant.canConvert::Ptr>()) { - qWarning() << "Attempted to cast to template type which does not exist in this " - "item! (input list)"; + QList output; + + foreach (const CloudComposerItem* input_item, input_data) + { + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + if ( ! variant.canConvert ::Ptr> () ) + { + qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; return output; } } - foreach (const CloudItem* input_item, selected_item_index_map_.keys()) { - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - if (!variant.canConvert::Ptr>()) { - qWarning() << "Attempted to cast to template type which does not exist in this " - "item! (selected list)"; + foreach (const CloudItem* input_item, selected_item_index_map_.keys ()) + { + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + if ( ! variant.canConvert ::Ptr> () ) + { + qWarning () << "Attempted to cast to template type which does not exist in this item! (selected list)"; return output; } - } + } pcl::ExtractIndices filter; - typename PointCloud::Ptr merged_cloud(new PointCloud); - - foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys()) { - input_cloud_item->printNumPoints(); - // If this cloud hasn't been completely selected - if (!input_data.contains(input_cloud_item)) { - typename PointCloud::Ptr input_cloud = - input_cloud_item->data(ItemDataRole::CLOUD_TEMPLATED) - .value::Ptr>(); - qDebug() << "Extracting " - << selected_item_index_map_.value(input_cloud_item)->indices.size() - << " points out of " << input_cloud->width; - filter.setInputCloud(input_cloud); - filter.setIndices(selected_item_index_map_.value(input_cloud_item)); - typename PointCloud::Ptr original_minus_indices(new PointCloud); - filter.setNegative(true); - filter.filter(*original_minus_indices); - filter.setNegative(false); - typename PointCloud::Ptr selected_points(new PointCloud); - filter.filter(*selected_points); - - qDebug() << "Original minus indices is " << original_minus_indices->width; + typename PointCloud::Ptr merged_cloud (new PointCloud); - CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate( - input_cloud_item->text(), original_minus_indices); - - output.append(new_cloud_item); + foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys ()) + { + input_cloud_item->printNumPoints (); + //If this cloud hasn't been completely selected + if (!input_data.contains (input_cloud_item)) + { + typename PointCloud::Ptr input_cloud = input_cloud_item->data (ItemDataRole::CLOUD_TEMPLATED).value ::Ptr> (); + qDebug () << "Extracting "<indices.size() << " points out of "<width; + filter.setInputCloud (input_cloud); + filter.setIndices (selected_item_index_map_.value (input_cloud_item)); + typename PointCloud::Ptr original_minus_indices (new PointCloud); + filter.setNegative (true); + filter.filter (*original_minus_indices); + filter.setNegative (false); + typename PointCloud::Ptr selected_points (new PointCloud); + filter.filter (*selected_points); + + qDebug () << "Original minus indices is "<width; + + CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(input_cloud_item->text (),original_minus_indices); + + output.append (new_cloud_item); *merged_cloud += *selected_points; } - // Append the input item to the original list - // input_data.append (input_cloud_item); + //Append the input item to the original list + //input_data.append (input_cloud_item); } - // Just concatenate for all fully selected clouds - foreach (const CloudComposerItem* input_item, input_data) { - typename PointCloud::Ptr input_cloud = - input_item->data(ItemDataRole::CLOUD_TEMPLATED) - .value::Ptr>(); + //Just concatenate for all fully selected clouds + foreach (const CloudComposerItem* input_item, input_data) + { + typename PointCloud::Ptr input_cloud = input_item->data (ItemDataRole::CLOUD_TEMPLATED).value ::Ptr> (); *merged_cloud += *input_cloud; } - CloudItem* cloud_item = CloudItem::createCloudItemFromTemplate( - "Cloud from Selection", merged_cloud); - - output.append(cloud_item); - + CloudItem* cloud_item = CloudItem::createCloudItemFromTemplate("Cloud from Selection",merged_cloud); + + output.append (cloud_item); + return output; + } -#define PCL_INSTANTIATE_performTemplatedAction(T) \ - template void pcl::cloud_composer::MergeSelection::performTemplatedAction( \ - QList); -#endif // IMPL_MERGE_SELECTION_H_ +#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::MergeSelection::performTemplatedAction (QList ); + + + +#endif //IMPL_MERGE_SELECTION_H_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp index 5fce284b5ab..92574aec769 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp @@ -1,4 +1,4 @@ -/* + /* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org @@ -38,61 +38,61 @@ #ifndef IMPL_TRANSFORM_CLOUDS_HPP_ #define IMPL_TRANSFORM_CLOUDS_HPP_ -#include #include -#include +#include #include +#include -template -QList -pcl::cloud_composer::TransformClouds::performTemplatedAction( - const QList& input_data) +template QList +pcl::cloud_composer::TransformClouds::performTemplatedAction (const QList & input_data) { - QList output; - - foreach (const CloudComposerItem* input_item, input_data) { - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - if (!variant.canConvert::Ptr>()) { - qWarning() << "Attempted to cast to template type which does not exist in this " - "item! (input list)"; + QList output; + + foreach (const CloudComposerItem* input_item, input_data) + { + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + if ( ! variant.canConvert ::Ptr> () ) + { + qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; return output; } - if (!transform_map_.contains("AllSelectedClouds") && - !transform_map_.contains(input_item->getId())) { - qCritical() << "No transform found for id " << input_item->getId() - << " in TransformClouds::performTemplatedAction"; + if (!transform_map_.contains ("AllSelectedClouds") && !transform_map_.contains (input_item->getId ())) + { + qCritical () << "No transform found for id "<getId ()<<" in TransformClouds::performTemplatedAction"; return output; } } - - foreach (const CloudComposerItem* input_item, input_data) { - qDebug() << "Transforming cloud " << input_item->getId(); - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - typename PointCloud::Ptr input_cloud = - variant.value::Ptr>(); - + + foreach (const CloudComposerItem* input_item, input_data) + { + qDebug () << "Transforming cloud "<getId (); + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); + Eigen::Matrix4f transform; - if (transform_map_.contains("AllSelectedClouds")) - pcl::visualization::PCLVisualizer::convertToEigenMatrix( - transform_map_.value("AllSelectedClouds"), transform); + if (transform_map_.contains ("AllSelectedClouds")) + pcl::visualization::PCLVisualizer::convertToEigenMatrix (transform_map_.value ("AllSelectedClouds"), transform); else - pcl::visualization::PCLVisualizer::convertToEigenMatrix( - transform_map_.value(input_item->getId()), transform); - - typename PointCloud::Ptr transformed_cloud(new PointCloud); + pcl::visualization::PCLVisualizer::convertToEigenMatrix (transform_map_.value (input_item->getId ()), transform); + + typename PointCloud::Ptr transformed_cloud (new PointCloud); + + transformPointCloud (*input_cloud, *transformed_cloud, transform); + CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(input_item->text (),transformed_cloud); + + output.append (new_cloud_item); + } - transformPointCloud(*input_cloud, *transformed_cloud, transform); - CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate( - input_item->text(), transformed_cloud); + - output.append(new_cloud_item); - } return output; + } -#define PCL_INSTANTIATE_performTemplatedAction(T) \ - template void pcl::cloud_composer::TransformClouds::performTemplatedAction( \ - QList); -#endif // IMPL_TRANSFORM_CLOUDS_HPP_ +#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::TransformClouds::performTemplatedAction (QList ); + + + +#endif //IMPL_TRANSFORM_CLOUDS_HPP_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h index f03ab1e812b..dcf7f78cc42 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h @@ -37,58 +37,65 @@ #pragma once +#include + #include #include -#include - class QItemSelectionModel; class QTreeView; -namespace pcl { -namespace cloud_composer { -/** \brief View class for displaying properties of an item - * \author Jeremie Papon - * \ingroup cloud_composer - */ -class ItemInspector : public QTabWidget { - Q_OBJECT -public: - ItemInspector(QWidget* parent = nullptr); - -public Q_SLOTS: - void - setModel(ProjectModel* new_model); - void - selectionChanged(const QModelIndex& current, const QModelIndex& previous); - void - itemChanged(QStandardItem* item); - -private: - void - createItemWidgets(); - /** \brief Stores the state of the current tree view in item_treestate_map_ */ - void - storeTreeState(); - /** \brief Restores the state of \param model 's view from item_treestate_map_ */ - void - restoreTreeState(); - /** \brief Removes the extra tabs the item might have */ - void - removeTabs(); - /** \brief Refreshes the data shown in the current displayed view widget */ - void - updateView(); - - //! The tree object used to display/edit parameters - QTreeView* parameter_view_; - - ProjectModel* current_project_model_; - PropertiesModel* current_item_properties_model_; - const QItemSelectionModel* current_selection_model_; - QMap itemtype_widget_map; - QMap> item_treestate_map_; -}; - -} // namespace cloud_composer -} // namespace pcl +namespace pcl +{ + namespace cloud_composer + { + /** \brief View class for displaying properties of an item + * \author Jeremie Papon + * \ingroup cloud_composer + */ + class ItemInspector : public QTabWidget + { + Q_OBJECT + public: + ItemInspector (QWidget* parent = nullptr); + + public Q_SLOTS: + void + setModel (ProjectModel* new_model); + void + selectionChanged (const QModelIndex ¤t, const QModelIndex &previous); + void + itemChanged (QStandardItem* item); + + + + private: + void + createItemWidgets (); + /** \brief Stores the state of the current tree view in item_treestate_map_ */ + void + storeTreeState (); + /** \brief Restores the state of \param model 's view from item_treestate_map_ */ + void + restoreTreeState (); + /** \brief Removes the extra tabs the item might have */ + void + removeTabs (); + /** \brief Refreshes the data shown in the current displayed view widget */ + void + updateView (); + + //! The tree object used to display/edit parameters + QTreeView* parameter_view_; + + + ProjectModel* current_project_model_; + PropertiesModel* current_item_properties_model_; + const QItemSelectionModel *current_selection_model_; + QMap itemtype_widget_map; + QMap > item_treestate_map_; + }; + + + } +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h index 422f8e3d512..07f9bc10355 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h @@ -37,133 +37,128 @@ #pragma once -#include -#include #include +#include +#include -static QStringList ITEM_TYPES_STRINGS(QStringList() << "Cloud Composer Item" - << "Cloud Item" - << "Normals Item" - << "FPFH Item"); - -namespace pcl { -namespace cloud_composer { -class PropertiesModel; -namespace ItemDataRole { -enum { - PROPERTIES = Qt::UserRole, - ITEM_ID, - CLOUD_BLOB, - CLOUD_TEMPLATED, - GEOMETRY_HANDLER, - COLOR_HANDLER, - ORIGIN, - ORIENTATION, - KD_TREE_SEARCH -}; -}; -class CloudComposerItem : public QStandardItem { -public: - enum ItemType { - CLOUD_COMPOSER_ITEM = QStandardItem::UserType, - CLOUD_ITEM, - NORMALS_ITEM, - FPFH_ITEM - }; - - CloudComposerItem(const QString& name = "default item"); - CloudComposerItem(const CloudComposerItem& to_copy); - ~CloudComposerItem(); - - inline int - type() const override - { - return CLOUD_COMPOSER_ITEM; - } - - /** \brief Convenience function to get Item's ID String */ - inline QString - getId() const - { - return data(ItemDataRole::ITEM_ID).toString(); - } - - /** \brief Convenience function to get Item's Property Pointer */ - inline PropertiesModel* - getPropertiesModel() const - { - return properties_; - } - - /** \brief Returns all children of item type type*/ - QList - getChildren(ItemType type) const; - - void - addChild(CloudComposerItem* item_arg); - - CloudComposerItem* - clone() const override; - - // /** \brief Convenience function which pulls out a cloud Ptr of type CloudPtrT */ - // template - // CloudPtrT - // getCloudPtr () const; - - /** \brief Paint View function - reimplement in item subclass if it can be displayed - * in PCLVisualizer*/ - virtual void - paintView(pcl::visualization::PCLVisualizer::Ptr vis) const; - - /** \brief Remove from View function - reimplement in item subclass if it can be - * displayed in PCLVisualizer*/ - virtual void - removeFromView(pcl::visualization::PCLVisualizer::Ptr vis) const; - - /** \brief Inspector additional tabs paint function - reimplement in item subclass if - * item has additional tabs to show in Inspector*/ - virtual QMap - getInspectorTabs(); - - /** \brief The property model calls this when a property changes */ - inline void - propertyChanged() - { - emitDataChanged(); - } - - virtual bool - isSanitized() const - { - return false; - } - -protected: - /** \brief Model for storing the properties of the item - pointer kept for convenience - */ - PropertiesModel* properties_; -}; - -/** \brief Templated helper class for converting QVariant to/from pointer classes */ -template -class VPtr { -public: - static T* - asPtr(const QVariant& v) - { - return (static_cast(v.value())); - } +static QStringList ITEM_TYPES_STRINGS(QStringList() + << "Cloud Composer Item" + << "Cloud Item" + << "Normals Item" + << "FPFH Item" + ); - static QVariant - asQVariant(T* ptr) +namespace pcl +{ + namespace cloud_composer { - return (QVariant::fromValue(static_cast(ptr))); + class PropertiesModel; + namespace ItemDataRole + { + enum + { + PROPERTIES = Qt::UserRole, + ITEM_ID, + CLOUD_BLOB, + CLOUD_TEMPLATED, + GEOMETRY_HANDLER, + COLOR_HANDLER, + ORIGIN, + ORIENTATION, + KD_TREE_SEARCH + }; + }; + class CloudComposerItem : public QStandardItem + { + public: + + + enum ItemType + { + CLOUD_COMPOSER_ITEM = QStandardItem::UserType, + CLOUD_ITEM, + NORMALS_ITEM, + FPFH_ITEM + }; + + CloudComposerItem (const QString& name = "default item"); + CloudComposerItem (const CloudComposerItem& to_copy); + ~CloudComposerItem (); + + inline int + type () const override { return CLOUD_COMPOSER_ITEM; } + + /** \brief Convenience function to get Item's ID String */ + inline QString + getId () const { return data (ItemDataRole::ITEM_ID).toString (); } + + /** \brief Convenience function to get Item's Property Pointer */ + inline PropertiesModel* + getPropertiesModel () const { return properties_; } + + /** \brief Returns all children of item type type*/ + QList + getChildren (ItemType type) const; + + void + addChild (CloudComposerItem* item_arg); + + CloudComposerItem* + clone () const override; + + // /** \brief Convenience function which pulls out a cloud Ptr of type CloudPtrT */ + // template + // CloudPtrT + // getCloudPtr () const; + + /** \brief Paint View function - reimplement in item subclass if it can be displayed in PCLVisualizer*/ + virtual void + paintView (pcl::visualization::PCLVisualizer::Ptr vis) const; + + /** \brief Remove from View function - reimplement in item subclass if it can be displayed in PCLVisualizer*/ + virtual void + removeFromView (pcl::visualization::PCLVisualizer::Ptr vis) const; + + /** \brief Inspector additional tabs paint function - reimplement in item subclass if item has additional tabs to show in Inspector*/ + virtual QMap + getInspectorTabs (); + + /** \brief The property model calls this when a property changes */ + inline void + propertyChanged () + { + emitDataChanged (); + } + + virtual bool + isSanitized () const { return false; } + protected: + + /** \brief Model for storing the properties of the item - pointer kept for convenience */ + PropertiesModel* properties_; + + }; + + + + /** \brief Templated helper class for converting QVariant to/from pointer classes */ + template class VPtr + { + public: + static T* asPtr (const QVariant& v) + { + return (static_cast (v.value ())); + } + + static QVariant asQVariant (T* ptr) + { + return (QVariant::fromValue (static_cast(ptr))); + } + }; + } -}; - -} // namespace cloud_composer -} // namespace pcl +} -using ConstItemList = QList; +using ConstItemList = QList; -Q_DECLARE_METATYPE(pcl::cloud_composer::CloudComposerItem); +Q_DECLARE_METATYPE (pcl::cloud_composer::CloudComposerItem); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h index 8e4a6a4b2f5..aabf5aab381 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h @@ -37,171 +37,162 @@ #pragma once +#include + #include -#include -#include -#include -#include + +#include +#include +#include #include #include -#include -#include -#include +#include +#include +#include +#include -#include -// Typedefs to make things sane -using GeometryHandler = - pcl::visualization::PointCloudGeometryHandler; +//Typedefs to make things sane +using GeometryHandler = pcl::visualization::PointCloudGeometryHandler; using ColorHandler = pcl::visualization::PointCloudColorHandler; -namespace pcl { -namespace cloud_composer { -namespace PointTypeFlags { -enum PointType { - NONE = 0, - XYZ = (1 << 0), - RGB = (1 << 1), - RGBA = (1 << 2), - NORMAL = (1 << 3), - HSV = (1 << 4), - AXIS = (1 << 5), -}; -} -class CloudItem : public CloudComposerItem { -public: - // This is needed because we have members which are Vector4f and Quaternionf - PCL_MAKE_ALIGNED_OPERATOR_NEW - - CloudItem(const QString name, - const pcl::PCLPointCloud2::Ptr& cloud_ptr, - const Eigen::Vector4f& origin = Eigen::Vector4f(), - const Eigen::Quaternionf& orientation = Eigen::Quaternionf(), - bool make_templated_cloud = true); - - CloudItem(const CloudItem& to_copy); - - /** \brief This creates a CloudItem from a templated cloud type */ - template - static CloudItem* - createCloudItemFromTemplate(const QString& name, - typename PointCloud::Ptr cloud_ptr); - - /** \brief virtual data getter which calls QStandardItem::data; used to create - * template cloud if not created yet WARNING : This function modifies "this" - it sets - * up the templated type if you request one when it doesn't exist yet! It had to - * remain const because it is virtual, and we need to keep run-time polymorphism - */ - QVariant - data(int role = Qt::UserRole + 1) const override; - - /** \brief Virtual data setter which calls QStandardItem::data; used to ensure that - * template_cloud_set_ is set when a templated cloud is added */ - void - setData(const QVariant& value, int role = Qt::UserRole + 1) override; - - inline int - type() const override - { - return CLOUD_ITEM; - } - - CloudItem* - clone() const override; - - /** \brief Paint View function - puts this cloud item into a PCLVisualizer object*/ - void - paintView(pcl::visualization::PCLVisualizer::Ptr vis) const override; - - /** \brief Remove from View function - removes this cloud from a PCLVisualizer - * object*/ - void - removeFromView(pcl::visualization::PCLVisualizer::Ptr vis) const override; - - /** \brief Initializes and stores a templated PointCloud object with point type - * matching the blob */ - void - setTemplateCloudFromBlob(); - - int - getPointType() const - { - return point_type_; - } - - template - void - printNumPoints() const; - - bool - isSanitized() const override - { - return is_sanitized_; - } - -private: - // These are just stored for convenience - pcl::PCLPointCloud2::Ptr cloud_blob_ptr_; - ColorHandler::ConstPtr color_handler_; - GeometryHandler::ConstPtr geometry_handler_; - - // We keep actual local copies of these. - Eigen::Vector4f origin_; - Eigen::Quaternionf orientation_; - - bool template_cloud_set_; - - // Internal Storage of the templated type of this cloud - int point_type_; - - bool - checkIfFinite(); - - bool is_sanitized_; - - // Helper functions which set the point_type_ based on the current point type - template - inline void - setPointType() +namespace pcl +{ + namespace cloud_composer { - qCritical() << "CloudItem::setPointType for type with no specialization"; - point_type_ = PointTypeFlags::NONE; + namespace PointTypeFlags + { + enum PointType + { + NONE = 0, + XYZ = (1 << 0), + RGB = (1 << 1), + RGBA = (1 << 2), + NORMAL = (1 << 3), + HSV = (1 << 4), + AXIS = (1 << 5), + }; + } + class CloudItem : public CloudComposerItem + { + public: + + //This is needed because we have members which are Vector4f and Quaternionf + PCL_MAKE_ALIGNED_OPERATOR_NEW + + CloudItem (const QString name, + const pcl::PCLPointCloud2::Ptr& cloud_ptr, + const Eigen::Vector4f& origin = Eigen::Vector4f (), + const Eigen::Quaternionf& orientation = Eigen::Quaternionf (), + bool make_templated_cloud = true); + + CloudItem (const CloudItem& to_copy); + + /** \brief This creates a CloudItem from a templated cloud type */ + template + static CloudItem* + createCloudItemFromTemplate (const QString& name, typename PointCloud::Ptr cloud_ptr); + + /** \brief virtual data getter which calls QStandardItem::data; used to create template cloud if not created yet + * WARNING : This function modifies "this" - it sets up the templated type if you request one when it doesn't exist yet! + * It had to remain const because it is virtual, and we need to keep run-time polymorphism + */ + QVariant + data (int role = Qt::UserRole +1) const override; + + /** \brief Virtual data setter which calls QStandardItem::data; used to ensure that template_cloud_set_ is set + * when a templated cloud is added */ + void + setData ( const QVariant & value, int role = Qt::UserRole + 1 ) override; + + inline int + type () const override { return CLOUD_ITEM; } + + CloudItem* + clone () const override; + + /** \brief Paint View function - puts this cloud item into a PCLVisualizer object*/ + void + paintView (pcl::visualization::PCLVisualizer::Ptr vis) const override; + + /** \brief Remove from View function - removes this cloud from a PCLVisualizer object*/ + void + removeFromView (pcl::visualization::PCLVisualizer::Ptr vis) const override; + + /** \brief Initializes and stores a templated PointCloud object with point type matching the blob */ + void + setTemplateCloudFromBlob (); + + int + getPointType () const { return point_type_; } + + template void + printNumPoints () const; + + bool + isSanitized () const override { return is_sanitized_; } + private: + + //These are just stored for convenience + pcl::PCLPointCloud2::Ptr cloud_blob_ptr_; + ColorHandler::ConstPtr color_handler_; + GeometryHandler::ConstPtr geometry_handler_; + + //We keep actual local copies of these. + Eigen::Vector4f origin_; + Eigen::Quaternionf orientation_; + + bool template_cloud_set_; + + //Internal Storage of the templated type of this cloud + int point_type_; + + bool + checkIfFinite (); + + bool is_sanitized_; + + //Helper functions which set the point_type_ based on the current point type + template inline void + setPointType () + { + qCritical () << "CloudItem::setPointType for type with no specialization"; + point_type_ = PointTypeFlags::NONE; + } + + }; + + template <> inline void + CloudItem::setPointType () + { + point_type_ = PointTypeFlags::XYZ; + } + template <> inline void + CloudItem::setPointType () + { + point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGB; + } + template <> inline void + CloudItem::setPointType () + { + point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGBA; + } + + } -}; - -template <> -inline void -CloudItem::setPointType() -{ - point_type_ = PointTypeFlags::XYZ; -} -template <> -inline void -CloudItem::setPointType() -{ - point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGB; } -template <> -inline void -CloudItem::setPointType() -{ - point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGBA; -} - -} // namespace cloud_composer -} // namespace pcl -// Add PointCloud types to QT MetaType System -Q_DECLARE_METATYPE(pcl::PCLPointCloud2::ConstPtr); -Q_DECLARE_METATYPE(GeometryHandler::ConstPtr); -Q_DECLARE_METATYPE(ColorHandler::ConstPtr); -Q_DECLARE_METATYPE(Eigen::Vector4f); -Q_DECLARE_METATYPE(Eigen::Quaternionf); +//Add PointCloud types to QT MetaType System +Q_DECLARE_METATYPE (pcl::PCLPointCloud2::ConstPtr); +Q_DECLARE_METATYPE (GeometryHandler::ConstPtr); +Q_DECLARE_METATYPE (ColorHandler::ConstPtr); +Q_DECLARE_METATYPE (Eigen::Vector4f); +Q_DECLARE_METATYPE (Eigen::Quaternionf); -Q_DECLARE_METATYPE(pcl::search::KdTree::Ptr); -Q_DECLARE_METATYPE(pcl::search::KdTree::Ptr); -Q_DECLARE_METATYPE(pcl::search::KdTree::Ptr); +Q_DECLARE_METATYPE (pcl::search::KdTree::Ptr); +Q_DECLARE_METATYPE (pcl::search::KdTree::Ptr); +Q_DECLARE_METATYPE (pcl::search::KdTree::Ptr); -Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); -Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); -Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); +Q_DECLARE_METATYPE (pcl::PointCloud ::Ptr); +Q_DECLARE_METATYPE (pcl::PointCloud ::Ptr); +Q_DECLARE_METATYPE (pcl::PointCloud ::Ptr); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h index e1241504fa1..5a634272a8a 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h @@ -37,45 +37,47 @@ #pragma once -#include -#include -#include -#include #include +#include -namespace pcl { -namespace cloud_composer { - -class FPFHItem : public CloudComposerItem { -public: - FPFHItem(QString name, - const pcl::PointCloud::Ptr& fpfh_ptr, - double radius); - FPFHItem(const FPFHItem& to_copy); +#include +#include +#include - inline int - type() const override +namespace pcl +{ + namespace cloud_composer { - return FPFH_ITEM; - } - - FPFHItem* - clone() const override; + + class FPFHItem : public CloudComposerItem + { + public: - /** \brief Inspector additional tabs paint function - get the histogram plot widget*/ - QMap - getInspectorTabs() override; + FPFHItem (QString name, + const pcl::PointCloud::Ptr& fpfh_ptr, + double radius); + FPFHItem (const FPFHItem& to_copy); + + inline int + type () const override { return FPFH_ITEM; } -private: - pcl::PointCloud::Ptr fpfh_ptr_; - double radius_; - pcl::visualization::PCLPlotter::Ptr plot_; - PCLQVTKWidget* qvtk_; - QWidget* hist_page_; -}; + FPFHItem* + clone () const override; + + /** \brief Inspector additional tabs paint function - get the histogram plot widget*/ + QMap + getInspectorTabs () override; + + private: + pcl::PointCloud::Ptr fpfh_ptr_; + double radius_; + pcl::visualization::PCLPlotter::Ptr plot_; + PCLQVTKWidget* qvtk_; + QWidget *hist_page_; + }; -} // namespace cloud_composer -} // namespace pcl + } +} -Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); -Q_DECLARE_METATYPE(pcl::PointCloud::ConstPtr); +Q_DECLARE_METATYPE (pcl::PointCloud::Ptr); +Q_DECLARE_METATYPE (pcl::PointCloud::ConstPtr); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h index 40fb5c3cfdc..73c687bd298 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h @@ -37,43 +37,47 @@ #pragma once -#include -#include #include +#include -namespace pcl { -namespace cloud_composer { - -class NormalsItem : public CloudComposerItem { -public: - NormalsItem(QString name, - const pcl::PointCloud::Ptr& normals_ptr, - double radius); - NormalsItem(const NormalsItem& to_copy); +#include - inline int - type() const override +namespace pcl +{ + namespace cloud_composer { - return NORMALS_ITEM; - } - - NormalsItem* - clone() const override; + + class NormalsItem : public CloudComposerItem + { + public: - void - paintView(pcl::visualization::PCLVisualizer::Ptr vis) const override; + NormalsItem (QString name, + const pcl::PointCloud::Ptr& normals_ptr, + double radius); + NormalsItem (const NormalsItem& to_copy); + + inline int + type () const override { return NORMALS_ITEM; } - /** \brief Remove from View function - removes the normal cloud from a PCLVisualizer - * object*/ - void - removeFromView(pcl::visualization::PCLVisualizer::Ptr vis) const override; + NormalsItem* + clone () const override; + + void + paintView (pcl::visualization::PCLVisualizer::Ptr vis) const override; + + /** \brief Remove from View function - removes the normal cloud from a PCLVisualizer object*/ + void + removeFromView (pcl::visualization::PCLVisualizer::Ptr vis) const override; + + private: + pcl::PointCloud::Ptr normals_ptr_; -private: - pcl::PointCloud::Ptr normals_ptr_; -}; - -} // namespace cloud_composer -} // namespace pcl + }; + + + + } +} -Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); -Q_DECLARE_METATYPE(pcl::PointCloud::ConstPtr); +Q_DECLARE_METATYPE (pcl::PointCloud::Ptr); +Q_DECLARE_METATYPE (pcl::PointCloud::ConstPtr); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h index 0e4181c3bcd..af3d7afa95f 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h @@ -39,38 +39,31 @@ #include -namespace pcl { -namespace cloud_composer { -class MergeSelection : public MergeCloudTool { - Q_OBJECT -public: - MergeSelection( - QMap selected_item_index_map, - QObject* parent = nullptr); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override +namespace pcl +{ + namespace cloud_composer { - return "Merge Selection Tool"; - } + class MergeSelection : public MergeCloudTool + { + Q_OBJECT + public: + MergeSelection (QMap selected_item_index_map, QObject* parent = nullptr); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Merge Selection Tool";} + + QList + getSelectedItems () { return selected_item_index_map_.keys ();} + + template QList + performTemplatedAction (const QList & input_data); + + private: + QMap selected_item_index_map_; + }; - QList - getSelectedItems() - { - return selected_item_index_map_.keys(); } - - template - QList - performTemplatedAction(const QList& input_data); - -private: - QMap selected_item_index_map_; -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h index 7bb9d3fac7c..2477b33b525 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h @@ -41,83 +41,73 @@ #include -namespace pcl { -namespace cloud_composer { - -class ClickTrackballStyleInteractor : public vtkInteractorStyleTrackballActor { -public: - static ClickTrackballStyleInteractor* - New(); - vtkTypeMacro(ClickTrackballStyleInteractor, vtkInteractorStyleTrackballActor); - - ClickTrackballStyleInteractor(); - - /** \brief Pass a pointer to the actor map - * \param[in] actors the actor map that will be used with this style - */ - inline void - setCloudActorMap(const pcl::visualization::CloudActorMapPtr& actors) - { - actors_ = actors; - } - - /** \brief Get the cloud actor map pointer. */ - inline pcl::visualization::CloudActorMapPtr - getCloudActorMap() const - { - return (actors_); - } - - /** \brief Pass a set of renderers to the interactor style. - * \param[in] rens the vtkRendererCollection to use - */ - void - setRendererCollection(vtkSmartPointer& rens) - { - renderers_ = rens; - } - - /** \brief Function called on left mouse button release, ie, end of rectangular drag - */ - void - OnLeftButtonDown() override; - - /** \brief Function called on left mouse button release, ie, end of rectangular drag - */ - void - OnLeftButtonUp() override; - - void - OnRightButtonDown() override; - - void - OnRightButtonUp() override; - - /** \brief Event emitted once a valid selection has been made */ - int manipulation_complete_event_; - - inline void - setProjectModel(ProjectModel* model) +namespace pcl +{ + namespace cloud_composer { - model_ = model; + + class ClickTrackballStyleInteractor : public vtkInteractorStyleTrackballActor + { + public: + static ClickTrackballStyleInteractor* New(); + vtkTypeMacro(ClickTrackballStyleInteractor,vtkInteractorStyleTrackballActor); + + ClickTrackballStyleInteractor (); + + /** \brief Pass a pointer to the actor map + * \param[in] actors the actor map that will be used with this style + */ + inline void + setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; } + + /** \brief Get the cloud actor map pointer. */ + inline pcl::visualization::CloudActorMapPtr + getCloudActorMap () const { return (actors_); } + + /** \brief Pass a set of renderers to the interactor style. + * \param[in] rens the vtkRendererCollection to use + */ + void + setRendererCollection (vtkSmartPointer &rens) { renderers_ = rens; } + + /** \brief Function called on left mouse button release, ie, end of rectangular drag */ + void + OnLeftButtonDown () override; + + /** \brief Function called on left mouse button release, ie, end of rectangular drag */ + void + OnLeftButtonUp () override; + + void + OnRightButtonDown () override; + + void + OnRightButtonUp () override; + + /** \brief Event emitted once a valid selection has been made */ + int manipulation_complete_event_; + + inline void + setProjectModel (ProjectModel* model) { model_ = model; } + private: + + + /** \brief Actor map stored internally. */ + pcl::visualization::CloudActorMapPtr actors_; + + /** \brief Collection of vtkRenderers stored internally. */ + vtkSmartPointer renderers_; + + /** \brief Internal Pointer to Project Model */ + ProjectModel* model_; + + vtkSmartPointer start_matrix_; + vtkSmartPointer end_matrix_; + + vtkSmartPointer transform_; + + }; + } - -private: - /** \brief Actor map stored internally. */ - pcl::visualization::CloudActorMapPtr actors_; - - /** \brief Collection of vtkRenderers stored internally. */ - vtkSmartPointer renderers_; - - /** \brief Internal Pointer to Project Model */ - ProjectModel* model_; - - vtkSmartPointer start_matrix_; - vtkSmartPointer end_matrix_; - - vtkSmartPointer transform_; -}; - -} // namespace cloud_composer - -} // namespace pcl + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h index f7905862197..1f4fcd17544 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h @@ -37,122 +37,118 @@ #pragma once +#include + +#include #include #include -#include #include -#include - +#include #include -#include -#include #include -#include #include -#include +#include +#include +#include class QVTKWidget; -namespace pcl { -namespace cloud_composer { -namespace interactor_styles { -enum INTERACTOR_STYLES { - PCL_VISUALIZER = 0, - RECTANGULAR_FRUSTUM, - SELECTED_TRACKBALL, - CLICK_TRACKBALL -}; -} -namespace interactor_events { -enum { - SELECTION_COMPLETE_EVENT = vtkCommand::UserEvent + 1, - MANIPULATION_COMPLETE_EVENT -}; -}; - -class RectangularFrustumSelector; -class SelectedTrackballStyleInteractor; -class ClickTrackballStyleInteractor; -class ProjectModel; - -class InteractorStyleSwitch : public vtkInteractorStyle { -public: - static InteractorStyleSwitch* - New(); - vtkTypeMacro(InteractorStyleSwitch, vtkInteractorStyle); - - InteractorStyleSwitch(); - - void - SetInteractor(vtkRenderWindowInteractor* iren) override; - - vtkGetObjectMacro(current_style_, vtkInteractorStyle); - - void - initializeInteractorStyles(pcl::visualization::PCLVisualizer::Ptr vis, - ProjectModel* model); - - inline void - setQVTKWidget(QVTKWidget* qvtk) - { - qvtk_ = qvtk; - } - - void - setCurrentInteractorStyle(interactor_styles::INTERACTOR_STYLES interactor_style); - - // vtkSmartPointer - // getPCLVisInteractorStyle () { return pcl_vis_style_; } - - inline vtkSmartPointer - getInteractorStyle(const interactor_styles::INTERACTOR_STYLES interactor_style) const +namespace pcl +{ + namespace cloud_composer { - return name_to_style_map_.value(interactor_style); + namespace interactor_styles + { + enum INTERACTOR_STYLES + { + PCL_VISUALIZER = 0, + RECTANGULAR_FRUSTUM, + SELECTED_TRACKBALL, + CLICK_TRACKBALL + }; + } + namespace interactor_events + { + enum + { + SELECTION_COMPLETE_EVENT = vtkCommand::UserEvent + 1, + MANIPULATION_COMPLETE_EVENT + }; + }; + + class RectangularFrustumSelector; + class SelectedTrackballStyleInteractor; + class ClickTrackballStyleInteractor; + class ProjectModel; + + class InteractorStyleSwitch : public vtkInteractorStyle + { + public: + static InteractorStyleSwitch *New(); + vtkTypeMacro(InteractorStyleSwitch, vtkInteractorStyle); + + InteractorStyleSwitch(); + + void + SetInteractor(vtkRenderWindowInteractor *iren) override; + + vtkGetObjectMacro(current_style_, vtkInteractorStyle); + + void + initializeInteractorStyles (pcl::visualization::PCLVisualizer::Ptr vis, ProjectModel* model); + + inline void + setQVTKWidget (QVTKWidget* qvtk) { qvtk_ = qvtk; } + + void + setCurrentInteractorStyle (interactor_styles::INTERACTOR_STYLES interactor_style); + + // vtkSmartPointer + // getPCLVisInteractorStyle () { return pcl_vis_style_; } + + inline vtkSmartPointer + getInteractorStyle (const interactor_styles::INTERACTOR_STYLES interactor_style) const + { return name_to_style_map_.value (interactor_style); } + + + void SetDefaultRenderer(vtkRenderer*) override; + + void SetCurrentRenderer(vtkRenderer*) override; + + void + OnLeave () override; + + protected: + void + setCurrentStyle(); + + QMap > name_to_style_map_; + + + vtkRenderWindowInteractor* render_window_interactor_; + vtkSmartPointer rens_; + + vtkInteractorStyle* current_style_; + vtkSmartPointer pcl_vis_style_; + vtkSmartPointer rectangular_frustum_selector_; + + vtkSmartPointer selected_trackball_interactor_style_; + + vtkSmartPointer click_trackball_interactor_style_; + vtkSmartPointer area_picker_; + vtkSmartPointer point_picker_; + + /** \brief Internal pointer to QVTKWidget that this Switch works with */ + QVTKWidget* qvtk_; + /** \brief Internal pointer to PCLVisualizer that this Switch works with */ + pcl::visualization::PCLVisualizer::Ptr vis_; + private: + InteractorStyleSwitch(const InteractorStyleSwitch&); // Not implemented. + void operator=(const InteractorStyleSwitch&); // Not implemented. + ProjectModel* project_model_; + }; + } - - void - SetDefaultRenderer(vtkRenderer*) override; - - void - SetCurrentRenderer(vtkRenderer*) override; - - void - OnLeave() override; - -protected: - void - setCurrentStyle(); - - QMap> - name_to_style_map_; - - vtkRenderWindowInteractor* render_window_interactor_; - vtkSmartPointer rens_; - - vtkInteractorStyle* current_style_; - vtkSmartPointer pcl_vis_style_; - vtkSmartPointer rectangular_frustum_selector_; - - vtkSmartPointer - selected_trackball_interactor_style_; - - vtkSmartPointer click_trackball_interactor_style_; - vtkSmartPointer area_picker_; - vtkSmartPointer point_picker_; - - /** \brief Internal pointer to QVTKWidget that this Switch works with */ - QVTKWidget* qvtk_; - /** \brief Internal pointer to PCLVisualizer that this Switch works with */ - pcl::visualization::PCLVisualizer::Ptr vis_; - -private: - InteractorStyleSwitch(const InteractorStyleSwitch&); // Not implemented. - void - operator=(const InteractorStyleSwitch&); // Not implemented. - ProjectModel* project_model_; -}; - -} // namespace cloud_composer - -} // namespace pcl + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h index af1f09e875a..73efe79c25d 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h @@ -39,36 +39,35 @@ #include -namespace pcl { -namespace cloud_composer { - -class ManipulationEvent { - -public: - ManipulationEvent() {} - - void - addManipulation(const QString& id, - const vtkSmartPointer& start, - const vtkSmartPointer& end); - - inline QMap> - getStartMap() const - { - return id_start_map_; - } - - inline QMap> - getEndMap() const +namespace pcl +{ + namespace cloud_composer { - return id_end_map_; + + + class ManipulationEvent + { + + public: + ManipulationEvent () + {} + + void + addManipulation (const QString& id, const vtkSmartPointer& start, const vtkSmartPointer& end); + + inline QMap > + getStartMap () const { return id_start_map_;} + + inline QMap > + getEndMap () const { return id_end_map_;} + + + private: + QMap > id_start_map_; + QMap > id_end_map_; + + }; + } - -private: - QMap> id_start_map_; - QMap> id_end_map_; -}; - -} // namespace cloud_composer - -} // namespace pcl + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h index 6ad55d6eb95..bed9b5d570a 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h @@ -39,62 +39,55 @@ #include -#include -#include #include +#include +#include -namespace pcl { -namespace cloud_composer { - -class RectangularFrustumSelector : public vtkInteractorStyleRubberBandPick { -public: - static RectangularFrustumSelector* - New(); - vtkTypeMacro(RectangularFrustumSelector, vtkInteractorStyleRubberBandPick); - - RectangularFrustumSelector(); - - /** \brief Pass a pointer to the actor map - * \param[in] actors the actor map that will be used with this style - */ - inline void - setCloudActorMap(const pcl::visualization::CloudActorMapPtr& actors) - { - actors_ = actors; - } - - /** \brief Get the cloud actor map pointer. */ - inline pcl::visualization::CloudActorMapPtr - getCloudActorMap() const - { - return (actors_); - } - - /** \brief Pass a set of renderers to the interactor style. - * \param[in] rens the vtkRendererCollection to use - */ - void - setRendererCollection(vtkSmartPointer& rens) +namespace pcl +{ + namespace cloud_composer { - renderers_ = rens; - } + + class RectangularFrustumSelector : public vtkInteractorStyleRubberBandPick + { + public: + static RectangularFrustumSelector* New(); + vtkTypeMacro(RectangularFrustumSelector,vtkInteractorStyleRubberBandPick); + + RectangularFrustumSelector (); + + /** \brief Pass a pointer to the actor map + * \param[in] actors the actor map that will be used with this style + */ + inline void + setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; } - /** \brief Function called on left mouse button release, ie, end of rectangular drag - */ - void - OnLeftButtonUp() override; + /** \brief Get the cloud actor map pointer. */ + inline pcl::visualization::CloudActorMapPtr + getCloudActorMap () const { return (actors_); } - /** \brief Event emitted once a valid selection has been made */ - int selection_complete_event_; + /** \brief Pass a set of renderers to the interactor style. + * \param[in] rens the vtkRendererCollection to use + */ + void + setRendererCollection (vtkSmartPointer &rens) { renderers_ = rens; } -private: - /** \brief Actor map stored internally. */ - pcl::visualization::CloudActorMapPtr actors_; + /** \brief Function called on left mouse button release, ie, end of rectangular drag */ + void + OnLeftButtonUp () override; - /** \brief Collection of vtkRenderers stored internally. */ - vtkSmartPointer renderers_; -}; + /** \brief Event emitted once a valid selection has been made */ + int selection_complete_event_; + private: -} // namespace cloud_composer - -} // namespace pcl + + /** \brief Actor map stored internally. */ + pcl::visualization::CloudActorMapPtr actors_; + + /** \brief Collection of vtkRenderers stored internally. */ + vtkSmartPointer renderers_; + }; + + } + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h index 9133b19e2b5..3a9a20b32bc 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h @@ -38,94 +38,85 @@ #include #include -#include #include +#include -namespace pcl { -namespace cloud_composer { - -class SelectedTrackballStyleInteractor : public vtkInteractorStyleTrackballActor { -public: - static SelectedTrackballStyleInteractor* - New(); - vtkTypeMacro(SelectedTrackballStyleInteractor, vtkInteractorStyleTrackballActor); - - SelectedTrackballStyleInteractor(); - - /** \brief Pass a pointer to the actor map - * \param[in] actors the actor map that will be used with this style - */ - inline void - setCloudActorMap(const pcl::visualization::CloudActorMapPtr& actors) - { - actors_ = actors; - } - - /** \brief Get the cloud actor map pointer. */ - inline pcl::visualization::CloudActorMapPtr - getCloudActorMap() const - { - return (actors_); - } - - /** \brief Pass a set of renderers to the interactor style. - * \param[in] rens the vtkRendererCollection to use - */ - void - setRendererCollection(vtkSmartPointer& rens) - { - renderers_ = rens; - } - - /** \brief Function called on left mouse button click, ie, beginning of trackball */ - void - OnLeftButtonDown() override; - - void - OnRightButtonDown() override; - - /** \brief Function called on left mouse button release, ie, end of trackball*/ - void - OnLeftButtonUp() override; - - void - OnRightButtonUp() override; - - void - Rotate() override; - void - Spin() override; - void - Pan() override; - void - UniformScale() override; - - /** \brief Event emitted once a valid selection has been made */ - int manipulation_complete_event_; - - inline void - setProjectModel(ProjectModel* model) +namespace pcl +{ + namespace cloud_composer { - model_ = model; + + class SelectedTrackballStyleInteractor : public vtkInteractorStyleTrackballActor + { + public: + static SelectedTrackballStyleInteractor* New(); + vtkTypeMacro(SelectedTrackballStyleInteractor,vtkInteractorStyleTrackballActor); + + SelectedTrackballStyleInteractor (); + + /** \brief Pass a pointer to the actor map + * \param[in] actors the actor map that will be used with this style + */ + inline void + setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; } + + /** \brief Get the cloud actor map pointer. */ + inline pcl::visualization::CloudActorMapPtr + getCloudActorMap () const { return (actors_); } + + /** \brief Pass a set of renderers to the interactor style. + * \param[in] rens the vtkRendererCollection to use + */ + void + setRendererCollection (vtkSmartPointer &rens) { renderers_ = rens; } + + /** \brief Function called on left mouse button click, ie, beginning of trackball */ + void + OnLeftButtonDown () override; + + void + OnRightButtonDown () override; + + /** \brief Function called on left mouse button release, ie, end of trackball*/ + void + OnLeftButtonUp () override; + + void + OnRightButtonUp () override; + + void + Rotate() override; + void + Spin() override; + void + Pan() override; + void + UniformScale() override; + + /** \brief Event emitted once a valid selection has been made */ + int manipulation_complete_event_; + + inline void + setProjectModel (ProjectModel* model) { model_ = model; } + private: + + void + setSelectedActors (); + + /** \brief Actor map stored internally. */ + pcl::visualization::CloudActorMapPtr actors_; + + /** \brief Collection of vtkRenderers stored internally. */ + vtkSmartPointer renderers_; + + /** \brief Internal Pointer to Project Model */ + ProjectModel* model_; + + QMap > start_matrix_map_; + QMap selected_actors_map_; + + }; + } - -private: - void - setSelectedActors(); - - /** \brief Actor map stored internally. */ - pcl::visualization::CloudActorMapPtr actors_; - - /** \brief Collection of vtkRenderers stored internally. */ - vtkSmartPointer renderers_; - - /** \brief Internal Pointer to Project Model */ - ProjectModel* model_; - - QMap> start_matrix_map_; - QMap selected_actors_map_; -}; - -} // namespace cloud_composer - -} // namespace pcl + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h index e32d819afae..0e40fcb5e24 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h @@ -39,68 +39,57 @@ #include +#include +#include #include #include -#include #include -#include - -namespace pcl { -namespace cloud_composer { -class RectangularFrustumSelector; - -class SelectionEvent { - -public: - SelectionEvent(vtkSmartPointer selected_points, - vtkSmartPointer selected_actor, - vtkSmartPointer selected_mapper, - QMap id_selected_map, - vtkRenderer* renderer) - : selected_points_(std::move(selected_points)) - , selected_actor_(std::move(selected_actor)) - , selected_mapper_(std::move(selected_mapper)) - , id_selected_data_map_(std::move(id_selected_map)) - , renderer_(renderer) - {} - - ~SelectionEvent(); - - inline vtkIdType - getNumPoints() const - { - return selected_points_->GetNumberOfPoints(); - } - vtkSmartPointer - getPolyData() const +namespace pcl +{ + namespace cloud_composer { - return selected_points_; + class RectangularFrustumSelector; + + class SelectionEvent + { + + public: + SelectionEvent (vtkSmartPointer selected_points, vtkSmartPointer selected_actor, vtkSmartPointer selected_mapper, QMap < QString, vtkPolyData* > id_selected_map, vtkRenderer* renderer) + : selected_points_ (std::move(selected_points)) + , selected_actor_ (std::move(selected_actor)) + , selected_mapper_ (std::move(selected_mapper)) + , id_selected_data_map_ (std::move(id_selected_map)) + , renderer_ (renderer) + {} + + ~SelectionEvent (); + + inline vtkIdType + getNumPoints () const { return selected_points_->GetNumberOfPoints (); } + + vtkSmartPointer + getPolyData () const { return selected_points_; } + + vtkSmartPointer + getMapper () const { return selected_mapper_; } + + vtkSmartPointer + getActor () const { return selected_actor_; } + + void + findIndicesInItem (CloudItem* cloud_item, const pcl::PointIndices::Ptr& indices); + + private: + + vtkSmartPointer selected_points_; + vtkSmartPointer selected_actor_; + vtkSmartPointer selected_mapper_; + QMap < QString, vtkPolyData* > id_selected_data_map_; + vtkRenderer* renderer_; + + }; + } - - vtkSmartPointer - getMapper() const - { - return selected_mapper_; - } - - vtkSmartPointer - getActor() const - { - return selected_actor_; - } - - void - findIndicesInItem(CloudItem* cloud_item, const pcl::PointIndices::Ptr& indices); - -private: - vtkSmartPointer selected_points_; - vtkSmartPointer selected_actor_; - vtkSmartPointer selected_mapper_; - QMap id_selected_data_map_; - vtkRenderer* renderer_; -}; - -} // namespace cloud_composer - -} // namespace pcl + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h index 5394e2f1ec5..d4b30999923 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h @@ -37,179 +37,175 @@ #pragma once +#include +#include + +#include + #include -#include +#include #include -#include -#include +#include #include -#include -#include - class QItemSelection; class QItemSelectionModel; -namespace pcl { -namespace cloud_composer { -class CloudCommand; -class AbstractTool; -class WorkQueue; -class CloudComposerItem; -class CloudView; -class InteractorStyleSwitch; - -class ProjectModel : public QStandardItemModel { - Q_OBJECT - -public: - ProjectModel(QObject* parent = nullptr); - ProjectModel(const ProjectModel& to_copy); - ~ProjectModel(); - - ProjectModel(QString project_name, QObject* parent = nullptr); - - inline const QString - getName() - { - return horizontalHeaderItem(0)->text(); - } - - inline QUndoStack* - getUndoStack() +namespace pcl +{ + namespace cloud_composer { - return undo_stack_; + class CloudCommand; + class AbstractTool; + class WorkQueue; + class CloudComposerItem; + class CloudView; + class InteractorStyleSwitch; + + class ProjectModel : public QStandardItemModel + { + Q_OBJECT + + public: + ProjectModel (QObject *parent = nullptr); + ProjectModel (const ProjectModel& to_copy); + ~ProjectModel (); + + ProjectModel (QString project_name, QObject *parent = nullptr); + + inline const QString + getName () { return horizontalHeaderItem (0)->text (); } + + inline QUndoStack* + getUndoStack () { return undo_stack_; } + + /** \brief Sets the name of the project using the horizontalHeaderItem */ + void + setName (const QString& new_name); + + /** \brief Returns the selection model which is used for this project */ + inline QItemSelectionModel* + getSelectionModel () + { + return selection_model_; + } + + + + /** \brief Takes tool object issues signal to work queue to take control of it */ + void + enqueueToolAction (AbstractTool* tool); + + /** \brief Helper function which inserts the item into this model and makes connections for properties */ + void + insertNewCloudComposerItem (CloudComposerItem* new_item, QStandardItem* parent_item); + + /** \brief Sets the CloudView that this project is rendering in */ + void + setCloudView (CloudView* view); + + /** \brief This sets the selection for points which have been selected in the QVTKWindow */ + void + setPointSelection (const std::shared_ptr& selected_event); + + /** \brief This is invoked to perform the manipulations specified on the model */ + void + manipulateClouds (const std::shared_ptr& manip_event); + public Q_SLOTS: + void + commandCompleted (CloudCommand* command); + + void + clearSelection (); + + void + deleteSelectedItems (); + + /** \brief Loads from file and inserts a new pointcloud into the model */ + void + insertNewCloudFromFile (); + + /** \brief Loads from rgb and depth file and inserts a new pointcloud into the model */ + void + insertNewCloudFromRGBandDepth (); + + /** \brief Opens a file dialog and saves selected cloud to file */ + void + saveSelectedCloudToFile (); + + /** \brief This emits all the state signals, which updates the GUI action button status (enabled/disabled)" */ + void + emitAllStateSignals (); + + /** \brief This sets whether the CloudView for this project shows axes */ + void + setAxisVisibility (bool visible); + + /** \brief Slot called when the mouse style selected in the GUI changes */ + void + mouseStyleChanged (QAction* new_style_action); + + /** \brief Slot Called whenever the item selection_model_ changes */ + void + itemSelectionChanged ( const QItemSelection &, const QItemSelection &); + + /** \brief Creates a new cloud from the selected items and points */ + void + createNewCloudFromSelection (); + + /** \brief Selects all items in the model */ + void + selectAllItems (QStandardItem* item = nullptr ); + Q_SIGNALS: + void + enqueueNewAction (AbstractTool* tool, ConstItemList data); + + /** \brief Catch-all signal emitted whenever the model changes */ + void + modelChanged (); + + void + axisVisible (const bool axis_visible); + + void + deleteAvailable (bool can_delete); + + void + newCloudFromSelectionAvailable (bool can_create); + + void + mouseStyleState (interactor_styles::INTERACTOR_STYLES); + + private: + /** \brief Checks to see if selection contains only CloudItem s */ + bool + onlyCloudItemsSelected (); + + QItemSelectionModel* selection_model_; + QMap name_to_type_map_; + QUndoStack* undo_stack_; + WorkQueue* work_queue_; + QThread* work_thread_; + CloudView* cloud_view_; + + /** \brief Stores last directory used in file read/write operations */ + QDir last_directory_; + + //Variables for toggle action status + bool axis_visible_; + QMap selected_style_map_; + /** \brief Internal helper function for updating map */ + void + setSelectedStyle (interactor_styles::INTERACTOR_STYLES style); + + /** \brief Internal pointer storing the last selection event arriving from vtk */ + std::shared_ptr selection_event_; + /** \brief Map which stores which cloud items and indices were selected in the selection_event_ */ + QMap selected_item_index_map_; + }; } +} - /** \brief Sets the name of the project using the horizontalHeaderItem */ - void - setName(const QString& new_name); - - /** \brief Returns the selection model which is used for this project */ - inline QItemSelectionModel* - getSelectionModel() - { - return selection_model_; - } - - /** \brief Takes tool object issues signal to work queue to take control of it */ - void - enqueueToolAction(AbstractTool* tool); - - /** \brief Helper function which inserts the item into this model and makes - * connections for properties */ - void - insertNewCloudComposerItem(CloudComposerItem* new_item, QStandardItem* parent_item); - - /** \brief Sets the CloudView that this project is rendering in */ - void - setCloudView(CloudView* view); - - /** \brief This sets the selection for points which have been selected in the - * QVTKWindow */ - void - setPointSelection(const std::shared_ptr& selected_event); - - /** \brief This is invoked to perform the manipulations specified on the model */ - void - manipulateClouds(const std::shared_ptr& manip_event); -public Q_SLOTS: - void - commandCompleted(CloudCommand* command); - - void - clearSelection(); - - void - deleteSelectedItems(); - - /** \brief Loads from file and inserts a new pointcloud into the model */ - void - insertNewCloudFromFile(); - - /** \brief Loads from rgb and depth file and inserts a new pointcloud into the model - */ - void - insertNewCloudFromRGBandDepth(); - - /** \brief Opens a file dialog and saves selected cloud to file */ - void - saveSelectedCloudToFile(); - - /** \brief This emits all the state signals, which updates the GUI action button - * status (enabled/disabled)" */ - void - emitAllStateSignals(); - - /** \brief This sets whether the CloudView for this project shows axes */ - void - setAxisVisibility(bool visible); - - /** \brief Slot called when the mouse style selected in the GUI changes */ - void - mouseStyleChanged(QAction* new_style_action); - - /** \brief Slot Called whenever the item selection_model_ changes */ - void - itemSelectionChanged(const QItemSelection&, const QItemSelection&); - - /** \brief Creates a new cloud from the selected items and points */ - void - createNewCloudFromSelection(); - - /** \brief Selects all items in the model */ - void - selectAllItems(QStandardItem* item = nullptr); -Q_SIGNALS: - void - enqueueNewAction(AbstractTool* tool, ConstItemList data); - - /** \brief Catch-all signal emitted whenever the model changes */ - void - modelChanged(); - - void - axisVisible(const bool axis_visible); - - void - deleteAvailable(bool can_delete); - - void - newCloudFromSelectionAvailable(bool can_create); - - void mouseStyleState(interactor_styles::INTERACTOR_STYLES); - -private: - /** \brief Checks to see if selection contains only CloudItem s */ - bool - onlyCloudItemsSelected(); - - QItemSelectionModel* selection_model_; - QMap name_to_type_map_; - QUndoStack* undo_stack_; - WorkQueue* work_queue_; - QThread* work_thread_; - CloudView* cloud_view_; - - /** \brief Stores last directory used in file read/write operations */ - QDir last_directory_; - - // Variables for toggle action status - bool axis_visible_; - QMap selected_style_map_; - /** \brief Internal helper function for updating map */ - void - setSelectedStyle(interactor_styles::INTERACTOR_STYLES style); - - /** \brief Internal pointer storing the last selection event arriving from vtk */ - std::shared_ptr selection_event_; - /** \brief Map which stores which cloud items and indices were selected in the - * selection_event_ */ - QMap selected_item_index_map_; -}; -} // namespace cloud_composer -} // namespace pcl - -Q_DECLARE_METATYPE(pcl::cloud_composer::ProjectModel); -Q_DECLARE_METATYPE(pcl::cloud_composer::interactor_styles::INTERACTOR_STYLES); +Q_DECLARE_METATYPE (pcl::cloud_composer::ProjectModel); +Q_DECLARE_METATYPE (pcl::cloud_composer::interactor_styles::INTERACTOR_STYLES); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h index a4747ca42a5..57460d14062 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h @@ -39,50 +39,52 @@ #include -namespace pcl { -namespace cloud_composer { -class CloudComposerItem; -class PropertiesModel : public QStandardItemModel { - Q_OBJECT -public: - /** \brief Constructor used for tool parameters */ - PropertiesModel(QObject* parent = nullptr); - /** \brief Constructor used for item parameters */ - PropertiesModel(CloudComposerItem* parent_item, QObject* parent = nullptr); - PropertiesModel(const PropertiesModel& to_copy); +namespace pcl +{ + namespace cloud_composer + { + class CloudComposerItem; + class PropertiesModel : public QStandardItemModel + { + Q_OBJECT + public: + + /** \brief Constructor used for tool parameters */ + PropertiesModel (QObject *parent = nullptr); + /** \brief Constructor used for item parameters */ + PropertiesModel (CloudComposerItem* parent_item, QObject *parent = nullptr); + PropertiesModel (const PropertiesModel& to_copy); + + /** \brief Helper function for adding a new property */ + void + addProperty (const QString& prop_name, const QVariant& value, const Qt::ItemFlags flags = Qt::ItemIsSelectable, const QString& category = ""); + + /** \brief Helper function for adding a new property category */ + void + addCategory (const QString& category_name); + + /** \brief Helper function to get a property */ + QVariant + getProperty (const QString& prop_name) const; + + void + copyProperties (const PropertiesModel* to_copy); + + public Q_SLOTS: + void + propertyChanged (QStandardItem* property_item); + + Q_SIGNALS: + void + propertyChanged (const QStandardItem* property_item, const CloudComposerItem* parent_item_); + + + private: + CloudComposerItem* parent_item_; + + }; + } +} - /** \brief Helper function for adding a new property */ - void - addProperty(const QString& prop_name, - const QVariant& value, - const Qt::ItemFlags flags = Qt::ItemIsSelectable, - const QString& category = ""); - - /** \brief Helper function for adding a new property category */ - void - addCategory(const QString& category_name); - - /** \brief Helper function to get a property */ - QVariant - getProperty(const QString& prop_name) const; - - void - copyProperties(const PropertiesModel* to_copy); - -public Q_SLOTS: - void - propertyChanged(QStandardItem* property_item); - -Q_SIGNALS: - void - propertyChanged(const QStandardItem* property_item, - const CloudComposerItem* parent_item_); - -private: - CloudComposerItem* parent_item_; -}; -} // namespace cloud_composer -} // namespace pcl - -Q_DECLARE_METATYPE(pcl::cloud_composer::PropertiesModel); -Q_DECLARE_METATYPE(pcl::cloud_composer::PropertiesModel*); +Q_DECLARE_METATYPE (pcl::cloud_composer::PropertiesModel); +Q_DECLARE_METATYPE (pcl::cloud_composer::PropertiesModel*); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h index 4e27838b25a..c8a5224f524 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h @@ -1,12 +1,12 @@ /* * Software License Agreement (BSD License) * - * + * * Class to multiplex signal and slot connections. Qt 3 code from: * http://doc.trolltech.com/qq/qq08-action-multiplexer.html. * Converted to Qt 4 by a.somers@rathenau.nl. - * Modified for use in cloud_composer by jpapon@gmail.com - * + * Modified for use in cloud_composer by jpapon@gmail.com + * * Point Cloud Library (PCL) - www.pointclouds.org * * All rights reserved. @@ -46,105 +46,106 @@ #include #include -namespace pcl { -namespace cloud_composer { -class SignalMultiplexer : public QObject { - Q_OBJECT - -public: - SignalMultiplexer(QObject* parent = nullptr); - - /** - Use this connect function instead of QObject::connect() to connect - an actions activation signal to the receiving, multiplexed object. - - @param sender the sending action or object - @param signal the signal in the sender object that is connected to - @param slot the slot in the receiving object that is set through @ref - setCurrentObject that the signal should be connected to. - - @see connect(const char *signal, QObject *receiver, const char *slot) - @see disconnect(QObject *sender, const char *signal, const char *slot) - */ - void - connect(QObject* sender, const char* signal, const char* slot); - - /** - Disconnects a signal connection from a sending object to a multiplexed - receiving object. - @see connect(const char *signal, QObject *receiver, const char *slot) - */ - bool - disconnect(QObject* sender, const char* signal, const char* slot); - - /** - Use this connect function instead of QObject::connect() to connect - a multiplexed object's (status) signal to an action object's slot. - - @param signal the signal in the multiplexed sender object that is set through - @ref setCurrentObject that the connection should be from - @param receiver the receiving action or object - @param slot the slot in the receiving object - - @see connect(QObject *sender, const char *signal, const char *slot) - @see disconnect(const char *signal, QObject *receiver, const char *slot) - */ - void - connect(const char* signal, QObject* receiver, const char* slot); - - /** - Disconnects a signal from a multiplexed object to a receiving (action) - object. - @see connect(const char *signal, QObject *receiver, const char *slot) - */ - bool - disconnect(const char* signal, QObject* receiver, const char* slot); - - /** - @returns the object the connections are currently made with. - */ - QObject* - currentObject() const +namespace pcl +{ + namespace cloud_composer { - return object; + class SignalMultiplexer : public QObject + { + Q_OBJECT + + public: + SignalMultiplexer(QObject *parent = nullptr); + + /** + Use this connect function instead of QObject::connect() to connect + an actions activation signal to the receiving, multiplexed object. + + @param sender the sending action or object + @param signal the signal in the sender object that is connected to + @param slot the slot in the receiving object that is set through @ref + setCurrentObject that the signal should be connected to. + + @see connect(const char *signal, QObject *receiver, const char *slot) + @see disconnect(QObject *sender, const char *signal, const char *slot) + */ + void + connect (QObject *sender, const char *signal, const char *slot); + + /** + Disconnects a signal connection from a sending object to a multiplexed + receiving object. + @see connect(const char *signal, QObject *receiver, const char *slot) + */ + bool + disconnect (QObject *sender, const char *signal, const char *slot); + + /** + Use this connect function instead of QObject::connect() to connect + a multiplexed object's (status) signal to an action object's slot. + + @param signal the signal in the multiplexed sender object that is set through + @ref setCurrentObject that the connection should be from + @param receiver the receiving action or object + @param slot the slot in the receiving object + + @see connect(QObject *sender, const char *signal, const char *slot) + @see disconnect(const char *signal, QObject *receiver, const char *slot) + */ + void + connect (const char *signal, QObject *receiver, const char *slot); + + /** + Disconnects a signal from a multiplexed object to a receiving (action) + object. + @see connect(const char *signal, QObject *receiver, const char *slot) + */ + bool + disconnect (const char *signal, QObject *receiver, const char *slot); + + /** + @returns the object the connections are currently made with. + */ + QObject + *currentObject () const { return object; } + + public Q_SLOTS: + /** + Sets the current object the signals that are managed by the + SignalMultiplexer instance should be connected to. Any connections + of these signals to the previous object will be disconnected. + After the connections are hooked to the new object, the + @ref currentObjectChanged signal will be emitted. + + @param newObject the new object that the signals should be connected to + */ + void + setCurrentObject (QObject *newObject); + + Q_SIGNALS: + /** + Emitted when a new object is set to receive the signals managed by + this SignalMultiplexer instance. + */ + void + currentObjectChanged (QObject* newObject); + + private: + struct Connection + { + QPointer sender; + QPointer receiver; + const char *signal; + const char *slot; + }; + + void + connect (const Connection &conn); + void + disconnect (const Connection &conn); + + QPointer object; + QList connections; + }; } - -public Q_SLOTS: - /** - Sets the current object the signals that are managed by the - SignalMultiplexer instance should be connected to. Any connections - of these signals to the previous object will be disconnected. - After the connections are hooked to the new object, the - @ref currentObjectChanged signal will be emitted. - - @param newObject the new object that the signals should be connected to - */ - void - setCurrentObject(QObject* newObject); - -Q_SIGNALS: - /** - Emitted when a new object is set to receive the signals managed by - this SignalMultiplexer instance. - */ - void - currentObjectChanged(QObject* newObject); - -private: - struct Connection { - QPointer sender; - QPointer receiver; - const char* signal; - const char* slot; - }; - - void - connect(const Connection& conn); - void - disconnect(const Connection& conn); - - QPointer object; - QList connections; -}; -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h index 30bd06080c9..1eb18eaf1a0 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h @@ -43,145 +43,137 @@ #include -namespace pcl { -namespace cloud_composer { - -class AbstractTool : public QObject { - Q_OBJECT -public: - AbstractTool(PropertiesModel* parameter_model, QObject* parent); - - ~AbstractTool() { qDebug() << "Tool Destructed"; } - - /** \brief Function called which does work in plugin - * \param data input_data from the model - const for good reason - * Returned list will become the output, replacing input_data in the model - you must - * deep copy the input_data, since undo works by switching back and forth - */ - virtual QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) = 0; - - virtual CloudCommand* - createCommand(QList input_data) = 0; - - QString - getActionText() const - { - return action_text_; - } - - void - setActionText(const QString& text) - { - action_text_ = text; - } - - virtual QString - getToolName() const = 0; - -protected: - PropertiesModel* parameter_model_; - -private: - QString action_text_; -}; - -class ModifyItemTool : public AbstractTool { - Q_OBJECT -public: - ModifyItemTool(PropertiesModel* parameter_model, QObject* parent) - : AbstractTool(parameter_model, parent) - {} - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand(QList input_data) override +namespace pcl +{ + namespace cloud_composer { - return new ModifyItemCommand(input_data); - } + + + class AbstractTool : public QObject + { + Q_OBJECT + public: + + AbstractTool (PropertiesModel* parameter_model, QObject* parent); + + ~AbstractTool () { qDebug() << "Tool Destructed"; } + + /** \brief Function called which does work in plugin + * \param data input_data from the model - const for good reason + * Returned list will become the output, replacing input_data in the model - you must deep copy + * the input_data, since undo works by switching back and forth + */ + virtual QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) = 0; + + virtual CloudCommand* + createCommand (QList input_data) = 0; + + QString + getActionText () const {return action_text_;} + + void + setActionText (const QString& text) { action_text_ = text; } + + virtual QString + getToolName () const = 0; + + protected: + + PropertiesModel* parameter_model_; + + private: + QString action_text_; + + }; + + class ModifyItemTool : public AbstractTool + { + Q_OBJECT + public: + ModifyItemTool (PropertiesModel* parameter_model, QObject* parent) + : AbstractTool (parameter_model, parent) + {} + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand (QList input_data) override + { + return new ModifyItemCommand (input_data); + } + + inline QString + getToolName () const override { return "ModifyItemTool";} + + }; + + class NewItemTool : public AbstractTool + { + Q_OBJECT + public: + NewItemTool (PropertiesModel* parameter_model, QObject* parent) + : AbstractTool (parameter_model, parent) + {} + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand (QList input_data) override + { + return new NewItemCloudCommand (input_data); + } + + inline QString + getToolName () const override { return "NewItemTool";} + + }; + + class SplitItemTool : public AbstractTool + { + Q_OBJECT + public: + SplitItemTool (PropertiesModel* parameter_model, QObject* parent) + : AbstractTool (parameter_model, parent) + {} + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand (QList input_data) override + { + return new SplitCloudCommand (input_data); + } + + inline QString + getToolName () const override { return "SplitItemTool";} + + }; + + class MergeCloudTool : public AbstractTool + { + Q_OBJECT + public: + MergeCloudTool (PropertiesModel* parameter_model, QObject* parent) + : AbstractTool (parameter_model, parent) + {} + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand (QList input_data) override + { + return new MergeCloudCommand (input_data); + } + + inline QString + getToolName () const override { return "MergeCloudTool";} + + }; - inline QString - getToolName() const override - { - return "ModifyItemTool"; } -}; - -class NewItemTool : public AbstractTool { - Q_OBJECT -public: - NewItemTool(PropertiesModel* parameter_model, QObject* parent) - : AbstractTool(parameter_model, parent) - {} - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand(QList input_data) override - { - return new NewItemCloudCommand(input_data); - } - - inline QString - getToolName() const override - { - return "NewItemTool"; - } -}; - -class SplitItemTool : public AbstractTool { - Q_OBJECT -public: - SplitItemTool(PropertiesModel* parameter_model, QObject* parent) - : AbstractTool(parameter_model, parent) - {} - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand(QList input_data) override - { - return new SplitCloudCommand(input_data); - } - - inline QString - getToolName() const override - { - return "SplitItemTool"; - } -}; - -class MergeCloudTool : public AbstractTool { - Q_OBJECT -public: - MergeCloudTool(PropertiesModel* parameter_model, QObject* parent) - : AbstractTool(parameter_model, parent) - {} - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand(QList input_data) override - { - return new MergeCloudCommand(input_data); - } - - inline QString - getToolName() const override - { - return "MergeCloudTool"; - } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h index a8a7a242fdb..65781efadcd 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h @@ -41,52 +41,55 @@ class QAction; -namespace pcl { -namespace cloud_composer { - -class AbstractTool; -class AbstractCommand; -class PropertiesModel; - -class ToolFactory { -public: - virtual AbstractTool* - createTool(PropertiesModel* parameter_model = nullptr, QObject* parent = nullptr) = 0; - - virtual PropertiesModel* - createToolParameterModel(QObject* parent) = 0; - - virtual QString - getPluginName() const = 0; - - virtual QString - getToolGroupName() const = 0; - - virtual QString - getIconName() const = 0; - - /** \brief Reimplement this function to return the proper number if tool requires more - * than one input item */ - inline virtual int - getNumInputItems() const +namespace pcl +{ + namespace cloud_composer { - return 1; - } - - /** \brief Returns a list of allowed input item types. Implement in tools so GUI can - * prevent impossible actions */ - virtual CloudComposerItem::ItemType - getInputItemType() const = 0; + + + class AbstractTool; + class AbstractCommand; + class PropertiesModel; + + class ToolFactory + { + public: + virtual AbstractTool* + createTool (PropertiesModel* parameter_model = nullptr, QObject* parent = nullptr) = 0; + + virtual PropertiesModel* + createToolParameterModel (QObject* parent) = 0; + + virtual QString + getPluginName () const = 0; + + virtual QString + getToolGroupName () const = 0; + + virtual QString + getIconName () const = 0; + + /** \brief Reimplement this function to return the proper number if tool requires more than one input item */ + inline virtual int + getNumInputItems () const + { + return 1; + } + + /** \brief Returns a list of allowed input item types. Implement in tools so GUI can prevent impossible actions */ + virtual CloudComposerItem::ItemType + getInputItemType () const = 0; + + /** \brief Returns a list of required input children. Implement in tools so GUI can prevent impossible actions */ + virtual QList + getRequiredInputChildrenTypes () const = 0; + + }; - /** \brief Returns a list of required input children. Implement in tools so GUI can - * prevent impossible actions */ - virtual QList - getRequiredInputChildrenTypes() const = 0; -}; - -} // namespace cloud_composer -} // namespace pcl + } +} -Q_DECLARE_METATYPE(pcl::cloud_composer::ToolFactory*); +Q_DECLARE_METATYPE (pcl::cloud_composer::ToolFactory*); -Q_DECLARE_INTERFACE(pcl::cloud_composer::ToolFactory, "cloud_composer.ToolFactory/1.0") +Q_DECLARE_INTERFACE(pcl::cloud_composer::ToolFactory, + "cloud_composer.ToolFactory/1.0") diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h index f109c8d93a9..0121b56be5d 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h @@ -44,7 +44,8 @@ class QItemSelection; class QItemSelectionModel; class QTreeView; -enum TOOLBOX_ROLES { +enum TOOLBOX_ROLES +{ FACTORY = Qt::UserRole, PARAMETER_MODEL, ALLOWED_INPUT_ITEM_TYPES, @@ -52,72 +53,71 @@ enum TOOLBOX_ROLES { }; class QTreeView; -namespace pcl { -namespace cloud_composer { - -class CloudCommand; -class AbstractTool; -class ToolFactory; -class ProjectModel; - -class ToolBoxModel : public QStandardItemModel { - Q_OBJECT - -public: - ToolBoxModel(QTreeView* tool_view = nullptr, - QTreeView* parameter_view = nullptr, - QObject* parent = nullptr); - ToolBoxModel(const ToolBoxModel& to_copy); - - void - addTool(ToolFactory* tool_factory); - - void - setSelectionModel(QItemSelectionModel* selection_model); - - /** \brief Enables/Disables Tools based on currently selected items from model */ - void - updateEnabledTools(const QItemSelection& current_selection); - - void - enableAllTools(); - -public Q_SLOTS: - void - activeProjectChanged(ProjectModel* new_model, ProjectModel* previous_model); - - void - selectedToolChanged(const QModelIndex& current, const QModelIndex& previous); - - void - toolAction(); - - /** \brief This slot is called when the selection in cloud browser changes. Updates - * enabling of tools */ - void - selectedItemChanged(const QItemSelection& selected, const QItemSelection& deselected); - - /** \brief This slot is called whenever the current project model emits layoutChanged, - * and calls updateEnabledTools */ - void - modelChanged(); -Q_SIGNALS: - void - enqueueToolAction(AbstractTool* tool); - -private: - QStandardItem* - addToolGroup(const QString& tool_group_name); - - QTreeView* tool_view_; - QTreeView* parameter_view_; - QItemSelectionModel* selection_model_; - QSet tool_items; - - ProjectModel* project_model_; -}; -} // namespace cloud_composer -} // namespace pcl - -Q_DECLARE_METATYPE(pcl::cloud_composer::ToolBoxModel); -Q_DECLARE_METATYPE(QStandardItemModel*); +namespace pcl +{ + namespace cloud_composer + { + + class CloudCommand; + class AbstractTool; + class ToolFactory; + class ProjectModel; + + class ToolBoxModel : public QStandardItemModel + { + Q_OBJECT + + public: + ToolBoxModel (QTreeView* tool_view = nullptr, QTreeView* parameter_view = nullptr, QObject *parent = nullptr); + ToolBoxModel (const ToolBoxModel& to_copy); + + void + addTool (ToolFactory* tool_factory); + + void + setSelectionModel (QItemSelectionModel* selection_model); + + /** \brief Enables/Disables Tools based on currently selected items from model */ + void + updateEnabledTools (const QItemSelection& current_selection); + + void + enableAllTools (); + + public Q_SLOTS: + void + activeProjectChanged (ProjectModel* new_model, ProjectModel* previous_model); + + void + selectedToolChanged (const QModelIndex & current, const QModelIndex & previous); + + void + toolAction (); + + /** \brief This slot is called when the selection in cloud browser changes. Updates enabling of tools */ + void + selectedItemChanged ( const QItemSelection & selected, const QItemSelection & deselected ); + + /** \brief This slot is called whenever the current project model emits layoutChanged, and calls updateEnabledTools */ + void + modelChanged (); + Q_SIGNALS: + void + enqueueToolAction (AbstractTool* tool); + + private: + QStandardItem* + addToolGroup (const QString& tool_group_name); + + QTreeView* tool_view_; + QTreeView* parameter_view_; + QItemSelectionModel* selection_model_; + QSet tool_items; + + ProjectModel* project_model_; + }; + } +} + +Q_DECLARE_METATYPE (pcl::cloud_composer::ToolBoxModel); +Q_DECLARE_METATYPE (QStandardItemModel*); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h index c97be097638..9a9e82d75ec 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h @@ -40,68 +40,62 @@ #include #include -namespace pcl { -namespace cloud_composer { -class EuclideanClusteringTool : public SplitItemTool { - Q_OBJECT -public: - EuclideanClusteringTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override - { - return "Euclidean Clustering Tool"; - } -}; - -class EuclideanClusteringToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - SplitItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new EuclideanClusteringTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override +namespace pcl +{ + namespace cloud_composer { - return "Euclidean Clustering"; - } + class EuclideanClusteringTool : public SplitItemTool + { + Q_OBJECT + public: + EuclideanClusteringTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Euclidean Clustering Tool";} + }; - inline QString - getToolGroupName() const override - { - return "Segmentation"; - } + + class EuclideanClusteringToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + SplitItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new EuclideanClusteringTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Euclidean Clustering";} + + inline QString + getToolGroupName () const override { return "Segmentation";} + + inline QString + getIconName () const override { return ":/euclidean_clustering.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + return QList (); + } + }; - inline QString - getIconName() const override - { - return ":/euclidean_clustering.png"; - } - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - inline QList - getRequiredInputChildrenTypes() const override - { - return QList(); } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h index 35210217fb9..10287e4c1aa 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h @@ -40,70 +40,64 @@ #include #include -namespace pcl { -namespace cloud_composer { - -class FPFHEstimationTool : public NewItemTool { - Q_OBJECT -public: - FPFHEstimationTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override +namespace pcl +{ + namespace cloud_composer { - return "FPFH Estimation Tool"; - } -}; + + class FPFHEstimationTool : public NewItemTool + { + Q_OBJECT + public: + FPFHEstimationTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "FPFH Estimation Tool";} + }; -class FPFHEstimationToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - NewItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new FPFHEstimationTool(parameter_model, parent); - } + + class FPFHEstimationToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + NewItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new FPFHEstimationTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "FPFH Estimation";} + + QString + getToolGroupName () const override { return "Feature Estimation";} + + QString + getIconName () const override { return ":/fpfh_estimation.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + QList input_types; + return (input_types << CloudComposerItem::NORMALS_ITEM); + } + }; - PropertiesModel* - createToolParameterModel(QObject* parent) override; - inline QString - getPluginName() const override - { - return "FPFH Estimation"; - } - QString - getToolGroupName() const override - { - return "Feature Estimation"; } - - QString - getIconName() const override - { - return ":/fpfh_estimation.png"; - } - - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes() const override - { - QList input_types; - return (input_types << CloudComposerItem::NORMALS_ITEM); - } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp index a200e83c857..708ea1f34b1 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp @@ -38,160 +38,144 @@ #ifndef IMPL_ORGANIZED_SEGMENTATION_HPP_ #define IMPL_ORGANIZED_SEGMENTATION_HPP_ +#include #include #include -#include -#include -#include -#include -#include -#include +#include // for pcl::make_shared +#include + #include #include +#include #include -#include // for pcl::make_shared -#include +#include +#include +#include -template -QList -pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( - const QList& input_data) -{ - QList output; - foreach (const CloudComposerItem* input_item, input_data) { - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - if (!variant.canConvert::Ptr>()) { - qWarning() << "Attempted to cast to template type which does not exist in this " - "item! (input list)"; +template QList +pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction (const QList & input_data) +{ + QList output; + + foreach (const CloudComposerItem* input_item, input_data) + { + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + if ( ! variant.canConvert ::Ptr> () ) + { + qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; return output; } - typename PointCloud::Ptr input_cloud = - variant.value::Ptr>(); - if (!input_cloud->isOrganized()) { - qCritical() << "Organized Segmentation requires an organized cloud!"; + typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); + if ( ! input_cloud->isOrganized ()) + { + qCritical () << "Organized Segmentation requires an organized cloud!"; return output; } } - int min_inliers = parameter_model_->getProperty("Min Inliers").toInt(); - int min_plane_size = parameter_model_->getProperty("Min Plane Size").toInt(); - double angular_threshold = - parameter_model_->getProperty("Angular Threshold").toDouble(); - double distance_threshold = - parameter_model_->getProperty("Distance Threshold").toDouble(); - double cluster_distance_threshold = - parameter_model_->getProperty("Cluster Dist. Thresh.").toDouble(); - int min_cluster_size = parameter_model_->getProperty("Min Cluster Size").toInt(); - - foreach (const CloudComposerItem* input_item, input_data) { - QList normals_list = - input_item->getChildren(CloudComposerItem::NORMALS_ITEM); - // Get the normals cloud, we just use the first normals that were found if there are - // more than one - pcl::PointCloud::ConstPtr input_normals = - normals_list.value(0) - ->data(ItemDataRole::CLOUD_TEMPLATED) - .value::ConstPtr>(); - - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - typename PointCloud::Ptr input_cloud = - variant.value::Ptr>(); + int min_inliers = parameter_model_->getProperty ("Min Inliers").toInt (); + int min_plane_size = parameter_model_->getProperty ("Min Plane Size").toInt (); + double angular_threshold = parameter_model_->getProperty ("Angular Threshold").toDouble (); + double distance_threshold = parameter_model_->getProperty ("Distance Threshold").toDouble (); + double cluster_distance_threshold = parameter_model_->getProperty ("Cluster Dist. Thresh.").toDouble (); + int min_cluster_size = parameter_model_->getProperty ("Min Cluster Size").toInt (); + + foreach (const CloudComposerItem* input_item, input_data) + { + QList normals_list = input_item->getChildren (CloudComposerItem::NORMALS_ITEM); + //Get the normals cloud, we just use the first normals that were found if there are more than one + pcl::PointCloud::ConstPtr input_normals = normals_list.value(0)->data(ItemDataRole::CLOUD_TEMPLATED).value ::ConstPtr> (); + + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); pcl::OrganizedMultiPlaneSegmentation mps; - mps.setMinInliers(min_inliers); - mps.setAngularThreshold(pcl::deg2rad(angular_threshold)); // convert to radians - mps.setDistanceThreshold(distance_threshold); - mps.setInputNormals(input_normals); - mps.setInputCloud(input_cloud); - std::vector, - Eigen::aligned_allocator>> - regions; + mps.setMinInliers (min_inliers); + mps.setAngularThreshold (pcl::deg2rad (angular_threshold)); // convert to radians + mps.setDistanceThreshold (distance_threshold); + mps.setInputNormals (input_normals); + mps.setInputCloud (input_cloud); + std::vector, Eigen::aligned_allocator > > regions; std::vector model_coefficients; std::vector inlier_indices; - pcl::PointCloud::Ptr labels(new pcl::PointCloud); + pcl::PointCloud::Ptr labels (new pcl::PointCloud); std::vector label_indices; std::vector boundary_indices; - mps.segmentAndRefine(regions, - model_coefficients, - inlier_indices, - labels, - label_indices, - boundary_indices); - - auto plane_labels = pcl::make_shared>(); - for (std::size_t i = 0; i < label_indices.size(); ++i) - if (label_indices[i].indices.size() > (std::size_t)min_plane_size) - plane_labels->insert(i); + mps.segmentAndRefine (regions, model_coefficients, inlier_indices, labels, label_indices, boundary_indices); + + auto plane_labels = pcl::make_shared > (); + for (std::size_t i = 0; i < label_indices.size (); ++i) + if (label_indices[i].indices.size () > (std::size_t) min_plane_size) + plane_labels->insert (i); typename PointCloud::CloudVectorType clusters; - typename EuclideanClusterComparator::Ptr - euclidean_cluster_comparator( - new EuclideanClusterComparator); - euclidean_cluster_comparator->setInputCloud(input_cloud); - euclidean_cluster_comparator->setLabels(labels); - euclidean_cluster_comparator->setExcludeLabels(plane_labels); - euclidean_cluster_comparator->setDistanceThreshold(cluster_distance_threshold, - false); + typename EuclideanClusterComparator::Ptr euclidean_cluster_comparator(new EuclideanClusterComparator); + euclidean_cluster_comparator->setInputCloud (input_cloud); + euclidean_cluster_comparator->setLabels (labels); + euclidean_cluster_comparator->setExcludeLabels (plane_labels); + euclidean_cluster_comparator->setDistanceThreshold (cluster_distance_threshold, false); pcl::PointCloud euclidean_labels; std::vector euclidean_label_indices; - pcl::OrganizedConnectedComponentSegmentation - euclidean_segmentation(euclidean_cluster_comparator); - euclidean_segmentation.setInputCloud(input_cloud); - euclidean_segmentation.segment(euclidean_labels, euclidean_label_indices); - - pcl::IndicesPtr extracted_indices(new pcl::Indices()); - for (std::size_t i = 0; i < euclidean_label_indices.size(); i++) { - if (euclidean_label_indices[i].indices.size() >= (std::size_t)min_cluster_size) { - typename PointCloud::Ptr cluster(new PointCloud); - pcl::copyPointCloud(*input_cloud, euclidean_label_indices[i].indices, *cluster); - qDebug() << "Found cluster with size " << cluster->width; - QString name = input_item->text() + tr("- Clstr %1").arg(i); - CloudItem* new_cloud_item = - CloudItem::createCloudItemFromTemplate(name, cluster); - output.append(new_cloud_item); - extracted_indices->insert(extracted_indices->end(), - euclidean_label_indices[i].indices.begin(), - euclidean_label_indices[i].indices.end()); + pcl::OrganizedConnectedComponentSegmentation euclidean_segmentation (euclidean_cluster_comparator); + euclidean_segmentation.setInputCloud (input_cloud); + euclidean_segmentation.segment (euclidean_labels, euclidean_label_indices); + + pcl::IndicesPtr extracted_indices (new pcl::Indices ()); + for (std::size_t i = 0; i < euclidean_label_indices.size (); i++) + { + if (euclidean_label_indices[i].indices.size () >= (std::size_t) min_cluster_size) + { + typename PointCloud::Ptr cluster (new PointCloud); + pcl::copyPointCloud (*input_cloud,euclidean_label_indices[i].indices,*cluster); + qDebug () << "Found cluster with size " << cluster->width; + QString name = input_item->text () + tr ("- Clstr %1").arg (i); + CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(name,cluster); + output.append (new_cloud_item); + extracted_indices->insert (extracted_indices->end (), euclidean_label_indices[i].indices.begin (), euclidean_label_indices[i].indices.end ()); } } - for (std::size_t i = 0; i < label_indices.size(); i++) { - if (label_indices[i].indices.size() >= (std::size_t)min_plane_size) { - typename PointCloud::Ptr plane(new PointCloud); - pcl::copyPointCloud(*input_cloud, label_indices[i].indices, *plane); - qDebug() << "Found plane with size " << plane->width; - QString name = input_item->text() + tr("- Plane %1").arg(i); - CloudItem* new_cloud_item = - CloudItem::createCloudItemFromTemplate(name, plane); - output.append(new_cloud_item); - extracted_indices->insert(extracted_indices->end(), - label_indices[i].indices.begin(), - label_indices[i].indices.end()); + for (std::size_t i = 0; i < label_indices.size (); i++) + { + if (label_indices[i].indices.size () >= (std::size_t) min_plane_size) + { + typename PointCloud::Ptr plane (new PointCloud); + pcl::copyPointCloud (*input_cloud,label_indices[i].indices,*plane); + qDebug () << "Found plane with size " << plane->width; + QString name = input_item->text () + tr ("- Plane %1").arg (i); + CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(name,plane); + output.append (new_cloud_item); + extracted_indices->insert (extracted_indices->end (), label_indices[i].indices.begin (), label_indices[i].indices.end ()); + } } - typename PointCloud::Ptr leftovers(new PointCloud); - if (extracted_indices->empty()) - pcl::copyPointCloud(*input_cloud, *leftovers); - else { + typename PointCloud::Ptr leftovers (new PointCloud); + if (extracted_indices->empty ()) + pcl::copyPointCloud (*input_cloud,*leftovers); + else + { pcl::ExtractIndices filter; - filter.setInputCloud(input_cloud); - filter.setIndices(extracted_indices); - filter.setNegative(true); - filter.filter(*leftovers); + filter.setInputCloud (input_cloud); + filter.setIndices (extracted_indices); + filter.setNegative (true); + filter.filter (*leftovers); } - CloudItem* leftover_cloud_item = - CloudItem::createCloudItemFromTemplate(input_item->text(), leftovers); - output.append(leftover_cloud_item); + CloudItem* leftover_cloud_item = CloudItem::createCloudItemFromTemplate(input_item->text(),leftovers); + output.append (leftover_cloud_item); } + + + return output; + } -#define PCL_INSTANTIATE_performTemplatedAction(T) \ - template void \ - pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( \ - QList); -#endif // IMPL_TRANSFORM_CLOUDS_HPP_ +#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction (QList ); + + + +#endif //IMPL_TRANSFORM_CLOUDS_HPP_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp index 4222f215ec2..2d83912fdc2 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp @@ -1,117 +1,124 @@ /* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2012, Jeremie Papon. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ +* Software License Agreement (BSD License) +* +* Point Cloud Library (PCL) - www.pointclouds.org +* Copyright (c) 2012, Jeremie Papon. +* +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of Willow Garage, Inc. nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +*/ #ifndef IMPL_SUPERVOXELS_HPP_ #define IMPL_SUPERVOXELS_HPP_ +#include #include #include -#include -#include #include #include +#include -template -QList -pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( - const QList& input_data) -{ - QList output; - foreach (const CloudComposerItem* input_item, input_data) { - // if ( !input_item->isSanitized () ) - // { - // qCritical () << "SupervoxelsTool requires sanitized input!"; - // return output; - // } - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - if (!variant.canConvert::Ptr>()) { - qWarning() << "Attempted to cast to template type which does not exist in this " - "item! (input list)"; +template QList +pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (const QList & input_data) +{ + QList output; + + foreach (const CloudComposerItem* input_item, input_data) + { + // if ( !input_item->isSanitized () ) + // { + // qCritical () << "SupervoxelsTool requires sanitized input!"; + // return output; + // } + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + if ( ! variant.canConvert ::Ptr> () ) + { + qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; return output; } - typename PointCloud::Ptr input_cloud = - variant.value::Ptr>(); - // TODO: Check if Voxelized - } - - foreach (const CloudComposerItem* input_item, input_data) { - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - typename PointCloud::Ptr input_cloud = - variant.value::Ptr>(); - - float resolution = parameter_model_->getProperty("Resolution").toFloat(); - qDebug() << "Octree resolution = " << resolution; - float seed_resolution = parameter_model_->getProperty("Seed Resolution").toFloat(); - qDebug() << "Seed resolution = " << seed_resolution; - - float rgb_weight = parameter_model_->getProperty("RGB Weight").toFloat(); - float normal_weight = parameter_model_->getProperty("Normals Weight").toFloat(); - float spatial_weight = parameter_model_->getProperty("Spatial Weight").toFloat(); - - pcl::SupervoxelClustering super(resolution, seed_resolution); - super.setInputCloud(input_cloud); - super.setColorImportance(rgb_weight); - super.setSpatialImportance(spatial_weight); - super.setNormalImportance(normal_weight); - std::map::Ptr> supervoxel_clusters; - super.extract(supervoxel_clusters); - - std::map::Ptr> - refined_supervoxel_clusters; - super.refineSupervoxels(3, refined_supervoxel_clusters); + typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); + //TODO: Check if Voxelized + +} + + foreach (const CloudComposerItem* input_item, input_data) + { + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); + + float resolution = parameter_model_->getProperty("Resolution").toFloat (); + qDebug () << "Octree resolution = "<getProperty("Seed Resolution").toFloat (); + qDebug () << "Seed resolution = "<getProperty("RGB Weight").toFloat (); + float normal_weight = parameter_model_->getProperty("Normals Weight").toFloat (); + float spatial_weight = parameter_model_->getProperty("Spatial Weight").toFloat (); + + + pcl::SupervoxelClustering super (resolution, seed_resolution); + super.setInputCloud (input_cloud); + super.setColorImportance (rgb_weight); + super.setSpatialImportance (spatial_weight); + super.setNormalImportance (normal_weight); + std::map ::Ptr > supervoxel_clusters; + super.extract (supervoxel_clusters); + + std::map ::Ptr > refined_supervoxel_clusters; + super.refineSupervoxels (3, refined_supervoxel_clusters); + auto label_segments = super.getLabeledVoxelCloud(); auto color_segments = pcl::make_shared>(); pcl::copyPointCloud(*label_segments, *color_segments); for (size_t i = 0; i < label_segments->size(); ++i) - color_segments->at(i).rgba = - GlasbeyLUT::at(label_segments->at(i).label % GlasbeyLUT::size()).rgba; - CloudItem* cloud_item_out = CloudItem::createCloudItemFromTemplate( - input_item->text(), color_segments); - - output.append(cloud_item_out); + color_segments->at(i).rgba = GlasbeyLUT::at(label_segments->at(i).label % GlasbeyLUT::size()).rgba; + CloudItem* cloud_item_out = CloudItem::createCloudItemFromTemplate(input_item->text(), color_segments); + + output.append (cloud_item_out); + } - + + + + return output; + } -#define PCL_INSTANTIATE_performTemplatedAction(T) \ - template void pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( \ - QList); -#endif // IMPL_SUPERVOXELS_HPP_ + + +#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (QList ); + + + +#endif //IMPL_SUPERVOXELS_HPP_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h index cd27fbee0cc..b5091cc009a 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h @@ -40,68 +40,62 @@ #include #include -namespace pcl { -namespace cloud_composer { -class NormalEstimationTool : public NewItemTool { - Q_OBJECT -public: - NormalEstimationTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override - { - return "Normal Estimation Tool"; - } -}; - -class NormalEstimationToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - NewItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new NormalEstimationTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override +namespace pcl +{ + namespace cloud_composer { - return "Normal Estimation"; - } + class NormalEstimationTool : public NewItemTool + { + Q_OBJECT + public: + NormalEstimationTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Normal Estimation Tool";} + }; - QString - getToolGroupName() const override - { - return "Feature Estimation"; - } + + class NormalEstimationToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + NewItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new NormalEstimationTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Normal Estimation";} + + QString + getToolGroupName () const override { return "Feature Estimation";} + + QString + getIconName () const override { return ":/normal_estimation.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + return QList (); + } + }; - QString - getIconName() const override - { - return ":/normal_estimation.png"; - } - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - inline QList - getRequiredInputChildrenTypes() const override - { - return QList(); } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h index 41aaf9e4fd7..a35d946d2ba 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h @@ -1,112 +1,106 @@ -/* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2012, Jeremie Papon. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - + /* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2012, Jeremie Papon. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Willow Garage, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + #pragma once - -#include -#include - -namespace pcl { -namespace cloud_composer { -class OrganizedSegmentationTool : public SplitItemTool { - Q_OBJECT -public: - OrganizedSegmentationTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - template - QList - performTemplatedAction(const QList& input_data); - - inline QString - getToolName() const override - { - return "Organized Segmentation Tool"; - } -}; - -class OrganizedSegmentationToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - SplitItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new OrganizedSegmentationTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override - { - return "Organized Segmentation"; - } - - inline QString - getToolGroupName() const override - { - return "Segmentation"; - } - - inline QString - getIconName() const override - { - return ":/organized_segmentation.png"; - } - - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes() const override - { - QList input_types; - return (input_types << CloudComposerItem::NORMALS_ITEM); - } -}; - -} // namespace cloud_composer -} // namespace pcl + + #include + #include + + + namespace pcl + { + namespace cloud_composer + { + class OrganizedSegmentationTool : public SplitItemTool + { + Q_OBJECT + public: + OrganizedSegmentationTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + template QList + performTemplatedAction (const QList & input_data); + + inline QString + getToolName () const override { return "Organized Segmentation Tool";} + }; + + + class OrganizedSegmentationToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + SplitItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new OrganizedSegmentationTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Organized Segmentation";} + + inline QString + getToolGroupName () const override { return "Segmentation";} + + inline QString + getIconName () const override { return ":/organized_segmentation.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + QList input_types; + return (input_types << CloudComposerItem::NORMALS_ITEM); + } + }; + + + + } + } diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h index 2a8e33ccc94..f1c54653917 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h @@ -40,68 +40,62 @@ #include #include -namespace pcl { -namespace cloud_composer { -class SanitizeCloudTool : public ModifyItemTool { - Q_OBJECT -public: - SanitizeCloudTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override - { - return "Sanitize Cloud Tool"; - } -}; - -class SanitizeCloudToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - ModifyItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new SanitizeCloudTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override - { - return "Sanitize Cloud"; - } - - QString - getToolGroupName() const override - { - return "Filters"; - } - - QString - getIconName() const override +namespace pcl +{ + namespace cloud_composer { - return ":/sanitize_cloud.png"; + class SanitizeCloudTool : public ModifyItemTool + { + Q_OBJECT + public: + SanitizeCloudTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Sanitize Cloud Tool";} + }; + + + class SanitizeCloudToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + ModifyItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new SanitizeCloudTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Sanitize Cloud";} + + QString + getToolGroupName () const override { return "Filters";} + + QString + getIconName () const override { return ":/sanitize_cloud.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + return QList (); + } + }; + + + + } } - - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes() const override - { - return QList(); - } -}; - -} // namespace cloud_composer -} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h index 092edb0634f..86ce2cbebbd 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h @@ -40,68 +40,63 @@ #include #include -namespace pcl { -namespace cloud_composer { -class StatisticalOutlierRemovalTool : public ModifyItemTool { - Q_OBJECT -public: - StatisticalOutlierRemovalTool(PropertiesModel* parameter_model, QObject* parent); - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override +namespace pcl +{ + namespace cloud_composer { - return "Statistical Outlier Removal Tool"; - } -}; + class StatisticalOutlierRemovalTool : public ModifyItemTool + { + Q_OBJECT + public: + StatisticalOutlierRemovalTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Statistical Outlier Removal Tool";} + }; -class StatisticalOutlierRemovalToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - ModifyItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new StatisticalOutlierRemovalTool(parameter_model, parent); - } + + class StatisticalOutlierRemovalToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + ModifyItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new StatisticalOutlierRemovalTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Statistical Outlier Removal";} + + QString + getToolGroupName () const override { return "Filters";} + + QString + getIconName () const override { return ":/statistical_outlier_removal.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + return QList (); + } + }; - PropertiesModel* - createToolParameterModel(QObject* parent) override; - inline QString - getPluginName() const override - { - return "Statistical Outlier Removal"; - } - QString - getToolGroupName() const override - { - return "Filters"; } - - QString - getIconName() const override - { - return ":/statistical_outlier_removal.png"; - } - - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes() const override - { - return QList(); - } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h index 1383a599a18..39c6ea6656c 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h @@ -1,112 +1,108 @@ -/* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2012, Jeremie Papon. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - + /* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2012, Jeremie Papon. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Willow Garage, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + #pragma once - -#include -#include - -namespace pcl { -namespace cloud_composer { -class SupervoxelsTool : public SplitItemTool { - Q_OBJECT -public: - SupervoxelsTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - template - QList - performTemplatedAction(const QList& input_data); - - inline QString - getToolName() const override - { - return "Voxel Superpixels Tool"; - } -}; - -class SupervoxelsToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - SplitItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new SupervoxelsTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override - { - return "Supervoxels"; - } - - inline QString - getToolGroupName() const override - { - return "Segmentation"; - } - - inline QString - getIconName() const override - { - return ":/supervoxels.png"; - } - - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes() const override - { - QList input_types; - return input_types; - } -}; - -} // namespace cloud_composer -} // namespace pcl + + #include + #include + + + namespace pcl + { + namespace cloud_composer + { + class SupervoxelsTool : public SplitItemTool + { + Q_OBJECT + public: + SupervoxelsTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + template QList + performTemplatedAction (const QList & input_data); + + inline QString + getToolName () const override { return "Voxel Superpixels Tool";} + + + }; + + + class SupervoxelsToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + SplitItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new SupervoxelsTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Supervoxels";} + + inline QString + getToolGroupName () const override { return "Segmentation";} + + inline QString + getIconName () const override { return ":/supervoxels.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + QList input_types; + return input_types; + } + }; + + + + } + } diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h index 8672be64672..85499ca89b6 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h @@ -40,68 +40,62 @@ #include #include -namespace pcl { -namespace cloud_composer { -class VoxelGridDownsampleTool : public ModifyItemTool { - Q_OBJECT -public: - VoxelGridDownsampleTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override - { - return "Voxel Grid Downsample Tool"; - } -}; - -class VoxelGridDownsampleToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - ModifyItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new VoxelGridDownsampleTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override +namespace pcl +{ + namespace cloud_composer { - return "Voxel Grid Downsample"; - } + class VoxelGridDownsampleTool : public ModifyItemTool + { + Q_OBJECT + public: + VoxelGridDownsampleTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Voxel Grid Downsample Tool";} + }; - QString - getToolGroupName() const override - { - return "Filters"; - } + + class VoxelGridDownsampleToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + ModifyItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new VoxelGridDownsampleTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Voxel Grid Downsample";} + + QString + getToolGroupName () const override { return "Filters";} + + QString + getIconName () const override { return ":/voxel_grid_downsample.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + return QList (); + } + }; - QString - getIconName() const override - { - return ":/voxel_grid_downsample.png"; - } - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - inline QList - getRequiredInputChildrenTypes() const override - { - return QList(); } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h index e647b9f0da3..e2215296d35 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h @@ -39,31 +39,28 @@ #include -namespace pcl { -namespace cloud_composer { -class TransformClouds : public ModifyItemTool { - Q_OBJECT -public: - TransformClouds(QMap> transform_map, - QObject* parent = nullptr); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override +namespace pcl +{ + namespace cloud_composer { - return "Transform Clouds Tool"; - } + class TransformClouds : public ModifyItemTool + { + Q_OBJECT + public: + TransformClouds (QMap > transform_map, QObject* parent = nullptr); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Transform Clouds Tool";} + + template QList + performTemplatedAction (const QList & input_data); + + private: + QMap > transform_map_; + }; - template - QList - performTemplatedAction(const QList& input_data); - -private: - QMap> transform_map_; -}; - -} // namespace cloud_composer -} // namespace pcl + } +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h index fb6227ca82c..95652a67029 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h @@ -37,42 +37,47 @@ #pragma once -#include - #include -namespace pcl { -namespace cloud_composer { -class AbstractTool; -class CloudComposerItem; - -struct ActionPair { - CloudCommand* command; - AbstractTool* tool; -}; - -class WorkQueue : public QObject { - Q_OBJECT -public: - WorkQueue(QObject* parent = nullptr); -public Q_SLOTS: - void - enqueueNewAction(AbstractTool* new_tool, ConstItemList input_data); - - void - actionFinished(ActionPair finished_action); - - void - checkQueue(); -Q_SIGNALS: - void - commandProgress(QString command_text, double progress); +#include - void - commandComplete(CloudCommand* completed_command); +namespace pcl +{ + namespace cloud_composer + { + class AbstractTool; + class CloudComposerItem; + + struct ActionPair + { + CloudCommand* command; + AbstractTool* tool; + }; + + class WorkQueue : public QObject + { + Q_OBJECT + public: + WorkQueue (QObject* parent = nullptr); + public Q_SLOTS: + void + enqueueNewAction (AbstractTool* new_tool, ConstItemList input_data); + + void + actionFinished (ActionPair finished_action); + + void + checkQueue (); + Q_SIGNALS: + void + commandProgress (QString command_text, double progress); -private: - QQueue work_queue_; -}; -} // namespace cloud_composer -} // namespace pcl + void + commandComplete (CloudCommand* completed_command); + + private: + QQueue work_queue_; + + }; + } +} diff --git a/apps/cloud_composer/src/cloud_composer.cpp b/apps/cloud_composer/src/cloud_composer.cpp index 1c551d4db3d..1302b59819c 100644 --- a/apps/cloud_composer/src/cloud_composer.cpp +++ b/apps/cloud_composer/src/cloud_composer.cpp @@ -1,14 +1,14 @@ #include -#include +#include #include -#include +#include #include -#include -#include -#include -#include +#include #include +#include #include +#include +#include #include #include @@ -16,233 +16,215 @@ #include ///////////////////////////////////////////////////////////// -pcl::cloud_composer::ComposerMainWindow::ComposerMainWindow(QWidget* parent) -: QMainWindow(parent) +pcl::cloud_composer::ComposerMainWindow::ComposerMainWindow (QWidget *parent) + : QMainWindow (parent) { - setupUi(this); - - this->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); - this->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); - - // Register types in Qt - qRegisterMetaType("PCLPointCloud2Ptr"); - qRegisterMetaType("GeometryHandlerConstPtr"); - qRegisterMetaType("ColorHandlerConstPtr"); - qRegisterMetaType("EigenVector4f"); - qRegisterMetaType("EigenQuaternionf"); - qRegisterMetaType("ProjectModel"); - qRegisterMetaType("CloudView"); - qRegisterMetaType("ConstComposerItemList"); - + setupUi (this); + + this->setCorner (Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); + this->setCorner (Qt::BottomRightCorner, Qt::RightDockWidgetArea); + + //Register types in Qt + qRegisterMetaType ("PCLPointCloud2Ptr"); + qRegisterMetaType ("GeometryHandlerConstPtr"); + qRegisterMetaType ("ColorHandlerConstPtr"); + qRegisterMetaType ("EigenVector4f"); + qRegisterMetaType ("EigenQuaternionf"); + qRegisterMetaType ("ProjectModel"); + qRegisterMetaType ("CloudView"); + qRegisterMetaType ("ConstComposerItemList"); + current_model_ = nullptr; - - multiplexer_ = new SignalMultiplexer(this); - - initializeCloudBrowser(); - initializeCloudViewer(); - initializeItemInspector(); - initializeToolBox(); - initializePlugins(); - - undo_group_ = new QUndoGroup(this); - undo_view_->setGroup(undo_group_); - - // Auto connect signals and slots - // QMetaObject::connectSlotsByName(this); - connectFileActions(); - connectEditActions(); - connectViewActions(); + + multiplexer_ = new SignalMultiplexer (this); + + initializeCloudBrowser (); + initializeCloudViewer (); + initializeItemInspector (); + initializeToolBox (); + initializePlugins (); + + undo_group_ = new QUndoGroup (this); + undo_view_->setGroup (undo_group_); + + //Auto connect signals and slots + // QMetaObject::connectSlotsByName(this); + connectFileActions (); + connectEditActions (); + connectViewActions (); + } -pcl::cloud_composer::ComposerMainWindow::~ComposerMainWindow() +pcl::cloud_composer::ComposerMainWindow::~ComposerMainWindow () { - foreach (ProjectModel* to_delete, name_model_map_.values()) - to_delete->deleteLater(); + foreach (ProjectModel* to_delete, name_model_map_.values ()) + to_delete->deleteLater (); } void -pcl::cloud_composer::ComposerMainWindow::connectFileActions() -{} +pcl::cloud_composer::ComposerMainWindow::connectFileActions () +{ + + +} void -pcl::cloud_composer::ComposerMainWindow::connectEditActions() +pcl::cloud_composer::ComposerMainWindow::connectEditActions () { - // Replace the actions in the menu with undo actions created using the undo group - QAction* action_temp = undo_group_->createUndoAction(this); - action_temp->setShortcut(action_undo_->shortcut()); - menuEdit->insertAction(action_redo_, action_temp); - menuEdit->removeAction(action_undo_); + //Replace the actions in the menu with undo actions created using the undo group + QAction* action_temp = undo_group_->createUndoAction (this); + action_temp->setShortcut (action_undo_->shortcut ()); + menuEdit->insertAction (action_redo_, action_temp); + menuEdit->removeAction (action_undo_); action_undo_ = action_temp; - - action_temp = undo_group_->createRedoAction(this); - action_temp->setShortcut(action_redo_->shortcut()); - menuEdit->insertAction(action_redo_, action_temp); - menuEdit->removeAction(action_redo_); + + action_temp = undo_group_->createRedoAction (this); + action_temp->setShortcut (action_redo_->shortcut ()); + menuEdit->insertAction (action_redo_, action_temp); + menuEdit->removeAction (action_redo_); action_redo_ = action_temp; - - multiplexer_->connect( - action_clear_selection_, SIGNAL(triggered()), SLOT(clearSelection())); - - multiplexer_->connect( - action_delete_, SIGNAL(triggered()), SLOT(deleteSelectedItems())); - multiplexer_->connect( - SIGNAL(deleteAvailable(bool)), action_delete_, SLOT(setEnabled(bool))); - - multiplexer_->connect( - this, SIGNAL(insertNewCloudFromFile()), SLOT(insertNewCloudFromFile())); - multiplexer_->connect(this, - SIGNAL(insertNewCloudFromRGBandDepth()), - SLOT(insertNewCloudFromRGBandDepth())); - multiplexer_->connect( - this, SIGNAL(saveSelectedCloudToFile()), SLOT(saveSelectedCloudToFile())); - - mouse_style_group_ = new QActionGroup(this); - mouse_style_group_->addAction(action_trackball_camera_style_); - mouse_style_group_->addAction(action_manipulate_clicked_); - mouse_style_group_->addAction(action_manipulate_selected_); - mouse_style_group_->addAction(action_rectangular_frustum_select_); - mouse_style_group_->setExclusive(true); - multiplexer_->connect(mouse_style_group_, - SIGNAL(triggered(QAction*)), - SLOT(mouseStyleChanged(QAction*))); - multiplexer_->connect( - SIGNAL(mouseStyleState(interactor_styles::INTERACTOR_STYLES)), - this, - SLOT(setMouseStyleAction(interactor_styles::INTERACTOR_STYLES))); - action_trackball_camera_style_->setData( - QVariant::fromValue(interactor_styles::PCL_VISUALIZER)); - action_rectangular_frustum_select_->setData( - QVariant::fromValue(interactor_styles::RECTANGULAR_FRUSTUM)); - action_manipulate_selected_->setData( - QVariant::fromValue(interactor_styles::SELECTED_TRACKBALL)); - action_manipulate_clicked_->setData( - QVariant::fromValue(interactor_styles::CLICK_TRACKBALL)); - // multiplexer_->connect (action_manipulate_selected_, SIGNAL (triggered ()), SLOT - // (selectedTrackballInteractorStyle ())); - - multiplexer_->connect(action_new_cloud_from_selection_, - SIGNAL(triggered()), - SLOT(createNewCloudFromSelection())); - multiplexer_->connect(SIGNAL(newCloudFromSelectionAvailable(bool)), - action_new_cloud_from_selection_, - SLOT(setEnabled(bool))); - - multiplexer_->connect( - action_select_all_, SIGNAL(triggered()), SLOT(selectAllItems())); + + multiplexer_->connect (action_clear_selection_, SIGNAL (triggered ()), SLOT (clearSelection ())); + + multiplexer_->connect (action_delete_, SIGNAL (triggered ()), SLOT (deleteSelectedItems ())); + multiplexer_->connect (SIGNAL (deleteAvailable (bool)), action_delete_, SLOT (setEnabled (bool))); + + multiplexer_->connect (this, SIGNAL (insertNewCloudFromFile()), SLOT (insertNewCloudFromFile())); + multiplexer_->connect (this, SIGNAL (insertNewCloudFromRGBandDepth()), SLOT (insertNewCloudFromRGBandDepth())); + multiplexer_->connect (this, SIGNAL (saveSelectedCloudToFile()), SLOT (saveSelectedCloudToFile())); + + + mouse_style_group_ = new QActionGroup (this); + mouse_style_group_->addAction (action_trackball_camera_style_); + mouse_style_group_->addAction (action_manipulate_clicked_); + mouse_style_group_->addAction (action_manipulate_selected_); + mouse_style_group_->addAction (action_rectangular_frustum_select_); + mouse_style_group_->setExclusive (true); + multiplexer_->connect (mouse_style_group_, SIGNAL (triggered (QAction*)), SLOT (mouseStyleChanged (QAction*))); + multiplexer_->connect(SIGNAL (mouseStyleState (interactor_styles::INTERACTOR_STYLES)), this, SLOT(setMouseStyleAction(interactor_styles::INTERACTOR_STYLES))); + action_trackball_camera_style_->setData (QVariant::fromValue (interactor_styles::PCL_VISUALIZER)); + action_rectangular_frustum_select_->setData (QVariant::fromValue (interactor_styles::RECTANGULAR_FRUSTUM)); + action_manipulate_selected_->setData (QVariant::fromValue (interactor_styles::SELECTED_TRACKBALL)); + action_manipulate_clicked_->setData (QVariant::fromValue (interactor_styles::CLICK_TRACKBALL)); + //multiplexer_->connect (action_manipulate_selected_, SIGNAL (triggered ()), SLOT (selectedTrackballInteractorStyle ())); + + + multiplexer_->connect (action_new_cloud_from_selection_, SIGNAL (triggered ()), SLOT (createNewCloudFromSelection ())); + multiplexer_->connect (SIGNAL (newCloudFromSelectionAvailable (bool)), action_new_cloud_from_selection_, SLOT (setEnabled (bool))); + + multiplexer_->connect (action_select_all_, SIGNAL (triggered ()), SLOT (selectAllItems ())); } void -pcl::cloud_composer::ComposerMainWindow::setMouseStyleAction( - interactor_styles::INTERACTOR_STYLES selected_style) +pcl::cloud_composer::ComposerMainWindow::setMouseStyleAction (interactor_styles::INTERACTOR_STYLES selected_style) { - action_trackball_camera_style_->setChecked(false); - action_rectangular_frustum_select_->setChecked(false); - action_manipulate_selected_->setChecked(false); - action_manipulate_clicked_->setChecked(false); - - switch (selected_style) { - case interactor_styles::PCL_VISUALIZER: - action_trackball_camera_style_->setChecked(true); - break; - case interactor_styles::CLICK_TRACKBALL: - action_manipulate_clicked_->setChecked(true); - break; - case interactor_styles::RECTANGULAR_FRUSTUM: - action_rectangular_frustum_select_->setChecked(true); - break; - case interactor_styles::SELECTED_TRACKBALL: - action_manipulate_selected_->setChecked(true); - break; - default: - action_trackball_camera_style_->setChecked(true); + action_trackball_camera_style_->setChecked (false); + action_rectangular_frustum_select_->setChecked (false); + action_manipulate_selected_->setChecked (false); + action_manipulate_clicked_->setChecked (false); + + switch (selected_style) + { + case interactor_styles::PCL_VISUALIZER : + action_trackball_camera_style_->setChecked (true); + break; + case interactor_styles::CLICK_TRACKBALL : + action_manipulate_clicked_->setChecked (true); + break; + case interactor_styles::RECTANGULAR_FRUSTUM : + action_rectangular_frustum_select_->setChecked (true); + break; + case interactor_styles::SELECTED_TRACKBALL : + action_manipulate_selected_->setChecked (true); + break; + default : + action_trackball_camera_style_->setChecked (true); + } } void -pcl::cloud_composer::ComposerMainWindow::connectViewActions() +pcl::cloud_composer::ComposerMainWindow::connectViewActions () { - multiplexer_->connect( - action_show_axes_, SIGNAL(toggled(bool)), SLOT(setAxisVisibility(bool))); - multiplexer_->connect( - SIGNAL(axisVisible(bool)), action_show_axes_, SLOT(setChecked(bool))); + multiplexer_->connect (action_show_axes_, SIGNAL (toggled (bool)), SLOT (setAxisVisibility (bool))); + multiplexer_->connect (SIGNAL (axisVisible (bool)), action_show_axes_, SLOT (setChecked (bool))); + } void -pcl::cloud_composer::ComposerMainWindow::initializeCloudBrowser() +pcl::cloud_composer::ComposerMainWindow::initializeCloudBrowser () { - cloud_browser_->setSelectionMode(QAbstractItemView::ExtendedSelection); - + cloud_browser_->setSelectionMode (QAbstractItemView::ExtendedSelection); + cloud_browser_->setStyleSheet("selection-background-color: red;"); + } void -pcl::cloud_composer::ComposerMainWindow::initializeCloudViewer() +pcl::cloud_composer::ComposerMainWindow::initializeCloudViewer () { - // Signal emitted when user selects new tab (ie different project) in the viewer - connect(cloud_viewer_, - SIGNAL(newModelSelected(ProjectModel*)), - this, - SLOT(setCurrentModel(ProjectModel*))); + //Signal emitted when user selects new tab (ie different project) in the viewer + connect (cloud_viewer_, SIGNAL (newModelSelected (ProjectModel*)), + this, SLOT (setCurrentModel (ProjectModel*))); + } void -pcl::cloud_composer::ComposerMainWindow::initializeItemInspector() -{} +pcl::cloud_composer::ComposerMainWindow::initializeItemInspector () +{ + +} void -pcl::cloud_composer::ComposerMainWindow::initializeToolBox() +pcl::cloud_composer::ComposerMainWindow::initializeToolBox () { - tool_box_model_ = new ToolBoxModel(tool_box_view_, tool_parameter_view_, this); - tool_selection_model_ = new QItemSelectionModel(tool_box_model_); - tool_box_model_->setSelectionModel(tool_selection_model_); - - tool_box_view_->setModel(tool_box_model_); - tool_box_view_->setSelectionModel(tool_selection_model_); - tool_box_view_->setIconSize(QSize(32, 32)); - tool_box_view_->setIndentation(10); - - connect(tool_selection_model_, - SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), - tool_box_model_, - SLOT(selectedToolChanged(const QModelIndex&, const QModelIndex&))); - - connect(tool_box_model_, - SIGNAL(enqueueToolAction(AbstractTool*)), - this, - SLOT(enqueueToolAction(AbstractTool*))); - - connect(this, - SIGNAL(activeProjectChanged(ProjectModel*, ProjectModel*)), - tool_box_model_, - SLOT(activeProjectChanged(ProjectModel*, ProjectModel*))); - - // TODO : Remove this, tools should have a better way of being run - connect(action_run_tool_, SIGNAL(clicked()), tool_box_model_, SLOT(toolAction())); - // tool_box_view_->setStyleSheet("branch:has-siblings:!adjoins-item:image none"); - // tool_box_view_->setStyleSheet("branch:!has-children:!has-siblings:adjoins-item:image: - // none"); + tool_box_model_ = new ToolBoxModel (tool_box_view_, tool_parameter_view_,this); + tool_selection_model_ = new QItemSelectionModel (tool_box_model_); + tool_box_model_->setSelectionModel (tool_selection_model_); + + tool_box_view_->setModel (tool_box_model_); + tool_box_view_->setSelectionModel (tool_selection_model_); + tool_box_view_->setIconSize (QSize (32,32)); + tool_box_view_->setIndentation (10); + + connect ( tool_selection_model_, SIGNAL (currentChanged (const QModelIndex&, const QModelIndex&)), + tool_box_model_, SLOT (selectedToolChanged (const QModelIndex&, const QModelIndex&))); + + connect ( tool_box_model_, SIGNAL (enqueueToolAction (AbstractTool*)), + this, SLOT (enqueueToolAction (AbstractTool*))); + + connect (this, SIGNAL (activeProjectChanged (ProjectModel*,ProjectModel*)), + tool_box_model_, SLOT (activeProjectChanged (ProjectModel*,ProjectModel*))); + + //TODO : Remove this, tools should have a better way of being run + connect ( action_run_tool_, SIGNAL (clicked ()), + tool_box_model_, SLOT (toolAction ())); + //tool_box_view_->setStyleSheet("branch:has-siblings:!adjoins-item:image none"); + // tool_box_view_->setStyleSheet("branch:!has-children:!has-siblings:adjoins-item:image: none"); + + } -void -pcl::cloud_composer::ComposerMainWindow::initializePlugins() + +void +pcl::cloud_composer::ComposerMainWindow::initializePlugins () { - QDir plugin_dir = QCoreApplication::applicationDirPath(); - qDebug() << plugin_dir.path() << " " - << QDir::cleanPath("../lib/cloud_composer_plugins"); + QDir plugin_dir = QCoreApplication::applicationDirPath (); + qDebug() << plugin_dir.path ()<< " "<(plugin); + QObject *plugin = loader.instance (); + ToolFactory* tool_factory = qobject_cast (plugin); if (tool_factory) { - qWarning() << "Loaded " << tool_factory->getPluginName(); - // Create the action button for this tool - tool_box_model_->addTool(tool_factory); + qWarning () << "Loaded " << tool_factory->getPluginName (); + //Create the action button for this tool + tool_box_model_->addTool (tool_factory); + } - else { - qDebug() << "Could not load " << plugin_dir.relativeFilePath(filename); - qDebug() << loader.errorString(); + else{ + qDebug() << "Could not load " << plugin_dir.relativeFilePath (filename); + qDebug() << loader.errorString (); } + } } -void -pcl::cloud_composer::ComposerMainWindow::setCurrentModel(ProjectModel* model) + + +void +pcl::cloud_composer::ComposerMainWindow::setCurrentModel (ProjectModel* model) { - emit activeProjectChanged(model, current_model_); + emit activeProjectChanged (model, current_model_); current_model_ = model; - // qDebug () << "Setting cloud browser model"; - cloud_browser_->setModel(current_model_); - // qDebug () << "Setting cloud browser selection model"; - cloud_browser_->setSelectionModel(current_model_->getSelectionModel()); - // qDebug () << "Item inspector setting model"; - item_inspector_->setModel(current_model_); - // qDebug () << "Setting active stack in undo group"; - undo_group_->setActiveStack(current_model_->getUndoStack()); - - multiplexer_->setCurrentObject(current_model_); + //qDebug () << "Setting cloud browser model"; + cloud_browser_->setModel (current_model_); + //qDebug () << "Setting cloud browser selection model"; + cloud_browser_->setSelectionModel (current_model_->getSelectionModel ()); + //qDebug () << "Item inspector setting model"; + item_inspector_->setModel (current_model_); + //qDebug () << "Setting active stack in undo group"; + undo_group_->setActiveStack (current_model_->getUndoStack ()); + + multiplexer_->setCurrentObject (current_model_); } void -pcl::cloud_composer::ComposerMainWindow::enqueueToolAction(AbstractTool* tool) +pcl::cloud_composer::ComposerMainWindow::enqueueToolAction (AbstractTool* tool) { if (current_model_) - current_model_->enqueueToolAction(tool); + current_model_->enqueueToolAction (tool); else - QMessageBox::warning( - this, "No Project Open!", "Cannot use tool, no project is open!"); + QMessageBox::warning (this, "No Project Open!", "Cannot use tool, no project is open!"); } ///////// FILE MENU SLOTS /////////// -void pcl::cloud_composer::ComposerMainWindow::on_action_new_project__triggered( - /*QString name*/) +void +pcl::cloud_composer::ComposerMainWindow::on_action_new_project__triggered (/*QString name*/) { QString name("unsaved project"); - qDebug() << "Creating New Project"; - ProjectModel* new_project_model = new ProjectModel(this); + qDebug () << "Creating New Project"; + ProjectModel* new_project_model = new ProjectModel (this); // Check if we have a project with this name already, append int if so - if (name_model_map_.contains(name)) { + if (name_model_map_.contains (name)) + { int k = 2; - while (name_model_map_.contains(name + tr("-%1").arg(k))) + while (name_model_map_.contains (name + tr ("-%1").arg (k))) ++k; - name += tr("-%1").arg(k); + name += tr ("-%1").arg (k); } - // qDebug () << "Setting name"; - new_project_model->setName(name); - // qDebug () << "Inserting into map"; - name_model_map_.insert(name, new_project_model); - // qDebug () << "Adding to undo group"; - undo_group_->addStack(new_project_model->getUndoStack()); - // qDebug () << "Setting current model"; - cloud_viewer_->addNewProject(new_project_model); - - setCurrentModel(new_project_model); - // qDebug () << "Project " <setName (name); + //qDebug () << "Inserting into map"; + name_model_map_.insert (name,new_project_model); + //qDebug () << "Adding to undo group"; + undo_group_->addStack (new_project_model->getUndoStack ()); + //qDebug () << "Setting current model"; + cloud_viewer_->addNewProject (new_project_model); + + setCurrentModel (new_project_model); + //qDebug () << "Project " <trigger(); - - emit insertNewCloudFromFile(); + action_new_project_->trigger (); + + emit insertNewCloudFromFile (); } void -pcl::cloud_composer::ComposerMainWindow::on_action_insert_from_rgb_depth__triggered() +pcl::cloud_composer::ComposerMainWindow::on_action_insert_from_rgb_depth__triggered () { if (!current_model_) - action_new_project_->trigger(); - - emit insertNewCloudFromRGBandDepth(); + action_new_project_->trigger (); + + emit insertNewCloudFromRGBandDepth (); } + void -pcl::cloud_composer::ComposerMainWindow:: - on_action_insert_from_openNi_source__triggered() +pcl::cloud_composer::ComposerMainWindow::on_action_insert_from_openNi_source__triggered () { - qDebug() << "Inserting cloud from OpenNi Source..."; + qDebug () << "Inserting cloud from OpenNi Source..."; } + + + diff --git a/apps/cloud_composer/src/cloud_viewer.cpp b/apps/cloud_composer/src/cloud_viewer.cpp index 1479ef25847..f47c1c053ae 100644 --- a/apps/cloud_composer/src/cloud_viewer.cpp +++ b/apps/cloud_composer/src/cloud_viewer.cpp @@ -1,62 +1,66 @@ -#include #include #include +#include #include -pcl::cloud_composer::CloudViewer::CloudViewer(QWidget* parent) : QTabWidget(parent) +pcl::cloud_composer::CloudViewer::CloudViewer (QWidget* parent) + : QTabWidget (parent) { - connect(this, SIGNAL(currentChanged(int)), this, SLOT(modelChanged(int))); + connect (this, SIGNAL (currentChanged (int)), + this, SLOT (modelChanged (int))); } void -pcl::cloud_composer::CloudViewer::addModel(ProjectModel* new_model) +pcl::cloud_composer::CloudViewer::addModel (ProjectModel* new_model) { - CloudView* new_view = new CloudView(new_model); - connect(new_model->getSelectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), - new_view, - SLOT(selectedItemChanged(QItemSelection, QItemSelection))); - new_model->setCloudView(new_view); - - QStandardItem* title = new_model->horizontalHeaderItem(0); - this->addTab(new_view, title->text()); + CloudView* new_view = new CloudView (new_model); + connect (new_model->getSelectionModel (), SIGNAL (selectionChanged (QItemSelection,QItemSelection)), + new_view, SLOT (selectedItemChanged (QItemSelection,QItemSelection))); + new_model->setCloudView (new_view); + + QStandardItem* title = new_model->horizontalHeaderItem (0); + this->addTab (new_view, title->text ()); + + model_view_map_.insert (new_model,new_view); + + setCurrentWidget (model_view_map_.value (new_model)); + //Refresh the view + new_view->refresh (); - model_view_map_.insert(new_model, new_view); - - setCurrentWidget(model_view_map_.value(new_model)); - // Refresh the view - new_view->refresh(); } - + pcl::cloud_composer::ProjectModel* -pcl::cloud_composer::CloudViewer::getModel() const +pcl::cloud_composer::CloudViewer::getModel () const { if (this->count() == 0) return nullptr; - return dynamic_cast(currentWidget())->getModel(); + return dynamic_cast (currentWidget ())->getModel (); } void -pcl::cloud_composer::CloudViewer::addNewProject(ProjectModel* new_model) +pcl::cloud_composer::CloudViewer::addNewProject (ProjectModel* new_model) { - // If we're already there, abort - if (new_model == getModel()) + //If we're already there, abort + if (new_model == getModel ()) return; - // Check whether we've seen the model yet - if (!model_view_map_.contains(new_model)) { - addModel(new_model); + //Check whether we've seen the model yet + if ( !model_view_map_.contains (new_model)) + { + addModel (new_model); } - else { - setCurrentWidget(model_view_map_.value(new_model)); - // Refresh the view - model_view_map_.value(new_model)->refresh(); + else + { + setCurrentWidget (model_view_map_.value (new_model)); + //Refresh the view + model_view_map_.value (new_model)->refresh (); } } void -pcl::cloud_composer::CloudViewer::modelChanged(int) +pcl::cloud_composer::CloudViewer::modelChanged (int) { - emit newModelSelected(getModel()); + emit newModelSelected (getModel ()); } + diff --git a/apps/cloud_composer/src/commands.cpp b/apps/cloud_composer/src/commands.cpp index 03ff9c15659..c8a0b9730d0 100644 --- a/apps/cloud_composer/src/commands.cpp +++ b/apps/cloud_composer/src/commands.cpp @@ -1,32 +1,38 @@ #include -#include -#include #include +#include +#include -pcl::cloud_composer::CloudCommand::CloudCommand( - QList input_data, QUndoCommand* parent) -: QUndoCommand(parent) -, original_data_(std::move(input_data)) -, can_use_templates_(false) -, template_type_(-1) -{} +pcl::cloud_composer::CloudCommand::CloudCommand (QList input_data, QUndoCommand* parent) + : QUndoCommand (parent) + , original_data_ (std::move(input_data)) + , can_use_templates_(false) + , template_type_ (-1) +{ -pcl::cloud_composer::CloudCommand::~CloudCommand() +} + +pcl::cloud_composer::CloudCommand::~CloudCommand () { - qDebug() << "Command Destructor"; - // If we have removed items, we delete them - if (!last_was_undo_) { - qDebug() << "Last was redo, removing original items "; - QList items_to_remove = removed_to_parent_map_.keys(); - foreach (QStandardItem* to_remove, items_to_remove) { - delete to_remove; + qDebug () << "Command Destructor"; + //If we have removed items, we delete them + if (!last_was_undo_) + { + qDebug () << "Last was redo, removing original items "; + QList items_to_remove = removed_to_parent_map_.keys (); + foreach (QStandardItem* to_remove, items_to_remove) + { + delete to_remove; } } - else { - qDebug() << "Last was undo, removing new items"; - foreach (OutputPair output_pair, output_data_) { - QList new_items = output_pair.output_items_; - foreach (CloudComposerItem* item, new_items) { + else + { + qDebug () << "Last was undo, removing new items"; + foreach (OutputPair output_pair, output_data_) + { + QList new_items = output_pair.output_items_; + foreach (CloudComposerItem* item, new_items) + { delete item; } } @@ -35,43 +41,44 @@ pcl::cloud_composer::CloudCommand::~CloudCommand() ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::CloudCommand::setProjectModel(ProjectModel* model) +pcl::cloud_composer::CloudCommand::setProjectModel (ProjectModel* model) { project_model_ = model; } bool -pcl::cloud_composer::CloudCommand::canUseTemplates(ConstItemList& input_data) +pcl::cloud_composer::CloudCommand::canUseTemplates (ConstItemList &input_data) { - // Make sure the input list isn't empty - if (input_data.empty()) { - qCritical() << "Cannot call a templated tool on an empty input in " - "CloudCommand::executeToolOnTemplateCloud!"; + //Make sure the input list isn't empty + if (input_data.empty ()) + { + qCritical () << "Cannot call a templated tool on an empty input in CloudCommand::executeToolOnTemplateCloud!"; template_type_ = -2; return false; } - // Make sure all input items are clouds - QList cloud_items; - foreach (const CloudComposerItem* item, input_data) { - const CloudItem* cloud_item = dynamic_cast(item); + //Make sure all input items are clouds + QList cloud_items; + foreach (const CloudComposerItem* item, input_data) + { + const CloudItem* cloud_item = dynamic_cast (item); if (cloud_item) - cloud_items.append(cloud_item); + cloud_items.append (cloud_item); } - if (cloud_items.size() != input_data.size()) { - qCritical() << "All input items are not clouds in " - "CloudCommand::executeToolOnTemplateCloud!"; + if (cloud_items.size () != input_data.size ()) + { + qCritical () << "All input items are not clouds in CloudCommand::executeToolOnTemplateCloud!"; template_type_ = -3; return false; } - + // Now make sure all input clouds have the same templated type - int type = cloud_items.value(0)->getPointType(); - foreach (const CloudItem* cloud_item, cloud_items) { - if (cloud_item->getPointType() != type) { - qCritical() << "All input point cloud template types in " - "CloudCommand::executeToolOnTemplateCloud are not the same!"; - qCritical() << cloud_item->text() << "'s type does not match " - << cloud_items.value(0)->type(); + int type = cloud_items.value (0)->getPointType (); + foreach (const CloudItem* cloud_item, cloud_items) + { + if (cloud_item->getPointType () != type) + { + qCritical () << "All input point cloud template types in CloudCommand::executeToolOnTemplateCloud are not the same!"; + qCritical () << cloud_item->text () << "'s type does not match "<type (); template_type_ = -3; return false; } @@ -82,114 +89,111 @@ pcl::cloud_composer::CloudCommand::canUseTemplates(ConstItemList& input_data) } /* -QList -pcl::cloud_composer::CloudCommand::executeToolOnTemplateCloud (AbstractTool* tool, -ConstItemList &input_data) +QList +pcl::cloud_composer::CloudCommand::executeToolOnTemplateCloud (AbstractTool* tool, ConstItemList &input_data) { QList output; // If can_use_templates_ is false and type is -1 we haven't checked if we can yet if (!can_use_templates_ && template_type_ == -1) this->canUseTemplates (input_data); - - + + //If this is true now, we can go ahead and run it if (can_use_templates_ && template_type_ >= 0) { - output = tool->performAction( input_data, static_cast -(template_type_)); + output = tool->performAction( input_data, static_cast (template_type_)); } else { - qDebug () << "Tried CloudCommand::executeToolOnTemplateCloud but input data was not -templated clouds!"; + qDebug () << "Tried CloudCommand::executeToolOnTemplateCloud but input data was not templated clouds!"; } return output; - + } */ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool -pcl::cloud_composer::CloudCommand::replaceOriginalWithNew( - const QList& originals, - const QList& new_items) -{ - // Find the input item's parent - if (originals.empty()) { - qCritical() << "No items to replace specified!"; +bool +pcl::cloud_composer::CloudCommand::replaceOriginalWithNew (const QList & originals, const QList & new_items) +{ + //Find the input item's parent + if (originals.empty ()) + { + qCritical () << "No items to replace specified!"; return false; } - - QStandardItem* parent_item = originals.value(0)->parent(); - // Verify that all items have same parent - foreach (const CloudComposerItem* item, originals) { - if (item->parent() != parent_item) { - qCritical() << "All original items must have same parent!"; + + QStandardItem* parent_item = originals.value(0)->parent (); + //Verify that all items have same parent + foreach (const CloudComposerItem* item, originals) + { + if (item->parent () != parent_item) + { + qCritical () << "All original items must have same parent!"; return false; } } // If parent is 0, it's parent is invisiblerootitem (That's how Qt defines it... boo!) if (parent_item == nullptr) - parent_item = project_model_->invisibleRootItem(); - - // Now remove all the originals - foreach (const CloudComposerItem* item, originals) { - QPersistentModelIndex original_index = - QPersistentModelIndex(project_model_->indexFromItem(item)); - if (!original_index.isValid()) { - qCritical() << "Index of item to replace is not valid!"; + parent_item = project_model_->invisibleRootItem (); + + //Now remove all the originals + foreach (const CloudComposerItem* item, originals) + { + QPersistentModelIndex original_index = QPersistentModelIndex(project_model_->indexFromItem (item)); + if (!original_index.isValid ()) + { + qCritical () << "Index of item to replace is not valid!"; return false; } - QList removed_items = parent_item->takeRow(original_index.row()); - removed_to_parent_map_.insert(removed_items.value(0), parent_item); + QList removed_items = parent_item->takeRow (original_index.row ()); + removed_to_parent_map_.insert (removed_items.value(0),parent_item); } - // Insert the new items below the parent item' - foreach (CloudComposerItem* item, new_items) { - parent_item->appendRow(item); + //Insert the new items below the parent item' + foreach (CloudComposerItem* item, new_items) + { + parent_item->appendRow (item); } return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool -pcl::cloud_composer::CloudCommand::restoreOriginalRemoveNew( - const QList& originals, - const QList& new_items) -{ - - // Now remove all the new items - foreach (CloudComposerItem* item, new_items) { - QStandardItem* parent_item = item->parent(); - // If parent is 0, it's parent is invisiblerootitem (That's how Qt defines it... - // boo!) +bool +pcl::cloud_composer::CloudCommand::restoreOriginalRemoveNew (const QList & originals, const QList & new_items) +{ + + //Now remove all the new items + foreach (CloudComposerItem* item, new_items) + { + QStandardItem* parent_item = item->parent (); + // If parent is 0, it's parent is invisiblerootitem (That's how Qt defines it... boo!) if (parent_item == nullptr) - parent_item = project_model_->invisibleRootItem(); - QPersistentModelIndex to_remove_index = - QPersistentModelIndex(project_model_->indexFromItem(item)); - if (!to_remove_index.isValid()) { - qCritical() << "Index of item to remove while restoring originals not valid"; + parent_item = project_model_->invisibleRootItem (); + QPersistentModelIndex to_remove_index = QPersistentModelIndex(project_model_->indexFromItem (item)); + if (!to_remove_index.isValid ()) + { + qCritical () << "Index of item to remove while restoring originals not valid"; return false; } - // Take them, they're still stored so we don't worry about them - QList removed = parent_item->takeRow(to_remove_index.row()); - } - // Restore the original items - foreach (const CloudComposerItem* item, originals) { - // Point iterator to the correct spot - // Find doesn't modify parameter so it should accept a const pointer, but it can't - // be because it is templated to the map type So we hack to get around this with a - // const cast - const auto& itr = removed_to_parent_map_.find(const_cast(item)); - QStandardItem* parent = itr.value(); - QStandardItem* original = itr.key(); - parent->appendRow(original); - int num = removed_to_parent_map_.remove(original); + //Take them, they're still stored so we don't worry about them + QList removed = parent_item->takeRow (to_remove_index.row ()); + } + //Restore the original items + foreach (const CloudComposerItem* item, originals) + { + //Point iterator to the correct spot + // Find doesn't modify parameter so it should accept a const pointer, but it can't be because it is templated to the map type + // So we hack to get around this with a const cast + const auto& itr = removed_to_parent_map_.find (const_cast (item)); + QStandardItem* parent = itr.value (); + QStandardItem* original = itr.key (); + parent->appendRow (original); + int num = removed_to_parent_map_.remove (original); if (num > 1) - qCritical() << "More than one item with same pointer in removed_to_parent_map_, " - "this is undefined behavior"; - else if (num == 0) - qCritical() << "Could not find key in map to remove, not good!"; + qCritical () << "More than one item with same pointer in removed_to_parent_map_, this is undefined behavior"; + else if (num == 0) + qCritical () << "Could not find key in map to remove, not good!"; } return true; @@ -198,42 +202,44 @@ pcl::cloud_composer::CloudCommand::restoreOriginalRemoveNew( ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////// MODIFY CLOUD COMMAND -pcl::cloud_composer::ModifyItemCommand::ModifyItemCommand( - QList input_data, QUndoCommand* parent) -: CloudCommand(std::move(input_data), parent) -{} +pcl::cloud_composer::ModifyItemCommand::ModifyItemCommand (QList input_data, QUndoCommand* parent) + : CloudCommand (std::move(input_data), parent) +{ + +} bool -pcl::cloud_composer::ModifyItemCommand::runCommand(AbstractTool* tool) +pcl::cloud_composer::ModifyItemCommand::runCommand (AbstractTool* tool) { - this->setText(tool->getToolName()); - // For modify item cloud command, each selected item should be processed separately + this->setText (tool->getToolName ()); + //For modify item cloud command, each selected item should be processed separately int num_items_returned = 0; - foreach (const CloudComposerItem* item, original_data_) { - QList input_list; - input_list.append(item); - QList output; + foreach (const CloudComposerItem *item, original_data_) + { + QList input_list; + input_list.append (item); + QList output; if (canUseTemplates(input_list)) - output = tool->performAction( - input_list, static_cast(template_type_)); + output = tool->performAction (input_list, static_cast (template_type_)); else - output = tool->performAction(input_list); - if (output.empty()) - qWarning() << "Warning: Tool " << tool->getToolName() - << "returned no item in a ModifyItemCommand"; - else { + output = tool->performAction (input_list); + if (output.empty ()) + qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a ModifyItemCommand"; + else + { OutputPair output_pair = {input_list, output}; - output_data_.append(output_pair); + output_data_.append (output_pair); num_items_returned++; } - if (output.size() > 1) { - qCritical() << "Tool " << tool->getToolName() - << "returned multiple items in a ModifyCloudCommand"; + if (output.size () > 1) + { + qCritical () << "Tool " << tool->getToolName () << "returned multiple items in a ModifyCloudCommand"; } + } - if (num_items_returned != original_data_.size()) { - qDebug() << "Modify Item command generated " << num_items_returned - << " which does not match input of " << original_data_.size() << " items"; + if (num_items_returned != original_data_.size ()) + { + qDebug () << "Modify Item command generated "< input_data, QUndoCommand* parent) -: CloudCommand(std::move(input_data), parent) -{} +pcl::cloud_composer::NewItemCloudCommand::NewItemCloudCommand (QList input_data, QUndoCommand* parent) + : CloudCommand (std::move(input_data), parent) +{ + +} bool -pcl::cloud_composer::NewItemCloudCommand::runCommand(AbstractTool* tool) +pcl::cloud_composer::NewItemCloudCommand::runCommand (AbstractTool* tool) { - this->setText(tool->getToolName()); - // For new item cloud command, each selected item should be processed separately - // e.g. calculate normals for every selected cloud + this->setText (tool->getToolName ()); + //For new item cloud command, each selected item should be processed separately + //e.g. calculate normals for every selected cloud int num_new_items = 0; - foreach (const CloudComposerItem* item, original_data_) { - QList input_list; - input_list.append(item); - QList output; + foreach (const CloudComposerItem *item, original_data_) + { + QList input_list; + input_list.append (item); + QList output; if (canUseTemplates(input_list)) - output = tool->performAction( - input_list, static_cast(template_type_)); + output = tool->performAction (input_list, static_cast (template_type_)); else - output = tool->performAction(input_list); - if (output.empty()) - qWarning() << "Warning: Tool " << tool->getToolName() - << "returned no item in a NewItemCloudCommand"; - else { + output = tool->performAction (input_list); + if (output.empty ()) + qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a NewItemCloudCommand"; + else + { OutputPair output_pair = {input_list, output}; - output_data_.append(output_pair); - num_new_items += output.size(); + output_data_.append (output_pair); + num_new_items += output.size (); } + } - if (num_new_items > 0) { - qDebug() << "New Item command generated " << num_new_items << " new items"; + if (num_new_items > 0) + { + qDebug () << "New Item command generated "< output_items = output_pair.output_items_; - // Find the input_item index in the project_model_ - QModelIndex input_index = project_model_->indexFromItem(const_input_item); - if (!input_index.isValid()) { - qCritical() << "Index of input cloud item is no longer valid, cannot undo " - "NewItemCloudCommand"; + qDebug () << "Undo in NewItemCloudCommand"; + foreach (OutputPair output_pair, output_data_) + { + //Each pair can only have one input item, so get it + const CloudComposerItem* const_input_item = output_pair.input_items_.value (0); + QList output_items = output_pair.output_items_; + //Find the input_item index in the project_model_ + QModelIndex input_index = project_model_->indexFromItem (const_input_item); + if (!input_index.isValid ()) + { + qCritical () << "Index of input cloud item is no longer valid, cannot undo NewItemCloudCommand"; return; } - // Get a copy of the input item we can modify - QStandardItem* item_to_change = project_model_->itemFromIndex(input_index); - // Remove the items we added - foreach (CloudComposerItem* output_item, output_items) { - QModelIndex output_index = project_model_->indexFromItem(output_item); - item_to_change->takeRow(output_index.row()); + //Get a copy of the input item we can modify + QStandardItem* item_to_change = project_model_->itemFromIndex (input_index); + //Remove the items we added + foreach (CloudComposerItem* output_item, output_items) + { + QModelIndex output_index = project_model_->indexFromItem (output_item); + item_to_change->takeRow (output_index.row ()); } + } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::NewItemCloudCommand::redo() +pcl::cloud_composer::NewItemCloudCommand::redo () { last_was_undo_ = false; - qDebug() << "Redo in NewItemCloudCommand - output data size=" << output_data_.size(); - foreach (OutputPair output_pair, output_data_) { - // Each pair can only have one input item, so get it - const CloudComposerItem* const_input_item = output_pair.input_items_.value(0); - QList output_items = output_pair.output_items_; - // Find the input_item index in the project_model_ - QPersistentModelIndex input_index = - QPersistentModelIndex(project_model_->indexFromItem(const_input_item)); - if (!input_index.isValid()) { - qCritical() - << "Index of input cloud item is no longer valid upon command completion!"; + qDebug () << "Redo in NewItemCloudCommand - output data size="< output_items = output_pair.output_items_; + //Find the input_item index in the project_model_ + QPersistentModelIndex input_index = QPersistentModelIndex(project_model_->indexFromItem (const_input_item)); + if (!input_index.isValid ()) + { + qCritical () << "Index of input cloud item is no longer valid upon command completion!"; return; } - // Get a copy of the input item we can modify - QStandardItem* input_item = (project_model_->itemFromIndex(input_index)); - // Append the output items to the input item - foreach (CloudComposerItem* output_item, output_items) { - input_item->appendRow(output_item); + //Get a copy of the input item we can modify + QStandardItem* input_item = (project_model_->itemFromIndex (input_index)); + //Append the output items to the input item + foreach (CloudComposerItem* output_item, output_items) + { + input_item->appendRow (output_item); } } } + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////// Split CLOUD COMMAND -////////////////////////////////////////////////////////////////////////////// +//////////// Split CLOUD COMMAND /////////////////////////////////////////////////////////////////////////// -pcl::cloud_composer::SplitCloudCommand::SplitCloudCommand( - QList input_data, QUndoCommand* parent) -: CloudCommand(std::move(input_data), parent) -{} +pcl::cloud_composer::SplitCloudCommand::SplitCloudCommand (QList input_data, QUndoCommand* parent) + : CloudCommand (std::move(input_data), parent) +{ + +} bool -pcl::cloud_composer::SplitCloudCommand::runCommand(AbstractTool* tool) +pcl::cloud_composer::SplitCloudCommand::runCommand (AbstractTool* tool) { - this->setText(tool->getToolName()); - // For split cloud command, each selected item should be processed separately - // e.g. calculate normals for every selected cloud + this->setText (tool->getToolName ()); + //For split cloud command, each selected item should be processed separately + //e.g. calculate normals for every selected cloud int num_new_items = 0; - foreach (const CloudComposerItem* item, original_data_) { - // Check to see if this is a cloud - QList input_list; - input_list.append(item); - QList output; + foreach (const CloudComposerItem *item, original_data_) + { + //Check to see if this is a cloud + QList input_list; + input_list.append (item); + QList output; if (canUseTemplates(input_list)) - output = tool->performAction( - input_list, static_cast(template_type_)); + output = tool->performAction (input_list, static_cast (template_type_)); else - output = tool->performAction(input_list); - if (output.empty()) - qWarning() << "Warning: Tool " << tool->getToolName() - << "returned no item in a SplitCloudCommand"; - else { - qDebug() << "Split command returned " << output.size() << " items"; + output = tool->performAction (input_list); + if (output.empty ()) + qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a SplitCloudCommand"; + else + { + qDebug () << "Split command returned "< 0) { - qDebug() << "Split Item command generated " << num_new_items << " new items"; + if (num_new_items > 0) + { + qDebug () << "Split Item command generated "< input_data, QUndoCommand* parent) -: CloudCommand(std::move(input_data), parent) -{} +pcl::cloud_composer::DeleteItemCommand::DeleteItemCommand (QList input_data, QUndoCommand* parent) + : CloudCommand (std::move(input_data), parent) +{ + +} bool -pcl::cloud_composer::DeleteItemCommand::runCommand(AbstractTool*) +pcl::cloud_composer::DeleteItemCommand::runCommand (AbstractTool*) { - - // For delete item command, each selected item should be processed separately - // e.g. delete every selected item - foreach (const CloudComposerItem* item, original_data_) { - QList output; - QList to_delete; - to_delete.append(item); + + //For delete item command, each selected item should be processed separately + //e.g. delete every selected item + foreach (const CloudComposerItem *item, original_data_) + { + QList output; + QList to_delete; + to_delete.append (item); OutputPair output_pair = {to_delete, output}; - output_data_.append(output_pair); - this->setText("Delete " + item->text()); + output_data_.append (output_pair); + this->setText ("Delete "+item->text ()); } - if (!original_data_.empty()) - this->setText("Delete multiple items"); + if (!original_data_.empty ()) + this->setText ("Delete multiple items"); return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::DeleteItemCommand::undo() +pcl::cloud_composer::DeleteItemCommand::undo () { last_was_undo_ = true; - // Add the original items back into the model - foreach (OutputPair output_pair, output_data_) { - if (!restoreOriginalRemoveNew(output_pair.input_items_, output_pair.output_items_)) - qCritical() << "Failed to restore items in DeleteItemCommand::undo!"; + //Add the original items back into the model + foreach (OutputPair output_pair, output_data_) + { + if (!restoreOriginalRemoveNew (output_pair.input_items_, output_pair.output_items_)) + qCritical () << "Failed to restore items in DeleteItemCommand::undo!"; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::DeleteItemCommand::redo() +pcl::cloud_composer::DeleteItemCommand::redo () { last_was_undo_ = false; - qDebug() << "Redo in DeleteItemCommand - num items to delete=" << output_data_.size(); - foreach (OutputPair output_pair, output_data_) { - // Replace the input with the output for this pair - if (!replaceOriginalWithNew(output_pair.input_items_, output_pair.output_items_)) - qCritical() << "Removal of items failed in DeleteItemCommand::redo"; + qDebug () << "Redo in DeleteItemCommand - num items to delete="< output_items; + //In merge command, input clouds will be combined, so send them to tool together + QList output_items; if (canUseTemplates(original_data_)) - output_items = tool->performAction( - original_data_, static_cast(template_type_)); + output_items = tool->performAction (original_data_, static_cast (template_type_)); else - output_items = tool->performAction(original_data_); - MergeSelection* merge_selection = dynamic_cast(tool); - // If this is a merge selection we need to put the partially selected items into the - // original data list too! We didn't send them before because merge selection already - // knows about them (and needs to tree input list differently from selected items) - if (merge_selection) { - QList selected_items = merge_selection->getSelectedItems(); + output_items = tool->performAction (original_data_); + MergeSelection* merge_selection = dynamic_cast (tool); + // If this is a merge selection we need to put the partially selected items into the original data list too! + // We didn't send them before because merge selection already knows about them (and needs to tree input list differently from selected items) + if (merge_selection) + { + QList selected_items = merge_selection->getSelectedItems(); foreach (const CloudItem* item, selected_items) - original_data_.append(item); + original_data_.append (item); } OutputPair output_pair = {original_data_, output_items}; - output_data_.append(output_pair); - - if (output_items.empty()) { - qWarning() << "Warning: Tool " << tool->getToolName() - << "returned no item in a MergeCloudCommand"; + output_data_.append (output_pair); + + if (output_items.empty ()) + { + qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a MergeCloudCommand"; return false; } - - this->setText("Merge Clouds"); + + this->setText ("Merge Clouds"); return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::MergeCloudCommand::undo() +pcl::cloud_composer::MergeCloudCommand::undo () { last_was_undo_ = true; - // Add the original items back into the model - foreach (OutputPair output_pair, output_data_) { - if (!restoreOriginalRemoveNew(output_pair.input_items_, output_pair.output_items_)) - qCritical() << "Failed to restore original clouds in MergeCloudCommand::undo!"; + //Add the original items back into the model + foreach (OutputPair output_pair, output_data_) + { + if (!restoreOriginalRemoveNew (output_pair.input_items_, output_pair.output_items_)) + qCritical () << "Failed to restore original clouds in MergeCloudCommand::undo!"; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::MergeCloudCommand::redo() +pcl::cloud_composer::MergeCloudCommand::redo () { - qDebug() << "Redo in MergeCloudCommand "; + qDebug () << "Redo in MergeCloudCommand "; last_was_undo_ = false; - // There is only one output_pair, but that's ok - foreach (OutputPair output_pair, output_data_) { - // Replace the input with the output for this pair - // This works because all input clouds must have same parent, the root item (clouds - // must be on top level) - if (!replaceOriginalWithNew(output_pair.input_items_, output_pair.output_items_)) - qCritical() << "Removal of items failed in MergeCloudCommand::redo"; + //There is only one output_pair, but that's ok + foreach (OutputPair output_pair, output_data_) + { + //Replace the input with the output for this pair + // This works because all input clouds must have same parent, the root item (clouds must be on top level) + if (! replaceOriginalWithNew (output_pair.input_items_, output_pair.output_items_)) + qCritical () << "Removal of items failed in MergeCloudCommand::redo"; + } } + diff --git a/apps/cloud_composer/src/item_inspector.cpp b/apps/cloud_composer/src/item_inspector.cpp index 5851c6da7b2..c32914f26ce 100644 --- a/apps/cloud_composer/src/item_inspector.cpp +++ b/apps/cloud_composer/src/item_inspector.cpp @@ -3,121 +3,133 @@ #include -pcl::cloud_composer::ItemInspector::ItemInspector(QWidget* parent) : QTabWidget(parent) +pcl::cloud_composer::ItemInspector::ItemInspector (QWidget* parent) + : QTabWidget(parent) { current_item_properties_model_ = nullptr; current_project_model_ = nullptr; current_selection_model_ = nullptr; + + parameter_view_ = new QTreeView (); + addTab (parameter_view_, "Parameters"); - parameter_view_ = new QTreeView(); - addTab(parameter_view_, "Parameters"); + } void -pcl::cloud_composer::ItemInspector::setModel(ProjectModel* new_model) +pcl::cloud_composer::ItemInspector::setModel (ProjectModel* new_model) { // DISABLED: JUST KEEP TREES ALWAYS EXPANDED - // If we have a model loaded, save its tree state - // if (current_item_properties_model_) - // storeTreeState (); - QItemSelectionModel* new_selection_model = new_model->getSelectionModel(); + //If we have a model loaded, save its tree state + //if (current_item_properties_model_) + // storeTreeState (); + QItemSelectionModel* new_selection_model = new_model->getSelectionModel (); current_project_model_ = new_model; - - if (current_selection_model_) { - disconnect(current_selection_model_, - SIGNAL(currentChanged(const QModelIndex, const QModelIndex)), - this, - SLOT(selectionChanged(const QModelIndex, const QModelIndex))); - removeTabs(); + + if (current_selection_model_) + { + disconnect (current_selection_model_, SIGNAL (currentChanged (const QModelIndex, const QModelIndex)), + this, SLOT (selectionChanged (const QModelIndex, const QModelIndex))); + removeTabs (); + } current_selection_model_ = new_selection_model; - connect(current_selection_model_, - SIGNAL(currentChanged(const QModelIndex, const QModelIndex)), - this, - SLOT(selectionChanged(const QModelIndex, const QModelIndex))); - - updateView(); + connect (current_selection_model_, SIGNAL (currentChanged (const QModelIndex, const QModelIndex)), + this, SLOT (selectionChanged (const QModelIndex,const QModelIndex))); + + updateView (); + } void -pcl::cloud_composer::ItemInspector::selectionChanged(const QModelIndex&, - const QModelIndex&) +pcl::cloud_composer::ItemInspector::selectionChanged (const QModelIndex &, const QModelIndex &) { - // If we have a model loaded, save its tree state - // if (current_item_properties_model_) - // storeTreeState (); + //If we have a model loaded, save its tree state + // if (current_item_properties_model_) + // storeTreeState (); if (current_project_model_) - updateView(); + updateView (); + } void -pcl::cloud_composer::ItemInspector::storeTreeState() +pcl::cloud_composer::ItemInspector::storeTreeState () { - QList expanded_list; - int row_count = current_item_properties_model_->rowCount(); - for (int i = 0; i < row_count; ++i) { - QModelIndex index = current_item_properties_model_->index(i, 0); - if (parameter_view_->isExpanded(index)) { - expanded_list << QPersistentModelIndex(index); + QList expanded_list; + int row_count = current_item_properties_model_->rowCount (); + for (int i = 0; i < row_count ; ++i) + { + QModelIndex index = current_item_properties_model_->index (i, 0); + if (parameter_view_->isExpanded (index)) + { + expanded_list << QPersistentModelIndex (index); } } // save list - item_treestate_map_.insert(current_item_properties_model_, expanded_list); + item_treestate_map_.insert (current_item_properties_model_, expanded_list); } void -pcl::cloud_composer::ItemInspector::restoreTreeState() +pcl::cloud_composer::ItemInspector::restoreTreeState () { - if (item_treestate_map_.contains(current_item_properties_model_)) { - parameter_view_->setUpdatesEnabled(false); - - foreach (QPersistentModelIndex item_index, - item_treestate_map_.value(current_item_properties_model_)) { - if (item_index.isValid()) - parameter_view_->setExpanded(item_index, true); + if (item_treestate_map_.contains (current_item_properties_model_)) + { + parameter_view_->setUpdatesEnabled (false); + + foreach (QPersistentModelIndex item_index, item_treestate_map_.value (current_item_properties_model_)) + { + if (item_index.isValid ()) + parameter_view_->setExpanded (item_index, true); } - parameter_view_->setUpdatesEnabled(true); + parameter_view_->setUpdatesEnabled (true); } + } -void -pcl::cloud_composer::ItemInspector::itemChanged(QStandardItem*) -{} +void +pcl::cloud_composer::ItemInspector::itemChanged (QStandardItem *) +{ + + +} void -pcl::cloud_composer::ItemInspector::removeTabs() +pcl::cloud_composer::ItemInspector::removeTabs () { - clear(); - addTab(parameter_view_, "Parameters"); + clear (); + addTab (parameter_view_, "Parameters"); } void -pcl::cloud_composer::ItemInspector::updateView() +pcl::cloud_composer::ItemInspector::updateView () { current_item_properties_model_ = nullptr; - QModelIndex current_item = current_selection_model_->currentIndex(); + QModelIndex current_item = current_selection_model_->currentIndex (); const QStandardItemModel* model = nullptr; CloudComposerItem* cloud_item = nullptr; - if (current_item.isValid()) - model = dynamic_cast(current_item.model()); - - if (model) { - cloud_item = dynamic_cast(model->itemFromIndex(current_item)); - if (cloud_item) { - current_item_properties_model_ = - cloud_item->data(ItemDataRole::PROPERTIES).value(); - // Display any additional graphical data if this item has any - QMap tabs = cloud_item->getInspectorTabs(); - foreach (QString tab_name, tabs.keys()) { - addTab(tabs.value(tab_name), tab_name); - tabs.value(tab_name)->show(); + if (current_item.isValid ()) + model = dynamic_cast (current_item.model ()); + + if (model) + { + cloud_item = dynamic_cast (model->itemFromIndex (current_item)); + if (cloud_item) + { + current_item_properties_model_ = cloud_item->data (ItemDataRole::PROPERTIES).value (); + //Display any additional graphical data if this item has any + QMap tabs = cloud_item->getInspectorTabs (); + foreach (QString tab_name, tabs.keys ()) + { + addTab (tabs.value (tab_name), tab_name); + tabs.value (tab_name)->show (); } } } - - parameter_view_->setModel(current_item_properties_model_); - parameter_view_->resizeColumnToContents(0); + + + parameter_view_->setModel (current_item_properties_model_); + parameter_view_->resizeColumnToContents (0); // restoreTreeState (); - parameter_view_->expandAll(); + parameter_view_->expandAll (); } diff --git a/apps/cloud_composer/src/items/cloud_composer_item.cpp b/apps/cloud_composer/src/items/cloud_composer_item.cpp index a87d5a2dba3..2d5c786f7c5 100644 --- a/apps/cloud_composer/src/items/cloud_composer_item.cpp +++ b/apps/cloud_composer/src/items/cloud_composer_item.cpp @@ -2,74 +2,74 @@ #include -pcl::cloud_composer::CloudComposerItem::CloudComposerItem(const QString& name) -: QStandardItem(name) +pcl::cloud_composer::CloudComposerItem::CloudComposerItem (const QString& name) + : QStandardItem(name) { - // Set up the properties, store pointer locally for convenience - properties_ = new PropertiesModel(this); - - QString item_id = name + QString("%1").arg((long)this); - - this->setData(QVariant::fromValue(properties_), ItemDataRole::PROPERTIES); - this->setData(QVariant(item_id), ItemDataRole::ITEM_ID); - - this->setForeground(QBrush(Qt::black)); + //Set up the properties, store pointer locally for convenience + properties_ = new PropertiesModel (this); + + QString item_id = name + QString ("%1").arg ((long)this); + + + this->setData (QVariant::fromValue (properties_), ItemDataRole::PROPERTIES); + this->setData (QVariant (item_id), ItemDataRole::ITEM_ID); + + this->setForeground (QBrush (Qt::black)); } -pcl::cloud_composer::CloudComposerItem::~CloudComposerItem() +pcl::cloud_composer::CloudComposerItem::~CloudComposerItem () { - properties_->deleteLater(); + properties_->deleteLater (); } pcl::cloud_composer::CloudComposerItem* -pcl::cloud_composer::CloudComposerItem::clone() const +pcl::cloud_composer::CloudComposerItem::clone () const { - CloudComposerItem* new_item = new CloudComposerItem(this->text()); - - PropertiesModel* new_item_properties = new_item->getPropertiesModel(); - new_item_properties->copyProperties(properties_); - - return new_item; + CloudComposerItem* new_item = new CloudComposerItem (this->text ()); + + PropertiesModel* new_item_properties = new_item->getPropertiesModel (); + new_item_properties->copyProperties (properties_); + + return new_item; } -QList -pcl::cloud_composer::CloudComposerItem::getChildren( - CloudComposerItem::ItemType type) const +QList +pcl::cloud_composer::CloudComposerItem::getChildren (CloudComposerItem::ItemType type) const { - QList items; - for (int i = 0; i < this->rowCount(); ++i) { - if (this->child(i)->type() == type) { - items.append(dynamic_cast(this->child(i))); + QList items; + for (int i = 0; i < this->rowCount (); ++i) + { + if ( this->child (i)->type () == type ) + { + items.append (dynamic_cast (this->child (i))); } } - + return items; } -void -pcl::cloud_composer::CloudComposerItem::addChild(CloudComposerItem* item_arg) +void +pcl::cloud_composer::CloudComposerItem::addChild (CloudComposerItem *item_arg) { - this->appendRow(item_arg); + this->appendRow (item_arg); } void -pcl::cloud_composer::CloudComposerItem::paintView( - pcl::visualization::PCLVisualizer::Ptr) const +pcl::cloud_composer::CloudComposerItem::paintView (pcl::visualization::PCLVisualizer::Ptr) const { - qDebug() << "Paint View in Cloud Composer Item - doing nothing"; + qDebug () << "Paint View in Cloud Composer Item - doing nothing"; } void -pcl::cloud_composer::CloudComposerItem::removeFromView( - pcl::visualization::PCLVisualizer::Ptr) const +pcl::cloud_composer::CloudComposerItem::removeFromView (pcl::visualization::PCLVisualizer::Ptr) const { - qDebug() << "Remove from View in Cloud Composer Item - doing nothing"; + qDebug () << "Remove from View in Cloud Composer Item - doing nothing"; } -QMap -pcl::cloud_composer::CloudComposerItem::getInspectorTabs() +QMap +pcl::cloud_composer::CloudComposerItem::getInspectorTabs () { - return QMap(); + return QMap (); } /* @@ -78,13 +78,15 @@ CloudPtrT pcl::cloud_composer::CloudComposerItem::getCloudPtr () const { QVariant cloud_variant = this->data (CLOUD); - // Get Extract the pointer from the cloud contained in this item, if the type can't be -converted, default-constructed value is returned CloudPtrT ptr; if -(cloud_variant.canConvert ()) ptr = cloud_variant.value (); + // Get Extract the pointer from the cloud contained in this item, if the type can't be converted, default-constructed value is returned + CloudPtrT ptr; + if (cloud_variant.canConvert ()) + ptr = cloud_variant.value (); else - qCritical () << "Requested Cloud of incorrect type from "<text ()<<" correct -type is "<text ()<<" correct type is "< +#include #include -#include - -pcl::cloud_composer::FPFHItem::FPFHItem( - QString name, - const pcl::PointCloud::Ptr& fpfh_ptr, - double radius) -: CloudComposerItem(std::move(name)), fpfh_ptr_(fpfh_ptr), radius_(radius) +pcl::cloud_composer::FPFHItem::FPFHItem (QString name, const pcl::PointCloud::Ptr& fpfh_ptr, double radius) + : CloudComposerItem (std::move(name)) + , fpfh_ptr_ (fpfh_ptr) + , radius_ (radius) { pcl::PointCloud::ConstPtr fpfh_const = fpfh_ptr; - this->setData(QVariant::fromValue(fpfh_const), ItemDataRole::CLOUD_TEMPLATED); - properties_->addCategory("Core Properties"); - properties_->addProperty( - "Radius", QVariant(radius_), Qt::ItemIsEnabled, "Core Properties"); + this->setData (QVariant::fromValue (fpfh_const), ItemDataRole::CLOUD_TEMPLATED); + properties_->addCategory ("Core Properties"); + properties_->addProperty ("Radius", QVariant (radius_), Qt::ItemIsEnabled, "Core Properties"); } pcl::cloud_composer::FPFHItem* -pcl::cloud_composer::FPFHItem::clone() const +pcl::cloud_composer::FPFHItem::clone () const { - pcl::PointCloud::Ptr fpfh_copy( - new pcl::PointCloud(*fpfh_ptr_)); - FPFHItem* new_item = new FPFHItem(this->text(), fpfh_copy, radius_); - - PropertiesModel* new_item_properties = new_item->getPropertiesModel(); - new_item_properties->copyProperties(properties_); - - return new_item; + pcl::PointCloud::Ptr fpfh_copy (new pcl::PointCloud (*fpfh_ptr_)); + FPFHItem* new_item = new FPFHItem (this->text (), fpfh_copy, radius_); + + PropertiesModel* new_item_properties = new_item->getPropertiesModel (); + new_item_properties->copyProperties (properties_); + + return new_item; } -QMap -pcl::cloud_composer::FPFHItem::getInspectorTabs() -{ - // Create the plotter and QVTKWidget if it doesn't exist - if (!plot_) { - plot_.reset(new pcl::visualization::PCLPlotter); +QMap +pcl::cloud_composer::FPFHItem::getInspectorTabs () +{ + //Create the plotter and QVTKWidget if it doesn't exist + if (!plot_) + { + plot_.reset (new pcl::visualization::PCLPlotter); qvtk_ = new PCLQVTKWidget(); - hist_page_ = new QWidget(); - QGridLayout* mainLayout = new QGridLayout(hist_page_); - mainLayout->addWidget(qvtk_, 0, 0); + hist_page_ = new QWidget (); + QGridLayout *mainLayout = new QGridLayout (hist_page_); + mainLayout-> addWidget (qvtk_,0,0); } - // Plot the histogram - plot_->addFeatureHistogram(*fpfh_ptr_, - fpfh_ptr_->width, - data(ItemDataRole::ITEM_ID).toString().toStdString()); - // Set the render window of the QVTK widget, update + //Plot the histogram + plot_->addFeatureHistogram (*fpfh_ptr_, fpfh_ptr_->width, data(ItemDataRole::ITEM_ID).toString().toStdString ()); + //Set the render window of the QVTK widget, update plot_->setViewInteractor(getInteractorCompat(*qvtk_)); setRenderWindowCompat(*qvtk_, *(plot_->getRenderWindow())); #if VTK_MAJOR_VERSION > 8 @@ -55,9 +50,12 @@ pcl::cloud_composer::FPFHItem::getInspectorTabs() #else qvtk_->update(); #endif // VTK_MAJOR_VERSION > 8 - qvtk_->show(); - - QMap tabs; - tabs.insert("Histogram", hist_page_); + qvtk_->show (); + + + QMap tabs; + tabs.insert ("Histogram",hist_page_); return tabs; } + + diff --git a/apps/cloud_composer/src/main.cpp b/apps/cloud_composer/src/main.cpp index d16a6f6a146..939bad15e72 100644 --- a/apps/cloud_composer/src/main.cpp +++ b/apps/cloud_composer/src/main.cpp @@ -2,12 +2,12 @@ /////////// MAIN //////////////////// int -main(int argc, char** argv) +main (int argc, char ** argv) { // Initialize QT - QApplication app(argc, argv); - + QApplication app (argc, argv); + pcl::cloud_composer::ComposerMainWindow cc; - cc.show(); - return (QApplication::exec()); + cc.show (); + return (QApplication::exec ()); } diff --git a/apps/cloud_composer/src/merge_selection.cpp b/apps/cloud_composer/src/merge_selection.cpp index 9999d9c67dc..63b670f2985 100644 --- a/apps/cloud_composer/src/merge_selection.cpp +++ b/apps/cloud_composer/src/merge_selection.cpp @@ -1,110 +1,112 @@ -#include -#include #include +#include + #include -#include -#include // for pcl::make_shared +#include // for pcl::make_shared #include +#include +#include -pcl::cloud_composer::MergeSelection::MergeSelection( - QMap selected_item_index_map, - QObject* parent) -: MergeCloudTool(nullptr, parent) -, selected_item_index_map_(std::move(selected_item_index_map)) -{} +pcl::cloud_composer::MergeSelection::MergeSelection (QMap selected_item_index_map, QObject* parent) + : MergeCloudTool (nullptr, parent) + , selected_item_index_map_ (std::move(selected_item_index_map)) +{ + +} -QList -pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, - PointTypeFlags::PointType type) +QList +pcl::cloud_composer::MergeSelection::performAction (ConstItemList input_data, PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) { - switch ((std::uint8_t)type) { - case (PointTypeFlags::XYZ): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction(input_data); + if (type != PointTypeFlags::NONE) + { + switch ((std::uint8_t) type) + { + case (PointTypeFlags::XYZ): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction (input_data); } } - QList output; + QList output; // Check input data length - if (input_data.empty() && selected_item_index_map_.isEmpty()) { - qCritical() << "Empty input in MergeSelection!"; + if ( input_data.empty () && selected_item_index_map_.isEmpty() ) + { + qCritical () << "Empty input in MergeSelection!"; return output; } - // Make sure all input items are cloud items - foreach (const CloudComposerItem* input_item, input_data) { - if (input_item->type() != CloudComposerItem::CLOUD_ITEM) { - qCritical() << "Input in MergeSelection not valid, contained non-CloudItem input"; + //Make sure all input items are cloud items + foreach (const CloudComposerItem* input_item, input_data) + { + if (input_item->type () != CloudComposerItem::CLOUD_ITEM ) + { + qCritical () << "Input in MergeSelection not valid, contained non-CloudItem input"; return output; } } pcl::ExtractIndices filter; - pcl::PCLPointCloud2::Ptr merged_cloud(new pcl::PCLPointCloud2); - // To Save the pose of the first original item + pcl::PCLPointCloud2::Ptr merged_cloud (new pcl::PCLPointCloud2); + //To Save the pose of the first original item Eigen::Vector4f source_origin; Eigen::Quaternionf source_orientation; bool pose_found = false; - foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys()) { - // If this cloud hasn't been completely selected - if (!input_data.contains(input_cloud_item)) { - pcl::PCLPointCloud2::ConstPtr input_cloud = - input_cloud_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - qDebug() << "Extracting " - << selected_item_index_map_.value(input_cloud_item)->indices.size() - << " points out of " << input_cloud->width; - filter.setInputCloud(input_cloud); - filter.setIndices(selected_item_index_map_.value(input_cloud_item)); - pcl::PCLPointCloud2::Ptr original_minus_indices = - pcl::make_shared(); - filter.setNegative(true); - filter.filter(*original_minus_indices); - filter.setNegative(false); - pcl::PCLPointCloud2::Ptr selected_points(new pcl::PCLPointCloud2); - filter.filter(*selected_points); + foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys ()) + { + //If this cloud hasn't been completely selected + if (!input_data.contains (input_cloud_item)) + { + pcl::PCLPointCloud2::ConstPtr input_cloud = input_cloud_item->data (ItemDataRole::CLOUD_BLOB).value (); + qDebug () << "Extracting "<indices.size() << " points out of "<width; + filter.setInputCloud (input_cloud); + filter.setIndices (selected_item_index_map_.value (input_cloud_item)); + pcl::PCLPointCloud2::Ptr original_minus_indices = pcl::make_shared (); + filter.setNegative (true); + filter.filter (*original_minus_indices); + filter.setNegative (false); + pcl::PCLPointCloud2::Ptr selected_points (new pcl::PCLPointCloud2); + filter.filter (*selected_points); - qDebug() << "Original minus indices is " << original_minus_indices->width; + qDebug () << "Original minus indices is "<width; - if (!pose_found) { - source_origin = - input_cloud_item->data(ItemDataRole::ORIGIN).value(); - source_orientation = input_cloud_item->data(ItemDataRole::ORIENTATION) - .value(); + if (!pose_found) + { + source_origin = input_cloud_item->data (ItemDataRole::ORIGIN).value (); + source_orientation = input_cloud_item->data (ItemDataRole::ORIENTATION).value (); pose_found = true; } - CloudItem* new_cloud_item = new CloudItem(input_cloud_item->text(), - original_minus_indices, - source_origin, - source_orientation); - output.append(new_cloud_item); - pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared(); - concatenate(*merged_cloud, *selected_points, *temp_cloud); + CloudItem* new_cloud_item = new CloudItem (input_cloud_item->text () + , original_minus_indices + , source_origin + , source_orientation); + output.append (new_cloud_item); + pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared (); + concatenate (*merged_cloud, *selected_points, *temp_cloud); merged_cloud = temp_cloud; } - // Append the input item to the original list - // input_data.append (input_cloud_item); + //Append the input item to the original list + //input_data.append (input_cloud_item); } - // Just concatenate for all fully selected clouds - foreach (const CloudComposerItem* input_item, input_data) { - pcl::PCLPointCloud2::ConstPtr input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); + //Just concatenate for all fully selected clouds + foreach (const CloudComposerItem* input_item, input_data) + { + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); - pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared(); - concatenate(*merged_cloud, *input_cloud, *temp_cloud); + pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared (); + concatenate (*merged_cloud, *input_cloud, *temp_cloud); merged_cloud = temp_cloud; } - CloudItem* cloud_item = new CloudItem( - "Cloud from Selection", merged_cloud, source_origin, source_orientation); + CloudItem* cloud_item = new CloudItem ("Cloud from Selection" + , merged_cloud + , source_origin + , source_orientation); - output.append(cloud_item); + output.append (cloud_item); return output; } diff --git a/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp b/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp index 96971e09ef2..791e0218ad6 100644 --- a/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp +++ b/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp @@ -4,105 +4,117 @@ #include + #include // For vtkStandardNewMacro #include -namespace pcl { -namespace cloud_composer { -vtkStandardNewMacro(ClickTrackballStyleInteractor); +namespace pcl +{ + namespace cloud_composer + { + vtkStandardNewMacro(ClickTrackballStyleInteractor); + } } -} // namespace pcl -pcl::cloud_composer::ClickTrackballStyleInteractor::ClickTrackballStyleInteractor() +pcl::cloud_composer::ClickTrackballStyleInteractor::ClickTrackballStyleInteractor () { manipulation_complete_event_ = interactor_events::MANIPULATION_COMPLETE_EVENT; - start_matrix_ = vtkSmartPointer::New(); - end_matrix_ = vtkSmartPointer::New(); - transform_ = vtkSmartPointer::New(); + start_matrix_= vtkSmartPointer::New (); + end_matrix_ = vtkSmartPointer::New (); + transform_ = vtkSmartPointer::New (); } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonDown() +pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonDown () { vtkInteractorStyleTrackballActor::OnLeftButtonDown(); - + vtkActor* selected_actor = vtkActor::SafeDownCast(this->InteractionProp); if (selected_actor) - selected_actor->GetMatrix(start_matrix_); + selected_actor->GetMatrix (start_matrix_); + } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonDown() +pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonDown () { vtkInteractorStyleTrackballActor::OnRightButtonDown(); - + vtkActor* selected_actor = vtkActor::SafeDownCast(this->InteractionProp); if (selected_actor) - selected_actor->GetMatrix(start_matrix_); + selected_actor->GetMatrix (start_matrix_); + } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonUp() +pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonUp () { vtkInteractorStyleTrackballActor::OnLeftButtonUp(); - vtkSmartPointer selected_actor = - vtkActor::SafeDownCast(this->InteractionProp); - if (selected_actor) { - // Fetch the actor we manipulated - - selected_actor->GetMatrix(end_matrix_); + vtkSmartPointer selected_actor = vtkActor::SafeDownCast(this->InteractionProp); + if (selected_actor) + { + //Fetch the actor we manipulated + + selected_actor->GetMatrix (end_matrix_); // Find the id of the actor we manipulated - pcl::visualization::CloudActorMap::const_iterator end = actors_->end(); + pcl::visualization::CloudActorMap::const_iterator end = actors_->end (); QString manipulated_id; - for (pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin(); - itr != end; - ++itr) { - // qDebug () << "Id = "<first); - if ((itr->second).actor == selected_actor) { - manipulated_id = (QString::fromStdString(itr->first)); + for( pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin (); itr != end; ++itr) + { + //qDebug () << "Id = "<first); + if ( (itr->second).actor == selected_actor) + { + manipulated_id = (QString::fromStdString (itr->first)); + } } - if (!manipulated_id.isEmpty()) { - ManipulationEvent* manip_event = new ManipulationEvent(); - manip_event->addManipulation(manipulated_id, start_matrix_, end_matrix_); - this->InvokeEvent(this->manipulation_complete_event_, manip_event); + if ( !manipulated_id.isEmpty() ) + { + ManipulationEvent* manip_event = new ManipulationEvent (); + manip_event->addManipulation (manipulated_id, start_matrix_, end_matrix_); + this->InvokeEvent (this->manipulation_complete_event_, manip_event); } - else { - qWarning() << "Could not find actor which matches manipulated actor in " - "ClickTrackballStyleInteractor::OnLeftButtonUp!!!"; + else + { + qWarning () << "Could not find actor which matches manipulated actor in ClickTrackballStyleInteractor::OnLeftButtonUp!!!"; } } } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonUp() +pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonUp () { vtkInteractorStyleTrackballActor::OnRightButtonUp(); - vtkSmartPointer selected_actor = - vtkActor::SafeDownCast(this->InteractionProp); - if (selected_actor) { - // Fetch the actor we manipulated - - selected_actor->GetMatrix(end_matrix_); + vtkSmartPointer selected_actor = vtkActor::SafeDownCast(this->InteractionProp); + if (selected_actor) + { + //Fetch the actor we manipulated + + selected_actor->GetMatrix (end_matrix_); // Find the id of the actor we manipulated - pcl::visualization::CloudActorMap::const_iterator end = actors_->end(); + pcl::visualization::CloudActorMap::const_iterator end = actors_->end (); QString manipulated_id; - for (pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin(); - itr != end; - ++itr) { - // qDebug () << "Id = "<first); - if ((itr->second).actor == selected_actor) { - manipulated_id = (QString::fromStdString(itr->first)); + for( pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin (); itr != end; ++itr) + { + //qDebug () << "Id = "<first); + if ( (itr->second).actor == selected_actor) + { + manipulated_id = (QString::fromStdString (itr->first)); + } } - if (!manipulated_id.isEmpty()) { - ManipulationEvent* manip_event = new ManipulationEvent(); - manip_event->addManipulation(manipulated_id, start_matrix_, end_matrix_); - this->InvokeEvent(this->manipulation_complete_event_, manip_event); + if ( !manipulated_id.isEmpty() ) + { + ManipulationEvent* manip_event = new ManipulationEvent (); + manip_event->addManipulation (manipulated_id, start_matrix_, end_matrix_); + this->InvokeEvent (this->manipulation_complete_event_, manip_event); } - else { - qWarning() << "Could not find actor which matches manipulated actor in " - "ClickTrackballStyleInteractor::OnRightButtonUp!!!"; + else + { + qWarning () << "Could not find actor which matches manipulated actor in ClickTrackballStyleInteractor::OnRightButtonUp!!!"; } } + } + + diff --git a/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp b/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp index a04d2d45a27..3744a244a32 100644 --- a/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp +++ b/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp @@ -1,7 +1,7 @@ -#include #include #include #include +#include #include #include @@ -9,113 +9,118 @@ #include #include -namespace pcl { -namespace cloud_composer { -vtkStandardNewMacro(InteractorStyleSwitch); +namespace pcl +{ + namespace cloud_composer + { + vtkStandardNewMacro(InteractorStyleSwitch); + } } -} // namespace pcl -pcl::cloud_composer::InteractorStyleSwitch::InteractorStyleSwitch() +pcl::cloud_composer::InteractorStyleSwitch::InteractorStyleSwitch () { - pcl_vis_style_ = - vtkSmartPointer::New(); - name_to_style_map_.insert(interactor_styles::PCL_VISUALIZER, pcl_vis_style_); - - rectangular_frustum_selector_ = vtkSmartPointer::New(); - name_to_style_map_.insert(interactor_styles::RECTANGULAR_FRUSTUM, - rectangular_frustum_selector_); - - selected_trackball_interactor_style_ = - vtkSmartPointer::New(); - name_to_style_map_.insert(interactor_styles::SELECTED_TRACKBALL, - selected_trackball_interactor_style_); - - click_trackball_interactor_style_ = - vtkSmartPointer::New(); - name_to_style_map_.insert(interactor_styles::CLICK_TRACKBALL, - click_trackball_interactor_style_); - + pcl_vis_style_ = vtkSmartPointer::New (); + name_to_style_map_.insert (interactor_styles::PCL_VISUALIZER, pcl_vis_style_); + + rectangular_frustum_selector_ = vtkSmartPointer::New (); + name_to_style_map_.insert (interactor_styles::RECTANGULAR_FRUSTUM, rectangular_frustum_selector_); + + selected_trackball_interactor_style_ = vtkSmartPointer ::New (); + name_to_style_map_.insert (interactor_styles::SELECTED_TRACKBALL, selected_trackball_interactor_style_); + + click_trackball_interactor_style_ = vtkSmartPointer ::New (); + name_to_style_map_.insert (interactor_styles::CLICK_TRACKBALL, click_trackball_interactor_style_); + area_picker_ = vtkSmartPointer::New(); - point_picker_ = vtkSmartPointer::New(); - + point_picker_ = vtkSmartPointer::New (); + current_style_ = nullptr; + } void -pcl::cloud_composer::InteractorStyleSwitch::initializeInteractorStyles( - pcl::visualization::PCLVisualizer::Ptr vis, ProjectModel* model) +pcl::cloud_composer::InteractorStyleSwitch::initializeInteractorStyles (pcl::visualization::PCLVisualizer::Ptr vis, ProjectModel* model) { - qDebug() << "Initializing Interactor Styles"; + qDebug () << "Initializing Interactor Styles"; vis_ = std::move(vis); project_model_ = model; - - pcl_vis_style_->Initialize(); - rens_ = vis_->getRendererCollection(); - pcl_vis_style_->setRendererCollection(rens_); - pcl_vis_style_->setCloudActorMap(vis_->getCloudActorMap()); - - rectangular_frustum_selector_->setCloudActorMap(vis_->getCloudActorMap()); - - selected_trackball_interactor_style_->setCloudActorMap(vis_->getCloudActorMap()); - selected_trackball_interactor_style_->setProjectModel(project_model_); - - click_trackball_interactor_style_->setCloudActorMap(vis_->getCloudActorMap()); - click_trackball_interactor_style_->setProjectModel(project_model_); + + pcl_vis_style_->Initialize (); + rens_ = vis_->getRendererCollection (); + pcl_vis_style_->setRendererCollection (rens_); + pcl_vis_style_->setCloudActorMap (vis_->getCloudActorMap ()); + + rectangular_frustum_selector_->setCloudActorMap (vis_->getCloudActorMap ()); + + selected_trackball_interactor_style_->setCloudActorMap (vis_->getCloudActorMap ()); + selected_trackball_interactor_style_->setProjectModel (project_model_); + + click_trackball_interactor_style_->setCloudActorMap (vis_->getCloudActorMap ()); + click_trackball_interactor_style_->setProjectModel (project_model_); } void -pcl::cloud_composer::InteractorStyleSwitch::setCurrentInteractorStyle( - interactor_styles::INTERACTOR_STYLES interactor_style) +pcl::cloud_composer::InteractorStyleSwitch::setCurrentInteractorStyle (interactor_styles::INTERACTOR_STYLES interactor_style) { - qDebug() << "Setting interactor style"; - vtkSmartPointer style_ptr = - name_to_style_map_.value(interactor_style); + qDebug () << "Setting interactor style"; + vtkSmartPointer style_ptr = name_to_style_map_.value (interactor_style); if (current_style_) - current_style_->SetInteractor(nullptr); - current_style_ = style_ptr; - - if (current_style_) { - qDebug() << "Modifying current interactor of style!"; - current_style_->SetInteractor(this->Interactor); - current_style_->SetTDxStyle(this->TDxStyle); - - if (interactor_style == interactor_styles::RECTANGULAR_FRUSTUM) { - vtkInteractorStyleRubberBandPick* rubber_band_style = - vtkInteractorStyleRubberBandPick::SafeDownCast(current_style_); - if (rubber_band_style) { - vis_->getRenderWindow()->GetInteractor()->SetPicker(area_picker_); - rubber_band_style->StartSelect(); + current_style_->SetInteractor (nullptr); + current_style_= style_ptr; + + if (current_style_) + { + qDebug () << "Modifying current interactor of style!"; + current_style_->SetInteractor (this->Interactor); + current_style_->SetTDxStyle (this->TDxStyle); + + if (interactor_style == interactor_styles::RECTANGULAR_FRUSTUM) + { + vtkInteractorStyleRubberBandPick* rubber_band_style = vtkInteractorStyleRubberBandPick::SafeDownCast (current_style_); + if (rubber_band_style) + { + vis_->getRenderWindow ()->GetInteractor ()->SetPicker (area_picker_); + rubber_band_style->StartSelect (); } } + + } + + + } //---------------------------------------------------------------------------- -void -pcl::cloud_composer::InteractorStyleSwitch::SetInteractor( - vtkRenderWindowInteractor* iren) +void +pcl::cloud_composer::InteractorStyleSwitch::SetInteractor (vtkRenderWindowInteractor *iren) { - if (iren == this->Interactor) { + if(iren == this->Interactor) + { return; } // if we already have an Interactor then stop observing it - if (this->Interactor) { + if(this->Interactor) + { this->Interactor->RemoveObserver(this->EventCallbackCommand); } this->Interactor = iren; // add observers for each of the events handled in ProcessEvents - if (iren) { - iren->AddObserver( - vtkCommand::CharEvent, this->EventCallbackCommand, this->Priority); - - iren->AddObserver( - vtkCommand::DeleteEvent, this->EventCallbackCommand, this->Priority); + if(iren) + { + iren->AddObserver(vtkCommand::CharEvent, + this->EventCallbackCommand, + this->Priority); + + iren->AddObserver(vtkCommand::DeleteEvent, + this->EventCallbackCommand, + this->Priority); } } //---------------------------------------------------------------------------- -void -pcl::cloud_composer::InteractorStyleSwitch::SetDefaultRenderer(vtkRenderer* renderer) +void +pcl::cloud_composer::InteractorStyleSwitch::SetDefaultRenderer (vtkRenderer* renderer) { vtkInteractorStyle::SetDefaultRenderer(renderer); pcl_vis_style_->SetDefaultRenderer(renderer); @@ -123,8 +128,8 @@ pcl::cloud_composer::InteractorStyleSwitch::SetDefaultRenderer(vtkRenderer* rend } //---------------------------------------------------------------------------- -void -pcl::cloud_composer::InteractorStyleSwitch::SetCurrentRenderer(vtkRenderer* renderer) +void +pcl::cloud_composer::InteractorStyleSwitch::SetCurrentRenderer (vtkRenderer* renderer) { this->vtkInteractorStyle::SetCurrentRenderer(renderer); pcl_vis_style_->SetCurrentRenderer(renderer); @@ -132,7 +137,7 @@ pcl::cloud_composer::InteractorStyleSwitch::SetCurrentRenderer(vtkRenderer* rend } void -pcl::cloud_composer::InteractorStyleSwitch::OnLeave() +pcl::cloud_composer::InteractorStyleSwitch::OnLeave () { - qDebug() << "ON LEAVE"; + qDebug () << "ON LEAVE"; } diff --git a/apps/cloud_composer/src/point_selectors/manipulation_event.cpp b/apps/cloud_composer/src/point_selectors/manipulation_event.cpp index f416edfbd10..7c70d738fa2 100644 --- a/apps/cloud_composer/src/point_selectors/manipulation_event.cpp +++ b/apps/cloud_composer/src/point_selectors/manipulation_event.cpp @@ -1,11 +1,9 @@ #include void -pcl::cloud_composer::ManipulationEvent::addManipulation( - const QString& id, - const vtkSmartPointer& start, - const vtkSmartPointer& end) +pcl::cloud_composer::ManipulationEvent::addManipulation (const QString& id, const vtkSmartPointer& start, const vtkSmartPointer& end) { - id_start_map_.insert(id, start); - id_end_map_.insert(id, end); + id_start_map_.insert (id, start); + id_end_map_.insert (id, end); + } diff --git a/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp b/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp index e1d87ac8ffb..22f0de1c526 100644 --- a/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp +++ b/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp @@ -3,99 +3,88 @@ #include -#include -#include -#include -#if VTK_MAJOR_VERSION > 9 || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 4) -#include -#else -#include -#endif -#include -#include #include +#include +#include #include +#include +#include +#include -namespace pcl { -namespace cloud_composer { -vtkStandardNewMacro(RectangularFrustumSelector); +namespace pcl +{ + namespace cloud_composer + { + vtkStandardNewMacro(RectangularFrustumSelector); + } } -} // namespace pcl -pcl::cloud_composer::RectangularFrustumSelector::RectangularFrustumSelector() +pcl::cloud_composer::RectangularFrustumSelector::RectangularFrustumSelector () { selection_complete_event_ = interactor_events::SELECTION_COMPLETE_EVENT; } void -pcl::cloud_composer::RectangularFrustumSelector::OnLeftButtonUp() +pcl::cloud_composer::RectangularFrustumSelector::OnLeftButtonUp () { - + vtkSmartPointer selected_actor = vtkSmartPointer::New(); - vtkSmartPointer selected_mapper = - vtkSmartPointer::New(); + vtkSmartPointer selected_mapper = vtkSmartPointer::New(); selected_actor->SetMapper(selected_mapper); - - vtkInteractorStyleRubberBandPick::OnLeftButtonUp(); - - vtkPlanes* frustum = - static_cast(this->GetInteractor()->GetPicker())->GetFrustum(); - -#if VTK_MAJOR_VERSION > 9 || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 4) - vtkSmartPointer id_filter = vtkSmartPointer::New(); -#else - vtkSmartPointer id_filter = vtkSmartPointer::New(); -#endif - id_filter->PointIdsOn(); - - vtkSmartPointer extract_geometry = - vtkSmartPointer::New(); - extract_geometry->SetImplicitFunction(frustum); - extract_geometry->SetInputConnection(id_filter->GetOutputPort()); - - vtkSmartPointer glyph_filter = - vtkSmartPointer::New(); - glyph_filter->SetInputConnection(extract_geometry->GetOutputPort()); - - vtkSmartPointer append = vtkAppendPolyData::New(); - - QMap id_selected_data_map; - for (const auto& actor : *actors_) { - const pcl::visualization::CloudActor* act = &actor.second; - vtkMapper* mapper = act->actor->GetMapper(); - vtkDataSet* data = mapper->GetInput(); - vtkPolyData* poly_data = vtkPolyData::SafeDownCast(data); - id_filter->SetInputData(poly_data); - - vtkSmartPointer selected = vtkSmartPointer::New(); - glyph_filter->SetOutput(selected); - glyph_filter->Update(); - if (selected->GetNumberOfPoints() > 0) { - qDebug() << "Selected " << selected->GetNumberOfPoints() << " points."; - id_selected_data_map.insert(QString::fromStdString(actor.first), selected); - append->AddInputData(selected); - } + + vtkInteractorStyleRubberBandPick::OnLeftButtonUp (); + + vtkPlanes* frustum = static_cast (this->GetInteractor ()->GetPicker ())->GetFrustum (); + + vtkSmartPointer id_filter = vtkSmartPointer::New (); + id_filter->PointIdsOn (); + + vtkSmartPointer extract_geometry = vtkSmartPointer::New (); + extract_geometry->SetImplicitFunction (frustum); + extract_geometry->SetInputConnection (id_filter->GetOutputPort ()); + + vtkSmartPointer glyph_filter = vtkSmartPointer::New (); + glyph_filter->SetInputConnection (extract_geometry->GetOutputPort ()); + + vtkSmartPointer append = vtkAppendPolyData::New (); + + QMap < QString, vtkPolyData* > id_selected_data_map; + for (const auto &actor : *actors_) + { + const pcl::visualization::CloudActor *act = &actor.second; + vtkMapper* mapper = act->actor->GetMapper (); + vtkDataSet* data = mapper->GetInput (); + vtkPolyData* poly_data = vtkPolyData::SafeDownCast (data); + id_filter->SetInputData (poly_data); + + vtkSmartPointer selected = vtkSmartPointer::New (); + glyph_filter->SetOutput (selected); + glyph_filter->Update (); + if (selected->GetNumberOfPoints() > 0) + { + qDebug () << "Selected " << selected->GetNumberOfPoints () << " points."; + id_selected_data_map.insert ( QString::fromStdString (actor.first), selected); + append->AddInputData (selected); + } } - append->Update(); - vtkSmartPointer all_points = append->GetOutput(); - qDebug() << "Allpoints = " << all_points->GetNumberOfPoints(); - - selected_mapper->SetInputData(all_points); - selected_mapper->ScalarVisibilityOff(); - - selected_actor->GetProperty()->SetColor(0.0, 1.0, 0.0); //(R,G,B) - selected_actor->GetProperty()->SetPointSize(3); - - this->CurrentRenderer->AddActor(selected_actor); - this->GetInteractor()->GetRenderWindow()->Render(); - this->HighlightProp(nullptr); - - if (all_points->GetNumberOfPoints() > 0) { - SelectionEvent* selected = new SelectionEvent(all_points, - selected_actor, - selected_mapper, - id_selected_data_map, - this->CurrentRenderer); - this->InvokeEvent(this->selection_complete_event_, selected); + append->Update (); + vtkSmartPointer all_points = append->GetOutput (); + qDebug () << "Allpoints = " <GetNumberOfPoints (); + + selected_mapper->SetInputData (all_points); + selected_mapper->ScalarVisibilityOff (); + + selected_actor->GetProperty ()->SetColor (0.0, 1.0, 0.0); //(R,G,B) + selected_actor->GetProperty ()->SetPointSize (3); + + this->CurrentRenderer->AddActor (selected_actor); + this->GetInteractor ()->GetRenderWindow ()->Render (); + this->HighlightProp (nullptr); + + if (all_points->GetNumberOfPoints () > 0) + { + SelectionEvent* selected = new SelectionEvent (all_points, selected_actor, selected_mapper, id_selected_data_map, this->CurrentRenderer); + this->InvokeEvent (this->selection_complete_event_, selected); } } + diff --git a/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp b/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp index 16fef7815e7..264e5f2f64b 100644 --- a/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp +++ b/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp @@ -4,116 +4,124 @@ #include #include -#include -#include +#include #include -#include +#include +#include #include -#include #include +#include -namespace pcl { -namespace cloud_composer { -vtkStandardNewMacro(SelectedTrackballStyleInteractor); + +namespace pcl +{ + namespace cloud_composer + { + vtkStandardNewMacro(SelectedTrackballStyleInteractor); + } } -} // namespace pcl -pcl::cloud_composer::SelectedTrackballStyleInteractor:: - SelectedTrackballStyleInteractor() +pcl::cloud_composer::SelectedTrackballStyleInteractor::SelectedTrackballStyleInteractor () { - manipulation_complete_event_ = interactor_events::MANIPULATION_COMPLETE_EVENT; + manipulation_complete_event_ = interactor_events::MANIPULATION_COMPLETE_EVENT; } void -pcl::cloud_composer::SelectedTrackballStyleInteractor::setSelectedActors() +pcl::cloud_composer::SelectedTrackballStyleInteractor::setSelectedActors () { - QList selected_cloud_ids; - QModelIndexList selected_indexes = model_->getSelectionModel()->selectedIndexes(); - foreach (QModelIndex index, selected_indexes) { - QStandardItem* item = model_->itemFromIndex(index); - CloudItem* cloud_item = dynamic_cast(item); + QList selected_cloud_ids; + QModelIndexList selected_indexes = model_->getSelectionModel()->selectedIndexes (); + foreach (QModelIndex index, selected_indexes) + { + QStandardItem* item = model_->itemFromIndex (index); + CloudItem* cloud_item = dynamic_cast (item); if (cloud_item) - selected_cloud_ids.append(cloud_item->getId()); + selected_cloud_ids.append (cloud_item->getId ()); } - - for (const auto& actorItem : *actors_) { - QString id = QString::fromStdString(actorItem.first); - if (selected_cloud_ids.contains(id)) { + + for (const auto &actorItem : *actors_) + { + QString id = QString::fromStdString (actorItem.first); + if (selected_cloud_ids.contains (id)) + { vtkLODActor* actor = actorItem.second.actor; - qDebug() << "Adding " << id << " to selected manip! ptr =" << actor; - selected_actors_map_.insert(id, actor); - vtkSmartPointer start_matrix = vtkSmartPointer::New(); - actor->GetMatrix(start_matrix); - start_matrix_map_.insert(id, start_matrix); + qDebug () << "Adding "<getId())) { - vtkPolyData* points_in_item = id_selected_data_map_.value(cloud_item->getId()); - vtkIdTypeArray* point_ids = vtkIdTypeArray::SafeDownCast( - points_in_item->GetPointData()->GetArray("vtkIdFilter_Ids")); - - indices->indices.resize(point_ids->GetNumberOfTuples()); - for (vtkIdType i = 0; i < point_ids->GetNumberOfTuples(); ++i) { - // qDebug () << "id="<GetValue (i); - indices->indices[i] = point_ids->GetValue(i); + if (id_selected_data_map_.contains (cloud_item->getId ())) + { + vtkPolyData* points_in_item = id_selected_data_map_.value (cloud_item->getId ()); + vtkIdTypeArray* point_ids = vtkIdTypeArray::SafeDownCast(points_in_item->GetPointData ()->GetArray ("vtkIdFilter_Ids")); + + indices->indices.resize (point_ids->GetNumberOfTuples ()); + for(vtkIdType i =0; i < point_ids->GetNumberOfTuples (); ++i) + { + //qDebug () << "id="<GetValue (i); + indices->indices[i] = point_ids->GetValue (i); } - // qDebug () << points_in_item->GetNumberOfPoints () << " selected points in - // "<getId (); + //qDebug () << points_in_item->GetNumberOfPoints () << " selected points in "<getId (); } + } diff --git a/apps/cloud_composer/src/properties_model.cpp b/apps/cloud_composer/src/properties_model.cpp index b9daf99d721..5ac24ddb669 100644 --- a/apps/cloud_composer/src/properties_model.cpp +++ b/apps/cloud_composer/src/properties_model.cpp @@ -1,129 +1,126 @@ -#include #include +#include #include -pcl::cloud_composer::PropertiesModel::PropertiesModel(QObject* parent) -: QStandardItemModel(parent) +pcl::cloud_composer::PropertiesModel::PropertiesModel (QObject* parent) + : QStandardItemModel (parent) { - setHorizontalHeaderItem(0, new QStandardItem("Name")); - setHorizontalHeaderItem(1, new QStandardItem("Value")); + setHorizontalHeaderItem (0, new QStandardItem ("Name")); + setHorizontalHeaderItem (1, new QStandardItem ("Value")); } -pcl::cloud_composer::PropertiesModel::PropertiesModel(CloudComposerItem* parent_item, - QObject* parent) -: QStandardItemModel(parent), parent_item_(parent_item) +pcl::cloud_composer::PropertiesModel::PropertiesModel (CloudComposerItem* parent_item, QObject* parent) + : QStandardItemModel (parent) + , parent_item_ (parent_item) { - setHorizontalHeaderItem(0, new QStandardItem("Name")); - setHorizontalHeaderItem(1, new QStandardItem("Value")); - - connect(this, - SIGNAL(itemChanged(QStandardItem*)), - this, - SLOT(propertyChanged(QStandardItem*))); + setHorizontalHeaderItem (0, new QStandardItem ("Name")); + setHorizontalHeaderItem (1, new QStandardItem ("Value")); + + connect (this, SIGNAL (itemChanged (QStandardItem*)), + this, SLOT (propertyChanged (QStandardItem*))); } -pcl::cloud_composer::PropertiesModel::PropertiesModel(const PropertiesModel& to_copy) -: QStandardItemModel() +pcl::cloud_composer::PropertiesModel::PropertiesModel (const PropertiesModel& to_copy) +: QStandardItemModel () { - for (int i = 0; i < to_copy.rowCount(); ++i) { - QList new_row; - QStandardItem* parent = to_copy.item(i, 0); - QModelIndex parent_index = to_copy.index(i, 0); - new_row.append(parent->clone()); - for (int j = 0; j < to_copy.columnCount(parent_index); ++j) { - if (to_copy.item(i, j)) - new_row.append(to_copy.item(i, j)->clone()); + for (int i=0; i < to_copy.rowCount (); ++i){ + QList new_row; + QStandardItem* parent = to_copy.item(i,0); + QModelIndex parent_index = to_copy.index(i,0); + new_row.append (parent->clone ()); + for (int j=0; j < to_copy.columnCount (parent_index); ++j) + { + if (to_copy.item (i,j)) + new_row.append (to_copy.item(i,j)->clone ()); } - appendRow(new_row); + appendRow (new_row); } } void -pcl::cloud_composer::PropertiesModel::addProperty(const QString& prop_name, - const QVariant& value, - Qt::ItemFlags flags, - const QString& category) +pcl::cloud_composer::PropertiesModel::addProperty (const QString& prop_name, const QVariant& value, Qt::ItemFlags flags, const QString& category) { - QStandardItem* parent_item = invisibleRootItem(); - if (category.size() > 0) { - QList items = findItems(category); - if (items.empty()) - qWarning() << "No category named " << prop_name << " found in " - << parent_item_->text() << " adding to root"; - else if (items.size() > 1) - qCritical() << "Multiple categories with same name found!! This is not good..."; + QStandardItem* parent_item = invisibleRootItem (); + if (category.size () > 0) + { + QList items = findItems (category); + if (items.empty ()) + qWarning () << "No category named "<text ()<<" adding to root"; + else if (items.size () > 1) + qCritical () << "Multiple categories with same name found!! This is not good..."; else - parent_item = items.at(0); + parent_item = items.at (0); } - QList new_row; - QStandardItem* new_property = new QStandardItem(prop_name); - new_property->setFlags(Qt::ItemIsSelectable); - new_row.append(new_property); - - QStandardItem* new_value = new QStandardItem(); - new_value->setFlags(flags); - new_value->setData(value, Qt::EditRole); - new_row.append(new_value); - - parent_item->appendRow(new_row); + QList new_row; + QStandardItem* new_property = new QStandardItem (prop_name); + new_property->setFlags (Qt::ItemIsSelectable); + new_row.append (new_property); + + QStandardItem* new_value = new QStandardItem (); + new_value->setFlags (flags); + new_value->setData (value, Qt::EditRole); + new_row.append (new_value); + + parent_item->appendRow (new_row); } void -pcl::cloud_composer::PropertiesModel::addCategory(const QString& category_name) +pcl::cloud_composer::PropertiesModel::addCategory (const QString& category_name) { - QStandardItem* new_category = new QStandardItem(category_name); - appendRow(new_category); + QStandardItem* new_category = new QStandardItem (category_name); + appendRow (new_category); } -QVariant -pcl::cloud_composer::PropertiesModel::getProperty(const QString& prop_name) const +QVariant +pcl::cloud_composer::PropertiesModel::getProperty (const QString& prop_name) const { - // qDebug () << "Searching for property " << prop_name; - QList items = - findItems(prop_name, Qt::MatchExactly | Qt::MatchRecursive, 0); - if (items.empty()) { - qWarning() << "No property named " << prop_name << " found in " - << parent_item_->text(); - return QVariant(); + //qDebug () << "Searching for property " << prop_name; + QList items = findItems (prop_name, Qt::MatchExactly | Qt::MatchRecursive, 0); + if (items.empty ()) + { + qWarning () << "No property named "<text (); + return QVariant (); } - if (items.size() > 1) { - qWarning() << "Multiple properties found with name " << prop_name << " in " - << parent_item_->text(); + if (items.size () > 1) + { + qWarning () << "Multiple properties found with name "<text (); } - // qDebug () << "Found properties size ="<text() << " cols =" << to_copy->columnCount(); - new_row.append(parent->clone()); - for (int j = 1; j < to_copy->columnCount(); ++j) { - if (to_copy->item(i, j)) { - new_row.append(to_copy->item(i, j)->clone()); + for (int i=0; i < to_copy->rowCount (); ++i){ + QList new_row; + QStandardItem* parent = to_copy->item(i,0); + qDebug () << "Copying "<text()<< " cols ="<columnCount (); + new_row.append (parent->clone ()); + for (int j=1; j < to_copy->columnCount (); ++j) + { + if (to_copy->item (i,j)) + { + new_row.append (to_copy->item(i,j)->clone ()); } } - appendRow(new_row); + appendRow (new_row); } } + void -pcl::cloud_composer::PropertiesModel::propertyChanged(QStandardItem*) +pcl::cloud_composer::PropertiesModel::propertyChanged (QStandardItem*) { - // qDebug () << "Property Changed in properties model"; - parent_item_->propertyChanged(); + //qDebug () << "Property Changed in properties model"; + parent_item_->propertyChanged (); } diff --git a/apps/cloud_composer/src/signal_multiplexer.cpp b/apps/cloud_composer/src/signal_multiplexer.cpp index 16612f078d4..be0506b6496 100644 --- a/apps/cloud_composer/src/signal_multiplexer.cpp +++ b/apps/cloud_composer/src/signal_multiplexer.cpp @@ -1,14 +1,15 @@ -#include #include +#include + +pcl::cloud_composer::SignalMultiplexer::SignalMultiplexer (QObject* parent) + : QObject (parent) +{ + +} -pcl::cloud_composer::SignalMultiplexer::SignalMultiplexer(QObject* parent) -: QObject(parent) -{} void -pcl::cloud_composer::SignalMultiplexer::connect(QObject* sender, - const char* signal, - const char* slot) +pcl::cloud_composer::SignalMultiplexer::connect (QObject* sender, const char* signal, const char* slot) { Connection conn; conn.sender = sender; @@ -16,13 +17,12 @@ pcl::cloud_composer::SignalMultiplexer::connect(QObject* sender, conn.slot = slot; connections << conn; - connect(conn); + connect (conn); } + void -pcl::cloud_composer::SignalMultiplexer::connect(const char* signal, - QObject* receiver, - const char* slot) +pcl::cloud_composer::SignalMultiplexer::connect (const char* signal, QObject* receiver, const char* slot) { Connection conn; conn.receiver = receiver; @@ -30,20 +30,21 @@ pcl::cloud_composer::SignalMultiplexer::connect(const char* signal, conn.slot = slot; connections << conn; - connect(conn); + connect (conn); } + bool -pcl::cloud_composer::SignalMultiplexer::disconnect(QObject* sender, - const char* signal, - const char* slot) +pcl::cloud_composer::SignalMultiplexer::disconnect (QObject* sender, const char* signal, const char* slot) { - QMutableListIterator it(connections); - while (it.hasNext()) { + QMutableListIterator it (connections); + while (it.hasNext ()) + { Connection conn = it.next(); - if ((QObject*)conn.sender == sender && qstrcmp(conn.signal, signal) == 0 && - qstrcmp(conn.slot, slot) == 0) { - disconnect(conn); + if ( (QObject*) conn.sender == sender && + qstrcmp (conn.signal, signal) == 0 && qstrcmp (conn.slot, slot) == 0) + { + disconnect (conn); it.remove(); return true; } @@ -51,17 +52,18 @@ pcl::cloud_composer::SignalMultiplexer::disconnect(QObject* sender, return false; } + bool -pcl::cloud_composer::SignalMultiplexer::disconnect(const char* signal, - QObject* receiver, - const char* slot) +pcl::cloud_composer::SignalMultiplexer::disconnect (const char* signal, QObject* receiver, const char* slot) { - QMutableListIterator it(connections); - while (it.hasNext()) { + QMutableListIterator it (connections); + while (it.hasNext ()) + { Connection conn = it.next(); - if ((QObject*)conn.receiver == receiver && qstrcmp(conn.signal, signal) == 0 && - qstrcmp(conn.slot, slot) == 0) { - disconnect(conn); + if ( (QObject*) conn.receiver == receiver && + qstrcmp (conn.signal, signal) == 0 && qstrcmp (conn.slot, slot) == 0) + { + disconnect (conn); it.remove(); return true; } @@ -69,8 +71,9 @@ pcl::cloud_composer::SignalMultiplexer::disconnect(const char* signal, return false; } + void -pcl::cloud_composer::SignalMultiplexer::connect(const Connection& conn) +pcl::cloud_composer::SignalMultiplexer::connect (const Connection& conn) { if (!object) return; @@ -78,13 +81,14 @@ pcl::cloud_composer::SignalMultiplexer::connect(const Connection& conn) return; if (conn.sender) - QObject::connect((QObject*)conn.sender, conn.signal, (QObject*)object, conn.slot); + QObject::connect ( (QObject*) conn.sender, conn.signal, (QObject*) object, conn.slot); else - QObject::connect((QObject*)object, conn.signal, (QObject*)conn.receiver, conn.slot); + QObject::connect ( (QObject*) object, conn.signal, (QObject*) conn.receiver, conn.slot); } -void -pcl::cloud_composer::SignalMultiplexer::disconnect(const Connection& conn) + +void +pcl::cloud_composer::SignalMultiplexer::disconnect (const Connection& conn) { if (!object) return; @@ -92,29 +96,29 @@ pcl::cloud_composer::SignalMultiplexer::disconnect(const Connection& conn) return; if (conn.sender) - QObject::disconnect( - (QObject*)conn.sender, conn.signal, (QObject*)object, conn.slot); + QObject::disconnect ( (QObject*) conn.sender, conn.signal, (QObject*) object, conn.slot); else - QObject::disconnect( - (QObject*)object, conn.signal, (QObject*)conn.receiver, conn.slot); + QObject::disconnect ( (QObject*) object, conn.signal, (QObject*) conn.receiver, conn.slot); + } -void -pcl::cloud_composer::SignalMultiplexer::setCurrentObject(QObject* newObject) + +void +pcl::cloud_composer::SignalMultiplexer::setCurrentObject (QObject* newObject) { if (newObject == object) return; - for (const auto& connection : connections) - disconnect(connection); + for (const auto &connection : connections) + disconnect (connection); object = newObject; - for (const auto& connection : connections) - connect(connection); + for (const auto &connection : connections) + connect (connection); - ProjectModel* model = dynamic_cast(newObject); + ProjectModel* model = dynamic_cast (newObject); if (model) - model->emitAllStateSignals(); - - // let the world know about who's on top now - emit currentObjectChanged(object); + model->emitAllStateSignals (); + + //let the world know about who's on top now + emit currentObjectChanged (object); } diff --git a/apps/cloud_composer/src/tool_interface/abstract_tool.cpp b/apps/cloud_composer/src/tool_interface/abstract_tool.cpp index 21708ef50ca..8a23d6947db 100644 --- a/apps/cloud_composer/src/tool_interface/abstract_tool.cpp +++ b/apps/cloud_composer/src/tool_interface/abstract_tool.cpp @@ -1,21 +1,23 @@ #include -pcl::cloud_composer::AbstractTool::AbstractTool(PropertiesModel* parameter_model, - QObject* parent) -: QObject(parent) - +pcl::cloud_composer::AbstractTool::AbstractTool (PropertiesModel* parameter_model, QObject* parent) + : QObject (parent) + { - parameter_model_ = new PropertiesModel(this); - // If there's a model copy it into the local copy - if (parameter_model) { + parameter_model_ = new PropertiesModel (this); + //If there's a model copy it into the local copy + if (parameter_model) + { parameter_model_->copyProperties(parameter_model); + } + + } -QList -pcl::cloud_composer::AbstractTool::performAction(QList, - PointTypeFlags::PointType) +QList +pcl::cloud_composer::AbstractTool::performAction (QList , PointTypeFlags::PointType) { - qDebug() << "AbstractTool::performTemplatedAction"; - return QList(); + qDebug () << "AbstractTool::performTemplatedAction"; + return QList (); } diff --git a/apps/cloud_composer/src/toolbox_model.cpp b/apps/cloud_composer/src/toolbox_model.cpp index 8e3f70bd33e..dd70fbd2c13 100644 --- a/apps/cloud_composer/src/toolbox_model.cpp +++ b/apps/cloud_composer/src/toolbox_model.cpp @@ -1,242 +1,247 @@ -#include -#include +#include #include #include -#include +#include +#include #include #include -pcl::cloud_composer::ToolBoxModel::ToolBoxModel(QTreeView* tool_view, - QTreeView* parameter_view_, - QObject* parent) -: QStandardItemModel(parent) -, tool_view_(tool_view) -, parameter_view_(parameter_view_) -, project_model_(nullptr) -{} +pcl::cloud_composer::ToolBoxModel::ToolBoxModel (QTreeView* tool_view, QTreeView* parameter_view_, QObject* parent) +: QStandardItemModel (parent) +, tool_view_ (tool_view) +, parameter_view_ (parameter_view_) +, project_model_ (nullptr) +{ + +} -pcl::cloud_composer::ToolBoxModel::ToolBoxModel(const ToolBoxModel&) -: QStandardItemModel() -{} +pcl::cloud_composer::ToolBoxModel::ToolBoxModel (const ToolBoxModel&) +: QStandardItemModel () +{ +} void -pcl::cloud_composer::ToolBoxModel::addTool(ToolFactory* tool_factory) +pcl::cloud_composer::ToolBoxModel::addTool (ToolFactory* tool_factory) { - // qDebug () << "Icon name:"<< tool_factory->getIconName (); - QIcon new_tool_icon = QIcon(tool_factory->getIconName()); - QStandardItem* new_tool_item = - new QStandardItem(new_tool_icon, tool_factory->getPluginName()); - new_tool_item->setEditable(false); - - new_tool_item->setData(QVariant::fromValue(tool_factory), FACTORY); - PropertiesModel* new_tool_parameters = tool_factory->createToolParameterModel(this); - new_tool_item->setData(QVariant::fromValue(new_tool_parameters), PARAMETER_MODEL); - - tool_items.insert(new_tool_item); - QStandardItem* group_item = addToolGroup(tool_factory->getToolGroupName()); - group_item->appendRow(new_tool_item); - // Expand the view for this tool group + //qDebug () << "Icon name:"<< tool_factory->getIconName (); + QIcon new_tool_icon = QIcon (tool_factory->getIconName ()); + QStandardItem* new_tool_item = new QStandardItem (new_tool_icon, tool_factory->getPluginName ()); + new_tool_item->setEditable (false); + + new_tool_item->setData (QVariant::fromValue (tool_factory), FACTORY); + PropertiesModel* new_tool_parameters= tool_factory->createToolParameterModel (this); + new_tool_item->setData (QVariant::fromValue (new_tool_parameters), PARAMETER_MODEL); + + tool_items.insert (new_tool_item); + QStandardItem* group_item = addToolGroup (tool_factory->getToolGroupName ()); + group_item->appendRow (new_tool_item); + //Expand the view for this tool group QModelIndex group_index = this->indexFromItem(group_item); - tool_view_->setExpanded(group_index, true); + tool_view_->setExpanded (group_index, true); } void -pcl::cloud_composer::ToolBoxModel::setSelectionModel( - QItemSelectionModel* selection_model) +pcl::cloud_composer::ToolBoxModel::setSelectionModel (QItemSelectionModel* selection_model) { selection_model_ = selection_model; } - + QStandardItem* -pcl::cloud_composer::ToolBoxModel::addToolGroup(const QString& tool_group_name) +pcl::cloud_composer::ToolBoxModel::addToolGroup (const QString& tool_group_name) { - QList matches_name = findItems(tool_group_name); - if (matches_name.empty()) { - QStandardItem* new_group_item = new QStandardItem(tool_group_name); - appendRow(new_group_item); - new_group_item->setSelectable(false); - new_group_item->setEditable(false); + QList matches_name = findItems (tool_group_name); + if (matches_name.empty ()) + { + QStandardItem* new_group_item = new QStandardItem (tool_group_name); + appendRow (new_group_item); + new_group_item->setSelectable (false); + new_group_item->setEditable (false); return new_group_item; } - if (matches_name.size() > 1) { - qWarning() << "Multiple tool groups with same name in ToolBoxModel!!"; + if (matches_name.size () > 1) + { + qWarning () << "Multiple tool groups with same name in ToolBoxModel!!"; } - - return matches_name.value(0); + + return matches_name.value (0); + } -void -pcl::cloud_composer::ToolBoxModel::activeProjectChanged(ProjectModel* new_model, - ProjectModel*) +void +pcl::cloud_composer::ToolBoxModel::activeProjectChanged(ProjectModel* new_model, ProjectModel*) { - // Disconnect old project model signal for selection change - if (project_model_) { - disconnect(project_model_->getSelectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), - this, - SLOT(selectedItemChanged(QItemSelection, QItemSelection))); - disconnect(project_model_, SIGNAL(modelChanged()), this, SLOT(modelChanged())); - } - qDebug() << "Active project changed in ToolBox Model!"; + //Disconnect old project model signal for selection change + if (project_model_) + { + disconnect (project_model_->getSelectionModel (), SIGNAL (selectionChanged (QItemSelection,QItemSelection)), + this, SLOT (selectedItemChanged (QItemSelection,QItemSelection))); + disconnect (project_model_, SIGNAL (modelChanged()), + this, SLOT (modelChanged())); + + } + qDebug () << "Active project changed in ToolBox Model!"; project_model_ = new_model; - - // Update enabled tools, make connection for doing this automatically - if (project_model_) { - updateEnabledTools(project_model_->getSelectionModel()->selection()); - connect(project_model_->getSelectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), - this, - SLOT(selectedItemChanged(QItemSelection, QItemSelection))); - connect(project_model_, SIGNAL(modelChanged()), this, SLOT(modelChanged())); + + //Update enabled tools, make connection for doing this automatically + if (project_model_) + { + updateEnabledTools (project_model_->getSelectionModel ()->selection ()); + connect (project_model_->getSelectionModel (), SIGNAL (selectionChanged (QItemSelection,QItemSelection)), + this, SLOT (selectedItemChanged (QItemSelection,QItemSelection))); + connect (project_model_, SIGNAL (modelChanged()), + this, SLOT (modelChanged())); } + } void -pcl::cloud_composer::ToolBoxModel::selectedToolChanged(const QModelIndex& current, - const QModelIndex&) +pcl::cloud_composer::ToolBoxModel::selectedToolChanged (const QModelIndex & current, const QModelIndex &) { - // qDebug() << "Selected Tool changed"; - if (!parameter_view_) { - qCritical() << "Toolbox parameter view not set!!!"; + //qDebug() << "Selected Tool changed"; + if (!parameter_view_) + { + qCritical () << "Toolbox parameter view not set!!!"; return; - } - QVariant parameter_model = current.data(PARAMETER_MODEL); - parameter_view_->setModel(parameter_model.value()); - parameter_view_->expandAll(); + } + QVariant parameter_model = current.data (PARAMETER_MODEL); + parameter_view_->setModel ( parameter_model.value ()); + parameter_view_->expandAll (); } + void -pcl::cloud_composer::ToolBoxModel::toolAction() +pcl::cloud_composer::ToolBoxModel::toolAction () { - QModelIndex current_index = selection_model_->currentIndex(); - if (!current_index.isValid()) { - QMessageBox::warning(qobject_cast(this->parent()), - "No Tool Selected", - "Cannot execute action, no tool selected!"); + QModelIndex current_index = selection_model_->currentIndex (); + if (!current_index.isValid ()) + { + QMessageBox::warning (qobject_cast(this->parent ()), "No Tool Selected", "Cannot execute action, no tool selected!"); return; } - ToolFactory* tool_factory = (current_index.data(FACTORY)).value(); - PropertiesModel* parameter_model = - (current_index.data(PARAMETER_MODEL)).value(); + ToolFactory* tool_factory = (current_index.data (FACTORY)).value (); + PropertiesModel* parameter_model = (current_index.data (PARAMETER_MODEL)).value (); // - AbstractTool* tool = tool_factory->createTool(parameter_model); - - emit enqueueToolAction(tool); + AbstractTool* tool = tool_factory->createTool (parameter_model); + + emit enqueueToolAction (tool); } -void -pcl::cloud_composer::ToolBoxModel::selectedItemChanged(const QItemSelection& selected, - const QItemSelection&) +void +pcl::cloud_composer::ToolBoxModel::selectedItemChanged ( const QItemSelection & selected, const QItemSelection &) { - updateEnabledTools(selected); + updateEnabledTools (selected); } -void -pcl::cloud_composer::ToolBoxModel::enableAllTools() +void +pcl::cloud_composer::ToolBoxModel::enableAllTools () { - foreach (QStandardItem* tool, tool_items) { - tool->setEnabled(true); + foreach (QStandardItem* tool, tool_items) + { + tool->setEnabled (true); } } void -pcl::cloud_composer::ToolBoxModel::modelChanged() +pcl::cloud_composer::ToolBoxModel::modelChanged () { - updateEnabledTools(project_model_->getSelectionModel()->selection()); + updateEnabledTools (project_model_->getSelectionModel ()->selection ()); } void -pcl::cloud_composer::ToolBoxModel::updateEnabledTools( - const QItemSelection& current_selection) +pcl::cloud_composer::ToolBoxModel::updateEnabledTools (const QItemSelection& current_selection) { - // qDebug () << "UPDATING ENABLED TOOLS!"; - QModelIndexList current_indices = current_selection.indexes(); - QMultiMap type_items_map; - foreach (QModelIndex current, current_indices) { - if (current.isValid()) { - QStandardItem* current_item = project_model_->itemFromIndex(current); - type_items_map.insert(current_item->type(), current_item); + //qDebug () << "UPDATING ENABLED TOOLS!"; + QModelIndexList current_indices = current_selection.indexes (); + QMultiMap < int, QStandardItem* > type_items_map; + foreach (QModelIndex current, current_indices) + { + if (current.isValid ()) + { + QStandardItem* current_item = project_model_->itemFromIndex (current); + type_items_map.insert (current_item->type (), current_item); } } - enableAllTools(); - QList enabled_tools = tool_items.values(); - QMap disabled_tools; + enableAllTools (); + QList enabled_tools = tool_items.values (); + QMap disabled_tools; QMutableListIterator enabled_itr(enabled_tools); - // Go through tools, removing from enabled list if they fail to pass tests - while (enabled_itr.hasNext()) { - QStandardItem* tool_item = enabled_itr.next(); - ToolFactory* tool_factory = (tool_item->data(FACTORY)).value(); - CloudComposerItem::ItemType input_type = tool_factory->getInputItemType(); - QList required_children_types = - tool_factory->getRequiredInputChildrenTypes(); - // Check if enough items for tool are selected - if (tool_factory->getNumInputItems() > current_indices.size()) { - enabled_itr.remove(); - disabled_tools.insert(tool_item, - tr("Tool Requires %1 Items (%2 Selected)") - .arg(tool_factory->getNumInputItems()) - .arg(current_indices.size())); + //Go through tools, removing from enabled list if they fail to pass tests + while (enabled_itr.hasNext()) + { + QStandardItem* tool_item = enabled_itr.next (); + ToolFactory* tool_factory = (tool_item->data (FACTORY)).value (); + CloudComposerItem::ItemType input_type = tool_factory->getInputItemType (); + QList required_children_types = tool_factory->getRequiredInputChildrenTypes(); + //Check if enough items for tool are selected + if ( tool_factory-> getNumInputItems() > current_indices.size() ) + { + enabled_itr.remove (); + disabled_tools.insert (tool_item, tr("Tool Requires %1 Items (%2 Selected)").arg(tool_factory-> getNumInputItems()).arg(current_indices.size ())); } - // Check if selection includes at least one item with correct input type - else if (!type_items_map.keys().contains(input_type)) { - enabled_itr.remove(); - disabled_tools.insert( - tool_item, - tr("Tool Requires item type %1 selected") - .arg(ITEM_TYPES_STRINGS.value(input_type - - CloudComposerItem::CLOUD_COMPOSER_ITEM))); + //Check if selection includes at least one item with correct input type + else if ( ! type_items_map.keys ().contains (input_type)) + { + enabled_itr.remove (); + disabled_tools.insert (tool_item, tr("Tool Requires item type %1 selected").arg (ITEM_TYPES_STRINGS.value (input_type - CloudComposerItem::CLOUD_COMPOSER_ITEM))); } - // Check if any of selected items have required children - else if (!required_children_types.empty()) { - QList matching_selected_items = type_items_map.values(input_type); + //Check if any of selected items have required children + else if ( !required_children_types.empty ()) + { + QList matching_selected_items = type_items_map.values (input_type); bool found_valid_items = false; - QList missing_children = required_children_types; - foreach (QStandardItem* item, matching_selected_items) { - QList found_children_types; - if (!item->hasChildren()) + QList missing_children = required_children_types; + foreach (QStandardItem* item, matching_selected_items) + { + QList found_children_types; + if (!item->hasChildren ()) continue; - - // Find types of all children + + //Find types of all children for (int i = 0; i < item->rowCount(); ++i) - found_children_types.append( - static_cast(item->child(i)->type())); - // Make temporary copy, remove type from it if is present as child - QList req_children_temp = required_children_types; + found_children_types.append ( static_cast(item->child (i)->type ())); + //Make temporary copy, remove type from it if is present as child + QList req_children_temp = required_children_types; foreach (CloudComposerItem::ItemType type, found_children_types) - req_children_temp.removeAll(type); - // If temporary is empty, we found all required children - if (req_children_temp.isEmpty()) { + req_children_temp.removeAll (type); + //If temporary is empty, we found all required children + if (req_children_temp.isEmpty ()) + { found_valid_items = true; break; } - // Otherwise, set missing children list - if (req_children_temp.size() < missing_children.size()) + //Otherwise, set missing children list + if (req_children_temp.size () < missing_children.size ()) missing_children = req_children_temp; + + } - // If we didn't find all required children - if (!found_valid_items) { - enabled_itr.remove(); + //If we didn't find all required children + if (!found_valid_items) + { + enabled_itr.remove (); QString missing_children_string; foreach (CloudComposerItem::ItemType type, missing_children) - missing_children_string.append( - " " + - ITEM_TYPES_STRINGS.value(type - CloudComposerItem::CLOUD_COMPOSER_ITEM)); - disabled_tools.insert( - tool_item, - tr("Tool Requires child item of type(s) %1").arg(missing_children_string)); + missing_children_string.append (" "+ITEM_TYPES_STRINGS.value (type - CloudComposerItem::CLOUD_COMPOSER_ITEM)); + disabled_tools.insert (tool_item, tr ("Tool Requires child item of type(s) %1").arg (missing_children_string)); } } } - foreach (QStandardItem* tool, tool_items) { - if (enabled_tools.contains(tool)) { - // qDebug () << tool->text() << " is enabled!"; - tool->setToolTip(tool->text() + " is enabled"); + foreach (QStandardItem* tool, tool_items) + { + if (enabled_tools.contains (tool)) + { + //qDebug () << tool->text() << " is enabled!"; + tool->setToolTip (tool->text() + " is enabled"); } - else { - // qDebug () << tool->text() << " disabled: "<setToolTip(disabled_tools.value(tool)); - tool->setEnabled(false); + else + { + // qDebug () << tool->text() << " disabled: "<setToolTip (disabled_tools.value (tool)); + tool->setEnabled (false); } } + + + } diff --git a/apps/cloud_composer/src/transform_clouds.cpp b/apps/cloud_composer/src/transform_clouds.cpp index cde2459a371..54658e745fa 100644 --- a/apps/cloud_composer/src/transform_clouds.cpp +++ b/apps/cloud_composer/src/transform_clouds.cpp @@ -1,31 +1,36 @@ -#include -#include #include +#include + #include -pcl::cloud_composer::TransformClouds::TransformClouds( - QMap> transform_map, QObject* parent) -: ModifyItemTool(nullptr, parent), transform_map_(std::move(transform_map)) -{} +#include + +pcl::cloud_composer::TransformClouds::TransformClouds (QMap > transform_map, QObject* parent) + : ModifyItemTool (nullptr, parent) + , transform_map_ (std::move(transform_map)) +{ + +} -QList -pcl::cloud_composer::TransformClouds::performAction(ConstItemList input_data, - PointTypeFlags::PointType type) +QList +pcl::cloud_composer::TransformClouds::performAction (ConstItemList input_data, PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) { - switch ((std::uint8_t)type) { - case (PointTypeFlags::XYZ): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction(input_data); + if (type != PointTypeFlags::NONE) + { + switch ((std::uint8_t) type) + { + case (PointTypeFlags::XYZ): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction (input_data); } } + + QList output; - QList output; - - qCritical() << "Transform requires templated types!"; - + qCritical () << "Transform requires templated types!"; + return output; } diff --git a/apps/cloud_composer/src/work_queue.cpp b/apps/cloud_composer/src/work_queue.cpp index b8662619d0b..2d4fb11d09c 100644 --- a/apps/cloud_composer/src/work_queue.cpp +++ b/apps/cloud_composer/src/work_queue.cpp @@ -1,45 +1,58 @@ -#include #include +#include -pcl::cloud_composer::WorkQueue::WorkQueue(QObject* parent) : QObject(parent) {} +pcl::cloud_composer::WorkQueue::WorkQueue (QObject* parent) + : QObject (parent) +{ + + + +} void -pcl::cloud_composer::WorkQueue::enqueueNewAction(AbstractTool* new_tool, - ConstItemList input_data) +pcl::cloud_composer::WorkQueue::enqueueNewAction (AbstractTool* new_tool, ConstItemList input_data) { ActionPair new_action; - // Create a command which will manage data for the tool - new_action.command = new_tool->createCommand(std::move(input_data)); + //Create a command which will manage data for the tool + new_action.command = new_tool->createCommand (std::move(input_data)); new_action.tool = new_tool; - - work_queue_.enqueue(new_action); - checkQueue(); + + work_queue_.enqueue (new_action); + checkQueue (); } void -pcl::cloud_composer::WorkQueue::actionFinished(ActionPair finished_action) +pcl::cloud_composer::WorkQueue::actionFinished (ActionPair finished_action) { - // Signal the project model that the command is done - emit commandComplete(finished_action.command); - - // Queue the tool for deletion - finished_action.tool->deleteLater(); - // Check if there are any remaining commands in queue - checkQueue(); + //Signal the project model that the command is done + emit commandComplete (finished_action.command); + + //Queue the tool for deletion + finished_action.tool->deleteLater (); + //Check if there are any remaining commands in queue + checkQueue (); + } void -pcl::cloud_composer::WorkQueue::checkQueue() +pcl::cloud_composer::WorkQueue::checkQueue ( ) { - if (work_queue_.length() > 0) { - ActionPair action_to_execute = work_queue_.dequeue(); - if (action_to_execute.command->runCommand(action_to_execute.tool)) { - // Success, send the command back to the main thread - actionFinished(action_to_execute); + if (work_queue_.length () > 0) + { + ActionPair action_to_execute = work_queue_.dequeue (); + if (action_to_execute.command->runCommand (action_to_execute.tool)) + { + //Success, send the command back to the main thread + actionFinished (action_to_execute); } - else { - qDebug() << "FAILED TO EXECUTE COMMAND"; - // Failure, what to do with data?? + else + { + qDebug () << "FAILED TO EXECUTE COMMAND"; + //Failure, what to do with data?? } + + } + + } diff --git a/apps/cloud_composer/tools/euclidean_clustering.cpp b/apps/cloud_composer/tools/euclidean_clustering.cpp index 2413544ec90..fc1a407350a 100644 --- a/apps/cloud_composer/tools/euclidean_clustering.cpp +++ b/apps/cloud_composer/tools/euclidean_clustering.cpp @@ -1,138 +1,131 @@ -#include #include +#include + +#include // for pcl::make_shared +#include #include #include #include -#include // for pcl::make_shared -#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::EuclideanClusteringTool::EuclideanClusteringTool( - PropertiesModel* parameter_model, QObject* parent) -: SplitItemTool(parameter_model, parent) -{} +pcl::cloud_composer::EuclideanClusteringTool::EuclideanClusteringTool (PropertiesModel* parameter_model, QObject* parent) + : SplitItemTool (parameter_model, parent) +{ + +} -QList -pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType) +QList +pcl::cloud_composer::EuclideanClusteringTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in Euclidean Clustering Tool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in Euclidean Clustering Tool!"; return output; } - if (input_data.size() > 1) { - qWarning() << "Input vector has more than one item in Euclidean Clustering!"; + if ( input_data.size () > 1) + { + qWarning () << "Input vector has more than one item in Euclidean Clustering!"; } - input_item = input_data.value(0); + input_item = input_data.value (0); - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - const CloudItem* cloud_item = dynamic_cast(input_item); - if (cloud_item->isSanitized()) { - double cluster_tolerance = - parameter_model_->getProperty("Cluster Tolerance").toDouble(); - int min_cluster_size = parameter_model_->getProperty("Min Cluster Size").toInt(); - int max_cluster_size = parameter_model_->getProperty("Max Cluster Size").toInt(); + if (input_item->type () == CloudComposerItem::CLOUD_ITEM) + { + const CloudItem* cloud_item = dynamic_cast (input_item); + if ( cloud_item->isSanitized()) + { + double cluster_tolerance = parameter_model_->getProperty ("Cluster Tolerance").toDouble(); + int min_cluster_size = parameter_model_->getProperty ("Min Cluster Size").toInt(); + int max_cluster_size = parameter_model_->getProperty ("Max Cluster Size").toInt(); - pcl::PCLPointCloud2::ConstPtr input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - // Get the cloud in template form - pcl::PointCloud::Ptr cloud(new pcl::PointCloud); - pcl::fromPCLPointCloud2(*input_cloud, *cloud); + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + //Get the cloud in template form + pcl::PointCloud::Ptr cloud (new pcl::PointCloud); + pcl::fromPCLPointCloud2 (*input_cloud, *cloud); //////////////// THE WORK - COMPUTING CLUSTERS /////////////////// // Creating the KdTree object for the search method of the extraction - pcl::search::KdTree::Ptr tree( - new pcl::search::KdTree); - tree->setInputCloud(cloud); + pcl::search::KdTree::Ptr tree (new pcl::search::KdTree); + tree->setInputCloud (cloud); std::vector cluster_indices; pcl::EuclideanClusterExtraction ec; - ec.setClusterTolerance(cluster_tolerance); - ec.setMinClusterSize(min_cluster_size); - ec.setMaxClusterSize(max_cluster_size); - ec.setSearchMethod(tree); - ec.setInputCloud(cloud); - ec.extract(cluster_indices); + ec.setClusterTolerance (cluster_tolerance); + ec.setMinClusterSize (min_cluster_size); + ec.setMaxClusterSize (max_cluster_size); + ec.setSearchMethod (tree); + ec.setInputCloud (cloud); + ec.extract (cluster_indices); ////////////////////////////////////////////////////////////////// - // Get copies of the original origin and orientation - Eigen::Vector4f source_origin = - input_item->data(ItemDataRole::ORIGIN).value(); - Eigen::Quaternionf source_orientation = - input_item->data(ItemDataRole::ORIENTATION).value(); - // Vector to accumulate the extracted indices - pcl::IndicesPtr extracted_indices(new pcl::Indices()); - // Put found clusters into new cloud_items! - qDebug() << "Found " << cluster_indices.size() << " clusters!"; + //Get copies of the original origin and orientation + Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); + Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); + //Vector to accumulate the extracted indices + pcl::IndicesPtr extracted_indices (new pcl::Indices ()); + //Put found clusters into new cloud_items! + qDebug () << "Found "< filter; - for (const auto& cluster : cluster_indices) { - filter.setInputCloud(input_cloud); - // It's annoying that I have to do this, but Euclidean returns a PointIndices - // struct - pcl::PointIndices::ConstPtr indices_ptr = - pcl::make_shared(cluster); - filter.setIndices(indices_ptr); - extracted_indices->insert( - extracted_indices->end(), cluster.indices.begin(), cluster.indices.end()); - // This means remove the other points - filter.setKeepOrganized(false); - pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); - filter.filter(*cloud_filtered); + for (const auto& cluster : cluster_indices) + { + filter.setInputCloud (input_cloud); + // It's annoying that I have to do this, but Euclidean returns a PointIndices struct + pcl::PointIndices::ConstPtr indices_ptr = pcl::make_shared(cluster); + filter.setIndices (indices_ptr); + extracted_indices->insert (extracted_indices->end (), cluster.indices.begin (), cluster.indices.end ()); + //This means remove the other points + filter.setKeepOrganized (false); + pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2); + filter.filter (*cloud_filtered); qDebug() << "Cluster has " << cloud_filtered->width << " data points."; - CloudItem* cloud_item = - new CloudItem(input_item->text() + tr("-Clstr %1").arg(cluster_count), - cloud_filtered, - source_origin, - source_orientation); - output.append(cloud_item); + CloudItem* cloud_item = new CloudItem (input_item->text ()+tr("-Clstr %1").arg(cluster_count) + , cloud_filtered + , source_origin + , source_orientation); + output.append (cloud_item); ++cluster_count; } - // We copy input cloud over for special case that no clusters found, since - // ExtractIndices doesn't work for 0 length vectors - pcl::PCLPointCloud2::Ptr remainder_cloud(new pcl::PCLPointCloud2(*input_cloud)); - if (!cluster_indices.empty()) { - // make a cloud containing all the remaining points - filter.setIndices(extracted_indices); - filter.setNegative(true); - filter.filter(*remainder_cloud); + //We copy input cloud over for special case that no clusters found, since ExtractIndices doesn't work for 0 length vectors + pcl::PCLPointCloud2::Ptr remainder_cloud (new pcl::PCLPointCloud2(*input_cloud)); + if (!cluster_indices.empty ()) + { + //make a cloud containing all the remaining points + filter.setIndices (extracted_indices); + filter.setNegative (true); + filter.filter (*remainder_cloud); } - qDebug() << "Cloud has " << remainder_cloud->width - << " data points after clusters removed."; - CloudItem* cloud_item = new CloudItem(input_item->text() + " unclustered", - remainder_cloud, - source_origin, - source_orientation); - output.push_front(cloud_item); + qDebug() << "Cloud has " << remainder_cloud->width << " data points after clusters removed."; + CloudItem* cloud_item = new CloudItem (input_item->text ()+ " unclustered" + , remainder_cloud + , source_origin + , source_orientation); + output.push_front (cloud_item); } else - qCritical() << "Input item in Clustering is not SANITIZED!!!"; + qCritical () << "Input item in Clustering is not SANITIZED!!!"; } - else { - qCritical() << "Input item in Clustering is not a cloud!!!"; + else + { + qCritical () << "Input item in Clustering is not a cloud!!!"; } + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::EuclideanClusteringToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::EuclideanClusteringToolFactory::createToolParameterModel (QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - parameter_model->addProperty( - "Cluster Tolerance", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Min Cluster Size", 100, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Max Cluster Size", 25000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Cluster Tolerance", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Min Cluster Size", 100, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Max Cluster Size", 25000, Qt::ItemIsEditable | Qt::ItemIsEnabled); return parameter_model; } diff --git a/apps/cloud_composer/tools/fpfh_estimation.cpp b/apps/cloud_composer/tools/fpfh_estimation.cpp index 9366754584b..a65056a1567 100644 --- a/apps/cloud_composer/tools/fpfh_estimation.cpp +++ b/apps/cloud_composer/tools/fpfh_estimation.cpp @@ -1,107 +1,105 @@ +#include #include -#include #include -#include +#include + #include -#include #include +#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::FPFHEstimationTool::FPFHEstimationTool( - PropertiesModel* parameter_model, QObject* parent) -: NewItemTool(parameter_model, parent) -{} +pcl::cloud_composer::FPFHEstimationTool::FPFHEstimationTool (PropertiesModel* parameter_model, QObject* parent) + : NewItemTool (parameter_model, parent) +{ -QList -pcl::cloud_composer::FPFHEstimationTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType) + +} + +QList +pcl::cloud_composer::FPFHEstimationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in FPFH Estimation Tool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in FPFH Estimation Tool!"; return output; } - if (input_data.size() > 1) { - qWarning() << "Input vector has more than one item in FPFH Estimation!"; + if ( input_data.size () > 1) + { + qWarning () << "Input vector has more than one item in FPFH Estimation!"; } - input_item = input_data.value(0); - - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - // Check if this cloud has normals computed! - QList normals_list = - input_item->getChildren(CloudComposerItem::NORMALS_ITEM); - if (normals_list.empty()) { - qCritical() << "No normals item child found in this cloud item"; + input_item = input_data.value (0); + + + if (input_item->type () == CloudComposerItem::CLOUD_ITEM) + { + //Check if this cloud has normals computed! + QList normals_list = input_item->getChildren (CloudComposerItem::NORMALS_ITEM); + if ( normals_list.empty () ) + { + qCritical () << "No normals item child found in this cloud item"; return output; } - qDebug() << "Found item text=" << normals_list.at(0)->text(); + qDebug () << "Found item text="<text(); double radius = parameter_model_->getProperty("Radius").toDouble(); - - pcl::PCLPointCloud2::ConstPtr input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - // Get the cloud in template form - pcl::PointCloud::Ptr cloud(new pcl::PointCloud); - pcl::fromPCLPointCloud2(*input_cloud, *cloud); - - // Get the normals cloud, we just use the first normals that were found if there are - // more than one - pcl::PointCloud::ConstPtr input_normals = - normals_list.value(0) - ->data(ItemDataRole::CLOUD_TEMPLATED) - .value::ConstPtr>(); - + + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + //Get the cloud in template form + pcl::PointCloud::Ptr cloud (new pcl::PointCloud); + pcl::fromPCLPointCloud2 (*input_cloud, *cloud); + + //Get the normals cloud, we just use the first normals that were found if there are more than one + pcl::PointCloud::ConstPtr input_normals = normals_list.value(0)->data(ItemDataRole::CLOUD_TEMPLATED).value ::ConstPtr> (); + pcl::FPFHEstimation fpfh; - // qDebug () << "Input cloud size = "<size (); + // qDebug () << "Input cloud size = "<size (); //////////////// THE WORK - COMPUTING FPFH /////////////////// // Create the FPFH estimation class, and pass the input dataset+normals to it - fpfh.setInputCloud(cloud); - fpfh.setInputNormals(input_normals); + fpfh.setInputCloud (cloud); + fpfh.setInputNormals (input_normals); // Create an empty kdtree representation, and pass it to the FPFH estimation object. - // Its content will be filled inside the object, based on the given input dataset - // (as no other search surface is given). - qDebug() << "Building KD Tree"; - pcl::search::KdTree::Ptr tree(new pcl::search::KdTree); - fpfh.setSearchMethod(tree); + // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). + qDebug () << "Building KD Tree"; + pcl::search::KdTree::Ptr tree (new pcl::search::KdTree); + fpfh.setSearchMethod (tree); // Output datasets - pcl::PointCloud::Ptr fpfhs( - new pcl::PointCloud()); + pcl::PointCloud::Ptr fpfhs (new pcl::PointCloud ()); // Use all neighbors in a sphere of radius 5cm - // IMPORTANT: the radius used here has to be larger than the radius used to estimate - // the surface normals!!! - fpfh.setRadiusSearch(radius); + // IMPORTANT: the radius used here has to be larger than the radius used to estimate the surface normals!!! + fpfh.setRadiusSearch (radius); // Compute the features - qDebug() << "Computing FPFH features"; - fpfh.compute(*fpfhs); - qDebug() << "Size of computed features =" << fpfhs->width; + qDebug () << "Computing FPFH features"; + fpfh.compute (*fpfhs); + qDebug () << "Size of computed features ="<width; ////////////////////////////////////////////////////////////////// - FPFHItem* fpfh_item = new FPFHItem(tr("FPFH r=%1").arg(radius), fpfhs, radius); - output.append(fpfh_item); + FPFHItem* fpfh_item = new FPFHItem (tr("FPFH r=%1").arg(radius),fpfhs,radius); + output.append (fpfh_item); } - else { - qCritical() << "Input item in FPFH Estimation is not a cloud!!!"; + else + { + qCritical () << "Input item in FPFH Estimation is not a cloud!!!"; } - + + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::FPFHEstimationToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::FPFHEstimationToolFactory::createToolParameterModel (QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty("Radius", 0.03, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty ("Radius", 0.03, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/normal_estimation.cpp b/apps/cloud_composer/tools/normal_estimation.cpp index ddef0a393ed..55ced5d3e92 100644 --- a/apps/cloud_composer/tools/normal_estimation.cpp +++ b/apps/cloud_composer/tools/normal_estimation.cpp @@ -1,82 +1,83 @@ -#include #include +#include + #include #include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::NormalEstimationTool::NormalEstimationTool( - PropertiesModel* parameter_model, QObject* parent) -: NewItemTool(parameter_model, parent) -{} +pcl::cloud_composer::NormalEstimationTool::NormalEstimationTool (PropertiesModel* parameter_model, QObject* parent) + : NewItemTool (parameter_model, parent) +{ + + +} -QList -pcl::cloud_composer::NormalEstimationTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType) +QList +pcl::cloud_composer::NormalEstimationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in Normal Estimation Tool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in Normal Estimation Tool!"; return output; } - if (input_data.size() > 1) { - qWarning() << "Input vector has more than one item in Normal Estimation!"; + if ( input_data.size () > 1) + { + qWarning () << "Input vector has more than one item in Normal Estimation!"; } - input_item = input_data.value(0); - + input_item = input_data.value (0); + pcl::PCLPointCloud2::ConstPtr input_cloud; - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { + if (input_item->type () == CloudComposerItem::CLOUD_ITEM) + { double radius = parameter_model_->getProperty("Radius").toDouble(); - qDebug() << "Received Radius = " << radius; - pcl::PCLPointCloud2::ConstPtr input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - qDebug() << "Got cloud size = " << input_cloud->width; + qDebug () << "Received Radius = " <data (ItemDataRole::CLOUD_BLOB).value (); + qDebug () << "Got cloud size = "<width; //////////////// THE WORK - COMPUTING NORMALS /////////////////// - pcl::PointCloud::Ptr cloud(new pcl::PointCloud); - pcl::fromPCLPointCloud2(*input_cloud, *cloud); + pcl::PointCloud::Ptr cloud (new pcl::PointCloud); + pcl::fromPCLPointCloud2 (*input_cloud, *cloud); // Create the normal estimation class, and pass the input dataset to it pcl::NormalEstimation ne; - ne.setInputCloud(cloud); + ne.setInputCloud (cloud); - // Create an empty kdtree representation, and pass it to the normal estimation - // object. Its content will be filled inside the object, based on the given input - // dataset (as no other search surface is given). - pcl::search::KdTree::Ptr tree( - new pcl::search::KdTree()); - ne.setSearchMethod(tree); + // Create an empty kdtree representation, and pass it to the normal estimation object. + // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). + pcl::search::KdTree::Ptr tree (new pcl::search::KdTree ()); + ne.setSearchMethod (tree); // Output datasets - pcl::PointCloud::Ptr cloud_normals(new pcl::PointCloud); + pcl::PointCloud::Ptr cloud_normals (new pcl::PointCloud); // Use all neighbors in a sphere of radius 3cm - ne.setRadiusSearch(radius); + ne.setRadiusSearch (radius); // Compute the features - ne.compute(*cloud_normals); + ne.compute (*cloud_normals); ////////////////////////////////////////////////////////////////// - NormalsItem* normals_item = - new NormalsItem(tr("Normals r=%1").arg(radius), cloud_normals, radius); - output.append(normals_item); - qDebug() << "Calced normals"; + NormalsItem* normals_item = new NormalsItem (tr("Normals r=%1").arg(radius),cloud_normals,radius); + output.append (normals_item); + qDebug () << "Calced normals"; } - else { - qDebug() << "Input item in Normal Estimation is not a cloud!!!"; + else + { + qDebug () << "Input item in Normal Estimation is not a cloud!!!"; } - + + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::NormalEstimationToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::NormalEstimationToolFactory::createToolParameterModel (QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty("Radius", 0.04, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty ("Radius", 0.04, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/organized_segmentation.cpp b/apps/cloud_composer/tools/organized_segmentation.cpp index 73679e871d3..47d7430fad0 100644 --- a/apps/cloud_composer/tools/organized_segmentation.cpp +++ b/apps/cloud_composer/tools/organized_segmentation.cpp @@ -1,59 +1,58 @@ -#include -#include #include +#include + +#include #include #include #include -#include + + +#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::OrganizedSegmentationTool::OrganizedSegmentationTool( - PropertiesModel* parameter_model, QObject* parent) -: SplitItemTool(parameter_model, parent) -{} +pcl::cloud_composer::OrganizedSegmentationTool::OrganizedSegmentationTool (PropertiesModel* parameter_model, QObject* parent) +: SplitItemTool (parameter_model, parent) +{ + +} -QList -pcl::cloud_composer::OrganizedSegmentationTool::performAction( - ConstItemList input_data, PointTypeFlags::PointType type) +QList +pcl::cloud_composer::OrganizedSegmentationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) { - switch ((std::uint8_t)type) { - case (PointTypeFlags::XYZ): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction(input_data); + if (type != PointTypeFlags::NONE) + { + switch ((std::uint8_t) type) + { + case (PointTypeFlags::XYZ): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction (input_data); } } - - QList output; - - qCritical() << "organized_segmentation requires templated types!"; - + + QList output; + + qCritical () << "organized_segmentation requires templated types!"; + return output; -} +} /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::OrganizedSegmentationToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::OrganizedSegmentationToolFactory::createToolParameterModel (QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty( - "Min Inliers", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Min Plane Size", 10000, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Angular Threshold", 2.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Distance Threshold", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Cluster Dist. Thresh.", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Min Cluster Size", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty ("Min Inliers", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Min Plane Size", 10000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Angular Threshold", 2.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Distance Threshold", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Cluster Dist. Thresh.", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Min Cluster Size", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + + return parameter_model; } diff --git a/apps/cloud_composer/tools/sanitize_cloud.cpp b/apps/cloud_composer/tools/sanitize_cloud.cpp index 90d371954cd..d56d5276c36 100644 --- a/apps/cloud_composer/tools/sanitize_cloud.cpp +++ b/apps/cloud_composer/tools/sanitize_cloud.cpp @@ -1,75 +1,75 @@ -#include #include +#include #include -#include // for pcl::make_shared +#include // for pcl::make_shared Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::SanitizeCloudTool::SanitizeCloudTool( - PropertiesModel* parameter_model, QObject* parent) -: ModifyItemTool(parameter_model, parent) -{} +pcl::cloud_composer::SanitizeCloudTool::SanitizeCloudTool (PropertiesModel* parameter_model, QObject* parent) +: ModifyItemTool (parameter_model, parent) +{ +} -QList -pcl::cloud_composer::SanitizeCloudTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType) +QList +pcl::cloud_composer::SanitizeCloudTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in SanitizeCloudTool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in SanitizeCloudTool!"; return output; } - input_item = input_data.value(0); - - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - pcl::PCLPointCloud2::ConstPtr input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - - bool keep_organized = parameter_model_->getProperty("Keep Organized").toBool(); - + input_item = input_data.value (0); + + if (input_item->type () == CloudComposerItem::CLOUD_ITEM ) + { + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + + bool keep_organized = parameter_model_->getProperty("Keep Organized").toBool (); + //////////////// THE WORK - FILTERING NANS /////////////////// // Create the filtering object pcl::PassThrough pass_filter; - pass_filter.setInputCloud(input_cloud); - pass_filter.setKeepOrganized(keep_organized); - - // Create output cloud - pcl::PCLPointCloud2::Ptr cloud_filtered = pcl::make_shared(); - // Filter! - pass_filter.filter(*cloud_filtered); - + pass_filter.setInputCloud (input_cloud); + pass_filter.setKeepOrganized (keep_organized); + + //Create output cloud + pcl::PCLPointCloud2::Ptr cloud_filtered = pcl::make_shared (); + //Filter! + pass_filter.filter (*cloud_filtered); + ////////////////////////////////////////////////////////////////// - // Get copies of the original origin and orientation - Eigen::Vector4f source_origin = - input_item->data(ItemDataRole::ORIGIN).value(); - Eigen::Quaternionf source_orientation = - input_item->data(ItemDataRole::ORIENTATION).value(); - // Put the modified cloud into an item, stick in output - CloudItem* cloud_item = new CloudItem(input_item->text() + tr(" sanitized"), - cloud_filtered, - source_origin, - source_orientation); - - output.append(cloud_item); + //Get copies of the original origin and orientation + Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); + Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); + //Put the modified cloud into an item, stick in output + CloudItem* cloud_item = new CloudItem (input_item->text () + tr (" sanitized") + , cloud_filtered + , source_origin + , source_orientation); + + + output.append (cloud_item); } - else { - qDebug() << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; + else + { + qDebug () << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; } - + + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::SanitizeCloudToolFactory::createToolParameterModel(QObject* parent) +pcl::cloud_composer::SanitizeCloudToolFactory::createToolParameterModel (QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty( - "Keep Organized", false, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty ("Keep Organized", false, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } + diff --git a/apps/cloud_composer/tools/statistical_outlier_removal.cpp b/apps/cloud_composer/tools/statistical_outlier_removal.cpp index d67426016a9..3213a9755d5 100644 --- a/apps/cloud_composer/tools/statistical_outlier_removal.cpp +++ b/apps/cloud_composer/tools/statistical_outlier_removal.cpp @@ -1,87 +1,89 @@ -#include #include +#include + #include #include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::StatisticalOutlierRemovalTool::StatisticalOutlierRemovalTool( - PropertiesModel* parameter_model, QObject* parent) -: ModifyItemTool(parameter_model, parent) -{} +pcl::cloud_composer::StatisticalOutlierRemovalTool::StatisticalOutlierRemovalTool (PropertiesModel* parameter_model, QObject* parent) + : ModifyItemTool (parameter_model, parent) +{ -QList -pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction( - ConstItemList input_data, PointTypeFlags::PointType) + +} + +QList +pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in StatisticalOutlierRemovalTool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in StatisticalOutlierRemovalTool!"; return output; } - if (input_data.size() > 1) { - qWarning() - << "Input vector has more than one item in StatisticalOutlierRemovalTool"; + if ( input_data.size () > 1) + { + qWarning () << "Input vector has more than one item in StatisticalOutlierRemovalTool"; } - input_item = input_data.value(0); - if (!input_item->isSanitized()) { - qCritical() << "StatisticalOutlierRemovalTool requires sanitized input!"; + input_item = input_data.value (0); + if ( !input_item->isSanitized () ) + { + qCritical () << "StatisticalOutlierRemovalTool requires sanitized input!"; return output; } - - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - pcl::PCLPointCloud2::ConstPtr input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - - int mean_k = parameter_model_->getProperty("Mean K").toInt(); - double std_dev_thresh = parameter_model_->getProperty("Std Dev Thresh").toDouble(); - + + if (input_item->type () == CloudComposerItem::CLOUD_ITEM ) + { + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + + int mean_k = parameter_model_->getProperty("Mean K").toInt (); + double std_dev_thresh = parameter_model_->getProperty ("Std Dev Thresh").toDouble (); + //////////////// THE WORK - FILTERING OUTLIERS /////////////////// // Create the filtering object pcl::StatisticalOutlierRemoval sor; - sor.setInputCloud(input_cloud); - sor.setMeanK(mean_k); - sor.setStddevMulThresh(std_dev_thresh); - - // Create output cloud - pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); - // Filter! - sor.filter(*cloud_filtered); + sor.setInputCloud (input_cloud); + sor.setMeanK (mean_k); + sor.setStddevMulThresh (std_dev_thresh); + + //Create output cloud + pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2); + //Filter! + sor.filter (*cloud_filtered); ////////////////////////////////////////////////////////////////// - // Get copies of the original origin and orientation - Eigen::Vector4f source_origin = - input_item->data(ItemDataRole::ORIGIN).value(); - Eigen::Quaternionf source_orientation = - input_item->data(ItemDataRole::ORIENTATION).value(); - // Put the modified cloud into an item, stick in output - CloudItem* cloud_item = new CloudItem(input_item->text() + tr(" sor filtered"), - cloud_filtered, - source_origin, - source_orientation); + //Get copies of the original origin and orientation + Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); + Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); + //Put the modified cloud into an item, stick in output + CloudItem* cloud_item = new CloudItem (input_item->text () + tr (" sor filtered") + , cloud_filtered + , source_origin + , source_orientation); - output.append(cloud_item); + + output.append (cloud_item); } - else { - qDebug() << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; + else + { + qDebug () << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; } - + + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::StatisticalOutlierRemovalToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::StatisticalOutlierRemovalToolFactory::createToolParameterModel (QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty("Mean K", 50, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Std Dev Thresh", 1.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty ("Mean K", 50, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Std Dev Thresh", 1.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/supervoxels.cpp b/apps/cloud_composer/tools/supervoxels.cpp index 853a32e2555..6c22b37f9fc 100644 --- a/apps/cloud_composer/tools/supervoxels.cpp +++ b/apps/cloud_composer/tools/supervoxels.cpp @@ -1,61 +1,56 @@ -#include -#include #include +#include #include #include -#include #include +#include + +#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::SupervoxelsTool::SupervoxelsTool(PropertiesModel* parameter_model, - QObject* parent) -: SplitItemTool(parameter_model, parent) -{} +pcl::cloud_composer::SupervoxelsTool::SupervoxelsTool (PropertiesModel* parameter_model, QObject* parent) +: SplitItemTool (parameter_model, parent) +{ + +} -QList -pcl::cloud_composer::SupervoxelsTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType type) +QList +pcl::cloud_composer::SupervoxelsTool::performAction (ConstItemList input_data, PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) { - switch ((std::uint8_t)type) { - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction(input_data); + if (type != PointTypeFlags::NONE) + { + switch ((std::uint8_t) type) + { + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction (input_data); } } - - QList output; - - qCritical() << "supervoxels requires templated types!"; - + + QList output; + + qCritical () << "supervoxels requires templated types!"; + return output; -} +} + +template QList pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (const QList &); +//template QList pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (const QList &); -template QList -pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( - const QList&); -// template QList -// pcl::cloud_composer::SupervoxelsTool::performTemplatedAction -// (const QList &); /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::SupervoxelsToolFactory::createToolParameterModel(QObject* parent) +pcl::cloud_composer::SupervoxelsToolFactory::createToolParameterModel (QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty( - "Resolution", 0.008, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Seed Resolution", 0.08, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "RGB Weight", 0.2, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Normals Weight", 0.8, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Spatial Weight", 0.4, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty ("Resolution", 0.008, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Seed Resolution", 0.08, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("RGB Weight", 0.2, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Normals Weight", 0.8, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Spatial Weight", 0.4, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/voxel_grid_downsample.cpp b/apps/cloud_composer/tools/voxel_grid_downsample.cpp index 3590c273d32..5b15c3409d4 100644 --- a/apps/cloud_composer/tools/voxel_grid_downsample.cpp +++ b/apps/cloud_composer/tools/voxel_grid_downsample.cpp @@ -1,85 +1,88 @@ -#include #include +#include + #include #include + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::VoxelGridDownsampleTool::VoxelGridDownsampleTool( - PropertiesModel* parameter_model, QObject* parent) -: ModifyItemTool(parameter_model, parent) -{} +pcl::cloud_composer::VoxelGridDownsampleTool::VoxelGridDownsampleTool (PropertiesModel* parameter_model, QObject* parent) + : ModifyItemTool (parameter_model, parent) +{ + + +} -QList -pcl::cloud_composer::VoxelGridDownsampleTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType) +QList +pcl::cloud_composer::VoxelGridDownsampleTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in VoxelGridDownsampleTool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in VoxelGridDownsampleTool!"; return output; } - if (input_data.size() > 1) { - qWarning() << "Input vector has more than one item in VoxelGridDownsampleTool"; + if ( input_data.size () > 1) + { + qWarning () << "Input vector has more than one item in VoxelGridDownsampleTool"; } - input_item = input_data.value(0); - - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - double leaf_x = parameter_model_->getProperty("Leaf Size x").toDouble(); - double leaf_y = parameter_model_->getProperty("Leaf Size y").toDouble(); - double leaf_z = parameter_model_->getProperty("Leaf Size z").toDouble(); - - pcl::PCLPointCloud2::ConstPtr input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - + input_item = input_data.value (0); + + if (input_item->type () == CloudComposerItem::CLOUD_ITEM) + { + double leaf_x = parameter_model_->getProperty("Leaf Size x").toDouble (); + double leaf_y = parameter_model_->getProperty("Leaf Size y").toDouble (); + double leaf_z = parameter_model_->getProperty("Leaf Size z").toDouble (); + + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + //////////////// THE WORK - FILTERING OUTLIERS /////////////////// // Create the filtering object pcl::VoxelGrid vox_grid; - vox_grid.setInputCloud(input_cloud); - vox_grid.setLeafSize(float(leaf_x), float(leaf_y), float(leaf_z)); - - // Create output cloud - pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); - // Filter! - vox_grid.filter(*cloud_filtered); + vox_grid.setInputCloud (input_cloud); + vox_grid.setLeafSize (float (leaf_x), float (leaf_y), float (leaf_z)); + + + //Create output cloud + pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2); + //Filter! + vox_grid.filter (*cloud_filtered); ////////////////////////////////////////////////////////////////// - // Get copies of the original origin and orientation - Eigen::Vector4f source_origin = - input_item->data(ItemDataRole::ORIGIN).value(); - Eigen::Quaternionf source_orientation = - input_item->data(ItemDataRole::ORIENTATION).value(); - // Put the modified cloud into an item, stick in output - CloudItem* cloud_item = new CloudItem(input_item->text() + tr(" vox ds"), - cloud_filtered, - source_origin, - source_orientation); + //Get copies of the original origin and orientation + Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); + Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); + //Put the modified cloud into an item, stick in output + CloudItem* cloud_item = new CloudItem (input_item->text () + tr (" vox ds") + , cloud_filtered + , source_origin + , source_orientation); - output.append(cloud_item); + + output.append (cloud_item); } - else { - qDebug() << "Input item in VoxelGridDownsampleTool is not a cloud!!!"; + else + { + qDebug () << "Input item in VoxelGridDownsampleTool is not a cloud!!!"; } - + + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::VoxelGridDownsampleToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::VoxelGridDownsampleToolFactory::createToolParameterModel (QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); + + parameter_model->addProperty ("Leaf Size x", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Leaf Size y", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Leaf Size z", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Leaf Size x", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Leaf Size y", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Leaf Size z", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + return parameter_model; } diff --git a/apps/in_hand_scanner/CMakeLists.txt b/apps/in_hand_scanner/CMakeLists.txt index 8a670a5b81a..97e2c72ee11 100644 --- a/apps/in_hand_scanner/CMakeLists.txt +++ b/apps/in_hand_scanner/CMakeLists.txt @@ -1,7 +1,7 @@ set(SUBSUBSYS_NAME in_hand_scanner) set(SUBSUBSYS_DESC "In-hand scanner for small objects") -set(SUBSUBSYS_DEPS common geometry features io kdtree) -set(SUBSUBSYS_LIBS pcl_common pcl_geometry pcl_features pcl_io pcl_kdtree) +set(SUBSUBSYS_DEPS common features io kdtree apps) +set(SUBSUBSYS_LIBS pcl_common pcl_features pcl_io pcl_kdtree) set(SUBSUBSYS_EXT_DEPS ${QTX} OpenGL OpenGL_GLU openni) set(REASON "") set(DEFAULT OFF) @@ -19,7 +19,9 @@ pcl_add_doc("${SUBSUBSYS_NAME}") ################################################################################ set(INCS + "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/boost.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/common_types.h" + "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/eigen.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/icp.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/input_data_processing.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/integration.h" @@ -75,6 +77,8 @@ if(NOT build) return() endif() +include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") + set(EXE_NAME "pcl_${SUBSUBSYS_NAME}") PCL_ADD_EXECUTABLE( @@ -89,7 +93,6 @@ PCL_ADD_EXECUTABLE( BUNDLE) target_link_libraries("${EXE_NAME}" ${SUBSUBSYS_LIBS} ${OPENGL_LIBRARIES} ${QTX}::Concurrent ${QTX}::Widgets ${QTX}::OpenGL) -target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) if (${QTX} MATCHES "Qt6") target_link_libraries("${EXE_NAME}" ${QTX}::OpenGLWidgets) endif() @@ -109,7 +112,6 @@ PCL_ADD_EXECUTABLE( BUNDLE) target_link_libraries(pcl_offline_integration ${SUBSUBSYS_LIBS} ${OPENGL_LIBRARIES} ${QTX}::Concurrent ${QTX}::Widgets ${QTX}::OpenGL) -target_include_directories(pcl_offline_integration PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) if (${QTX} MATCHES "Qt6") target_link_libraries(pcl_offline_integration ${QTX}::OpenGLWidgets) endif() diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h new file mode 100644 index 00000000000..f4f535427ba --- /dev/null +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h @@ -0,0 +1,48 @@ +/* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2009-2012, Willow Garage, Inc. + * Copyright (c) 2012-, Open Perception, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the copyright holder(s) nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ + +#pragma once + +#ifdef __GNUC__ +#pragma GCC system_header +#endif +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") +#include +#include diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h new file mode 100644 index 00000000000..a4380316268 --- /dev/null +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h @@ -0,0 +1,49 @@ +/* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2009-2012, Willow Garage, Inc. + * Copyright (c) 2012-, Open Perception, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the copyright holder(s) nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ + +#pragma once + +#ifdef __GNUC__ +#pragma GCC system_header +#endif +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed eigen headers directly.") +#include +#include +#include diff --git a/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp b/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp index 119c9f3b9d2..549f893bcff 100644 --- a/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp +++ b/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp @@ -120,6 +120,7 @@ pcl::apps::DominantPlaneSegmentation::compute_table_plane() // Compute the plane coefficients Eigen::Vector4f model_coefficients; + EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; model_coefficients[0] = table_coefficients_->values[0]; model_coefficients[1] = table_coefficients_->values[1]; @@ -250,6 +251,7 @@ pcl::apps::DominantPlaneSegmentation::compute_fast( // Compute the plane coefficients Eigen::Vector4f model_coefficients; + EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; model_coefficients[0] = table_coefficients_->values[0]; model_coefficients[1] = table_coefficients_->values[1]; @@ -624,6 +626,7 @@ pcl::apps::DominantPlaneSegmentation::compute( // Compute the plane coefficients Eigen::Vector4f model_coefficients; + EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; model_coefficients[0] = table_coefficients_->values[0]; model_coefficients[1] = table_coefficients_->values[1]; @@ -792,6 +795,7 @@ pcl::apps::DominantPlaneSegmentation::compute_full( // Compute the plane coefficients Eigen::Vector4f model_coefficients; + EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; model_coefficients[0] = table_coefficients_->values[0]; model_coefficients[1] = table_coefficients_->values[1]; diff --git a/apps/include/pcl/apps/vfh_nn_classifier.h b/apps/include/pcl/apps/vfh_nn_classifier.h index eaa38ca9397..6da5036293c 100644 --- a/apps/include/pcl/apps/vfh_nn_classifier.h +++ b/apps/include/pcl/apps/vfh_nn_classifier.h @@ -41,7 +41,6 @@ #include #include #include -#include // for KdTree #include #include diff --git a/apps/modeler/CMakeLists.txt b/apps/modeler/CMakeLists.txt index f7d2bae150d..c48442c2f1c 100644 --- a/apps/modeler/CMakeLists.txt +++ b/apps/modeler/CMakeLists.txt @@ -23,6 +23,8 @@ if(NOT build) return() endif() +include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") + # Set Qt files and resources here set(uis main_window.ui @@ -33,7 +35,7 @@ set(resources ) set(incs - "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/main_window.h" + "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/main_window.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/scene_tree.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/parameter_dialog.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/thread_controller.h" @@ -112,8 +114,7 @@ PCL_ADD_EXECUTABLE( ${incs} ${impl_incs}) -target_link_libraries("${EXE_NAME}" pcl_common pcl_io pcl_kdtree pcl_filters pcl_registration pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search ${QTX}::Widgets) -target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_link_libraries("${EXE_NAME}" pcl_common pcl_io pcl_kdtree pcl_filters pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search ${QTX}::Widgets) # Install include files PCL_ADD_INCLUDES("${SUBSUBSYS_NAME}" "${SUBSUBSYS_NAME}" ${incs}) diff --git a/apps/modeler/src/normal_estimation_worker.cpp b/apps/modeler/src/normal_estimation_worker.cpp index 08f577858a3..468d7362fea 100755 --- a/apps/modeler/src/normal_estimation_worker.cpp +++ b/apps/modeler/src/normal_estimation_worker.cpp @@ -43,7 +43,6 @@ #include #include #include -#include // for KdTree ////////////////////////////////////////////////////////////////////////////////////////////// pcl::modeler::NormalEstimationWorker::NormalEstimationWorker( diff --git a/apps/point_cloud_editor/CMakeLists.txt b/apps/point_cloud_editor/CMakeLists.txt index 6a355b1ece6..814c88eafcf 100644 --- a/apps/point_cloud_editor/CMakeLists.txt +++ b/apps/point_cloud_editor/CMakeLists.txt @@ -68,6 +68,11 @@ set(SRCS src/denoiseParameterForm.cpp ) +include_directories( + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/include" +) + set(EXE_NAME "pcl_${SUBSUBSYS_NAME}") PCL_ADD_EXECUTABLE( ${EXE_NAME} @@ -79,7 +84,6 @@ PCL_ADD_EXECUTABLE( ${INCS}) target_link_libraries("${EXE_NAME}" ${QTX}::Widgets ${QTX}::OpenGL ${OPENGL_LIBRARIES} ${BOOST_LIBRARIES} pcl_common pcl_io pcl_filters) -target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) if (${QTX} MATCHES "Qt6") target_link_libraries("${EXE_NAME}" ${QTX}::OpenGLWidgets) endif() diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloud.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloud.h index d9a834fe48d..0557d073803 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloud.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloud.h @@ -41,22 +41,22 @@ #pragma once +#include #include #include -#include // for pcl::weak_ptr -#include +#include // for pcl::weak_ptr #ifdef OPENGL_IS_A_FRAMEWORK -#include -#include +# include +# include #else #ifdef _WIN32 // Need this to pull in APIENTRY, etc. #include "windows.h" #endif -#include -#include +# include +# include #endif /// @brief A wrapper which allows to use any implementation of cloud provided by @@ -75,400 +75,405 @@ // XXX - add functions for retrieving an unshifted Cloud3D // XXX - add functions for retrieving unshifted points by index // XXX - mark access functions below as returning shifted values -class Cloud : public Statistics { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; - - /// The type for weak pointer pointing to a selection buffer - using SelectionWeakPtr = pcl::weak_ptr; - - /// @brief Default Constructor - Cloud(); - - /// @brief Copy Constructor - /// @details This constructor creates a copy of the passed cloud. The - /// values of the member variables of the passed cloud are deep copied. - /// @param copy The cloud object to be used to initialize this cloud object. - Cloud(const Cloud& copy); - - /// @brief Construct a cloud from a Cloud3D. - /// @details This constructor creates a cloud object with the passed - /// cloud object stored with the internal representation. The member - /// variables of this object are initialized but not set. - Cloud(const Cloud3D& cloud, bool register_stats = false); - - /// @brief Equal Operator - /// @details Deep copies all the state of the passed cloud to this cloud. - /// @param cloud The cloud object whose status to be copied to this object - /// @return A reference to this cloud containing the new values. - Cloud& - operator=(const Cloud& cloud); - - /// @brief Subscript Operator - /// @details This operator returns a reference to the point with the - /// passed index in this cloud object. - /// @pre The index passed is expected to be within the limits of the cloud. - /// For debugging this is currently checked by an assert. - /// @param index The index of the point to be returned. - /// @return A reference to the indexed point. - Point3D& - operator[](unsigned int index); - - /// @brief Subscript Operator - /// @details This operator returns a const reference to the point with the - /// passed index in this cloud object. - /// @pre The index passed is expected to be within the limits of the cloud. - /// For debugging this is currently checked by an assert. - /// @param index The index of the point to be returned. - /// @return A const reference to the indexed point. - const Point3D& - operator[](unsigned int index) const; - - /// @brief Returns the center of the point cloud - /// @param x The x coordinate of the center (computed as the average point). - /// @param y The y coordinate of the center (computed as the average point). - /// @param z The z coordinate of the center (computed as the average point). - inline void - getCenter(float& x, float& y, float& z) const - { - x = center_xyz_[X]; - y = center_xyz_[Y]; - z = center_xyz_[Z]; - } - - /// @brief Returns the scaling factor for the point cloud - /// @return The scaling factor - inline float - getScalingFactor() const - { - return (display_scale_); - } - - /// @brief Gets the transform matrix. - /// @details The returned matrix is used to transform the cloud for - /// rendering only and does not affect the values of the points stored. - /// @return A 1-D array representing (4 x 4) matrix in - /// using OpenGL's column-major format. - inline const float* - getMatrix() const - { - return (cloud_matrix_); - } - - /// @brief Sets the transform matrix for the cloud. - /// @details The passed matrix is used to transform the cloud for - /// rendering only and does not affect the values of the points stored. - /// @pre The passed pointer represents a matrix having valid memory of at - /// least MATRIX_SIZE elements. - /// @param matrix a 1-D array representing (4 x 4) matrix in - /// using OpenGL's column-major format. - void - loadMatrix(const float* matrix); - - /// @brief Right multiplies the cloud matrix with the passed matrix - /// @details The application of this matrix effectively transforms the - /// cloud from its current state. The passed matrix is used for display - /// only and does not affect the values of the points stored. - /// @pre The passed pointer represents a matrix having valid memory of at - /// least MATRIX_SIZE elements. - /// @param matrix a 1-D array representing (4 x 4) matrix in - /// using OpenGL's column-major format. - void - multMatrix(const float* matrix); - - /// @brief Sets the selection transform matrix to the one passed. - /// @details The selection matrix represents the local transformations - /// applied to the selected points. The matrix is used relative to the - /// cloud's state after the application of its own matrices which can be - /// modified by loadMatrix and multMatrix functions. - /// @pre The passed pointer represents a matrix having valid memory of at - /// least MATRIX_SIZE elements. - /// @param matrix a 1-D array representing (4 x 4) matrix in - /// using OpenGL's column-major format. - /// @sa loadMatrix multMatrix - void - setSelectionRotation(const float* matrix); - - void - setSelectionTranslation(float dx, float dy, float dz); - - /// @brief Sets the selected points. - /// @details The cloud object is responsible for its display. As we have - /// tried to adopt a lazy approach in the application of modifications to - /// the cloud, the cloud must be notified of the selected points. This is - /// required as the user may move the selected points and we do not wish for - /// the selected points to be drawn twice, once in the user-updated position - /// and another in the points original location. - /// @pre Assumes that the selection stores the selected indices of the - /// points sorted. - /// @param A pointer pointing to a selection object. - /// @remarks This has been implemented using a weak pointer to allow a lazy - /// update to occur. When a selection is destroyed we can switch to - /// a faster rendering mode; this also occurs if the selection object is - /// empty. - void - setSelection(const SelectionPtr& selection_ptr); - - /// @brief Sets the RGB values for coloring points in COLOR_BY_PURE mode. - /// @param r the value for red color - /// @param g the value for the green color - /// @param b the value for the blue color - void - setRGB(float r, float g, float b); - - /// @brief Sets the RGB values used for highlighting the selected points. - /// @param r the value for red color - /// @param g the value for the green color - /// @param b the value for the blue color - void - setHighlightColor(float r, float g, float b); - - /// @brief Renders the cloud and highlights any selected points. - /// @param disableHighlight Defaults to false. If true the selected points - /// will not be drawn. - /// @sa setColorRampAxis, setColorRamp - void - draw(bool disable_highlight = false) const; - - /// @brief Renders the cloud and highlights any selected points. - /// @details The colors of the non-selected points come from a 1D texture - /// which is implemented by a color ramp. - void - drawWithTexture() const; - - /// @brief Renders the cloud and highlights any selected points. - /// @details The colors of the non-selected points uses the native color - /// of the original points - /// @pre The cloud should be originally colored. - void - drawWithRGB() const; - - /// @brief Renders the cloud and highlights any selected points. - /// @details The non-selected points are in a single color - void - drawWithPureColor() const; - - /// @brief Renders the cloud with the color used for highlighting the - /// selected points. - void - drawWithHighlightColor() const; - - /// @brief Sets the axis along which the displayed points should have the - /// color ramp applied. - /// @param a The axis id describing which direction the ramp should be - /// applied. - inline void - setColorRampAxis(Axis a) - { - color_ramp_axis_ = a; - } - - /// @brief Enables/Disables the use of the color ramp in display. - /// @details The color ramp aids in the visualization of the displayed - /// points by varying the color according to a linear ramp along one of the - /// axes. - /// @param onOff True enables the use of the color ramp and false disables. - inline void - setColorRamp(bool on_off) - { - use_color_ramp_ = on_off; - } - - /// @brief Appends a new 3D point to the cloud. - /// @param point the new point to be added. - void - append(const Point3D& point); - - /// @brief Appends the points of the passed cloud to this cloud. - /// @param cloud the cloud to be appended to this cloud. - void - append(const Cloud& cloud); - - /// @brief Removes the points in selection from the cloud. - /// @details Each indexed point in the selection will be removed from this - /// container. - /// @pre The index of each point in the selection is expected to be within - /// the limits of the cloud. For debugging this is currently checked by an - /// assert. Also, it is expected that the selection indices are sorted. - /// @param selection a selection object which stores the indices of the - /// selected points. - /// @remarks This function requires the use of Selection::isSelected and its - /// complexity can vary based on the implementation of that function. - void - remove(const Selection& selection); - - /// @brief Gets the size of the cloud - inline unsigned int - size() const - { - return (cloud_.size()); - } - - /// @brief Sets the size of the cloud of this object to the passed new size - /// @details If the size is smaller than the current size, only the first - /// new_size points will be kept, the rest being dropped. If new_size is - /// larger than the current size, the new points required to fill the - /// extended region are created with its default constructor. - /// @param new_size the new size of the cloud. - void - resize(unsigned int new_size); - - /// @brief Removes all points from the cloud and resets the object - void - clear(); - - /// @brief Set the sizes used for rendering the unselected points. - /// @param size The size, in pixels, used for rendering the points. - void - setPointSize(int size); - - /// @brief Set the sizes used for rendering the selected points. - /// @param size The size, in pixels, used for rendering the points. - void - setHighlightPointSize(int size); - - /// @brief Compute the transformed coordinates of the indexed point in the - /// cloud according to the object transform. - /// @details This applies the object rotation and translation of the - /// indexed point according to the user transforms. - /// @param index The index of the point whose coordinates are - /// transformed. - /// @return The transformed point. - Point3D - getObjectSpacePoint(unsigned int index) const; - - /// @brief Compute the transformed coordinates of the indexed point in the - /// cloud to match the display. - /// @details To save on computation, the points in the display are not - /// transformed on the cpu side, instead the gpu is allowed to manipulate - /// them for display. This function performs the same manipulation and - /// returns the transformed point. - /// @param index The index of the point whose coordinates are - /// transformed according to the display. - /// @return The transformed point. - Point3D - getDisplaySpacePoint(unsigned int index) const; - - /// @brief Compute the transformed coordinates of the all the points in the - /// cloud to match the display. - /// @details To save on computation, the points in the display are not - /// transformed on the cpu side, instead the gpu is allowed to manipulate - /// them for display. This function performs the same manipulation and - /// returns the transformed points. - /// @param pts a vector used to store the points whose coordinates are - /// transformed. - void - getDisplaySpacePoints(Point3DVector& pts) const; - - /// @brief Returns a const reference to the internal representation of this - /// object. - const Cloud3D& - getInternalCloud() const; - - /// @brief Places the points in the copy buffer into the cloud according - /// to the indices in the selection. - void - restore(const CopyBuffer& copy_buffer, const Selection& selection); - - /// @brief Get statistics of the selected points in string. - std::string - getStat() const override; - - /// Default Point Size - static const float DEFAULT_POINT_DISPLAY_SIZE_; - /// Default Highlight Point Size - static const float DEFAULT_POINT_HIGHLIGHT_SIZE_; - /// Default Point Color - Red component - static const float DEFAULT_POINT_DISPLAY_COLOR_RED_; - /// Default Point Color - Green component - static const float DEFAULT_POINT_DISPLAY_COLOR_GREEN_; - /// Default Point Color - Blue component - static const float DEFAULT_POINT_DISPLAY_COLOR_BLUE_; - /// Default Point Highlight Color - Red component - static const float DEFAULT_POINT_HIGHLIGHT_COLOR_RED_; - /// Default Point Highlight Color - Green component - static const float DEFAULT_POINT_HIGHLIGHT_COLOR_GREEN_; - /// Default Point Highlight Color - Blue component - static const float DEFAULT_POINT_HIGHLIGHT_COLOR_BLUE_; - -private: - /// @brief Computes the point cloud related members. - /// @details The cloud keeps track of certain values related to the points - /// in the cloud. These include the minimum coordinates and the ranges in - /// the coordinate directions. - /// @pre Assumes that there is at least one dimension of the point cloud - /// that has non-zero range. - void - updateCloudMembers(); - - /// @brief Enable the texture used for rendering the cloud - void - enableTexture() const; - - /// @brief Disable the texture used for rendering the cloud - void - disableTexture() const; - - /// The internal representation of the cloud - Cloud3D cloud_; - - /// @brief A weak pointer pointing to the selection object. - /// @details This implementation uses the weak pointer to allow for a lazy - /// update of the cloud if the selection object is destroyed. - SelectionWeakPtr selection_wk_ptr_; - - /// Flag that indicates whether a color ramp should be used (true) or not - /// (false) when displaying the cloud - bool use_color_ramp_; - - /// The axis which the color ramp is to be applied when drawing the cloud - Axis color_ramp_axis_; - - /// A scale value used to normalize the display of clouds. This is simply - /// one over the maximum of the range in each coordinate direction - float display_scale_; - - /// The center coordinate values in the point cloud. This is used for - /// display. - float center_xyz_[XYZ_SIZE]; - - /// The minimum coordinate values in the point cloud. This is used for - /// display. - float min_xyz_[XYZ_SIZE]; - - /// The maximum coordinate values in the point cloud. This is used for - /// display. - float max_xyz_[XYZ_SIZE]; - - /// A (4x4) OpenGL transform matrix for rendering the cloud - float cloud_matrix_[MATRIX_SIZE]; - - /// A (4x4) OpenGL transform matrix specifying the relative transformations - /// that are applied to the selected points in the cloud when drawing them - /// as highlighted. - float select_matrix_[MATRIX_SIZE]; - - /// A vector of indices for every point in the cloud. This vector is used - /// when a selection is set and sorted such that the selected indices - /// appear first in the vector. This is used during display to allow for - /// separate indexed drawing of the selection and the point cloud. Note - /// that this vector is partitioned according to selected and not-selected. - IndexVector partitioned_indices_; - - /// The size used for rendering the unselected points in the cloud - float point_size_; - - /// The size used for rendering the selected points in the cloud - float selected_point_size_; - - /// The R, G, B values used for coloring each points when the current - /// color scheme is COLOR_BY_PURE. - float color_[RGB]; - - /// The R, G, B values used for highlighting the selected points. - float highlight_color_[RGB]; - - /// The translations on x, y, and z axis on the selected points. - float select_translate_x_, select_translate_y_, select_translate_z_; +class Cloud : public Statistics +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; + + /// The type for weak pointer pointing to a selection buffer + using SelectionWeakPtr = pcl::weak_ptr; + + /// @brief Default Constructor + Cloud (); + + /// @brief Copy Constructor + /// @details This constructor creates a copy of the passed cloud. The + /// values of the member variables of the passed cloud are deep copied. + /// @param copy The cloud object to be used to initialize this cloud object. + Cloud (const Cloud& copy); + + /// @brief Construct a cloud from a Cloud3D. + /// @details This constructor creates a cloud object with the passed + /// cloud object stored with the internal representation. The member + /// variables of this object are initialized but not set. + Cloud (const Cloud3D& cloud, bool register_stats=false); + + /// @brief Equal Operator + /// @details Deep copies all the state of the passed cloud to this cloud. + /// @param cloud The cloud object whose status to be copied to this object + /// @return A reference to this cloud containing the new values. + Cloud& + operator= (const Cloud& cloud); + + /// @brief Subscript Operator + /// @details This operator returns a reference to the point with the + /// passed index in this cloud object. + /// @pre The index passed is expected to be within the limits of the cloud. + /// For debugging this is currently checked by an assert. + /// @param index The index of the point to be returned. + /// @return A reference to the indexed point. + Point3D& + operator[] (unsigned int index); + + /// @brief Subscript Operator + /// @details This operator returns a const reference to the point with the + /// passed index in this cloud object. + /// @pre The index passed is expected to be within the limits of the cloud. + /// For debugging this is currently checked by an assert. + /// @param index The index of the point to be returned. + /// @return A const reference to the indexed point. + const Point3D& + operator[] (unsigned int index) const; + + /// @brief Returns the center of the point cloud + /// @param x The x coordinate of the center (computed as the average point). + /// @param y The y coordinate of the center (computed as the average point). + /// @param z The z coordinate of the center (computed as the average point). + inline + void + getCenter (float &x, float &y, float &z) const + { + x = center_xyz_[X]; y = center_xyz_[Y]; z = center_xyz_[Z]; + } + + /// @brief Returns the scaling factor for the point cloud + /// @return The scaling factor + inline + float + getScalingFactor() const + { + return (display_scale_); + } + + /// @brief Gets the transform matrix. + /// @details The returned matrix is used to transform the cloud for + /// rendering only and does not affect the values of the points stored. + /// @return A 1-D array representing (4 x 4) matrix in + /// using OpenGL's column-major format. + inline + const float* + getMatrix () const + { + return (cloud_matrix_); + } + + /// @brief Sets the transform matrix for the cloud. + /// @details The passed matrix is used to transform the cloud for + /// rendering only and does not affect the values of the points stored. + /// @pre The passed pointer represents a matrix having valid memory of at + /// least MATRIX_SIZE elements. + /// @param matrix a 1-D array representing (4 x 4) matrix in + /// using OpenGL's column-major format. + void + loadMatrix (const float* matrix); + + /// @brief Right multiplies the cloud matrix with the passed matrix + /// @details The application of this matrix effectively transforms the + /// cloud from its current state. The passed matrix is used for display + /// only and does not affect the values of the points stored. + /// @pre The passed pointer represents a matrix having valid memory of at + /// least MATRIX_SIZE elements. + /// @param matrix a 1-D array representing (4 x 4) matrix in + /// using OpenGL's column-major format. + void + multMatrix (const float* matrix); + + /// @brief Sets the selection transform matrix to the one passed. + /// @details The selection matrix represents the local transformations + /// applied to the selected points. The matrix is used relative to the + /// cloud's state after the application of its own matrices which can be + /// modified by loadMatrix and multMatrix functions. + /// @pre The passed pointer represents a matrix having valid memory of at + /// least MATRIX_SIZE elements. + /// @param matrix a 1-D array representing (4 x 4) matrix in + /// using OpenGL's column-major format. + /// @sa loadMatrix multMatrix + void + setSelectionRotation (const float* matrix); + + void + setSelectionTranslation (float dx, float dy, float dz); + + /// @brief Sets the selected points. + /// @details The cloud object is responsible for its display. As we have + /// tried to adopt a lazy approach in the application of modifications to + /// the cloud, the cloud must be notified of the selected points. This is + /// required as the user may move the selected points and we do not wish for + /// the selected points to be drawn twice, once in the user-updated position + /// and another in the points original location. + /// @pre Assumes that the selection stores the selected indices of the + /// points sorted. + /// @param A pointer pointing to a selection object. + /// @remarks This has been implemented using a weak pointer to allow a lazy + /// update to occur. When a selection is destroyed we can switch to + /// a faster rendering mode; this also occurs if the selection object is + /// empty. + void + setSelection (const SelectionPtr& selection_ptr); + + /// @brief Sets the RGB values for coloring points in COLOR_BY_PURE mode. + /// @param r the value for red color + /// @param g the value for the green color + /// @param b the value for the blue color + void + setRGB (float r, float g, float b); + + /// @brief Sets the RGB values used for highlighting the selected points. + /// @param r the value for red color + /// @param g the value for the green color + /// @param b the value for the blue color + void + setHighlightColor (float r, float g, float b); + + /// @brief Renders the cloud and highlights any selected points. + /// @param disableHighlight Defaults to false. If true the selected points + /// will not be drawn. + /// @sa setColorRampAxis, setColorRamp + void + draw (bool disable_highlight = false) const; + + /// @brief Renders the cloud and highlights any selected points. + /// @details The colors of the non-selected points come from a 1D texture + /// which is implemented by a color ramp. + void + drawWithTexture () const; + + /// @brief Renders the cloud and highlights any selected points. + /// @details The colors of the non-selected points uses the native color + /// of the original points + /// @pre The cloud should be originally colored. + void + drawWithRGB () const; + + /// @brief Renders the cloud and highlights any selected points. + /// @details The non-selected points are in a single color + void + drawWithPureColor () const; + + /// @brief Renders the cloud with the color used for highlighting the + /// selected points. + void + drawWithHighlightColor () const; + + /// @brief Sets the axis along which the displayed points should have the + /// color ramp applied. + /// @param a The axis id describing which direction the ramp should be + /// applied. + inline + void + setColorRampAxis(Axis a) + { + color_ramp_axis_ = a; + } + + /// @brief Enables/Disables the use of the color ramp in display. + /// @details The color ramp aids in the visualization of the displayed + /// points by varying the color according to a linear ramp along one of the + /// axes. + /// @param onOff True enables the use of the color ramp and false disables. + inline + void + setColorRamp(bool on_off) + { + use_color_ramp_ = on_off; + } + + /// @brief Appends a new 3D point to the cloud. + /// @param point the new point to be added. + void + append (const Point3D& point); + + /// @brief Appends the points of the passed cloud to this cloud. + /// @param cloud the cloud to be appended to this cloud. + void + append (const Cloud& cloud); + + /// @brief Removes the points in selection from the cloud. + /// @details Each indexed point in the selection will be removed from this + /// container. + /// @pre The index of each point in the selection is expected to be within + /// the limits of the cloud. For debugging this is currently checked by an + /// assert. Also, it is expected that the selection indices are sorted. + /// @param selection a selection object which stores the indices of the + /// selected points. + /// @remarks This function requires the use of Selection::isSelected and its + /// complexity can vary based on the implementation of that function. + void + remove (const Selection& selection); + + /// @brief Gets the size of the cloud + inline + unsigned int + size () const + { + return (cloud_.size()); + } + + /// @brief Sets the size of the cloud of this object to the passed new size + /// @details If the size is smaller than the current size, only the first + /// new_size points will be kept, the rest being dropped. If new_size is + /// larger than the current size, the new points required to fill the + /// extended region are created with its default constructor. + /// @param new_size the new size of the cloud. + void + resize (unsigned int new_size); + + /// @brief Removes all points from the cloud and resets the object + void + clear (); + + /// @brief Set the sizes used for rendering the unselected points. + /// @param size The size, in pixels, used for rendering the points. + void + setPointSize (int size); + + /// @brief Set the sizes used for rendering the selected points. + /// @param size The size, in pixels, used for rendering the points. + void + setHighlightPointSize (int size); + + /// @brief Compute the transformed coordinates of the indexed point in the + /// cloud according to the object transform. + /// @details This applies the object rotation and translation of the + /// indexed point according to the user transforms. + /// @param index The index of the point whose coordinates are + /// transformed. + /// @return The transformed point. + Point3D + getObjectSpacePoint (unsigned int index) const; + + /// @brief Compute the transformed coordinates of the indexed point in the + /// cloud to match the display. + /// @details To save on computation, the points in the display are not + /// transformed on the cpu side, instead the gpu is allowed to manipulate + /// them for display. This function performs the same manipulation and + /// returns the transformed point. + /// @param index The index of the point whose coordinates are + /// transformed according to the display. + /// @return The transformed point. + Point3D + getDisplaySpacePoint (unsigned int index) const; + + /// @brief Compute the transformed coordinates of the all the points in the + /// cloud to match the display. + /// @details To save on computation, the points in the display are not + /// transformed on the cpu side, instead the gpu is allowed to manipulate + /// them for display. This function performs the same manipulation and + /// returns the transformed points. + /// @param pts a vector used to store the points whose coordinates are + /// transformed. + void + getDisplaySpacePoints (Point3DVector& pts) const; + + /// @brief Returns a const reference to the internal representation of this + /// object. + const Cloud3D& + getInternalCloud () const; + + /// @brief Places the points in the copy buffer into the cloud according + /// to the indices in the selection. + void + restore (const CopyBuffer& copy_buffer, const Selection& selection); + + /// @brief Get statistics of the selected points in string. + std::string + getStat () const override; + + /// Default Point Size + static const float DEFAULT_POINT_DISPLAY_SIZE_; + /// Default Highlight Point Size + static const float DEFAULT_POINT_HIGHLIGHT_SIZE_; + /// Default Point Color - Red component + static const float DEFAULT_POINT_DISPLAY_COLOR_RED_; + /// Default Point Color - Green component + static const float DEFAULT_POINT_DISPLAY_COLOR_GREEN_; + /// Default Point Color - Blue component + static const float DEFAULT_POINT_DISPLAY_COLOR_BLUE_; + /// Default Point Highlight Color - Red component + static const float DEFAULT_POINT_HIGHLIGHT_COLOR_RED_; + /// Default Point Highlight Color - Green component + static const float DEFAULT_POINT_HIGHLIGHT_COLOR_GREEN_; + /// Default Point Highlight Color - Blue component + static const float DEFAULT_POINT_HIGHLIGHT_COLOR_BLUE_; + + private: + /// @brief Computes the point cloud related members. + /// @details The cloud keeps track of certain values related to the points + /// in the cloud. These include the minimum coordinates and the ranges in + /// the coordinate directions. + /// @pre Assumes that there is at least one dimension of the point cloud + /// that has non-zero range. + void + updateCloudMembers (); + + /// @brief Enable the texture used for rendering the cloud + void + enableTexture () const; + + /// @brief Disable the texture used for rendering the cloud + void + disableTexture() const; + + /// The internal representation of the cloud + Cloud3D cloud_; + + /// @brief A weak pointer pointing to the selection object. + /// @details This implementation uses the weak pointer to allow for a lazy + /// update of the cloud if the selection object is destroyed. + SelectionWeakPtr selection_wk_ptr_; + + /// Flag that indicates whether a color ramp should be used (true) or not + /// (false) when displaying the cloud + bool use_color_ramp_; + + /// The axis which the color ramp is to be applied when drawing the cloud + Axis color_ramp_axis_; + + /// A scale value used to normalize the display of clouds. This is simply + /// one over the maximum of the range in each coordinate direction + float display_scale_; + + /// The center coordinate values in the point cloud. This is used for + /// display. + float center_xyz_[XYZ_SIZE]; + + /// The minimum coordinate values in the point cloud. This is used for + /// display. + float min_xyz_[XYZ_SIZE]; + + /// The maximum coordinate values in the point cloud. This is used for + /// display. + float max_xyz_[XYZ_SIZE]; + + /// A (4x4) OpenGL transform matrix for rendering the cloud + float cloud_matrix_[MATRIX_SIZE]; + + /// A (4x4) OpenGL transform matrix specifying the relative transformations + /// that are applied to the selected points in the cloud when drawing them + /// as highlighted. + float select_matrix_[MATRIX_SIZE]; + + /// A vector of indices for every point in the cloud. This vector is used + /// when a selection is set and sorted such that the selected indices + /// appear first in the vector. This is used during display to allow for + /// separate indexed drawing of the selection and the point cloud. Note + /// that this vector is partitioned according to selected and not-selected. + IndexVector partitioned_indices_; + + /// The size used for rendering the unselected points in the cloud + float point_size_; + + /// The size used for rendering the selected points in the cloud + float selected_point_size_; + + /// The R, G, B values used for coloring each points when the current + /// color scheme is COLOR_BY_PURE. + float color_[RGB]; + + /// The R, G, B values used for highlighting the selected points. + float highlight_color_[RGB]; + + /// The translations on x, y, and z axis on the selected points. + float select_translate_x_, select_translate_y_, select_translate_z_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h index 30ba56ebe04..91ff49e32fe 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h @@ -40,285 +40,288 @@ #pragma once -#include +#include #include +#include #include -#include #include #include -#include // for pcl::shared_ptr + +#include // for pcl::shared_ptr #include -#include // for std::array #include class Selection; /// @brief class declaration for the widget for editing and viewing /// point clouds. -class CloudEditorWidget : public QOpenGLWidget { +class CloudEditorWidget : public QOpenGLWidget +{ Q_OBJECT -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param parent a pointer which points to the parent widget - CloudEditorWidget(QWidget* parent = nullptr); - - /// @brief Destructor - ~CloudEditorWidget() override; - - /// @brief Attempts to load the point cloud designated by the passed file - /// name. - /// @param filename The name of the point cloud file to be loaded. - /// @remarks throws if the passed file can not be loaded. - void - loadFile(const std::string& filename); - -public Q_SLOTS: - /// @brief Loads a new cloud. - void - load(); - - /// @brief Saves a cloud to a .pcd file. The current format is ASCII. - void - save(); - - /// @brief Toggles the blend mode used to render the non-selected points - void - toggleBlendMode(); - - /// @brief Switches to the view mode. - void - view(); - - /// @brief Enters click selection mode. - void - select1D(); - - /// @brief Enters 2D selection mode. - void - select2D(); - - /// @brief Enters 3D selection mode. - void - select3D(); - - /// @brief Inverts the current selection. - void - invertSelect(); - - /// @brief Cancels the current selection. - void - cancelSelect(); - - /// @brief Copies the selected points. - void - copy(); - - /// @brief Pastes the copied points to the cloud. - void - paste(); - - /// @brief Removes the selected points. - void - remove(); - - /// @brief Copies and then removes the selected points. - void - cut(); - - /// @brief Enters the mode where users are able to translate the selected - /// points. - void - transform(); - - /// @brief Denoises the current cloud. - void - denoise(); - - /// @brief Undoes last change. - void - undo(); - - /// @brief Increases the size of the unselected points. - void - increasePointSize(); - - /// @brief Decreases the size of the unselected points. - void - decreasePointSize(); - - /// @brief Increases the size of the selected points. - void - increaseSelectedPointSize(); - - /// @brief Decreases the size of the selected points. - void - decreaseSelectedPointSize(); - - /// @brief Sets the size of the unselected points. - void - setPointSize(int size); - - /// @brief Sets the size of the selected points. - void - setSelectedPointSize(int size); - - /// @brief Colors the unselected points by its native color. - void - colorByRGB(); - - /// @brief Colors the unselected points with a color ramp based on the X - /// values of the points - void - colorByX(); - - /// @brief Colors the unselected points with a color ramp based on the Y - /// values of the points - void - colorByY(); - - /// @brief Colors the unselected points with a color ramp based on the Z - /// values of the points - void - colorByZ(); - - /// @brief Colors the unselected points using an single color. - void - colorByPure(); - - /// @brief Turn on the dialog box showing the statistics of the cloud. - void - showStat(); - -protected: - /// initializes GL - void - initializeGL() override; - - /// the rendering function. - void - paintGL() override; - - /// resizes widget - void - resizeGL(int width, int height) override; - - /// mouse press control - void - mousePressEvent(QMouseEvent* event) override; - - /// mouse move control - void - mouseMoveEvent(QMouseEvent* event) override; - - /// mouse release control - void - mouseReleaseEvent(QMouseEvent* event) override; - - /// key press control - void - keyPressEvent(QKeyEvent* event) override; - -private: - /// @brief Attempts to load a pcd file - /// @param filename The name of the pcd file to be loaded. - /// @remarks throws if the passed file can not be loaded. - void - loadFilePCD(const std::string& filename); - - /// @brief Adds all of our file loader functions to the extension map - void - initFileLoadMap(); - - /// @brief Returns true if the cloud stored in a file is colored - /// @param fileName a reference to a string storing the path of a cloud - bool - isColored(const std::string& fileName) const; - - /// @brief swap the values of r and b in each point of the cloud. - void - swapRBValues(); - - /// @brief initializes the map between key press events and the - /// corresponding functors. - void - initKeyMap(); - - struct ExtCompare { + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; + + /// @brief Constructor + /// @param parent a pointer which points to the parent widget + CloudEditorWidget (QWidget *parent = nullptr); + + /// @brief Destructor + ~CloudEditorWidget () override; + + /// @brief Attempts to load the point cloud designated by the passed file + /// name. + /// @param filename The name of the point cloud file to be loaded. + /// @remarks throws if the passed file can not be loaded. + void + loadFile(const std::string &filename); + + public Q_SLOTS: + /// @brief Loads a new cloud. + void + load (); + + /// @brief Saves a cloud to a .pcd file. The current format is ASCII. + void + save (); + + /// @brief Toggles the blend mode used to render the non-selected points + void + toggleBlendMode (); + + /// @brief Switches to the view mode. + void + view (); + + /// @brief Enters click selection mode. + void + select1D (); + + /// @brief Enters 2D selection mode. + void + select2D (); + + /// @brief Enters 3D selection mode. + void + select3D (); + + /// @brief Inverts the current selection. + void + invertSelect (); + + /// @brief Cancels the current selection. + void + cancelSelect (); + + /// @brief Copies the selected points. + void + copy (); + + /// @brief Pastes the copied points to the cloud. + void + paste (); + + /// @brief Removes the selected points. + void + remove (); + + /// @brief Copies and then removes the selected points. + void + cut (); + + /// @brief Enters the mode where users are able to translate the selected + /// points. + void + transform (); + + /// @brief Denoises the current cloud. + void + denoise (); + + /// @brief Undoes last change. + void + undo (); + + /// @brief Increases the size of the unselected points. + void + increasePointSize (); + + /// @brief Decreases the size of the unselected points. + void + decreasePointSize (); + + /// @brief Increases the size of the selected points. + void + increaseSelectedPointSize (); + + /// @brief Decreases the size of the selected points. + void + decreaseSelectedPointSize (); + + /// @brief Sets the size of the unselected points. + void + setPointSize (int size); + + /// @brief Sets the size of the selected points. + void + setSelectedPointSize (int size); + + /// @brief Colors the unselected points by its native color. + void + colorByRGB (); + + /// @brief Colors the unselected points with a color ramp based on the X + /// values of the points + void + colorByX (); + + /// @brief Colors the unselected points with a color ramp based on the Y + /// values of the points + void + colorByY (); + + /// @brief Colors the unselected points with a color ramp based on the Z + /// values of the points + void + colorByZ (); + + /// @brief Colors the unselected points using an single color. + void + colorByPure (); + + /// @brief Turn on the dialog box showing the statistics of the cloud. + void + showStat (); + + protected: + /// initializes GL + void + initializeGL () override; + + /// the rendering function. + void + paintGL () override; + + /// resizes widget + void + resizeGL (int width, int height) override; + + /// mouse press control + void + mousePressEvent (QMouseEvent *event) override; + + /// mouse move control + void + mouseMoveEvent (QMouseEvent *event) override; + + /// mouse release control + void + mouseReleaseEvent (QMouseEvent *event) override; + + /// key press control + void + keyPressEvent (QKeyEvent *event) override; + + private: + + /// @brief Attempts to load a pcd file + /// @param filename The name of the pcd file to be loaded. + /// @remarks throws if the passed file can not be loaded. + void + loadFilePCD(const std::string &filename); + + /// @brief Adds all of our file loader functions to the extension map + void + initFileLoadMap(); + + /// @brief Returns true if the cloud stored in a file is colored + /// @param fileName a reference to a string storing the path of a cloud bool - operator()(std::string lhs, std::string rhs) const - { - stringToLower(lhs); - stringToLower(rhs); - return lhs.compare(rhs) < 0; - } - }; + isColored (const std::string &fileName) const; + + /// @brief swap the values of r and b in each point of the cloud. + void + swapRBValues (); - using FileLoadFunc = std::function; - using FileLoadMap = std::map; + /// @brief initializes the map between key press events and the + /// corresponding functors. + void + initKeyMap(); + + struct ExtCompare + { + bool + operator()(std::string lhs, std::string rhs) const + { + stringToLower(lhs); + stringToLower(rhs); + return lhs.compare(rhs) < 0; + } + }; - /// a map of file type extensions to loader functions. - FileLoadMap cloud_load_func_map_; + using FileLoadFunc = std::function; + using FileLoadMap = std::map; - /// a pointer to the cloud being edited. - CloudPtr cloud_ptr_; + /// a map of file type extensions to loader functions. + FileLoadMap cloud_load_func_map_; + + /// a pointer to the cloud being edited. + CloudPtr cloud_ptr_; - /// The display size, in pixels, of the cloud points - unsigned int point_size_; + /// The display size, in pixels, of the cloud points + unsigned int point_size_; - /// The display size, in pixels, of the selected cloud points - unsigned int selected_point_size_; + /// The display size, in pixels, of the selected cloud points + unsigned int selected_point_size_; - /// The transformation tool being used. Either a cloud transform tool or - /// a selection transform tool is activated at a time. - std::shared_ptr tool_ptr_; + /// The transformation tool being used. Either a cloud transform tool or + /// a selection transform tool is activated at a time. + std::shared_ptr tool_ptr_; - /// a pointer to the selection object - SelectionPtr selection_ptr_; + /// a pointer to the selection object + SelectionPtr selection_ptr_; - /// a pointer to the copy buffer object. - CopyBufferPtr copy_buffer_ptr_; + /// a pointer to the copy buffer object. + CopyBufferPtr copy_buffer_ptr_; - /// a pointer to the command queue object - CommandQueuePtr command_queue_ptr_; + /// a pointer to the command queue object + CommandQueuePtr command_queue_ptr_; - /// The camera field of view - double cam_fov_; + /// The camera field of view + double cam_fov_; - /// The camera aspect ratio - double cam_aspect_; + /// The camera aspect ratio + double cam_aspect_; - /// The camera near clipping plane - double cam_near_; + /// The camera near clipping plane + double cam_near_; - /// The camera far clipping plane - double cam_far_; + /// The camera far clipping plane + double cam_far_; - /// @brief Initialize the texture used for rendering the cloud - void - initTexture(); + /// @brief Initialize the texture used for rendering the cloud + void + initTexture (); - /// The current scheme used for coloring the whole cloud - ColorScheme color_scheme_; + /// The current scheme used for coloring the whole cloud + ColorScheme color_scheme_; - /// A flag indicates whether the cloud is initially colored or not. - bool is_colored_; + /// A flag indicates whether the cloud is initially colored or not. + bool is_colored_; - using KeyMapFunc = std::function; + using KeyMapFunc = std::function; - /// map between pressed key and the corresponding functor - std::map key_map_; + /// map between pressed key and the corresponding functor + std::map key_map_; - /// a dialog displaying the statistics of the cloud editor - StatisticsDialog stat_dialog_; + /// a dialog displaying the statistics of the cloud editor + StatisticsDialog stat_dialog_; - /// the viewport, set by resizeGL - std::array viewport_; + /// the viewport, set by resizeGL + std::array viewport_; - /// the projection matrix, set by resizeGL - std::array projection_matrix_; + /// the projection matrix, set by resizeGL + std::array projection_matrix_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h index 33cdad5475a..66ae1b482d1 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h @@ -40,104 +40,108 @@ #pragma once -#include #include +#include #include /// @brief The cloud transform tool computes the transform matrix from user's /// mouse operation. It then updates the cloud with the new transform matrices /// to make the cloud be rendered appropriately. -class CloudTransformTool : public ToolInterface { -public: - /// @brief Constructor - /// @param cloud_ptr a shared pointer pointing to the cloud object. - CloudTransformTool(CloudPtr cloud_ptr); - - /// @brief Destructor - ~CloudTransformTool() override; - - /// @brief Initialize the current transform with mouse screen coordinates - /// and key modifiers. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers The keyboard modifiers. This function does not make - /// use of this parameter. - /// @param buttons The state of the mouse buttons. This function does not - /// make use of this parameter. - void - start(int x, int y, BitMask modifiers, BitMask buttons) override; - - /// @brief Updates the transform matrix of this object with mouse screen - /// coordinates and key modifiers. - /// @details When the LEFT mouse button is down the motion of the mouse is - /// used to compute various transforms for the cloud display. Depending on - /// the modifiers, the transformation matrix is computed correspondingly. - /// When shift is pressed, the motion of mouse indicates a scale. If - /// no key modifiers is pressed, the mouse move indicates a rotation. The - /// control key pans the display, and the alt key translates along the - /// z-axis. - /// @param x The x value of the mouse screen coordinates. - /// @param y The y value of the mouse screen coordinates. - /// @param modifiers the key modifier. SHIFT scales the point cloud - /// display. CONTROL pans the point cloud parallel to the view plane. ALT - /// moves the point cloud in/out along the z-axis (perpendicular to the - /// view plane). If no modifier is pressed then the cloud display is - /// rotated. - /// @param buttons The LEFT mouse button must be pressed for any transform - /// to be generated. All other buttons are ignored. - void - update(int x, int y, BitMask modifiers, BitMask buttons) override; - - /// @brief Updates the transform matrix of this object with mouse screen - /// coordinates and key modifiers. Then right multiplies the cloud_matrix_ - /// matrix of the cloud object with the transform matrix of this object. - /// @details This function is not required by this tool - void - end(int, int, BitMask, BitMask) override - {} - - /// @brief This function does nothing for this cloud transform tool. - void - draw() const override - {} - -private: - /// generate translate matrix for the xy plane - void - getTranslateMatrix(int dx, int dy, float* matrix); - - /// generate translate matrix for the z direction - void - getZTranslateMatrix(int dy, float* matrix); - - /// generate scale matrix - void - getScaleMatrix(int dy, float* matrix) const; - - /// the transform matrix to be used for updating the coordinates of all - /// the points in the cloud - float transform_matrix_[MATRIX_SIZE]; - - /// a shared pointer pointing to the cloud object. - CloudPtr cloud_ptr_; - - /// the trackball associated with this transform - TrackBall trackball_; - - /// last recorded mouse positions - int x_, y_; - - /// scaling factor used to control the speed which the display scales the - /// point cloud - float scale_factor_; - - /// scaling factor used to control the speed which the display translates - /// the point cloud - float translate_factor_; - - /// default scaling factor - static const float DEFAULT_SCALE_FACTOR_; - - /// default translation factor - static const float DEFAULT_TRANSLATE_FACTOR_; +class CloudTransformTool : public ToolInterface +{ + public: + /// @brief Constructor + /// @param cloud_ptr a shared pointer pointing to the cloud object. + CloudTransformTool (CloudPtr cloud_ptr); + + /// @brief Destructor + ~CloudTransformTool () override; + + /// @brief Initialize the current transform with mouse screen coordinates + /// and key modifiers. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers The keyboard modifiers. This function does not make + /// use of this parameter. + /// @param buttons The state of the mouse buttons. This function does not + /// make use of this parameter. + void + start (int x, int y, BitMask modifiers, BitMask buttons) override; + + /// @brief Updates the transform matrix of this object with mouse screen + /// coordinates and key modifiers. + /// @details When the LEFT mouse button is down the motion of the mouse is + /// used to compute various transforms for the cloud display. Depending on + /// the modifiers, the transformation matrix is computed correspondingly. + /// When shift is pressed, the motion of mouse indicates a scale. If + /// no key modifiers is pressed, the mouse move indicates a rotation. The + /// control key pans the display, and the alt key translates along the + /// z-axis. + /// @param x The x value of the mouse screen coordinates. + /// @param y The y value of the mouse screen coordinates. + /// @param modifiers the key modifier. SHIFT scales the point cloud + /// display. CONTROL pans the point cloud parallel to the view plane. ALT + /// moves the point cloud in/out along the z-axis (perpendicular to the + /// view plane). If no modifier is pressed then the cloud display is + /// rotated. + /// @param buttons The LEFT mouse button must be pressed for any transform + /// to be generated. All other buttons are ignored. + void + update (int x, int y, BitMask modifiers, BitMask buttons) override; + + /// @brief Updates the transform matrix of this object with mouse screen + /// coordinates and key modifiers. Then right multiplies the cloud_matrix_ + /// matrix of the cloud object with the transform matrix of this object. + /// @details This function is not required by this tool + void + end (int, int, BitMask, BitMask) override + { + } + + /// @brief This function does nothing for this cloud transform tool. + void + draw() const override + { + } + + private: + + /// generate translate matrix for the xy plane + void + getTranslateMatrix (int dx, int dy, float* matrix); + + /// generate translate matrix for the z direction + void + getZTranslateMatrix (int dy, float* matrix); + + /// generate scale matrix + void + getScaleMatrix (int dy, float* matrix) const; + + /// the transform matrix to be used for updating the coordinates of all + /// the points in the cloud + float transform_matrix_[MATRIX_SIZE]; + + /// a shared pointer pointing to the cloud object. + CloudPtr cloud_ptr_; + + /// the trackball associated with this transform + TrackBall trackball_; + + /// last recorded mouse positions + int x_, y_; + + /// scaling factor used to control the speed which the display scales the + /// point cloud + float scale_factor_; + + /// scaling factor used to control the speed which the display translates + /// the point cloud + float translate_factor_; + + /// default scaling factor + static const float DEFAULT_SCALE_FACTOR_; + + /// default translation factor + static const float DEFAULT_TRANSLATE_FACTOR_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h index 5b7f3af36df..ca4ef7fb128 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h @@ -47,48 +47,57 @@ /// @brief The abstract parent class of all the command classes. Commands are /// non-copyable. -class Command { -public: - /// @brief Destructor - virtual ~Command() = default; +class Command +{ + public: + /// @brief Destructor + virtual ~Command () + = default; -protected: - /// Allows command queues to be the only objects which are able to execute - /// commands. - friend class CommandQueue; + protected: + /// Allows command queues to be the only objects which are able to execute + /// commands. + friend class CommandQueue; - /// @brief The default constructor. - /// @details Derived commands are assumed to have undo by default. Each - /// is free to override this. - Command() : has_undo_(true) {} + /// @brief The default constructor. + /// @details Derived commands are assumed to have undo by default. Each + /// is free to override this. + Command () : has_undo_(true) + { + } - /// @brief Returns true if the command has an undo function. - inline bool - hasUndo() const - { - return (has_undo_); - } + /// @brief Returns true if the command has an undo function. + inline + bool + hasUndo () const + { + return (has_undo_); + } - /// @brief Executes the command. - virtual void - execute() = 0; + /// @brief Executes the command. + virtual + void + execute () = 0; - /// @brief Undos the command. - virtual void - undo() = 0; + /// @brief Undos the command. + virtual + void + undo () = 0; - /// @brief a flag indicates whether the command has an undo function. - bool has_undo_; + /// @brief a flag indicates whether the command has an undo function. + bool has_undo_; -private: - /// @brief Copy Constructor - object is non-copyable - Command(const Command&) { assert(false); } + private: + /// @brief Copy Constructor - object is non-copyable + Command (const Command&) + { + assert(false); + } - /// @brief Equal Operator - object is non-copyable - Command& - operator=(const Command&) - { - assert(false); - return *this; - } + /// @brief Equal Operator - object is non-copyable + Command& + operator= (const Command&) + { + assert(false); return (*this); + } }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/commandQueue.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/commandQueue.h index 3ec5e670492..f69d9fa05b4 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/commandQueue.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/commandQueue.h @@ -41,77 +41,80 @@ #pragma once -#include - #include #include +#include /// @brief A structure for managing commands /// @details A command queue object provides a dequeue of commands as well as /// operations to manipulate the commands in the queue. Operations include /// executing and undoing the commands in the queue. A command queue object /// is non-copyable. -class CommandQueue { -public: - /// @brief Default Constructor - /// @details Creates a command queue object and makes its depth limit - /// be the default value. - CommandQueue(); - - /// @brief Constructor - /// @details Create a command queue with specified depth limit. - /// @param max_size the value to be used to set the depth limit of this - /// object. - CommandQueue(unsigned int max_size); - - /// @brief Destructor - ~CommandQueue() = default; - - /// @brief Executes a command. If the command has an undo function, then - /// adds the command to the queue. - /// @param command_ptr a shared pointer pointing to a command object whose - /// execute function will be invoked by this object. - void - execute(const CommandPtr&); - - /// @brief Undoes the last command by popping the tail of the queue, invoke - /// the undo function of the command. - void - undo(); - - /// @brief Changes the command history limit. - /// @details If the passed size is smaller than the current size then the - /// oldest commands are removed (their undo functions are not called). - /// @param size The new maximum number of commands that may exist in this - /// queue for undo purposes. - /// @return The actual maximum size set. It may happen that the passed - /// value is too large and cannot be set. - unsigned int - setMaxSize(unsigned int size); - - /// @brief The default maximal size of the depth limit - static const unsigned int DEFAULT_MAX_SIZE_ = 200; - -private: - /// @brief Copy constructor - object is non-copyable - CommandQueue(const CommandQueue&) { assert(false); } - - /// @brief Equal operator - object is non-copyable - CommandQueue& - operator=(const CommandQueue&) - { - assert(false); - return *this; - } - - /// @brief Enforces the depth limit of the command queue. If the depth is - /// larger than the depth limit, a deque operation will be invoked. - void - enforceDequeLimit(); - - /// The internal representation of this object. - std::deque command_deque_; - - /// The depth limit of the command queue. - unsigned int depth_limit_; +class CommandQueue +{ + public: + /// @brief Default Constructor + /// @details Creates a command queue object and makes its depth limit + /// be the default value. + CommandQueue (); + + /// @brief Constructor + /// @details Create a command queue with specified depth limit. + /// @param max_size the value to be used to set the depth limit of this + /// object. + CommandQueue (unsigned int max_size); + + /// @brief Destructor + ~CommandQueue () + = default; + + /// @brief Executes a command. If the command has an undo function, then + /// adds the command to the queue. + /// @param command_ptr a shared pointer pointing to a command object whose + /// execute function will be invoked by this object. + void + execute (const CommandPtr&); + + /// @brief Undoes the last command by popping the tail of the queue, invoke + /// the undo function of the command. + void + undo (); + + /// @brief Changes the command history limit. + /// @details If the passed size is smaller than the current size then the + /// oldest commands are removed (their undo functions are not called). + /// @param size The new maximum number of commands that may exist in this + /// queue for undo purposes. + /// @return The actual maximum size set. It may happen that the passed + /// value is too large and cannot be set. + unsigned int + setMaxSize(unsigned int size); + + /// @brief The default maximal size of the depth limit + static const unsigned int DEFAULT_MAX_SIZE_ = 200; + + private: + /// @brief Copy constructor - object is non-copyable + CommandQueue(const CommandQueue&) + { + assert(false); + } + + /// @brief Equal operator - object is non-copyable + CommandQueue& + operator= (const CommandQueue&) + { + assert(false); return (*this); + } + + /// @brief Enforces the depth limit of the command queue. If the depth is + /// larger than the depth limit, a deque operation will be invoked. + void + enforceDequeLimit (); + + /// The internal representation of this object. + std::deque command_deque_; + + /// The depth limit of the command queue. + unsigned int depth_limit_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/common.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/common.h index 4a0884258f8..a90606aab5e 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/common.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/common.h @@ -68,4 +68,4 @@ invertMatrix(const float* matrix, float* inverse); /// @brief Converts the passed string to lowercase in place /// @param s The string to be made lower. void -stringToLower(std::string& s); +stringToLower(std::string &s); diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyBuffer.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyBuffer.h index d5ab3504e9b..9adc2cac82b 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyBuffer.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyBuffer.h @@ -40,57 +40,58 @@ #pragma once -#include #include +#include /// @brief a buffer holding the points being copied and a set of operations for /// manipulating the buffer. -class CopyBuffer : public Statistics { -public: - /// @brief Default Constructor - /// @details This creates an empty buffer - CopyBuffer(bool register_stats = false) - { - if (register_stats) - registerStats(); - } - - /// @brief Sets the points in the copy buffer. - /// @details The passed selection pointer is used to get specified points - /// from the stored cloud pointer and copy them into the internal buffer. - /// Any points that currently exist in this buffer are removed and replaced - /// with those passed. Note that this buffer is cleared prior to any - /// checking of the state of the passed parameters. - /// @param cloud_ptr a pointer to a cloud object whose points are to be - /// copied - /// @param selection a const reference to the selected points object - void - set(const ConstCloudPtr& cloud_ptr, const Selection& selection); - - /// @brief Returns the points stored in the internal buffer as a const Cloud - const Cloud& - get() const; +class CopyBuffer : public Statistics +{ + public: + /// @brief Default Constructor + /// @details This creates an empty buffer + CopyBuffer (bool register_stats=false) + { + if (register_stats) + registerStats(); + } - /// @brief Returns the points stored in the internal buffer as a Cloud - Cloud& - get(); + /// @brief Sets the points in the copy buffer. + /// @details The passed selection pointer is used to get specified points + /// from the stored cloud pointer and copy them into the internal buffer. + /// Any points that currently exist in this buffer are removed and replaced + /// with those passed. Note that this buffer is cleared prior to any + /// checking of the state of the passed parameters. + /// @param cloud_ptr a pointer to a cloud object whose points are to be + /// copied + /// @param selection a const reference to the selected points object + void + set (const ConstCloudPtr& cloud_ptr, const Selection& selection); - /// @brief Removes all the points from the copy buffer. - void - clean(); + /// @brief Returns the points stored in the internal buffer as a const Cloud + const Cloud& + get() const; - /// @brief Get the statistics of the copied points in string. - std::string - getStat() const override; + /// @brief Returns the points stored in the internal buffer as a Cloud + Cloud& + get(); + + /// @brief Removes all the points from the copy buffer. + void + clean (); + + /// @brief Get the statistics of the copied points in string. + std::string + getStat () const override; - /// @brief Returns true if the buffer is empty, false otherwise - bool - empty() const - { - return (buffer_.size() == 0); - } + /// @brief Returns true if the buffer is empty, false otherwise + bool + empty() const + { + return (buffer_.size() == 0); + } -private: - /// a cloud object holding all the copied points. - Cloud buffer_; + private: + /// a cloud object holding all the copied points. + Cloud buffer_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyCommand.h index 8c942087d93..2da976ab097 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyCommand.h @@ -41,64 +41,65 @@ #pragma once #include -#include #include -#include // for pcl::shared_ptr +#include + +#include // for pcl::shared_ptr class Selection; -class CopyCommand : public Command { -public: - /// The type for shared pointer pointing to a constant selection buffer - using ConstSelectionPtr = pcl::shared_ptr; +class CopyCommand : public Command +{ + public: + /// The type for shared pointer pointing to a constant selection buffer + using ConstSelectionPtr = pcl::shared_ptr; - /// @brief Constructor - /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - CopyCommand(CopyBufferPtr copy_buffer_ptr, - ConstSelectionPtr selection_ptr, - ConstCloudPtr cloud_ptr) - : copy_buffer_ptr_(std::move(copy_buffer_ptr)) - , selection_ptr_(std::move(selection_ptr)) - , cloud_ptr_(std::move(cloud_ptr)) - { - has_undo_ = false; - } + /// @brief Constructor + /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + CopyCommand (CopyBufferPtr copy_buffer_ptr, + ConstSelectionPtr selection_ptr, + ConstCloudPtr cloud_ptr) + : copy_buffer_ptr_(std::move(copy_buffer_ptr)), selection_ptr_(std::move(selection_ptr)), + cloud_ptr_(std::move(cloud_ptr)) + { + has_undo_ = false; + } - /// @brief Copy constructor - commands are non-copyable - CopyCommand(const CopyCommand&) = delete; + /// @brief Copy constructor - commands are non-copyable + CopyCommand (const CopyCommand&) = delete; - /// @brief Equal operator - commands are non-copyable - CopyCommand& - operator=(const CopyCommand&) = delete; + /// @brief Equal operator - commands are non-copyable + CopyCommand& + operator= (const CopyCommand&) = delete; -protected: - /// @brief Copy the selected points into the copy buffer. - /// @pre Assumes the constructor was given appropriate pointers to the - /// required objects. - void - execute() override - { - if (!cloud_ptr_) - return; - copy_buffer_ptr_->set(cloud_ptr_, *selection_ptr_); - } + protected: + /// @brief Copy the selected points into the copy buffer. + /// @pre Assumes the constructor was given appropriate pointers to the + /// required objects. + void + execute () override + { + if (!cloud_ptr_) + return; + copy_buffer_ptr_ -> set(cloud_ptr_, *selection_ptr_); + } - /// @brief undo is not supported for this command. - void - undo() override - { - assert(false); - } + /// @brief undo is not supported for this command. + void + undo () override + { + assert(false); + } -private: - /// a pointer to the copy buffer. - CopyBufferPtr copy_buffer_ptr_; + private: + /// a pointer to the copy buffer. + CopyBufferPtr copy_buffer_ptr_; - /// a shared pointer pointing to the selection - ConstSelectionPtr selection_ptr_; + /// a shared pointer pointing to the selection + ConstSelectionPtr selection_ptr_; - /// a shared pointer pointing to the cloud - ConstCloudPtr cloud_ptr_; + /// a shared pointer pointing to the cloud + ConstCloudPtr cloud_ptr_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cutCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cutCommand.h index 0e982cac5d6..6f1e0b81d88 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cutCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cutCommand.h @@ -41,61 +41,63 @@ #pragma once #include -#include #include +#include #include -#include // for pcl::shared_ptr - -class CutCommand : public Command { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - CutCommand(CopyBufferPtr copy_buffer_ptr, - SelectionPtr selection_ptr, - const CloudPtr& cloud_ptr); - - /// @brief Copy constructor - commands are non-copyable - CutCommand(const CutCommand&) = delete; - - /// @brief Equal operator - commands are non-copyable - CutCommand& - operator=(const CutCommand&) = delete; - - /// @brief Destructor - ~CutCommand() override; - -protected: - /// @brief Moves the selected points to the copy buffer and removes them - /// from the cloud. - /// @pre Assumes the constructor was given appropriate pointers to the - /// required objects. - void - execute() override; - - /// @brief Returns the cut points to the cloud. This does not reconstruct - /// the original ordering of the point cloud. - void - undo() override; - -private: - /// A shared pointer pointing to the selection object. - SelectionPtr selection_ptr_; - - /// a pointer pointing to the cloud - CloudPtr cloud_ptr_; - - /// a pointer pointing to the copy buffer. - CopyBufferPtr copy_buffer_ptr_; - - /// a selection which backs up the index of the points cut in the - /// original cloud. - Selection cut_selection_; - - /// The copy buffer which backs up the points removed from the cloud. - CopyBuffer cut_cloud_buffer_; + +#include // for pcl::shared_ptr + +class CutCommand : public Command +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; + + /// @brief Constructor + /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + CutCommand (CopyBufferPtr copy_buffer_ptr, + SelectionPtr selection_ptr, + const CloudPtr& cloud_ptr); + + /// @brief Copy constructor - commands are non-copyable + CutCommand (const CutCommand&) = delete; + + /// @brief Equal operator - commands are non-copyable + CutCommand& + operator= (const CutCommand&) = delete; + + /// @brief Destructor + ~CutCommand () override; + + protected: + /// @brief Moves the selected points to the copy buffer and removes them + /// from the cloud. + /// @pre Assumes the constructor was given appropriate pointers to the + /// required objects. + void + execute () override; + + /// @brief Returns the cut points to the cloud. This does not reconstruct + /// the original ordering of the point cloud. + void + undo () override; + + private: + /// A shared pointer pointing to the selection object. + SelectionPtr selection_ptr_; + + /// a pointer pointing to the cloud + CloudPtr cloud_ptr_; + + /// a pointer pointing to the copy buffer. + CopyBufferPtr copy_buffer_ptr_; + + /// a selection which backs up the index of the points cut in the + /// original cloud. + Selection cut_selection_; + + /// The copy buffer which backs up the points removed from the cloud. + CopyBuffer cut_cloud_buffer_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/deleteCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/deleteCommand.h index 7abde750480..25c22ac08a5 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/deleteCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/deleteCommand.h @@ -41,48 +41,50 @@ #pragma once #include -#include #include +#include #include -#include // for pcl::shared_ptr -class DeleteCommand : public Command { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; +#include // for pcl::shared_ptr - /// @brief Constructor - /// @param selection_ptr A shared pointer pointing to the selection object. - /// @param cloud_ptr A shared pointer pointing to the cloud object. - DeleteCommand(SelectionPtr selection_ptr, const CloudPtr& cloud_ptr); +class DeleteCommand : public Command +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; - /// @brief Copy constructor - commands are non-copyable - DeleteCommand(const DeleteCommand& c) = delete; + /// @brief Constructor + /// @param selection_ptr A shared pointer pointing to the selection object. + /// @param cloud_ptr A shared pointer pointing to the cloud object. + DeleteCommand (SelectionPtr selection_ptr, const CloudPtr& cloud_ptr); - /// @brief Equal operator - commands are non-copyable - DeleteCommand& - operator=(const DeleteCommand&) = delete; + /// @brief Copy constructor - commands are non-copyable + DeleteCommand (const DeleteCommand& c) = delete; -protected: - /// @brief Removes the selected points and maintains a backup for undo. - void - execute() override; + /// @brief Equal operator - commands are non-copyable + DeleteCommand& + operator= (const DeleteCommand&) = delete; - /// @brief Returns the deleted points to the cloud, Order is not preserved. - void - undo() override; + protected: + /// @brief Removes the selected points and maintains a backup for undo. + void + execute () override; + + /// @brief Returns the deleted points to the cloud, Order is not preserved. + void + undo () override; -private: - /// a pointer pointing to the cloud - CloudPtr cloud_ptr_; + private: + /// a pointer pointing to the cloud + CloudPtr cloud_ptr_; - /// A shared pointer pointing to the selection object. - SelectionPtr selection_ptr_; + /// A shared pointer pointing to the selection object. + SelectionPtr selection_ptr_; - /// a selection which backs up the index of the deleted points in the - /// original cloud. - Selection deleted_selection_; + /// a selection which backs up the index of the deleted points in the + /// original cloud. + Selection deleted_selection_; - /// a copy buffer which backs up the points deleted from the cloud. - CopyBuffer deleted_cloud_buffer_; + /// a copy buffer which backs up the points deleted from the cloud. + CopyBuffer deleted_cloud_buffer_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseCommand.h index e05f407a1a1..73a1cd11b63 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseCommand.h @@ -43,12 +43,14 @@ #pragma once #include -#include #include #include -#include // for pcl::shared_ptr +#include + +#include // for pcl::shared_ptr -class DenoiseCommand : public Command { +class DenoiseCommand : public Command +{ public: /// The type for shared pointer pointing to a selection buffer using SelectionPtr = pcl::shared_ptr; @@ -58,32 +60,28 @@ class DenoiseCommand : public Command { /// @param cloud_ptr a shared pointer pointing to the cloud object. /// @param mean the number of points to use for mean distance estimation. /// @param threshold the standard deviation multiplier threshold - DenoiseCommand(SelectionPtr selection_ptr, - const CloudPtr& cloud_ptr, - float mean, - float threshold) - : selection_ptr_(std::move(selection_ptr)) - , cloud_ptr_(cloud_ptr) - , mean_(mean) - , threshold_(threshold) - , removed_indices_(cloud_ptr) - {} + DenoiseCommand (SelectionPtr selection_ptr, const CloudPtr& cloud_ptr, + float mean, float threshold) + : selection_ptr_(std::move(selection_ptr)), cloud_ptr_(cloud_ptr), mean_(mean), + threshold_(threshold), removed_indices_(cloud_ptr) + { + } /// @brief Copy constructor - commands are non-copyable - DenoiseCommand(const DenoiseCommand&) = delete; + DenoiseCommand (const DenoiseCommand&) = delete; /// @brief Equal operator - commands are non-copyable DenoiseCommand& - operator=(const DenoiseCommand&) = delete; + operator= (const DenoiseCommand&) = delete; protected: /// @brief Runs the denois algorithm to remove all the outliers. void - execute() override; + execute () override; /// @brief Adds the removed noisy points back to the cloud void - undo() override; + undo () override; private: /// A shared pointer pointing to the selection object of the widget diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h index aa6e9eef1ce..7cd7e3164fa 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h @@ -40,68 +40,73 @@ #pragma once +#include #include #include #include -#include #include +#include -class DenoiseParameterForm : public QDialog { +class DenoiseParameterForm : public QDialog +{ Q_OBJECT -public: - /// @brief Default Constructor - DenoiseParameterForm(); + public: + /// @brief Default Constructor + DenoiseParameterForm(); - /// @brief Destructor - ~DenoiseParameterForm() override; + /// @brief Destructor + ~DenoiseParameterForm () override; - /// @brief Returns the mean - inline float - getMeanK() const - { - return (mean_k_); - } + /// @brief Returns the mean + inline + float + getMeanK () const + { + return (mean_k_); + } - /// @brief Returns the standard deviation multiplier threshold - inline float - getStdDevThresh() const - { - return (std_dev_thresh_); - } + /// @brief Returns the standard deviation multiplier threshold + inline + float + getStdDevThresh () const + { + return (std_dev_thresh_); + } - /// @brief Checks whether the OK button was pressed. - inline bool - ok() const - { - return (ok_); - } + /// @brief Checks whether the OK button was pressed. + inline + bool + ok () const + { + return (ok_); + } -private Q_SLOTS: - /// @brief Accepts and stores the current user inputs, and turns off the - /// dialog box. - void - accept() override; + private Q_SLOTS: + /// @brief Accepts and stores the current user inputs, and turns off the + /// dialog box. + void + accept () override; - /// @brief Rejects the current inputs, and turns off the dialog box. - void - reject() override; + /// @brief Rejects the current inputs, and turns off the dialog box. + void + reject () override; -private: - /// The line for entering the mean - QLineEdit* mean_K_line_; - /// The line for entering the standard deviation multiplier threshold - QLineEdit* std_dev_mul_thresh_line_; - /// The button box. - QDialogButtonBox* button_box_; - /// The layout of the two input QLineEdit objects - QFormLayout* layout_; - /// The main layout for the dialog - QVBoxLayout* main_layout_; - /// The mean - float mean_k_; - /// The standard deviation multiplier threshold - float std_dev_thresh_; - /// The flag indicating whether the OK button was pressed - bool ok_; + private: + /// The line for entering the mean + QLineEdit *mean_K_line_; + /// The line for entering the standard deviation multiplier threshold + QLineEdit *std_dev_mul_thresh_line_; + /// The button box. + QDialogButtonBox *button_box_; + /// The layout of the two input QLineEdit objects + QFormLayout *layout_; + /// The main layout for the dialog + QVBoxLayout* main_layout_; + /// The mean + float mean_k_; + /// The standard deviation multiplier threshold + float std_dev_thresh_; + /// The flag indicating whether the OK button was pressed + bool ok_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/localTypes.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/localTypes.h index 36e41250f6f..ed7fa8d76d2 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/localTypes.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/localTypes.h @@ -39,11 +39,11 @@ #pragma once -#include #include +#include -#include #include +#include // Forward declaration for commonly used objects class Command; @@ -105,26 +105,44 @@ using CommandQueuePtr = std::shared_ptr; using BitMask = unsigned int; /// ID's for the key modifiers. -enum KeyModifier { +enum KeyModifier +{ NONE = 0x00000000, SHFT = 0x02000000, CTRL = 0x04000000, - ALT = 0x08000000 + ALT = 0x08000000 }; /// ID's for the mouse buttons. -enum MouseButton { NOBUTTON, LEFT, RIGHT }; +enum MouseButton +{ + NOBUTTON, + LEFT, + RIGHT +}; /// Indices for the coordinate axes /// It is assumed that the ColorScheme X,Y,Z match these values -enum Axis { X, Y, Z }; +enum Axis +{ + X, + Y, + Z +}; /// Indices for color components -enum Color { RED, GREEN, BLUE, RGB }; +enum Color +{ + RED, + GREEN, + BLUE, + RGB +}; /// Scheme used for coloring the whole cloud. /// It is assumed that the Axiz X,Y,Z match the COLOR_BY_[X,Y,Z] values -enum ColorScheme { +enum ColorScheme +{ COLOR_BY_X = 0, COLOR_BY_Y, COLOR_BY_Z, @@ -133,11 +151,14 @@ enum ColorScheme { }; /// Simple functor that produces sequential integers from an initial value -struct IncIndex { +struct IncIndex +{ unsigned int val_; - IncIndex(int v = 0) { val_ = v; } - unsigned int - operator()() + IncIndex(int v=0) + { + val_ = v; + } + unsigned int operator()() { return (val_++); } diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/mainWindow.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/mainWindow.h index f8aeb69a1bc..ded8c6b1c4f 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/mainWindow.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/mainWindow.h @@ -42,201 +42,201 @@ #pragma once -#include - -#include +#include #include +#include +#include +#include +#include #include #include -#include -#include -#include -#include #include +#include // Forward declaration to prevent circular inclusion class CloudEditorWidget; /// @brief the class for point cloud editor -class MainWindow : public QMainWindow { - Q_OBJECT - -public: - /// @brief Constructor - MainWindow(); - - /// @brief Constructor - /// @param argc The number of c-strings to be expected in argv - /// @param argv An array of c-strings. The zero entry is expected to be - /// the name of the application. Any additional strings will be interpreted - /// as filenames designating point clouds to be loaded. - MainWindow(int argc, char** argv); - - /// @brief Destructor - ~MainWindow() override; +class MainWindow : public QMainWindow +{ + Q_OBJECT + + public: + /// @brief Constructor + MainWindow (); + + /// @brief Constructor + /// @param argc The number of c-strings to be expected in argv + /// @param argv An array of c-strings. The zero entry is expected to be + /// the name of the application. Any additional strings will be interpreted + /// as filenames designating point clouds to be loaded. + MainWindow (int argc, char **argv); - /// @brief Increase the value of the spinbox by 1. - void - increaseSpinBoxValue(); + /// @brief Destructor + ~MainWindow () override; - /// @brief Decrease the value of the spinbox by 1. - void - decreaseSpinBoxValue(); + /// @brief Increase the value of the spinbox by 1. + void + increaseSpinBoxValue (); - /// @brief Gets the value of the spinbox. - int - getSpinBoxValue(); + /// @brief Decrease the value of the spinbox by 1. + void + decreaseSpinBoxValue (); - /// @brief Increase the value of the selected pts size spinbox by 1. - void - increaseSelectedSpinBoxValue(); + /// @brief Gets the value of the spinbox. + int + getSpinBoxValue(); - /// @brief Decrease the value of the selected pts size spinbox by 1. - void - decreaseSelectedSpinBoxValue(); + /// @brief Increase the value of the selected pts size spinbox by 1. + void + increaseSelectedSpinBoxValue (); - /// @brief Gets the value of the selected pts size spinbox. - int - getSelectedSpinBoxValue(); + /// @brief Decrease the value of the selected pts size spinbox by 1. + void + decreaseSelectedSpinBoxValue (); -private Q_SLOTS: - void - about(); + /// @brief Gets the value of the selected pts size spinbox. + int + getSelectedSpinBoxValue (); - void - help(); + private Q_SLOTS: + void + about (); -private: - /// Initialization function. This handles the initialization of the widget, - /// menus, actions, etc. - void - initWindow(); + void + help (); - /// create actions which are connected to file menus - void - createActions(); + private: + /// Initialization function. This handles the initialization of the widget, + /// menus, actions, etc. + void + initWindow (); + + /// create actions which are connected to file menus + void + createActions (); - /// create menus such as file and help - void - createMenus(); + /// create menus such as file and help + void + createMenus (); - /// create buttons in the tool bar - void - createToolBars(); + /// create buttons in the tool bar + void + createToolBars (); - /// create spin boxes used in the tool bar. - void - createSpinBoxes(); + /// create spin boxes used in the tool bar. + void + createSpinBoxes (); - /// create sliders used in the tool bar. - void - createSliders(); + /// create sliders used in the tool bar. + void + createSliders (); - /// the cloud editor GL widget - CloudEditorWidget* cloud_editor_widget_; + /// the cloud editor GL widget + CloudEditorWidget *cloud_editor_widget_; - /// the action group for making actions checkable. - QActionGroup* action_group_; + /// the action group for making actions checkable. + QActionGroup* action_group_; - /// action for exit the cloud editor - QAction* exit_action_; + /// action for exit the cloud editor + QAction *exit_action_; - /// action for opening file - QAction* open_action_; + /// action for opening file + QAction *open_action_; - /// action for saving file - QAction* save_action_; + /// action for saving file + QAction *save_action_; - /// action for copying selected points - QAction* copy_action_; + /// action for copying selected points + QAction *copy_action_; - /// action for pasting copied points - QAction* paste_action_; + /// action for pasting copied points + QAction *paste_action_; - /// action for cutting selected points - QAction* cut_action_; + /// action for cutting selected points + QAction *cut_action_; - /// action for deleting selected points - QAction* delete_action_; + /// action for deleting selected points + QAction *delete_action_; - /// action for viewing the software information - QAction* about_action_; + /// action for viewing the software information + QAction *about_action_; - /// action for viewing the software use/control information - QAction* help_action_; + /// action for viewing the software use/control information + QAction *help_action_; - /// action for toggling the pseudo distance display - QAction* toggle_blend_action_; + /// action for toggling the pseudo distance display + QAction *toggle_blend_action_; - /// action for switching to view mode - QAction* view_action_; + /// action for switching to view mode + QAction *view_action_; - /// action for undo - QAction* undo_action_; + /// action for undo + QAction *undo_action_; - /// action for point selection - QAction* select_action_; + /// action for point selection + QAction *select_action_; - /// action for 2D point selection - QAction* select_2D_action_; + /// action for 2D point selection + QAction *select_2D_action_; - /// action for 3D point selection - // QAction *select_3D_action_; + /// action for 3D point selection + //QAction *select_3D_action_; - /// action for box edit - QAction* box_edit_action_; + /// action for box edit + QAction *box_edit_action_; - /// action for invert selection - QAction* invert_select_action_; + /// action for invert selection + QAction *invert_select_action_; - /// action for transforming the cloud - QAction* transform_action_; + /// action for transforming the cloud + QAction *transform_action_; - /// action for denoising the cloud - QAction* denoise_action_; + /// action for denoising the cloud + QAction *denoise_action_; - /// action for showing the statistics of the editor - QAction* show_stat_action_; + /// action for showing the statistics of the editor + QAction *show_stat_action_; - /// the file menu - QMenu* file_menu_; + /// the file menu + QMenu *file_menu_; - /// the menu for editing tools - QMenu* edit_menu_; + /// the menu for editing tools + QMenu *edit_menu_; - /// the menu for display options - QMenu* display_menu_; + /// the menu for display options + QMenu *display_menu_; - /// the menu for visualization tools - QMenu* view_menu_; + /// the menu for visualization tools + QMenu *view_menu_; - /// the menu for select tools - QMenu* select_menu_; + /// the menu for select tools + QMenu *select_menu_; - /// the menu for other algorithmic tools - QMenu* tool_menu_; + /// the menu for other algorithmic tools + QMenu *tool_menu_; - /// the help menu - QMenu* help_menu_; + /// the help menu + QMenu *help_menu_; - /// the spin box for adjusting point size. - QSpinBox* point_size_spin_box_; + /// the spin box for adjusting point size. + QSpinBox *point_size_spin_box_; - /// the spin box for adjusting the size of the selected point. - QSpinBox* selected_point_size_spin_box_; + /// the spin box for adjusting the size of the selected point. + QSpinBox *selected_point_size_spin_box_; - /// the tool bar containing all the cloud editing buttons. - QToolBar* edit_tool_bar_; + /// the tool bar containing all the cloud editing buttons. + QToolBar *edit_tool_bar_; - /// the tool bar containing all the visualization function buttons - QToolBar* view_tool_bar_; + /// the tool bar containing all the visualization function buttons + QToolBar *view_tool_bar_; - /// the width of the main window. - int window_width_; + /// the width of the main window. + int window_width_; - /// the height of the main window. - int window_height_; + /// the height of the main window. + int window_height_; - /// the slider used for adjusting moving speed. - QSlider* move_speed_slider_; + /// the slider used for adjusting moving speed. + QSlider *move_speed_slider_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/pasteCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/pasteCommand.h index ebdad385fc6..787e6721dcd 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/pasteCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/pasteCommand.h @@ -42,53 +42,54 @@ #include #include -#include // for pcl::shared_ptr -class PasteCommand : public Command { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; +#include // for pcl::shared_ptr - /// @brief Constructor - /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - PasteCommand(ConstCopyBufferPtr copy_buffer_ptr, - SelectionPtr selection_ptr, - CloudPtr cloud_ptr); - // comment that the selection is updated (also resets the matrix in cloud) +class PasteCommand : public Command +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; - /// @brief Copy constructor - commands are non-copyable - PasteCommand(const PasteCommand&) = delete; + /// @brief Constructor + /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + PasteCommand (ConstCopyBufferPtr copy_buffer_ptr, + SelectionPtr selection_ptr, CloudPtr cloud_ptr); + // comment that the selection is updated (also resets the matrix in cloud) - /// @brief Equal operator - commands are non-copyable - PasteCommand& - operator=(const PasteCommand&) = delete; + /// @brief Copy constructor - commands are non-copyable + PasteCommand (const PasteCommand&) = delete; -protected: - /// @brief Appends the points in the copy buffer into the cloud. - /// @details After appending the points to the cloud, this function also - /// updates the selection object to point to the newly pasted points. This - /// also updates the selection object to point to the newly pasted points. - void - execute() override; + /// @brief Equal operator - commands are non-copyable + PasteCommand& + operator= (const PasteCommand&) = delete; + + protected: + /// @brief Appends the points in the copy buffer into the cloud. + /// @details After appending the points to the cloud, this function also + /// updates the selection object to point to the newly pasted points. This + /// also updates the selection object to point to the newly pasted points. + void + execute () override; - /// @brief Removes the points that were pasted to the cloud. - void - undo() override; + /// @brief Removes the points that were pasted to the cloud. + void + undo () override; -private: - /// a pointer pointing to the copy buffer. - ConstCopyBufferPtr copy_buffer_ptr_; + private: + /// a pointer pointing to the copy buffer. + ConstCopyBufferPtr copy_buffer_ptr_; - /// A shared pointer pointing to the selection object. - SelectionPtr selection_ptr_; + /// A shared pointer pointing to the selection object. + SelectionPtr selection_ptr_; - /// a pointer pointing to the cloud - CloudPtr cloud_ptr_; + /// a pointer pointing to the cloud + CloudPtr cloud_ptr_; - /// The size of the cloud before new points are pasted. This value is used - /// to mark the point where points were added to the cloud. In order to - /// support undo, one only has to resize the cloud using this value. - unsigned int prev_cloud_size_; + /// The size of the cloud before new points are pasted. This value is used + /// to mark the point where points were added to the cloud. In order to + /// support undo, one only has to resize the cloud using this value. + unsigned int prev_cloud_size_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select1DTool.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select1DTool.h index 4e3365e0896..ee34d7d7502 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select1DTool.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select1DTool.h @@ -39,69 +39,78 @@ #pragma once -#include #include -#include // for pcl::shared_ptr +#include + +#include // for pcl::shared_ptr #include class Selection; -class Select1DTool : public ToolInterface { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - Select1DTool(SelectionPtr selection_ptr, CloudPtr cloud_ptr); - - /// @brief Destructor - ~Select1DTool() override = default; +class Select1DTool : public ToolInterface +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; - /// @brief Does nothing for 1D selection. - /// @sa end - void - start(int, int, BitMask, BitMask) override - {} + /// @brief Constructor + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + Select1DTool (SelectionPtr selection_ptr, CloudPtr cloud_ptr); - /// @brief Does nothing for 1D selection. - /// @sa end - void - update(int, int, BitMask, BitMask) override - {} + /// @brief Destructor + ~Select1DTool () override + = default; + + /// @brief Does nothing for 1D selection. + /// @sa end + void + start (int, int, BitMask, BitMask) override + { + } + + /// @brief Does nothing for 1D selection. + /// @sa end + void + update (int, int, BitMask, BitMask) override + { + } - /// @brief Select or deselect the point under the mouse using GL's selection - /// facility. - /// @details If shift is pressed when the selection is made, the selected - /// point is appended to the existing selection. If instead ctrl is pressed, - /// the selected point will be removed from the existing selection. If - /// neither shift nor ctrl is pressed when the selection is made then the - /// selected point, if any, will replace any current selection. Note that - /// the ctrl key may be evaluated as the command key in OSX. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. SHIFT adds selected points to the - /// selection. CTRL removes points and if neither are pressed then a new - /// selection is made. - /// @param buttons The state of the mouse buttons. All interaction with - /// this tool requires the LEFT mouse button. All others are ignored. - void - end(int x, int y, BitMask modifiers, BitMask buttons) override; + /// @brief Select or deselect the point under the mouse using GL's selection + /// facility. + /// @details If shift is pressed when the selection is made, the selected + /// point is appended to the existing selection. If instead ctrl is pressed, + /// the selected point will be removed from the existing selection. If + /// neither shift nor ctrl is pressed when the selection is made then the + /// selected point, if any, will replace any current selection. Note that + /// the ctrl key may be evaluated as the command key in OSX. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. SHIFT adds selected points to the + /// selection. CTRL removes points and if neither are pressed then a new + /// selection is made. + /// @param buttons The state of the mouse buttons. All interaction with + /// this tool requires the LEFT mouse button. All others are ignored. + void + end (int x, int y, BitMask modifiers, BitMask buttons) override; - /// @brief This function does nothing. - void - draw() const override - {} + /// @brief This function does nothing. + void + draw () const override + { + } -private: - /// @brief Default constructor - object is not default constructable - Select1DTool() { assert(false); } + private: + /// @brief Default constructor - object is not default constructable + Select1DTool() + { + assert(false); + } - /// a shared pointer pointing to the selection object - SelectionPtr selection_ptr_; + /// a shared pointer pointing to the selection object + SelectionPtr selection_ptr_; - /// a shared pointer pointing to the cloud object - CloudPtr cloud_ptr_; + /// a shared pointer pointing to the cloud object + CloudPtr cloud_ptr_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select2DTool.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select2DTool.h index b1936484f23..6243fcc65a6 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select2DTool.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select2DTool.h @@ -40,118 +40,121 @@ #pragma once -#include +#include #include -#include // for pcl::shared_ptr +#include -#include +#include // for pcl::shared_ptr class Selection; -class Select2DTool : public ToolInterface { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - /// @param get_viewport_and_projection_mat a function that can be used to get the - /// viewport and the projection matrix - Select2DTool(SelectionPtr selection_ptr, - CloudPtr cloud_ptr, - std::function get_viewport_and_projection_mat); - - /// @brief Destructor - ~Select2DTool() override; - - /// @brief Initializes the selection tool with the initial mouse screen - /// coordinates and key modifiers. The passed coordinates are used for - /// determining the coordinates of the upper left corner of the rubber band. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. There are three possible values for - /// modifiers: 1. shift key, 2. ctrl key, 3. no modifier is pressed. Note - /// that the ctrl key may be evaluated as the command key in OSX. - void - start(int x, int y, BitMask modifiers, BitMask mouseButton) override; - - /// @brief Update the selection tool from the current mouse screen - /// coordinates and key modifiers. - /// @details Creates a 2D rubberband. The coordinates of the lower right - /// corner of the rubberband is computed from the passed coordinates. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. - void - update(int x, int y, BitMask modifiers, BitMask mouseButton) override; - - /// @brief Update the coordinates of the lower right corner of the rubber - /// band and process the points in the rubber band. - /// @details The points which fall into the selection region are processed - /// according to the value of the modifier: If shift is pressed, the - /// selected points are appended to the existing selection. If ctrl is - /// pressed, the points will be removed from the existing selection - /// if they were elected previously, otherwise nothing happens. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. - void - end(int x, int y, BitMask modifiers, BitMask mouseButton) override; - - /// @brief Checks whether a point is inside the selection region. - /// @param pt the point to be checked against the selection region. - /// @param project the projection matrix obtained from GL. - /// @param viewport the current viewport obtained from GL. - bool - isInSelectBox(const Point3D& pt, const GLfloat* project, const GLint* viewport) const; - - /// @brief Draws the rubber band as well as any highlighted points during - /// the 'update' phase (i.e. before the selection is made by a call to end). - void - draw() const override; - - /// The default size in pixels of the rubberband tool outline - static const float DEFAULT_TOOL_DISPLAY_SIZE_; - - /// The default color of the rubberband tool - red component - static const float DEFAULT_TOOL_DISPLAY_COLOR_RED_; - /// The default color of the rubberband tool - green component - static const float DEFAULT_TOOL_DISPLAY_COLOR_GREEN_; - /// The default color of the rubberband tool - blue component - static const float DEFAULT_TOOL_DISPLAY_COLOR_BLUE_; - -private: - /// @brief Default constructor - object is not default constructable - Select2DTool() { assert(false); } - - /// @brief draw the 2D selection rubber band. - /// @param viewport the viewport obtained from GL - void - drawRubberBand(GLint* viewport) const; - - /// @brief highlight all the points in the rubber band. - /// @detail draw the cloud using a stencil buffer. During this time, the - /// points that are highlighted will not be recorded by the selection object. - /// @param viewport the viewport obtained from GL - void - highlightPoints(GLint* viewport) const; - - /// a shared pointer pointing to the selection object - SelectionPtr selection_ptr_; - - /// a shared pointer pointing to the cloud object - CloudPtr cloud_ptr_; - - /// the original mouse screen coordinates - int origin_x_, origin_y_; - - /// the final mouse screen coordinates - int final_x_, final_y_; - - /// switch for selection box rendering - bool display_box_; - - /// function to get the viewport and the projection matrix (initialized by ctor) - std::function get_viewport_and_projection_mat_; +class Select2DTool : public ToolInterface +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; + + /// @brief Constructor + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + /// @param get_viewport_and_projection_mat a function that can be used to get the viewport and the projection matrix + Select2DTool (SelectionPtr selection_ptr, CloudPtr cloud_ptr, std::function get_viewport_and_projection_mat); + + /// @brief Destructor + ~Select2DTool () override; + + /// @brief Initializes the selection tool with the initial mouse screen + /// coordinates and key modifiers. The passed coordinates are used for + /// determining the coordinates of the upper left corner of the rubber band. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. There are three possible values for + /// modifiers: 1. shift key, 2. ctrl key, 3. no modifier is pressed. Note + /// that the ctrl key may be evaluated as the command key in OSX. + void + start (int x, int y, BitMask modifiers, BitMask mouseButton) override; + + /// @brief Update the selection tool from the current mouse screen + /// coordinates and key modifiers. + /// @details Creates a 2D rubberband. The coordinates of the lower right + /// corner of the rubberband is computed from the passed coordinates. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. + void + update (int x, int y, BitMask modifiers, BitMask mouseButton) override; + + /// @brief Update the coordinates of the lower right corner of the rubber + /// band and process the points in the rubber band. + /// @details The points which fall into the selection region are processed + /// according to the value of the modifier: If shift is pressed, the + /// selected points are appended to the existing selection. If ctrl is + /// pressed, the points will be removed from the existing selection + /// if they were elected previously, otherwise nothing happens. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. + void + end (int x, int y, BitMask modifiers, BitMask mouseButton) override; + + /// @brief Checks whether a point is inside the selection region. + /// @param pt the point to be checked against the selection region. + /// @param project the projection matrix obtained from GL. + /// @param viewport the current viewport obtained from GL. + bool + isInSelectBox (const Point3D& pt, const GLfloat* project, + const GLint* viewport) const; + + /// @brief Draws the rubber band as well as any highlighted points during + /// the 'update' phase (i.e. before the selection is made by a call to end). + void + draw () const override; + + /// The default size in pixels of the rubberband tool outline + static const float DEFAULT_TOOL_DISPLAY_SIZE_; + + /// The default color of the rubberband tool - red component + static const float DEFAULT_TOOL_DISPLAY_COLOR_RED_; + /// The default color of the rubberband tool - green component + static const float DEFAULT_TOOL_DISPLAY_COLOR_GREEN_; + /// The default color of the rubberband tool - blue component + static const float DEFAULT_TOOL_DISPLAY_COLOR_BLUE_; + + + private: + /// @brief Default constructor - object is not default constructable + Select2DTool() + { + assert(false); + } + + /// @brief draw the 2D selection rubber band. + /// @param viewport the viewport obtained from GL + void + drawRubberBand (GLint* viewport) const; + + /// @brief highlight all the points in the rubber band. + /// @detail draw the cloud using a stencil buffer. During this time, the + /// points that are highlighted will not be recorded by the selection object. + /// @param viewport the viewport obtained from GL + void + highlightPoints (GLint* viewport) const; + + /// a shared pointer pointing to the selection object + SelectionPtr selection_ptr_; + + /// a shared pointer pointing to the cloud object + CloudPtr cloud_ptr_; + + /// the original mouse screen coordinates + int origin_x_, origin_y_; + + /// the final mouse screen coordinates + int final_x_, final_y_; + + /// switch for selection box rendering + bool display_box_; + + /// function to get the viewport and the projection matrix (initialized by ctor) + std::function get_viewport_and_projection_mat_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h index 7c11caf6712..d0e471517fe 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h @@ -40,148 +40,150 @@ #pragma once +#include #include #include -#include - /// @brief This class serves as a sort of mask for performing operations on a /// point cloud. It keeps track of the indices of identified/selected points /// and provides methods for accessing those indices and modifying them. -class Selection : public Statistics { -public: - /// @brief Constructor. - /// @param cloud_ptr A pointer to the const cloud object for which this - /// object is to maintain selections. - Selection(ConstCloudPtr cloud_ptr, bool register_stats = false) - : cloud_ptr_(std::move(cloud_ptr)) - { - if (register_stats) - registerStats(); - } - - /// @brief Copy constructor. - /// @param selection a const reference to a selection object whose - /// properties will be copied. - Selection(const Selection& selection) = default; - - /// @brief Equal operator - /// @param selection a const reference to a selection object whose - /// properties will be copied. - Selection& - operator=(const Selection& selection); - - /// @brief Adds the index of the selected point to the selection table. - /// @param index The index of the point that is selected. - /// @pre Assumes the passed index is valid with respect to the current - /// cloud. - void - addIndex(unsigned int index); - - /// @brief Removes the index of a point from the selection table. - /// @param index The index of the point to be removed from the table. - void - removeIndex(unsigned int index); - - /// @brief Adds a vector of indices of the selected points to the table. - /// @param indices A vector of indices of points to be added to the table. - /// @pre Assumes the passed index is valid with respect to the current - /// cloud. - void - addIndex(const IndexVector& indices); - - /// @brief Removes a vector of indices from the table - /// @param indices A vector of indices of points to be removed from the - /// table. - void - removeIndex(const IndexVector& indices); - - /// @brief Adds a range of consecutive indices into the selection table. - /// @param start the first index in the range. - /// @param num the total number of indices in the range. - /// @pre Assumes the passed index is valid with respect to the current - /// cloud. - void - addIndexRange(unsigned int start, unsigned int num); - - /// @brief Removes a range of consecutive indices into the selection table. - /// @param start the first index in the range. - /// @param num the total number of indices in the range. - void - removeIndexRange(unsigned int start, unsigned int num); - - /// @brief Removes all the indices from the selection table. - void - clear() - { - selected_indices_.clear(); - } - - using iterator = std::set::iterator; - using const_iterator = std::set::const_iterator; - - /// @brief Get the begin iterator of the selection. - const_iterator - begin() const - { - return (selected_indices_.begin()); - } - - /// @brief Get the end iterator of the selection. - const_iterator - end() const - { - return (selected_indices_.end()); - } - - using const_reverse_iterator = std::set::const_reverse_iterator; - - /// @brief Get the begin iterator of the selection. - const_reverse_iterator - rbegin() const - { - return (selected_indices_.rbegin()); - } - - /// @brief Get the end iterator of the selection. - const_reverse_iterator - rend() const - { - return (selected_indices_.rend()); - } - - /// @brief Returns true if the passed index is selected. - bool - isSelected(unsigned int index) const; - - /// @brief Returns true if no point is selected. - inline bool - empty() const - { - return (selected_indices_.empty()); - } - - /// @brief Returns the number of points in the selection - inline unsigned int - size() const - { - return (selected_indices_.size()); - } - - /// @brief Invert selection - /// @details Make the unselected points selected and deselect the previously - /// selected points. - void - invertSelect(); - - /// @brief Get the statistics of the selected points in string. - std::string - getStat() const override; - -private: - /// a pointer to the cloud - ConstCloudPtr cloud_ptr_; - - /// A set of unique indices that have been selected in the cloud. - std::set selected_indices_; +class Selection : public Statistics +{ + public: + /// @brief Constructor. + /// @param cloud_ptr A pointer to the const cloud object for which this + /// object is to maintain selections. + Selection (ConstCloudPtr cloud_ptr, bool register_stats=false) + : cloud_ptr_(std::move(cloud_ptr)) + { + if (register_stats) + registerStats(); + } + + /// @brief Copy constructor. + /// @param selection a const reference to a selection object whose + /// properties will be copied. + Selection (const Selection& selection) = default; + + /// @brief Equal operator + /// @param selection a const reference to a selection object whose + /// properties will be copied. + Selection& + operator= (const Selection& selection); + + /// @brief Adds the index of the selected point to the selection table. + /// @param index The index of the point that is selected. + /// @pre Assumes the passed index is valid with respect to the current + /// cloud. + void + addIndex (unsigned int index); + + /// @brief Removes the index of a point from the selection table. + /// @param index The index of the point to be removed from the table. + void + removeIndex (unsigned int index); + + /// @brief Adds a vector of indices of the selected points to the table. + /// @param indices A vector of indices of points to be added to the table. + /// @pre Assumes the passed index is valid with respect to the current + /// cloud. + void + addIndex (const IndexVector &indices); + + /// @brief Removes a vector of indices from the table + /// @param indices A vector of indices of points to be removed from the + /// table. + void + removeIndex (const IndexVector &indices); + + /// @brief Adds a range of consecutive indices into the selection table. + /// @param start the first index in the range. + /// @param num the total number of indices in the range. + /// @pre Assumes the passed index is valid with respect to the current + /// cloud. + void + addIndexRange (unsigned int start, unsigned int num); + + /// @brief Removes a range of consecutive indices into the selection table. + /// @param start the first index in the range. + /// @param num the total number of indices in the range. + void + removeIndexRange (unsigned int start, unsigned int num); + + /// @brief Removes all the indices from the selection table. + void + clear () + { + selected_indices_.clear(); + } + + using iterator = std::set::iterator; + using const_iterator = std::set::const_iterator; + + /// @brief Get the begin iterator of the selection. + const_iterator + begin () const + { + return (selected_indices_.begin()); + } + + /// @brief Get the end iterator of the selection. + const_iterator + end () const + { + return (selected_indices_.end()); + } + + using const_reverse_iterator = std::set::const_reverse_iterator; + + /// @brief Get the begin iterator of the selection. + const_reverse_iterator + rbegin () const + { + return (selected_indices_.rbegin()); + } + + /// @brief Get the end iterator of the selection. + const_reverse_iterator + rend () const + { + return (selected_indices_.rend()); + } + + /// @brief Returns true if the passed index is selected. + bool + isSelected (unsigned int index) const; + + /// @brief Returns true if no point is selected. + inline + bool + empty () const + { + return (selected_indices_.empty()); + } + + /// @brief Returns the number of points in the selection + inline + unsigned int + size () const + { + return (selected_indices_.size()); + } + + /// @brief Invert selection + /// @details Make the unselected points selected and deselect the previously + /// selected points. + void + invertSelect (); + + /// @brief Get the statistics of the selected points in string. + std::string + getStat () const override; + + private: + /// a pointer to the cloud + ConstCloudPtr cloud_ptr_; + + /// A set of unique indices that have been selected in the cloud. + std::set selected_indices_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selectionTransformTool.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selectionTransformTool.h index 8b7cb0b0a58..d555f007e54 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selectionTransformTool.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selectionTransformTool.h @@ -39,10 +39,11 @@ #pragma once -#include #include +#include #include -#include // for pcl::shared_ptr + +#include // for pcl::shared_ptr class Selection; @@ -53,115 +54,116 @@ class Selection; /// points are not updated until the end of the mouse input. At the end of a /// mouse input (i.e. when the mouse button is released), a transform command is /// created to update the actual coordinates of the selected points. -class SelectionTransformTool : public ToolInterface { -public: - /// The type for shared pointer pointing to a constant selection buffer - using ConstSelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - /// @param command_queue_ptr a shared pointer pointing to the command queue. - SelectionTransformTool(ConstSelectionPtr selection_ptr, - CloudPtr cloud_ptr, - CommandQueuePtr command_queue_ptr); - - /// @brief Destructor - ~SelectionTransformTool() override = default; - - /// @brief Initialize the transform tool with mouse screen coordinates - /// and key modifiers. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. - void - start(int x, int y, BitMask modifiers, BitMask buttons) override; - - /// @brief Updates the transform matrix of this object with mouse screen - /// coordinates and key modifiers. Then the selection_matrix_ in the cloud - /// is further updated. - /// @details We first compute the changes between the initial and the current - /// mouse screen coordinates. Then depending on the passed modifiers, the - /// transformation matrix is computed correspondingly. If CONTROL is pressed - /// the selection will be translated (panned) parallel to the view plane. If - /// ALT is pressed the selection will be translated along the z-axis - /// perpendicular to the view plane. If no key modifiers is pressed the - /// selection will be rotated. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. CONTROL pans the selection parallel - /// to the view plane. ALT moves the selection in/out along the z-axis - /// (perpendicular to the view plane). If no modifier is pressed then the - /// selection is rotated. - void - update(int x, int y, BitMask modifiers, BitMask buttons) override; - - /// @brief Update the transform matrix for the selected points using the - /// final position of the mouse. To finalize the transformation, we then - /// create a transform command which computes the new coordinates of the - /// selected points after transformation. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. - void - end(int x, int y, BitMask modifiers, BitMask buttons) override; - - /// @brief This does not do anything. - void - draw() const override - {} - -private: - /// @brief Computes the modelview matrix for rotation. - /// @param dx the distance between the x coordinates of the starting and - /// ending cursor position. - /// @param dy the distance between the y coordinates of the starting and - /// ending cursor position. - /// @param rotation_matrix_a a 4x4 matrix following OpenGL's format - /// implementing rotation along x-axis. - /// @param rotation_matrix_b a 4x4 matrix following OpenGL's format - /// implementing rotation along y or z-axis, which depens on which the mouse - /// button that is being pressed during the rotation operation. - void - getRotateMatrix(int dx, - int dy, - float* rotation_matrix_a, - float* rotation_matrix_b, - BitMask buttons) const; - - /// @brief Computes the centroid of the selected points - void - findSelectionCenter(); - - /// a shared pointer pointing to the selection object - ConstSelectionPtr selection_ptr_; - - /// a shared pointer pointing to the cloud object - CloudPtr cloud_ptr_; - - /// a shared pointer pointing to the command queue of the widget. - CommandQueuePtr command_queue_ptr_; - - /// the trackball associated with this transform - TrackBall trackball_; - - /// last recorded mouse positions - int x_, y_; - - /// The centroid of the selected points. - float center_xyz_[XYZ_SIZE]; - - /// the transform matrix to be used for updating the coordinates of the - /// selected points in the cloud - float transform_matrix_[MATRIX_SIZE]; - - /// scaling factor used to control the speed which the display translates - /// the point cloud - float translate_factor_; - - /// default translation factor - static const float DEFAULT_TRANSLATE_FACTOR_; - - /// the copy of the modifiers passed in the start function. - BitMask modifiers_; +class SelectionTransformTool : public ToolInterface +{ + public: + /// The type for shared pointer pointing to a constant selection buffer + using ConstSelectionPtr = pcl::shared_ptr; + + /// @brief Constructor + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + /// @param command_queue_ptr a shared pointer pointing to the command queue. + SelectionTransformTool (ConstSelectionPtr selection_ptr, + CloudPtr cloud_ptr, + CommandQueuePtr command_queue_ptr); + + /// @brief Destructor + ~SelectionTransformTool () override + = default; + + /// @brief Initialize the transform tool with mouse screen coordinates + /// and key modifiers. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. + void + start (int x, int y, BitMask modifiers, BitMask buttons) override; + + /// @brief Updates the transform matrix of this object with mouse screen + /// coordinates and key modifiers. Then the selection_matrix_ in the cloud + /// is further updated. + /// @details We first compute the changes between the initial and the current + /// mouse screen coordinates. Then depending on the passed modifiers, the + /// transformation matrix is computed correspondingly. If CONTROL is pressed + /// the selection will be translated (panned) parallel to the view plane. If + /// ALT is pressed the selection will be translated along the z-axis + /// perpendicular to the view plane. If no key modifiers is pressed the + /// selection will be rotated. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. CONTROL pans the selection parallel + /// to the view plane. ALT moves the selection in/out along the z-axis + /// (perpendicular to the view plane). If no modifier is pressed then the + /// selection is rotated. + void + update (int x, int y, BitMask modifiers, BitMask buttons) override; + + /// @brief Update the transform matrix for the selected points using the + /// final position of the mouse. To finalize the transformation, we then + /// create a transform command which computes the new coordinates of the + /// selected points after transformation. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. + void + end (int x, int y, BitMask modifiers, BitMask buttons) override; + + /// @brief This does not do anything. + void + draw () const override + { + } + + private: + /// @brief Computes the modelview matrix for rotation. + /// @param dx the distance between the x coordinates of the starting and + /// ending cursor position. + /// @param dy the distance between the y coordinates of the starting and + /// ending cursor position. + /// @param rotation_matrix_a a 4x4 matrix following OpenGL's format + /// implementing rotation along x-axis. + /// @param rotation_matrix_b a 4x4 matrix following OpenGL's format + /// implementing rotation along y or z-axis, which depens on which the mouse + /// button that is being pressed during the rotation operation. + void + getRotateMatrix (int dx, int dy, float* rotation_matrix_a, + float* rotation_matrix_b, BitMask buttons) const; + + /// @brief Computes the centroid of the selected points + void + findSelectionCenter (); + + /// a shared pointer pointing to the selection object + ConstSelectionPtr selection_ptr_; + + /// a shared pointer pointing to the cloud object + CloudPtr cloud_ptr_; + + /// a shared pointer pointing to the command queue of the widget. + CommandQueuePtr command_queue_ptr_; + + /// the trackball associated with this transform + TrackBall trackball_; + + /// last recorded mouse positions + int x_, y_; + + /// The centroid of the selected points. + float center_xyz_[XYZ_SIZE]; + + /// the transform matrix to be used for updating the coordinates of the + /// selected points in the cloud + float transform_matrix_[MATRIX_SIZE]; + + /// scaling factor used to control the speed which the display translates + /// the point cloud + float translate_factor_; + + /// default translation factor + static const float DEFAULT_TRANSLATE_FACTOR_; + + /// the copy of the modifiers passed in the start function. + BitMask modifiers_; + }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statistics.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statistics.h index 91d2cf7d7cc..80d3fc4744d 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statistics.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statistics.h @@ -40,47 +40,55 @@ #pragma once -#include - -#include -#include #include +#include +#include +#include -class Statistics { -public: - /// @brief Destructor - virtual ~Statistics() = default; - - /// @brief Returns the strings of the statistics. - static std::string - getStats(); - - static void - clear(); - -protected: - /// @brief The default constructor. - Statistics() = default; +class Statistics +{ + public: + /// @brief Destructor + virtual ~Statistics () + = default; - /// @brief Copy Constructor - Statistics(const Statistics&) { assert(false); } + /// @brief Returns the strings of the statistics. + static + std::string + getStats(); + + static + void + clear(); + + protected: + /// @brief The default constructor. + Statistics () + = default; - /// @brief Equal Operator - virtual Statistics& - operator=(const Statistics&) - { - assert(false); - return *this; - } + /// @brief Copy Constructor + Statistics (const Statistics&) + { + assert(false); + } - /// @brief Returns the statistics in string. - virtual std::string - getStat() const = 0; + /// @brief Equal Operator + virtual + Statistics& + operator= (const Statistics&) + { + assert(false); return (*this); + } - /// @brief Register a statistics - void - registerStats(); + /// @brief Returns the statistics in string. + virtual + std::string + getStat () const = 0; -private: - static std::vector stat_vec_; + /// @brief Register a statistics + void + registerStats (); + + private: + static std::vector stat_vec_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statisticsDialog.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statisticsDialog.h index 2d7f0c7dbfe..59ee72f4098 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statisticsDialog.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statisticsDialog.h @@ -40,40 +40,39 @@ #pragma once -#include - +#include #include #include #include -#include +#include #include +#include #include -#include +#include -class StatisticsDialog : public QDialog { +class StatisticsDialog : public QDialog +{ Q_OBJECT -public: - /// @brief Default Constructor - StatisticsDialog(QWidget* parent = nullptr); - /// @brief Destructor - ~StatisticsDialog() override; - -public Q_SLOTS: - /// @brief update the dialog box. - void - update(); - -private Q_SLOTS: - void - accept() override; - -private: - /// The button box. - QDialogButtonBox* button_box_; + public: + /// @brief Default Constructor + StatisticsDialog(QWidget *parent = nullptr); + /// @brief Destructor + ~StatisticsDialog () override; + + public Q_SLOTS: + /// @brief update the dialog box. + void update (); + + private Q_SLOTS: + void accept () override; + + private: + /// The button box. + QDialogButtonBox *button_box_; - QLabel* stat_label_; + QLabel *stat_label_; - /// A timer used for periodically update the statistics in the dialog. - QTimer timer_; + /// A timer used for periodically update the statistics in the dialog. + QTimer timer_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/toolInterface.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/toolInterface.h index 0beb4316147..38111acba28 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/toolInterface.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/toolInterface.h @@ -46,67 +46,76 @@ #include /// @brief the parent class of all the select and the transform tool classes -class ToolInterface { -public: - /// @brief Destructor. - virtual ~ToolInterface() = default; +class ToolInterface +{ + public: + /// @brief Destructor. + virtual ~ToolInterface () + = default; - /// @brief set the initial state of the tool from the screen coordinates - /// of the mouse as well as the value of the modifier. - /// @param x the x coordinate of the mouse screen coordinates. - /// @param y the y coordinate of the mouse screen coordinates. - /// @param modifiers The keyboard modifiers. We use modifier to change the - /// behavior of a tool. Values of a modifier can be control key, alt key - /// shift key, or no key is pressed. See the subclasses of this class - /// for specific usages of the modifiers. - /// @param buttons The state of the mouse buttons - virtual void - start(int x, int y, BitMask modifiers, BitMask buttons) = 0; + /// @brief set the initial state of the tool from the screen coordinates + /// of the mouse as well as the value of the modifier. + /// @param x the x coordinate of the mouse screen coordinates. + /// @param y the y coordinate of the mouse screen coordinates. + /// @param modifiers The keyboard modifiers. We use modifier to change the + /// behavior of a tool. Values of a modifier can be control key, alt key + /// shift key, or no key is pressed. See the subclasses of this class + /// for specific usages of the modifiers. + /// @param buttons The state of the mouse buttons + virtual + void + start (int x, int y, BitMask modifiers, BitMask buttons) = 0; - /// @brief update the state of the tool from the screen coordinates - /// of the mouse as well as the value of the modifier. - /// @param x the x coordinate of the mouse screen coordinates. - /// @param y the y coordinate of the mouse screen coordinates. - /// @param modifiers The keyboard modifiers. We use modifier to change the - /// behavior of a tool. Values of a modifier can be control key, alt key - /// shift key, or no key is pressed. See the subclasses of this class - /// for specific usages of the modifiers. - /// @param buttons The state of the mouse buttons - virtual void - update(int x, int y, BitMask modifiers, BitMask buttons) = 0; + /// @brief update the state of the tool from the screen coordinates + /// of the mouse as well as the value of the modifier. + /// @param x the x coordinate of the mouse screen coordinates. + /// @param y the y coordinate of the mouse screen coordinates. + /// @param modifiers The keyboard modifiers. We use modifier to change the + /// behavior of a tool. Values of a modifier can be control key, alt key + /// shift key, or no key is pressed. See the subclasses of this class + /// for specific usages of the modifiers. + /// @param buttons The state of the mouse buttons + virtual + void + update (int x, int y, BitMask modifiers, BitMask buttons) = 0; - /// @brief set final state of the tool from the screen coordinates - /// of the mouse as well as the value of the modifier. Also performs the - /// corresponding functionalities of the tool. - /// @param x the x coordinate of the mouse screen coordinates. - /// @param y the y coordinate of the mouse screen coordinates. - /// @param modifiers The keyboard modifiers. We use modifier to change the - /// behavior of a tool. Values of a modifier can be control key, alt key - /// shift key, or no key is pressed. See the subclasses of this class - /// for specific usages of the modifiers. - /// @param buttons The state of the mouse buttons - virtual void - end(int x, int y, BitMask modifiers, BitMask buttons) = 0; + /// @brief set final state of the tool from the screen coordinates + /// of the mouse as well as the value of the modifier. Also performs the + /// corresponding functionalities of the tool. + /// @param x the x coordinate of the mouse screen coordinates. + /// @param y the y coordinate of the mouse screen coordinates. + /// @param modifiers The keyboard modifiers. We use modifier to change the + /// behavior of a tool. Values of a modifier can be control key, alt key + /// shift key, or no key is pressed. See the subclasses of this class + /// for specific usages of the modifiers. + /// @param buttons The state of the mouse buttons + virtual + void + end (int x, int y, BitMask modifiers, BitMask buttons) = 0; + + /// @brief a rendering facility used by a tool. For instance, if this tool + /// is a selection tool, this function draws highlighted points as well as + /// selection region, e.g., rubberband, box, etc. + virtual + void + draw () const = 0; + + protected: + /// @brief Default constructor + ToolInterface () + = default; - /// @brief a rendering facility used by a tool. For instance, if this tool - /// is a selection tool, this function draws highlighted points as well as - /// selection region, e.g., rubberband, box, etc. - virtual void - draw() const = 0; + private: + /// @brief Copy constructor - tools are non-copyable + ToolInterface (const ToolInterface&) + { + assert(false); + } -protected: - /// @brief Default constructor - ToolInterface() = default; - -private: - /// @brief Copy constructor - tools are non-copyable - ToolInterface(const ToolInterface&) { assert(false); } - - /// @brief Equal operator - tools are non-copyable - ToolInterface& - operator=(const ToolInterface&) - { - assert(false); - return *this; - } + /// @brief Equal operator - tools are non-copyable + ToolInterface& + operator= (const ToolInterface&) + { + assert(false); return (*this); + } }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h index 88b861ca759..3856e84db7b 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h @@ -35,47 +35,42 @@ /// @file trackball.h /// @details Generic object for generating rotations given mouse input. This -/// class has been based on +/// class has been based on /// @author Matthew Hielsberg #pragma once -#include - #include +#include -class TrackBall { -public: - TrackBall(); - TrackBall(const TrackBall& copy); - ~TrackBall(); - - TrackBall& - operator=(const TrackBall& rhs); - - void - start(int s_x, int s_y); - - void - update(int s_x, int s_y); - - void - getRotationMatrix(float (&rot)[MATRIX_SIZE]); - - void - reset(); - -private: - void - getPointFromScreenPoint(int s_x, int s_y, float& x, float& y, float& z) const; - - /// the quaternion representing the current orientation of the trackball - boost::math::quaternion quat_; - - /// the original mouse screen coordinates converted to a 3d point - float origin_x_, origin_y_, origin_z_; - - /// the radius of the trackball squared - float radius_sqr_; +class TrackBall +{ + public: + TrackBall(); + TrackBall(const TrackBall ©); + ~TrackBall(); + + TrackBall& operator=(const TrackBall &rhs); + + void start(int s_x, int s_y); + + void update(int s_x, int s_y); + + void getRotationMatrix(float (&rot)[MATRIX_SIZE]); + + void reset(); + + private: + + void getPointFromScreenPoint(int s_x, int s_y, float &x, float &y, float &z) const; + /// the quaternion representing the current orientation of the trackball + boost::math::quaternion quat_; + + /// the original mouse screen coordinates converted to a 3d point + float origin_x_, origin_y_, origin_z_; + + /// the radius of the trackball squared + float radius_sqr_; + }; // class TrackBall diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/transformCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/transformCommand.h index cb2954838fc..5d79983853b 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/transformCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/transformCommand.h @@ -40,74 +40,73 @@ #pragma once -#include #include #include -#include // for pcl::shared_ptr +#include + +#include // for pcl::shared_ptr class Selection; -class TransformCommand : public Command { -public: - /// The type for shared pointer pointing to a constant selection buffer - using ConstSelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - /// @param matrix a (4x4) transform matrix following OpenGL's format. - /// @pre Assumes the selection_ptr is valid, non-NULL. - TransformCommand(const ConstSelectionPtr& selection_ptr, - CloudPtr cloud_ptr, - const float* matrix, - float translate_x, - float translate_y, - float translate_z); - - /// @brief Copy constructor - object is not copy-constructable - TransformCommand(const TransformCommand&) = delete; - - /// @brief Equal operator - object is non-copyable - TransformCommand& - operator=(const TransformCommand&) = delete; - -protected: - // Transforms the coordinates of the selected points according to the transform - // matrix. - void - execute() override; - - // Restore the coordinates of the transformed points. - void - undo() override; - -private: - /// @brief Applies the transformation to the point values - /// @param sel_ptr A pointer to the selection object whose points are to be - /// transformed. - void - applyTransform(const ConstSelectionPtr& sel_ptr); - - /// pointers to constructor params - ConstSelectionPtr selection_ptr_; - - /// a pointer pointing to the cloud - CloudPtr cloud_ptr_; - - float translate_x_, translate_y_, translate_z_; - - /// An internal selection object used to perform undo - SelectionPtr internal_selection_ptr_; - - /// the transform matrix to be used to compute the new coordinates - /// of the selected points - float transform_matrix_[MATRIX_SIZE]; - - /// The transform matrix of the cloud used by this command - float cloud_matrix_[MATRIX_SIZE]; - /// The inverted transform matrix of the cloud used by this command - float cloud_matrix_inv_[MATRIX_SIZE]; - - /// The center of the cloud used by this command - float cloud_center_[XYZ_SIZE]; +class TransformCommand : public Command +{ + public: + /// The type for shared pointer pointing to a constant selection buffer + using ConstSelectionPtr = pcl::shared_ptr; + + /// @brief Constructor + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + /// @param matrix a (4x4) transform matrix following OpenGL's format. + /// @pre Assumes the selection_ptr is valid, non-NULL. + TransformCommand (const ConstSelectionPtr& selection_ptr, CloudPtr cloud_ptr, + const float* matrix, float translate_x, + float translate_y, float translate_z); + + /// @brief Copy constructor - object is not copy-constructable + TransformCommand (const TransformCommand&) = delete; + + /// @brief Equal operator - object is non-copyable + TransformCommand& + operator= (const TransformCommand&) = delete; + + protected: + // Transforms the coordinates of the selected points according to the transform + // matrix. + void + execute () override; + + // Restore the coordinates of the transformed points. + void + undo () override; + + private: + /// @brief Applies the transformation to the point values + /// @param sel_ptr A pointer to the selection object whose points are to be + /// transformed. + void + applyTransform(const ConstSelectionPtr& sel_ptr); + + /// pointers to constructor params + ConstSelectionPtr selection_ptr_; + + /// a pointer pointing to the cloud + CloudPtr cloud_ptr_; + + float translate_x_, translate_y_, translate_z_; + + /// An internal selection object used to perform undo + SelectionPtr internal_selection_ptr_; + + /// the transform matrix to be used to compute the new coordinates + /// of the selected points + float transform_matrix_[MATRIX_SIZE]; + + /// The transform matrix of the cloud used by this command + float cloud_matrix_[MATRIX_SIZE]; + /// The inverted transform matrix of the cloud used by this command + float cloud_matrix_inv_[MATRIX_SIZE]; + + /// The center of the cloud used by this command + float cloud_center_[XYZ_SIZE]; }; diff --git a/apps/point_cloud_editor/src/cloud.cpp b/apps/point_cloud_editor/src/cloud.cpp index 41f87f87170..5a169e88458 100644 --- a/apps/point_cloud_editor/src/cloud.cpp +++ b/apps/point_cloud_editor/src/cloud.cpp @@ -137,7 +137,7 @@ Cloud::operator= (const Cloud &cloud) select_translate_x_ = cloud.select_translate_x_; select_translate_y_ = cloud.select_translate_y_; select_translate_z_ = cloud.select_translate_z_; - return *this; + return (*this); } Point3D& diff --git a/apps/point_cloud_editor/src/cloudEditorWidget.cpp b/apps/point_cloud_editor/src/cloudEditorWidget.cpp index e442aada8b4..f4cd6d4d03a 100644 --- a/apps/point_cloud_editor/src/cloudEditorWidget.cpp +++ b/apps/point_cloud_editor/src/cloudEditorWidget.cpp @@ -495,11 +495,8 @@ CloudEditorWidget::mousePressEvent (QMouseEvent *event) auto ratio = this->devicePixelRatio(); if (!tool_ptr_) return; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - tool_ptr_ -> start(event -> position().x()*ratio, event -> position().y()*ratio, event -> modifiers(), event -> buttons()); -#else - tool_ptr_ -> start(event -> x()*ratio, event -> y()*ratio, event -> modifiers(), event -> buttons()); -#endif + tool_ptr_ -> start(event -> x()*ratio, event -> y()*ratio, + event -> modifiers(), event -> buttons()); update(); } @@ -509,11 +506,8 @@ CloudEditorWidget::mouseMoveEvent (QMouseEvent *event) auto ratio = this->devicePixelRatio(); if (!tool_ptr_) return; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - tool_ptr_ -> update(event -> position().x()*ratio, event -> position().y()*ratio, event -> modifiers(), event -> buttons()); -#else - tool_ptr_ -> update(event -> x()*ratio, event -> y()*ratio, event -> modifiers(), event -> buttons()); -#endif + tool_ptr_ -> update(event -> x()*ratio, event -> y()*ratio, + event -> modifiers(), event -> buttons()); update(); } @@ -523,11 +517,8 @@ CloudEditorWidget::mouseReleaseEvent (QMouseEvent *event) auto ratio = this->devicePixelRatio(); if (!tool_ptr_) return; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - tool_ptr_ -> end(event -> position().x()*ratio, event -> position().y()*ratio, event -> modifiers(), event -> button()); -#else - tool_ptr_ -> end(event -> x()*ratio, event -> y()*ratio, event -> modifiers(), event -> button()); -#endif + tool_ptr_ -> end(event -> x()*ratio, event -> y()*ratio, + event -> modifiers(), event -> button()); update(); } diff --git a/apps/point_cloud_editor/src/selection.cpp b/apps/point_cloud_editor/src/selection.cpp index ac4aa1032ae..070452a5ec7 100644 --- a/apps/point_cloud_editor/src/selection.cpp +++ b/apps/point_cloud_editor/src/selection.cpp @@ -48,7 +48,7 @@ Selection::operator= (const Selection& selection) { cloud_ptr_ = selection.cloud_ptr_; selected_indices_ = selection.selected_indices_; - return *this; + return (*this); } void diff --git a/apps/src/face_detection/filesystem_face_detection.cpp b/apps/src/face_detection/filesystem_face_detection.cpp index a13a49c752f..f69b8f94f73 100644 --- a/apps/src/face_detection/filesystem_face_detection.cpp +++ b/apps/src/face_detection/filesystem_face_detection.cpp @@ -98,7 +98,7 @@ run(pcl::RFFaceDetectorTrainer& fdrf, bool result = face_detection_apps_utils::readMatrixFromFile(pose_file, pose_mat); if (result) { - Eigen::Vector3f ea = pose_mat.topLeftCorner<3, 3>().eulerAngles(0, 1, 2); + Eigen::Vector3f ea = pose_mat.block<3, 3>(0, 0).eulerAngles(0, 1, 2); Eigen::Vector3f trans_vector = Eigen::Vector3f(pose_mat(0, 3), pose_mat(1, 3), pose_mat(2, 3)); std::cout << ea << std::endl; @@ -127,7 +127,7 @@ run(pcl::RFFaceDetectorTrainer& fdrf, Eigen::AngleAxisf(ea[1], Eigen::Vector3f::UnitY()) * Eigen::AngleAxisf(ea[2], Eigen::Vector3f::UnitZ()); - // matrixxx = pose_mat.topLeftCorner<3,3>(); + // matrixxx = pose_mat.block<3,3>(0,0); vec = matrixxx * vec; cylinder_coeff.values[3] = vec[0]; diff --git a/apps/src/multiscale_feature_persistence_example.cpp b/apps/src/multiscale_feature_persistence_example.cpp index 4854347c0e2..a2bc67958d5 100644 --- a/apps/src/multiscale_feature_persistence_example.cpp +++ b/apps/src/multiscale_feature_persistence_example.cpp @@ -41,7 +41,6 @@ #include #include #include -#include // for KdTree #include #include diff --git a/apps/src/openni_boundary_estimation.cpp b/apps/src/openni_boundary_estimation.cpp index 4b343c1faa4..d0e45444d3a 100644 --- a/apps/src/openni_boundary_estimation.cpp +++ b/apps/src/openni_boundary_estimation.cpp @@ -42,7 +42,6 @@ #include #include #include -#include // for OrganizedNeighbor #include #include #include diff --git a/apps/src/openni_feature_persistence.cpp b/apps/src/openni_feature_persistence.cpp index 83412d7e970..0b397bffd51 100644 --- a/apps/src/openni_feature_persistence.cpp +++ b/apps/src/openni_feature_persistence.cpp @@ -44,7 +44,6 @@ #include #include #include -#include // for KdTree #include #include #include diff --git a/apps/src/openni_mobile_server.cpp b/apps/src/openni_mobile_server.cpp index aee1892abf6..bf6778d1ff5 100644 --- a/apps/src/openni_mobile_server.cpp +++ b/apps/src/openni_mobile_server.cpp @@ -157,7 +157,7 @@ class PCLMobileServer { viewer_.showCloud(getLatestPointCloud()); - boost::asio::io_context io_service; + boost::asio::io_service io_service; tcp::endpoint endpoint(tcp::v4(), static_cast(port_)); tcp::acceptor acceptor(io_service, endpoint); tcp::socket socket(io_service); diff --git a/apps/src/openni_octree_compression.cpp b/apps/src/openni_octree_compression.cpp index 4592cbd3407..0a056054f34 100644 --- a/apps/src/openni_octree_compression.cpp +++ b/apps/src/openni_octree_compression.cpp @@ -415,7 +415,7 @@ main(int argc, char** argv) if (bEnDecode) { // ENCODING try { - boost::asio::io_context io_service; + boost::asio::io_service io_service; tcp::endpoint endpoint(tcp::v4(), 6666); tcp::acceptor acceptor(io_service, endpoint); @@ -423,7 +423,7 @@ main(int argc, char** argv) std::cout << "Waiting for connection.." << std::endl; - acceptor.accept(socketStream.rdbuf()->socket()); + acceptor.accept(*socketStream.rdbuf()); std::cout << "Connected!" << std::endl; diff --git a/apps/src/openni_organized_compression.cpp b/apps/src/openni_organized_compression.cpp index f68314f4bf7..c0448bde55d 100644 --- a/apps/src/openni_organized_compression.cpp +++ b/apps/src/openni_organized_compression.cpp @@ -438,7 +438,7 @@ main(int argc, char** argv) if (bEnDecode) { // ENCODING try { - boost::asio::io_context io_service; + boost::asio::io_service io_service; tcp::endpoint endpoint(tcp::v4(), 6666); tcp::acceptor acceptor(io_service, endpoint); @@ -446,7 +446,7 @@ main(int argc, char** argv) std::cout << "Waiting for connection.." << std::endl; - acceptor.accept(socketStream.rdbuf()->socket()); + acceptor.accept(*socketStream.rdbuf()); std::cout << "Connected!" << std::endl; diff --git a/apps/src/ppf_object_recognition.cpp b/apps/src/ppf_object_recognition.cpp index 9889d0c6a5e..b12ac2a0f43 100644 --- a/apps/src/ppf_object_recognition.cpp +++ b/apps/src/ppf_object_recognition.cpp @@ -9,7 +9,6 @@ #include #include -#include #include using namespace pcl; diff --git a/apps/src/pyramid_surface_matching.cpp b/apps/src/pyramid_surface_matching.cpp index 5fd5f8bc4cb..b325b4473d9 100644 --- a/apps/src/pyramid_surface_matching.cpp +++ b/apps/src/pyramid_surface_matching.cpp @@ -3,7 +3,6 @@ #include #include #include -#include // for KdTree using namespace pcl; diff --git a/apps/src/surfel_smoothing_test.cpp b/apps/src/surfel_smoothing_test.cpp index 3e9e2d63f75..7b88a3bae6d 100644 --- a/apps/src/surfel_smoothing_test.cpp +++ b/apps/src/surfel_smoothing_test.cpp @@ -1,6 +1,5 @@ #include #include -#include // for KdTree #include using namespace pcl; diff --git a/common/include/pcl/common/fft/.clang-tidy b/common/include/pcl/common/fft/.clang-tidy new file mode 100644 index 00000000000..6b766d3d201 --- /dev/null +++ b/common/include/pcl/common/fft/.clang-tidy @@ -0,0 +1,3 @@ +--- +# Disable all clang-tidy checks for third-party code (kiss_fft) +Checks: '-*' diff --git a/common/src/fft/.clang-tidy b/common/src/fft/.clang-tidy new file mode 100644 index 00000000000..6b766d3d201 --- /dev/null +++ b/common/src/fft/.clang-tidy @@ -0,0 +1,3 @@ +--- +# Disable all clang-tidy checks for third-party code (kiss_fft) +Checks: '-*' diff --git a/examples/surface/example_nurbs_fitting_closed_curve.cpp b/examples/surface/example_nurbs_fitting_closed_curve.cpp index 65342497a35..9c6ffda9bdb 100644 --- a/examples/surface/example_nurbs_fitting_closed_curve.cpp +++ b/examples/surface/example_nurbs_fitting_closed_curve.cpp @@ -43,9 +43,9 @@ VisualizeCurve (ON_NurbsCurve &curve, double r, double g, double b, bool show_cp curve.GetCV (i, cp); pcl::PointXYZ p; - p.x = float (cp.x); - p.y = float (cp.y); - p.z = float (cp.z); + p.x = static_cast(cp.x); + p.y = static_cast(cp.y); + p.z = static_cast(cp.z); cps->push_back (p); } pcl::visualization::PointCloudColorHandlerCustom handler (cps, 255 * r, 255 * g, 255 * b); diff --git a/examples/surface/example_nurbs_fitting_closed_curve3d.cpp b/examples/surface/example_nurbs_fitting_closed_curve3d.cpp index c6da7235fac..4595e520b47 100644 --- a/examples/surface/example_nurbs_fitting_closed_curve3d.cpp +++ b/examples/surface/example_nurbs_fitting_closed_curve3d.cpp @@ -41,9 +41,9 @@ VisualizeCurve (ON_NurbsCurve &curve, double r, double g, double b, bool show_cp curve.GetCV (i, cp); pcl::PointXYZ p; - p.x = float (cp.x); - p.y = float (cp.y); - p.z = float (cp.z); + p.x = static_cast(cp.x); + p.y = static_cast(cp.y); + p.z = static_cast(cp.z); cps->push_back (p); } pcl::visualization::PointCloudColorHandlerCustom handler (cps, 255 * r, 255 * g, 255 * b); diff --git a/examples/surface/example_nurbs_fitting_curve2d.cpp b/examples/surface/example_nurbs_fitting_curve2d.cpp index f66b050cfdd..e43ee38fe3f 100644 --- a/examples/surface/example_nurbs_fitting_curve2d.cpp +++ b/examples/surface/example_nurbs_fitting_curve2d.cpp @@ -41,9 +41,9 @@ VisualizeCurve (ON_NurbsCurve &curve, double r, double g, double b, bool show_cp curve.GetCV (i, cp); pcl::PointXYZ p; - p.x = float (cp.x); - p.y = float (cp.y); - p.z = float (cp.z); + p.x = static_cast(cp.x); + p.y = static_cast(cp.y); + p.z = static_cast(cp.z); cps->push_back (p); } pcl::visualization::PointCloudColorHandlerCustom handler (cps, 255 * r, 255 * g, 255 * b); diff --git a/examples/surface/example_nurbs_fitting_surface.cpp b/examples/surface/example_nurbs_fitting_surface.cpp index 0cbda86ac80..ee52a8dea05 100644 --- a/examples/surface/example_nurbs_fitting_surface.cpp +++ b/examples/surface/example_nurbs_fitting_surface.cpp @@ -202,9 +202,9 @@ visualizeCurve (ON_NurbsCurve &curve, ON_NurbsSurface &surface, pcl::visualizati double pnt[3]; surface.Evaluate (p1.x, p1.y, 0, 3, pnt); pcl::PointXYZRGB p2; - p2.x = float (pnt[0]); - p2.y = float (pnt[1]); - p2.z = float (pnt[2]); + p2.x = static_cast(pnt[0]); + p2.y = static_cast(pnt[1]); + p2.z = static_cast(pnt[2]); p2.r = 255; p2.g = 0; diff --git a/examples/surface/example_nurbs_viewer_surface.cpp b/examples/surface/example_nurbs_viewer_surface.cpp index d77d7f02075..27ff9319469 100644 --- a/examples/surface/example_nurbs_viewer_surface.cpp +++ b/examples/surface/example_nurbs_viewer_surface.cpp @@ -48,7 +48,7 @@ main (int argc, char *argv[]) return -1; } - const ON_NurbsSurface& on_surf = *(ON_NurbsSurface*)on_object; + const ON_NurbsSurface& on_surf = *dynamic_cast(on_object); pcl::PolygonMesh mesh; std::string mesh_id = "mesh_nurbs"; @@ -68,7 +68,7 @@ main (int argc, char *argv[]) return -1; } - const ON_NurbsCurve& on_curv = *(ON_NurbsCurve*)on_object; + const ON_NurbsCurve& on_curv = *dynamic_cast(on_object); pcl::on_nurbs::Triangulation::convertTrimmedSurface2PolygonMesh (on_surf, on_curv, mesh, mesh_resolution); diff --git a/examples/surface/test_nurbs_fitting_surface.cpp b/examples/surface/test_nurbs_fitting_surface.cpp index 74a52083587..60832ea8bf4 100644 --- a/examples/surface/test_nurbs_fitting_surface.cpp +++ b/examples/surface/test_nurbs_fitting_surface.cpp @@ -12,15 +12,15 @@ CreateCylinderPoints (pcl::PointCloud::Ptr cloud, pcl::on_nurbs::vector_v { for (unsigned i = 0; i < npoints; i++) { - double da = alpha * double (rand ()) / RAND_MAX; - double dh = h * (double (rand ()) / RAND_MAX - 0.5); + double da = alpha * static_cast(rand ()) / RAND_MAX; + double dh = h * (static_cast(rand ()) / RAND_MAX - 0.5); Point p; - p.x = float (r * std::cos (da)); - p.y = float (r * sin (da)); - p.z = float (dh); + p.x = static_cast(r * std::cos (da)); + p.y = static_cast(r * sin (da)); + p.z = static_cast(dh); - data.push_back (Eigen::Vector3d (p.x, p.y, p.z)); + data.emplace_back(p.x, p.y, p.z); cloud->push_back (p); } } diff --git a/features/include/pcl/features/ppfrgb.h b/features/include/pcl/features/ppfrgb.h index c50fee1d314..9bbf999ae79 100644 --- a/features/include/pcl/features/ppfrgb.h +++ b/features/include/pcl/features/ppfrgb.h @@ -64,7 +64,7 @@ namespace pcl * \param output the resulting point cloud (which should be of type pcl::PPFRGBSignature); */ void - computeFeature (PointCloudOut &output); + computeFeature (PointCloudOut &output) override; }; template diff --git a/geometry/include/pcl/geometry/impl/polygon_operations.hpp b/geometry/include/pcl/geometry/impl/polygon_operations.hpp index 585ba6ae93f..de12bad1955 100644 --- a/geometry/include/pcl/geometry/impl/polygon_operations.hpp +++ b/geometry/include/pcl/geometry/impl/polygon_operations.hpp @@ -218,7 +218,7 @@ pcl::approximatePolygon2D(const typename pcl::PointCloud::VectorType& po covariance.coeffRef(2) = covariance.coeff(1); - float norm = 1.0f / float(num_points); + float norm = 1.0f / static_cast(num_points); centroid *= norm; covariance *= norm; covariance.coeffRef(0) -= centroid[0] * centroid[0]; @@ -235,7 +235,7 @@ pcl::approximatePolygon2D(const typename pcl::PointCloud::VectorType& po direction[1] = polygon[result[nIdx]].y - polygon[result[rIdx]].y; direction.normalize(); - if (std::abs(direction.dot(normal)) > float(M_SQRT1_2)) { + if (std::abs(direction.dot(normal)) > static_cast(M_SQRT1_2)) { std::swap(normal[0], normal[1]); normal[0] = -normal[0]; } @@ -289,9 +289,7 @@ pcl::approximatePolygon2D(const typename pcl::PointCloud::VectorType& po } else { // we have a new polygon in results, but inverted (clockwise <-> counter-clockwise) - for (std::vector::reverse_iterator it = result.rbegin(); - it != result.rend(); - ++it) + for (auto it = result.rbegin(); it != result.rend(); ++it) approx_polygon.push_back(polygon[*it]); } } diff --git a/keypoints/include/pcl/keypoints/harris_2d.h b/keypoints/include/pcl/keypoints/harris_2d.h index 5305d4f0eaf..3e5b109373c 100644 --- a/keypoints/include/pcl/keypoints/harris_2d.h +++ b/keypoints/include/pcl/keypoints/harris_2d.h @@ -77,15 +77,14 @@ namespace pcl */ HarrisKeypoint2D (ResponseMethod method = HARRIS, int window_width = 3, int window_height = 3, int min_distance = 5, float threshold = 0.0) : threshold_ (threshold) - , refine_ (false) - , nonmax_ (true) - , method_ (method) - , threads_ (0) - , response_ (new pcl::PointCloud ()) + , + method_ (method) + , + response_ (new pcl::PointCloud ()) , window_width_ (window_width) , window_height_ (window_height) - , skipped_pixels_ (0) - , min_distance_ (min_distance) + , + min_distance_ (min_distance) { name_ = "HarrisKeypoint2D"; } @@ -156,13 +155,13 @@ namespace pcl /// threshold for non maxima suppression float threshold_; /// corner refinement - bool refine_; + bool refine_{false}; /// non maximas suppression - bool nonmax_; + bool nonmax_{true}; /// cornerness computation method ResponseMethod method_; /// number of threads to be used - unsigned int threads_; + unsigned int threads_{0}; private: Eigen::MatrixXf derivatives_rows_; @@ -184,7 +183,7 @@ namespace pcl /// half window height int half_window_height_; /// number of pixels to skip within search window - int skipped_pixels_; + int skipped_pixels_{0}; /// minimum distance between two keypoints int min_distance_; /// intensity field accessor diff --git a/keypoints/include/pcl/keypoints/impl/harris_2d.hpp b/keypoints/include/pcl/keypoints/impl/harris_2d.hpp index fa8da44a169..0c9905f8da9 100644 --- a/keypoints/include/pcl/keypoints/impl/harris_2d.hpp +++ b/keypoints/include/pcl/keypoints/impl/harris_2d.hpp @@ -43,6 +43,8 @@ #include +#include + namespace pcl { @@ -472,7 +474,7 @@ HarrisKeypoint2D::responseTomasi (PointCloudOut { computeSecondMomentMatrix (index, covar); // min egenvalue - out_point.intensity = ((covar[0] + covar[2] - sqrt((covar[0] - covar[2])*(covar[0] - covar[2]) + 4 * covar[1] * covar[1])) /2.0f); + out_point.intensity = ((covar[0] + covar[2] - std::sqrt((covar[0] - covar[2])*(covar[0] - covar[2]) + 4 * covar[1] * covar[1])) /2.0f); } } diff --git a/outofcore/include/pcl/outofcore/impl/lru_cache.hpp b/outofcore/include/pcl/outofcore/impl/lru_cache.hpp index 9bdef7920fd..1a81400ea3b 100644 --- a/outofcore/include/pcl/outofcore/impl/lru_cache.hpp +++ b/outofcore/include/pcl/outofcore/impl/lru_cache.hpp @@ -53,7 +53,7 @@ class LRUCache get (const KeyT& k) { // Get existing key - const CacheIterator it = cache_.find (k); + const auto it = cache_.find (k); assert(it != cache_.end ()); // Move key to MRU key index @@ -67,7 +67,7 @@ class LRUCache touch (const KeyT& key) { // Get existing key - const CacheIterator it = cache_.find (key); + const auto it = cache_.find (key); assert(it != cache_.end ()); // Move key to MRU key index @@ -93,7 +93,7 @@ class LRUCache while (size + item_size >= capacity_) { - const CacheIterator cache_it = cache_.find (*key_it); + const auto cache_it = cache_.find (*key_it); // Get tail item (Least Recently Used) std::size_t tail_timestamp = cache_it->second.first.timestamp; @@ -153,7 +153,7 @@ class LRUCache return false; // Get LRU item - const CacheIterator it = cache_.find (key_index_.front ()); + const auto it = cache_.find (key_index_.front ()); assert(it != cache_.end()); // Remove LRU item from cache and key index diff --git a/recognition/include/pcl/recognition/3rdparty/.clang-tidy b/recognition/include/pcl/recognition/3rdparty/.clang-tidy new file mode 100644 index 00000000000..ff63dfcacf5 --- /dev/null +++ b/recognition/include/pcl/recognition/3rdparty/.clang-tidy @@ -0,0 +1,3 @@ +--- +# Disable all clang-tidy checks for third-party code +Checks: '-*' diff --git a/recognition/include/pcl/recognition/crh_alignment.h b/recognition/include/pcl/recognition/crh_alignment.h index a8853e6f57d..3cec516a434 100644 --- a/recognition/include/pcl/recognition/crh_alignment.h +++ b/recognition/include/pcl/recognition/crh_alignment.h @@ -170,7 +170,7 @@ namespace pcl translation2 (2, 3) = centroid_input_[2] - centr[2]; Eigen::Matrix4f resultHom (translation2 * rollHomMatrix); - transforms_.push_back(resultHom.inverse()); + transforms_.emplace_back(resultHom.inverse()); } } @@ -194,7 +194,7 @@ namespace pcl int peak_distance = 5; int cutoff = nbins_ - 1; - kiss_fft_cpx * multAB = new kiss_fft_cpx[nr_bins_after_padding]; + auto * multAB = new kiss_fft_cpx[nr_bins_after_padding]; for (int i = 0; i < nr_bins_after_padding; i++) multAB[i].r = multAB[i].i = 0.f; @@ -221,7 +221,7 @@ namespace pcl multAB[nbins_ - 1].r = input_ftt_negate[0].histogram[nbins_ - 1] * target_ftt[0].histogram[nbins_ - 1]; kiss_fft_cfg mycfg = kiss_fft_alloc (nr_bins_after_padding, 1, nullptr, nullptr); - kiss_fft_cpx * invAB = new kiss_fft_cpx[nr_bins_after_padding]; + auto * invAB = new kiss_fft_cpx[nr_bins_after_padding]; kiss_fft (mycfg, multAB, invAB); std::vector < std::pair > scored_peaks (nr_bins_after_padding); diff --git a/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h b/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h index 67592875996..e3b0892d507 100644 --- a/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h +++ b/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h @@ -155,11 +155,11 @@ namespace pcl const std::uint32_t &label1 = (*labels_)[idx1].label; const std::uint32_t &label2 = (*labels_)[idx2].label; - const std::set::const_iterator it1 = exclude_labels_->find (label1); + const auto it1 = exclude_labels_->find (label1); if (it1 == exclude_labels_->end ()) return false; - const std::set::const_iterator it2 = exclude_labels_->find (label2); + const auto it2 = exclude_labels_->find (label2); if (it2 == exclude_labels_->end ()) return false; } diff --git a/surface/include/pcl/surface/3rdparty/.clang-tidy b/surface/include/pcl/surface/3rdparty/.clang-tidy new file mode 100644 index 00000000000..ff63dfcacf5 --- /dev/null +++ b/surface/include/pcl/surface/3rdparty/.clang-tidy @@ -0,0 +1,3 @@ +--- +# Disable all clang-tidy checks for third-party code +Checks: '-*' diff --git a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d.h b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d.h index 6e9c90e8655..49db7046ef9 100644 --- a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d.h +++ b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d.h @@ -58,12 +58,9 @@ namespace pcl /** \brief Parameters for fitting */ struct Parameter { - double smoothness; - double rScale; - Parameter () : - smoothness (0.1), rScale (1.0) - { - } + double smoothness{0.1}; + double rScale{1.0}; + Parameter () = default; }; struct FitParameter diff --git a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_apdm.h b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_apdm.h index 72853647919..24fa6fc0c44 100644 --- a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_apdm.h +++ b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_apdm.h @@ -58,18 +58,14 @@ namespace pcl /** \brief Parameters for fitting */ struct Parameter { - double interior_sigma2; - double smoothness; - double closest_point_weight; - double closest_point_sigma2; - unsigned closest_point_resolution; - double smooth_concavity; - double rScale; - Parameter () : - interior_sigma2 (0.1), smoothness (0.1), closest_point_weight (0.1), closest_point_sigma2 (0.1), - closest_point_resolution (0), smooth_concavity (1.0), rScale (1.0) - { - } + double interior_sigma2{0.1}; + double smoothness{0.1}; + double closest_point_weight{0.1}; + double closest_point_sigma2{0.1}; + unsigned closest_point_resolution{0}; + double smooth_concavity{1.0}; + double rScale{1.0}; + Parameter () = default; }; struct FitParameter diff --git a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_pdm.h b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_pdm.h index 59c457131b4..10ea6bcddc2 100644 --- a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_pdm.h +++ b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_pdm.h @@ -58,12 +58,9 @@ namespace pcl /** \brief Parameters for fitting */ struct Parameter { - double smoothness; - double rScale; - Parameter () : - smoothness (0.1), rScale (1.0) - { - } + double smoothness{0.1}; + double rScale{1.0}; + Parameter () = default; }; struct FitParameter diff --git a/surface/include/pcl/surface/on_nurbs/fitting_surface_im.h b/surface/include/pcl/surface/on_nurbs/fitting_surface_im.h index 3fefdcf3b2d..047c70660a9 100644 --- a/surface/include/pcl/surface/on_nurbs/fitting_surface_im.h +++ b/surface/include/pcl/surface/on_nurbs/fitting_surface_im.h @@ -59,11 +59,8 @@ namespace pcl /** \brief Parameters for fitting */ struct Parameter { - double smoothness; - Parameter () : - smoothness (0.1) - { - } + double smoothness{0.1}; + Parameter () = default; }; protected: diff --git a/surface/include/pcl/surface/on_nurbs/nurbs_data.h b/surface/include/pcl/surface/on_nurbs/nurbs_data.h index d74f3503bac..c3052357547 100644 --- a/surface/include/pcl/surface/on_nurbs/nurbs_data.h +++ b/surface/include/pcl/surface/on_nurbs/nurbs_data.h @@ -51,9 +51,9 @@ namespace pcl { // http://eigen.tuxfamily.org/dox-devel/TopicStlContainers.html - typedef std::vector > vector_vec2i; - typedef std::vector > vector_vec2d; - typedef std::vector > vector_vec3d; + using vector_vec2i = std::vector>; + using vector_vec2d = std::vector>; + using vector_vec3d = std::vector>; /** \brief Data structure for NURBS surface fitting * (FittingSurface, FittingSurfaceTDM, FittingCylinder, GlobalOptimization, GlobalOptimizationTDM) */ diff --git a/surface/include/pcl/surface/on_nurbs/nurbs_solve.h b/surface/include/pcl/surface/on_nurbs/nurbs_solve.h index 491da21a465..c4739746331 100644 --- a/surface/include/pcl/surface/on_nurbs/nurbs_solve.h +++ b/surface/include/pcl/surface/on_nurbs/nurbs_solve.h @@ -53,10 +53,7 @@ namespace pcl { public: /** \brief Empty constructor */ - NurbsSolve () : - m_quiet (true) - { - } + NurbsSolve () = default; /** \brief Assign size and dimension (2D, 3D) of system of equations. */ void @@ -122,7 +119,7 @@ namespace pcl } private: - bool m_quiet; + bool m_quiet{true}; SparseMat m_Ksparse; Eigen::MatrixXd m_Keig; Eigen::MatrixXd m_xeig; diff --git a/surface/src/3rdparty/.clang-tidy b/surface/src/3rdparty/.clang-tidy new file mode 100644 index 00000000000..ff63dfcacf5 --- /dev/null +++ b/surface/src/3rdparty/.clang-tidy @@ -0,0 +1,3 @@ +--- +# Disable all clang-tidy checks for third-party code +Checks: '-*' diff --git a/surface/src/on_nurbs/closing_boundary.cpp b/surface/src/on_nurbs/closing_boundary.cpp index 4bb1637e36b..2b1c4ba65bd 100644 --- a/surface/src/on_nurbs/closing_boundary.cpp +++ b/surface/src/on_nurbs/closing_boundary.cpp @@ -243,7 +243,7 @@ ClosingBoundary::sampleUniform (ON_NurbsSurface *nurbs, vector_vec3d &point_list { params (0) = minU + (maxU - minU) * ds * i; nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); } } } @@ -262,10 +262,10 @@ ClosingBoundary::sampleRandom (ON_NurbsSurface *nurbs, vector_vec3d &point_list, for (unsigned i = 0; i < samples; i++) { - params (0) = minU + (maxU - minU) * (double (rand ()) / RAND_MAX); - params (1) = minV + (maxV - minV) * (double (rand ()) / RAND_MAX); + params (0) = minU + (maxU - minU) * (static_cast(rand ()) / RAND_MAX); + params (1) = minV + (maxV - minV) * (static_cast(rand ()) / RAND_MAX); nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); } } @@ -290,7 +290,7 @@ ClosingBoundary::sampleFromBoundary (ON_NurbsSurface *nurbs, vector_vec3d &point { params (1) = minV + (maxV - minV) * ds * i; nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); param_list.push_back (params); } @@ -300,7 +300,7 @@ ClosingBoundary::sampleFromBoundary (ON_NurbsSurface *nurbs, vector_vec3d &point { params (1) = minV + (maxV - minV) * ds * i; nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); param_list.push_back (params); } @@ -310,7 +310,7 @@ ClosingBoundary::sampleFromBoundary (ON_NurbsSurface *nurbs, vector_vec3d &point { params (0) = minU + (maxU - minU) * ds * i; nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); param_list.push_back (params); } @@ -320,7 +320,7 @@ ClosingBoundary::sampleFromBoundary (ON_NurbsSurface *nurbs, vector_vec3d &point { params (0) = minU + (maxU - minU) * ds * i; nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); param_list.push_back (params); } } diff --git a/surface/src/on_nurbs/fitting_curve_2d.cpp b/surface/src/on_nurbs/fitting_curve_2d.cpp index fbafd5a8fa5..0aceacb41e7 100644 --- a/surface/src/on_nurbs/fitting_curve_2d.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d.cpp @@ -74,7 +74,7 @@ int FittingCurve2d::findElement (double xi, const std::vector &elements) { if (xi >= elements.back ()) - return (int (elements.size ()) - 2); + return (static_cast(elements.size ()) - 2); for (std::size_t i = 0; i < elements.size () - 1; i++) { @@ -120,7 +120,7 @@ FittingCurve2d::assemble (const Parameter ¶meter) { int ncp = m_nurbs.m_cv_count; int nCageReg = m_nurbs.m_cv_count - 2; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -290,7 +290,7 @@ FittingCurve2d::initNurbsPCA (int order, NurbsDataCurve2d *data, int ncps) if (ncps < order) ncps = order; - unsigned s = static_cast (data->interior.size ()); + auto s = static_cast (data->interior.size ()); data->interior_param.clear (); NurbsTools::pca (data->interior, mean, eigenvectors, eigenvalues); @@ -399,7 +399,7 @@ FittingCurve2d::getElementVector (const ON_NurbsCurve &nurbs) void FittingCurve2d::assembleInterior (double wInt, double rScale, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); m_data->interior_error.clear (); m_data->interior_normals.clear (); m_data->interior_line_start.clear (); @@ -413,7 +413,7 @@ FittingCurve2d::assembleInterior (double wInt, double rScale, unsigned &row) double param; Eigen::Vector2d pt, t; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = findClosestElementMidPoint (m_nurbs, pcp, m_data->interior_param[p]); param = inverseMapping (m_nurbs, pcp, param, error, pt, t, rScale, in_max_steps, in_accuracy, m_quiet); @@ -428,7 +428,7 @@ FittingCurve2d::assembleInterior (double wInt, double rScale, unsigned &row) m_data->interior_error.push_back (error); - if (p < int (m_data->interior_weight.size ())) + if (p < static_cast(m_data->interior_weight.size ())) wInt = m_data->interior_weight[p]; m_data->interior_line_start.push_back (pcp); diff --git a/surface/src/on_nurbs/fitting_curve_2d_apdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_apdm.cpp index b30bc04f74b..0693b70dbfe 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_apdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_apdm.cpp @@ -75,7 +75,7 @@ int FittingCurve2dAPDM::findElement (double xi, const std::vector &elements) { if (xi >= elements.back ()) - return (int (elements.size ()) - 2); + return (static_cast(elements.size ()) - 2); for (std::size_t i = 0; i < elements.size () - 1; i++) { @@ -148,8 +148,8 @@ FittingCurve2dAPDM::assemble (const Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); - int nClosestP = int (elements.size ()) * cp_res; + int nInt = static_cast(m_data->interior.size ()); + int nClosestP = static_cast(elements.size ()) * cp_res; double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -330,8 +330,8 @@ FittingCurve2dAPDM::removeCPsOnLine (const ON_NurbsCurve &nurbs, double min_curv } int order = nurbs.Order (); - ON_NurbsCurve nurbs_opt = ON_NurbsCurve (2, false, order, int (cps.size ()) + 2 * cp_red); - nurbs_opt.MakePeriodicUniformKnotVector (1.0 / (double (cps.size ()))); + ON_NurbsCurve nurbs_opt = ON_NurbsCurve (2, false, order, static_cast(cps.size ()) + 2 * cp_red); + nurbs_opt.MakePeriodicUniformKnotVector (1.0 / (static_cast(cps.size ()))); nurbs_opt.m_knot[cp_red] = 0.0; nurbs_opt.m_knot[nurbs_opt.m_knot_capacity - cp_red - 1] = 1.0; @@ -428,7 +428,7 @@ FittingCurve2dAPDM::addCageRegularisation (double weight, unsigned &row, const s { int i = j % ncp; - if (i >= int (m_data->closest_points_error.size () - 1)) + if (i >= static_cast(m_data->closest_points_error.size () - 1)) { printf ("[FittingCurve2dAPDM::addCageRegularisation] Warning, index for closest_points_error out of bounds\n"); m_solver.f (row, 0, 0.0); @@ -512,7 +512,7 @@ FittingCurve2dAPDM::initCPsNurbsCurve2D (int order, const vector_vec2d &cps) return nurbs; } - int ncps = int (cps.size ()) + 2 * cp_red; // +2*cp_red for smoothness and +1 for closing + int ncps = static_cast(cps.size ()) + 2 * cp_red; // +2*cp_red for smoothness and +1 for closing nurbs = ON_NurbsCurve (2, false, order, ncps); nurbs.MakePeriodicUniformKnotVector (1.0 / (ncps - order + 1)); @@ -520,7 +520,7 @@ FittingCurve2dAPDM::initCPsNurbsCurve2D (int order, const vector_vec2d &cps) nurbs.SetCV (cp_red + j, ON_3dPoint (cps[j] (0), cps[j] (1), 0.0)); // close nurbs - nurbs.SetCV (cp_red + int (cps.size ()), ON_3dPoint (cps[0] (0), cps[0] (1), 0.0)); + nurbs.SetCV (cp_red + static_cast(cps.size ()), ON_3dPoint (cps[0] (0), cps[0] (1), 0.0)); // make smooth at closing point for (int j = 0; j < cp_red; j++) @@ -544,7 +544,7 @@ FittingCurve2dAPDM::initNurbsCurve2D (int order, const vector_vec2d &data, int n Eigen::Vector2d mean = NurbsTools::computeMean (data); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); double r (0.0); for (unsigned i = 0; i < s; i++) @@ -641,7 +641,7 @@ FittingCurve2dAPDM::getElementVector (const ON_NurbsCurve &nurbs) void FittingCurve2dAPDM::assembleInterior (double wInt, double sigma2, double rScale, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); bool wFunction (true); double ds = 1.0 / (2.0 * sigma2); m_data->interior_error.clear (); @@ -657,7 +657,7 @@ FittingCurve2dAPDM::assembleInterior (double wInt, double sigma2, double rScale, double param; Eigen::Vector2d pt, t; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = findClosestElementMidPoint (m_nurbs, pcp, m_data->interior_param[p]); param = inverseMapping (m_nurbs, pcp, param, error, pt, t, rScale, in_max_steps, in_accuracy, m_quiet); @@ -677,10 +677,10 @@ FittingCurve2dAPDM::assembleInterior (double wInt, double sigma2, double rScale, Eigen::Vector3d b (t (0), t (1), 0.0); Eigen::Vector3d z = a.cross (b); - if (p < int (m_data->interior_weight.size ())) + if (p < static_cast(m_data->interior_weight.size ())) wInt = m_data->interior_weight[p]; - if (p < int (m_data->interior_weight_function.size ())) + if (p < static_cast(m_data->interior_weight_function.size ())) wFunction = m_data->interior_weight_function[p]; double w (wInt); diff --git a/surface/src/on_nurbs/fitting_curve_2d_asdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_asdm.cpp index dbdc041942c..1cf4d3f333d 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_asdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_asdm.cpp @@ -59,12 +59,12 @@ FittingCurve2dASDM::assemble (const FittingCurve2dAPDM::Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); // int nCommon = m_data->common.size(); // int nClosestP = parameter.closest_point_resolution; std::vector elements = getElementVector (m_nurbs); - int nClosestP = int (elements.size ()); + int nClosestP = static_cast(elements.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -213,7 +213,7 @@ FittingCurve2dASDM::addCageRegularisation (double weight, unsigned &row, const s { int i = j % ncp; - if (i >= int (m_data->closest_points_error.size () - 1)) + if (i >= static_cast(m_data->closest_points_error.size () - 1)) { printf ("[FittingCurve2dASDM::addCageRegularisation] Warning, index for closest_points_error out of bounds\n"); } @@ -259,7 +259,7 @@ FittingCurve2dASDM::addCageRegularisation (double weight, unsigned &row, const s void FittingCurve2dASDM::assembleInterior (double wInt, double sigma2, double rScale, unsigned &row) { - unsigned nInt = unsigned (m_data->interior.size ()); + auto nInt = static_cast(m_data->interior.size ()); bool wFunction (true); double ds = 1.0 / (2.0 * sigma2); m_data->interior_line_start.clear (); @@ -410,7 +410,7 @@ FittingCurve2dASDM::assembleClosestPoints (const std::vector &elements, for (std::size_t i = 0; i < elements.size (); i++) { - int j = (i + 1) % int (elements.size ()); + int j = (i + 1) % static_cast(elements.size ()); double dxi = elements[j] - elements[i]; double xi = elements[i] + 0.5 * dxi; @@ -444,7 +444,7 @@ FittingCurve2dASDM::assembleClosestPoints (const std::vector &elements, if (m_data->closest_rho.size () != elements.size ()) { printf ("[FittingCurve2dASDM::assembleClosestPoints] ERROR: size does not match %d %d\n", - int (m_data->closest_rho.size ()), int (elements.size ())); + static_cast(m_data->closest_rho.size ()), static_cast(elements.size ())); } else { diff --git a/surface/src/on_nurbs/fitting_curve_2d_atdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_atdm.cpp index 8c66856a47e..10fe12c2c2e 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_atdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_atdm.cpp @@ -58,12 +58,12 @@ FittingCurve2dATDM::assemble (const FittingCurve2dAPDM::Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); // int nCommon = m_data->common.size(); // int nClosestP = parameter.closest_point_resolution; std::vector elements = getElementVector (m_nurbs); - int nClosestP = int (elements.size ()); + int nClosestP = static_cast(elements.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -189,7 +189,7 @@ FittingCurve2dATDM::addCageRegularisation (double weight, unsigned &row, const s { int i = j % ncp; - if (i >= int (m_data->closest_points_error.size () - 1)) + if (i >= static_cast(m_data->closest_points_error.size () - 1)) { printf ("[FittingCurve2dATDM::addCageRegularisation] Warning, index for closest_points_error out of bounds\n"); } @@ -235,7 +235,7 @@ FittingCurve2dATDM::addCageRegularisation (double weight, unsigned &row, const s void FittingCurve2dATDM::assembleInterior (double wInt, double sigma2, double rScale, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); bool wFunction (true); double ds = 1.0 / (2.0 * sigma2); m_data->interior_line_start.clear (); @@ -250,7 +250,7 @@ FittingCurve2dATDM::assembleInterior (double wInt, double sigma2, double rScale, double param; Eigen::Vector2d pt, t, n; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = findClosestElementMidPoint (m_nurbs, pcp, m_data->interior_param[p]); param = inverseMapping (m_nurbs, pcp, param, error, pt, t, rScale, in_max_steps, in_accuracy, m_quiet); @@ -279,10 +279,10 @@ FittingCurve2dATDM::assembleInterior (double wInt, double sigma2, double rScale, Eigen::Vector3d b (t (0), t (1), 0.0); Eigen::Vector3d z = a.cross (b); - if (p < int (m_data->interior_weight.size ())) + if (p < static_cast(m_data->interior_weight.size ())) wInt = m_data->interior_weight[p]; - if (p < int (m_data->interior_weight_function.size ())) + if (p < static_cast(m_data->interior_weight_function.size ())) wFunction = m_data->interior_weight_function[p]; double w (wInt); @@ -325,7 +325,7 @@ FittingCurve2dATDM::assembleClosestPoints (const std::vector &elements, for (std::size_t i = 0; i < elements.size (); i++) { - int j = i % int (elements.size ()); + int j = i % static_cast(elements.size ()); double dxi = elements[j] - elements[i]; double xi = elements[i] + 0.5 * dxi; diff --git a/surface/src/on_nurbs/fitting_curve_2d_pdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_pdm.cpp index 4310a8d4b34..0bc30e45ca6 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_pdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_pdm.cpp @@ -74,7 +74,7 @@ int FittingCurve2dPDM::findElement (double xi, const std::vector &elements) { if (xi >= elements.back ()) - return (int (elements.size ()) - 2); + return (static_cast(elements.size ()) - 2); for (std::size_t i = 0; i < elements.size () - 1; i++) { @@ -121,7 +121,7 @@ FittingCurve2dPDM::assemble (const Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -296,8 +296,8 @@ FittingCurve2dPDM::removeCPsOnLine (const ON_NurbsCurve &nurbs, double min_curve } int order = nurbs.Order (); - ON_NurbsCurve nurbs_opt = ON_NurbsCurve (2, false, order, int (cps.size ()) + 2 * cp_red); - nurbs_opt.MakePeriodicUniformKnotVector (1.0 / double (cps.size ())); + ON_NurbsCurve nurbs_opt = ON_NurbsCurve (2, false, order, static_cast(cps.size ()) + 2 * cp_red); + nurbs_opt.MakePeriodicUniformKnotVector (1.0 / static_cast(cps.size ())); nurbs_opt.m_knot[cp_red] = 0.0; nurbs_opt.m_knot[nurbs_opt.m_knot_capacity - cp_red - 1] = 1.0; @@ -372,7 +372,7 @@ FittingCurve2dPDM::initCPsNurbsCurve2D (int order, const vector_vec2d &cps) return nurbs; } - int ncps = int (cps.size ()) + 2 * cp_red; // +2*cp_red for smoothness and +1 for closing + int ncps = static_cast(cps.size ()) + 2 * cp_red; // +2*cp_red for smoothness and +1 for closing nurbs = ON_NurbsCurve (2, false, order, ncps); nurbs.MakePeriodicUniformKnotVector (1.0 / (ncps - order + 1)); @@ -380,7 +380,7 @@ FittingCurve2dPDM::initCPsNurbsCurve2D (int order, const vector_vec2d &cps) nurbs.SetCV (cp_red + j, ON_3dPoint (cps[j] (0), cps[j] (1), 0.0)); // close nurbs - nurbs.SetCV (cp_red + int (cps.size ()), ON_3dPoint (cps[0] (0), cps[0] (1), 0.0)); + nurbs.SetCV (cp_red + static_cast(cps.size ()), ON_3dPoint (cps[0] (0), cps[0] (1), 0.0)); // make smooth at closing point for (int j = 0; j < cp_red; j++) @@ -404,7 +404,7 @@ FittingCurve2dPDM::initNurbsCurve2D (int order, const vector_vec2d &data, int nc Eigen::Vector2d mean = NurbsTools::computeMean (data); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); double r (0.0); for (unsigned i = 0; i < s; i++) @@ -516,7 +516,7 @@ FittingCurve2dPDM::getElementVector (const ON_NurbsCurve &nurbs) void FittingCurve2dPDM::assembleInterior (double wInt, double rScale, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); m_data->interior_error.clear (); m_data->interior_normals.clear (); m_data->interior_line_start.clear (); @@ -530,7 +530,7 @@ FittingCurve2dPDM::assembleInterior (double wInt, double rScale, unsigned &row) double param; Eigen::Vector2d pt, t; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = findClosestElementMidPoint (m_nurbs, pcp, m_data->interior_param[p]); param = inverseMapping (m_nurbs, pcp, param, error, pt, t, rScale, in_max_steps, in_accuracy, m_quiet); @@ -545,7 +545,7 @@ FittingCurve2dPDM::assembleInterior (double wInt, double rScale, unsigned &row) m_data->interior_error.push_back (error); - if (p < int (m_data->interior_weight.size ())) + if (p < static_cast(m_data->interior_weight.size ())) wInt = m_data->interior_weight[p]; m_data->interior_line_start.push_back (pcp); diff --git a/surface/src/on_nurbs/fitting_curve_2d_sdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_sdm.cpp index a08b6faece8..60e109f549b 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_sdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_sdm.cpp @@ -59,7 +59,7 @@ FittingCurve2dSDM::assemble (const FittingCurve2dPDM::Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -211,7 +211,7 @@ FittingCurve2dSDM::addCageRegularisation (double weight, unsigned &row) void FittingCurve2dSDM::assembleInterior (double wInt, double rScale, unsigned &row) { - unsigned nInt = int (m_data->interior.size ()); + unsigned nInt = static_cast(m_data->interior.size ()); m_data->interior_line_start.clear (); m_data->interior_line_end.clear (); m_data->interior_error.clear (); diff --git a/surface/src/on_nurbs/fitting_curve_2d_tdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_tdm.cpp index e7b04cf3c11..88478b19fc0 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_tdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_tdm.cpp @@ -57,7 +57,7 @@ FittingCurve2dTDM::assemble (const FittingCurve2dPDM::Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -189,7 +189,7 @@ FittingCurve2dTDM::addCageRegularisation (double weight, unsigned &row) void FittingCurve2dTDM::assembleInterior (double wInt, double rScale, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); m_data->interior_line_start.clear (); m_data->interior_line_end.clear (); m_data->interior_error.clear (); @@ -202,7 +202,7 @@ FittingCurve2dTDM::assembleInterior (double wInt, double rScale, unsigned &row) double param; Eigen::Vector2d pt, t, n; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = findClosestElementMidPoint (m_nurbs, pcp, m_data->interior_param[p]); param = inverseMapping (m_nurbs, pcp, param, error, pt, t, rScale, in_max_steps, in_accuracy, m_quiet); @@ -227,7 +227,7 @@ FittingCurve2dTDM::assembleInterior (double wInt, double rScale, unsigned &row) n (1) = pointAndTangents[5]; n.normalize (); - if (p < int (m_data->interior_weight.size ())) + if (p < static_cast(m_data->interior_weight.size ())) wInt = m_data->interior_weight[p]; addPointConstraint (m_data->interior_param[p], m_data->interior[p], n, wInt, row); diff --git a/surface/src/on_nurbs/fitting_curve_pdm.cpp b/surface/src/on_nurbs/fitting_curve_pdm.cpp index 95ec19b1538..67e993ada8e 100644 --- a/surface/src/on_nurbs/fitting_curve_pdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_pdm.cpp @@ -74,7 +74,7 @@ int FittingCurve::findElement (double xi, const std::vector &elements) { if (xi >= elements.back ()) - return (int (elements.size ()) - 2); + return (static_cast(elements.size ()) - 2); for (std::size_t i = 0; i < elements.size () - 1; i++) { @@ -109,7 +109,7 @@ FittingCurve::assemble (const Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); int nrows = nInt + nCageReg; @@ -213,7 +213,7 @@ FittingCurve::initNurbsCurve2D (int order, const vector_vec2d &data) Eigen::Vector2d mean = NurbsTools::computeMean (data); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); double r (0.0); for (unsigned i = 0; i < s; i++) @@ -252,7 +252,7 @@ FittingCurve::initNurbsCurvePCA (int order, const vector_vec3d &data, int ncps, Eigen::Matrix3d eigenvectors; Eigen::Vector3d eigenvalues; - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); NurbsTools::pca (data, mean, eigenvectors, eigenvalues); @@ -312,7 +312,7 @@ FittingCurve::getElementVector (const ON_NurbsCurve &nurbs) void FittingCurve::assembleInterior (double wInt, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); m_data->interior_line_start.clear (); m_data->interior_line_end.clear (); m_data->interior_error.clear (); @@ -325,7 +325,7 @@ FittingCurve::assembleInterior (double wInt, unsigned &row) double param; Eigen::Vector3d pt, t; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = inverseMapping (m_nurbs, pcp, m_data->interior_param[p], error, pt, t, in_max_steps, in_accuracy); m_data->interior_param[p] = param; diff --git a/surface/src/on_nurbs/fitting_cylinder_pdm.cpp b/surface/src/on_nurbs/fitting_cylinder_pdm.cpp index 5f3b970df9a..bebcc2dcedc 100644 --- a/surface/src/on_nurbs/fitting_cylinder_pdm.cpp +++ b/surface/src/on_nurbs/fitting_cylinder_pdm.cpp @@ -136,7 +136,7 @@ FittingCylinder::assemble (double smoothness) { int cp_red = (m_nurbs.m_order[1] - 2); int ncp = m_nurbs.m_cv_count[0] * (m_nurbs.m_cv_count[1] - 2 * cp_red); - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); int nCageRegInt = (m_nurbs.m_cv_count[0] - 2) * (m_nurbs.m_cv_count[1] - 2 * cp_red); int nCageRegBnd = 2 * (m_nurbs.m_cv_count[1] - 2 * cp_red); @@ -224,7 +224,7 @@ FittingCylinder::initNurbsPCACylinder (int order, NurbsDataSurface *data) Eigen::Matrix3d eigenvectors; Eigen::Vector3d eigenvalues; - unsigned s = unsigned (data->interior.size ()); + auto s = static_cast(data->interior.size ()); NurbsTools::pca (data->interior, mean, eigenvectors, eigenvalues); @@ -289,7 +289,7 @@ FittingCylinder::initNurbsCylinderWithAxes (int order, NurbsDataSurface *data, E { Eigen::Vector3d mean; - unsigned s = unsigned (data->interior.size ()); + auto s = static_cast(data->interior.size ()); mean = NurbsTools::computeMean (data->interior); data->mean = mean; @@ -410,7 +410,7 @@ FittingCylinder::assembleInterior (double wInt, unsigned &row) m_data->interior_line_end.clear (); m_data->interior_error.clear (); m_data->interior_normals.clear (); - unsigned nInt = unsigned (m_data->interior.size ()); + auto nInt = static_cast(m_data->interior.size ()); for (unsigned p = 0; p < nInt; p++) { Vector3d pcp; diff --git a/surface/src/on_nurbs/fitting_sphere_pdm.cpp b/surface/src/on_nurbs/fitting_sphere_pdm.cpp index 296df348d4c..23ddcf9214e 100644 --- a/surface/src/on_nurbs/fitting_sphere_pdm.cpp +++ b/surface/src/on_nurbs/fitting_sphere_pdm.cpp @@ -83,7 +83,7 @@ FittingSphere::assemble (double smoothness) { int cp_red = (m_nurbs.m_order[1] - 2); int ncp = m_nurbs.m_cv_count[0] * (m_nurbs.m_cv_count[1] - 2 * cp_red); - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); int nCageRegInt = (m_nurbs.m_cv_count[0] - 2) * (m_nurbs.m_cv_count[1] - 2 * cp_red); int nCageRegBnd = 2 * (m_nurbs.m_cv_count[1] - 2 * cp_red); @@ -311,7 +311,7 @@ FittingSphere::assembleInterior (double wInt, unsigned &row) m_data->interior_line_end.clear (); m_data->interior_error.clear (); m_data->interior_normals.clear (); - unsigned nInt = unsigned (m_data->interior.size ()); + auto nInt = static_cast(m_data->interior.size ()); for (unsigned p = 0; p < nInt; p++) { Vector3d pcp; diff --git a/surface/src/on_nurbs/fitting_surface_im.cpp b/surface/src/on_nurbs/fitting_surface_im.cpp index f86d0d653f1..a2d0b2537c3 100644 --- a/surface/src/on_nurbs/fitting_surface_im.cpp +++ b/surface/src/on_nurbs/fitting_surface_im.cpp @@ -53,7 +53,7 @@ FittingSurfaceIM::computeMean () const u.y = 0.0; u.z = 0.0; - double ds = 1.0 / double (m_indices.size ()); + double ds = 1.0 / static_cast(m_indices.size ()); const pcl::PointCloud &cloud_ref = *m_cloud; for (const auto &index : m_indices) @@ -65,9 +65,9 @@ FittingSurfaceIM::computeMean () const if (std::isnan (point.x) || std::isnan (point.y) || std::isnan (point.z)) continue; - u.x += point.x * float (ds); - u.y += point.y * float (ds); - u.z += point.z * float (ds); + u.x += point.x * static_cast(ds); + u.y += point.y * static_cast(ds); + u.z += point.z * static_cast(ds); } return u; @@ -181,19 +181,19 @@ FittingSurfaceIM::refine () Eigen::Vector2d bbx (m_nurbs.Knot (0, 0), m_nurbs.Knot (0, m_nurbs.KnotCount (0) - 1)); Eigen::Vector2d bby (m_nurbs.Knot (1, 0), m_nurbs.Knot (1, m_nurbs.KnotCount (1) - 1)); - int dx = int (bbx (1) - bbx (0)); - int dy = int (bby (1) - bby (0)); - double ddx = double (dx) / (m_nurbs.CVCount (0) - 1); - double ddy = double (dy) / (m_nurbs.CVCount (1) - 1); + int dx = static_cast(bbx (1) - bbx (0)); + int dy = static_cast(bby (1) - bby (0)); + double ddx = static_cast(dx) / (m_nurbs.CVCount (0) - 1); + double ddy = static_cast(dy) / (m_nurbs.CVCount (1) - 1); m_cps_px.clear (); for (int i = 0; i < m_nurbs.CVCount (0); i++) { for (int j = 0; j < m_nurbs.CVCount (1); j++) { - int px = int (bbx (0) + ddx * i); - int py = int (bby (0) + ddy * j); - m_cps_px.push_back (Eigen::Vector2i (px, py)); + int px = static_cast(bbx (0) + ddx * i); + int py = static_cast(bby (0) + ddy * j); + m_cps_px.emplace_back(px, py); } } } @@ -244,10 +244,10 @@ FittingSurfaceIM::initSurface (int order, const Eigen::Vector4d &bb) { for (int j = 0; j < m_nurbs.Order (1); j++) { - int px = int (m_bb (0) + ddx * i + 0.5); - int py = int (m_bb (2) + ddy * j + 0.5); + int px = static_cast(m_bb (0) + ddx * i + 0.5); + int py = static_cast(m_bb (2) + ddy * j + 0.5); - m_cps_px.push_back (Eigen::Vector2i (px, py)); + m_cps_px.emplace_back(px, py); ON_3dPoint p; p.x = pt.z * (px - m_intrinsic (0, 2)) / m_intrinsic (0, 0); @@ -265,7 +265,7 @@ FittingSurfaceIM::initSurface (int order, const Eigen::Vector4d &bb) void FittingSurfaceIM::assemble (bool inverse_mapping) { - int nInt = int (m_indices.size ()); + int nInt = static_cast(m_indices.size ()); int nCageReg = (m_nurbs.m_cv_count[0] - 2) * (m_nurbs.m_cv_count[1] - 2); int nCageRegBnd = 2 * (m_nurbs.m_cv_count[0] - 1) + 2 * (m_nurbs.m_cv_count[1] - 1); @@ -296,8 +296,8 @@ FittingSurfaceIM::assemble (bool inverse_mapping) Eigen::Vector3d p, tu, tv; Eigen::Vector2d params1 (params (0), params (1)); params1 = inverseMapping (m_nurbs, point, params1, error, p, tu, tv, 200, 1e-6, true); - params (0) = int (params1 (0)); - params (1) = int (params1 (1)); + params (0) = static_cast(params1 (0)); + params (1) = static_cast(params1 (1)); } addPointConstraint (params, pt.z, 1.0, row); diff --git a/surface/src/on_nurbs/fitting_surface_pdm.cpp b/surface/src/on_nurbs/fitting_surface_pdm.cpp index 0fd07201d25..c57a20f22c6 100644 --- a/surface/src/on_nurbs/fitting_surface_pdm.cpp +++ b/surface/src/on_nurbs/fitting_surface_pdm.cpp @@ -282,7 +282,7 @@ FittingSurface::assembleInterior (double wInt, unsigned &row) m_data->interior_line_end.clear (); m_data->interior_error.clear (); m_data->interior_normals.clear (); - unsigned nInt = static_cast (m_data->interior.size ()); + auto nInt = static_cast (m_data->interior.size ()); for (unsigned p = 0; p < nInt; p++) { Vector3d &pcp = m_data->interior[p]; @@ -326,7 +326,7 @@ FittingSurface::assembleBoundary (double wBnd, unsigned &row) m_data->boundary_line_end.clear (); m_data->boundary_error.clear (); m_data->boundary_normals.clear (); - unsigned nBnd = static_cast (m_data->boundary.size ()); + auto nBnd = static_cast (m_data->boundary.size ()); for (unsigned p = 0; p < nBnd; p++) { Vector3d &pcp = m_data->boundary[p]; @@ -407,7 +407,7 @@ FittingSurface::initNurbsPCA (int order, NurbsDataSurface *m_data, Eigen::Vector Eigen::Matrix3d eigenvectors; Eigen::Vector3d eigenvalues; - unsigned s = static_cast (m_data->interior.size ()); + auto s = static_cast (m_data->interior.size ()); NurbsTools::pca (m_data->interior, mean, eigenvectors, eigenvalues); @@ -455,7 +455,7 @@ FittingSurface::initNurbsPCABoundingBox (int order, NurbsDataSurface *m_data, Ei Eigen::Matrix3d eigenvectors; Eigen::Vector3d eigenvalues; - unsigned s = static_cast (m_data->interior.size ()); + auto s = static_cast (m_data->interior.size ()); m_data->interior_param.clear (); NurbsTools::pca (m_data->interior, mean, eigenvectors, eigenvalues); @@ -479,7 +479,7 @@ FittingSurface::initNurbsPCABoundingBox (int order, NurbsDataSurface *m_data, Ei for (unsigned i = 0; i < s; i++) { Eigen::Vector3d p (eigenvectors_inv * (m_data->interior[i] - mean)); - m_data->interior_param.push_back (Eigen::Vector2d (p (0), p (1))); + m_data->interior_param.emplace_back(p (0), p (1)); if (p (0) > v_max (0)) v_max (0) = p (0); diff --git a/surface/src/on_nurbs/fitting_surface_tdm.cpp b/surface/src/on_nurbs/fitting_surface_tdm.cpp index fd71feb60de..fe2df537472 100644 --- a/surface/src/on_nurbs/fitting_surface_tdm.cpp +++ b/surface/src/on_nurbs/fitting_surface_tdm.cpp @@ -145,7 +145,7 @@ FittingSurfaceTDM::assembleInterior (double wInt, double wTangent, unsigned &row m_data->interior_line_end.clear (); m_data->interior_error.clear (); m_data->interior_normals.clear (); - unsigned nInt = static_cast (m_data->interior.size ()); + auto nInt = static_cast (m_data->interior.size ()); for (unsigned p = 0; p < nInt; p++) { Vector3d &pcp = m_data->interior[p]; @@ -190,7 +190,7 @@ FittingSurfaceTDM::assembleBoundary (double wBnd, double wTangent, unsigned &row m_data->boundary_line_end.clear (); m_data->boundary_error.clear (); m_data->boundary_normals.clear (); - unsigned nBnd = static_cast (m_data->boundary.size ()); + auto nBnd = static_cast (m_data->boundary.size ()); for (unsigned p = 0; p < nBnd; p++) { Vector3d &pcp = m_data->boundary[p]; diff --git a/surface/src/on_nurbs/global_optimization_pdm.cpp b/surface/src/on_nurbs/global_optimization_pdm.cpp index 079dc0726a1..d3875524ab8 100644 --- a/surface/src/on_nurbs/global_optimization_pdm.cpp +++ b/surface/src/on_nurbs/global_optimization_pdm.cpp @@ -78,7 +78,7 @@ GlobalOptimization::assemble (Parameter params) { // determine number of rows of matrix m_ncols = 0; - unsigned nnurbs = static_cast (m_nurbs.size ()); + auto nnurbs = static_cast (m_nurbs.size ()); unsigned nInt (0), nBnd (0), nCageRegInt (0), nCageRegBnd (0), nCommonBnd (0), nCommonPar (0); for (unsigned i = 0; i < nnurbs; i++) { @@ -413,7 +413,7 @@ GlobalOptimization::assembleBoundaryPoints (unsigned id, int ncps, double weight ON_NurbsSurface *nurbs = m_nurbs[id]; NurbsDataSurface *data = m_data[id]; - unsigned nBnd = static_cast (m_data[id]->boundary.size ()); + auto nBnd = static_cast (m_data[id]->boundary.size ()); // interior points should lie on surface data->boundary_line_start.clear (); diff --git a/surface/src/on_nurbs/global_optimization_tdm.cpp b/surface/src/on_nurbs/global_optimization_tdm.cpp index fa9bd21606d..a0ae969fbae 100644 --- a/surface/src/on_nurbs/global_optimization_tdm.cpp +++ b/surface/src/on_nurbs/global_optimization_tdm.cpp @@ -57,7 +57,7 @@ GlobalOptimizationTDM::assemble (Parameter params) { // determine number of rows of matrix m_ncols = 0; - unsigned nnurbs = static_cast (m_nurbs.size ()); + auto nnurbs = static_cast (m_nurbs.size ()); unsigned nInt (0), nBnd (0), nCageRegInt (0), nCageRegBnd (0), nCommonBnd (0); for (unsigned i = 0; i < nnurbs; i++) { @@ -127,7 +127,7 @@ GlobalOptimizationTDM::assemble (ParameterTDM params) { // determine number of rows of matrix m_ncols = 0; - unsigned nnurbs = static_cast (m_nurbs.size ()); + auto nnurbs = static_cast (m_nurbs.size ()); unsigned nInt (0), nBnd (0), nCageRegInt (0), nCageRegBnd (0), nCommonBnd (0), nCommonPar (0); for (unsigned i = 0; i < nnurbs; i++) { @@ -453,7 +453,7 @@ GlobalOptimizationTDM::assembleInteriorPoints (unsigned id, int ncps, double wei ON_NurbsSurface *nurbs = m_nurbs[id]; NurbsDataSurface *data = m_data[id]; - unsigned nInt = static_cast (m_data[id]->interior.size ()); + auto nInt = static_cast (m_data[id]->interior.size ()); // interior points should lie on surface data->interior_line_start.clear (); @@ -506,7 +506,7 @@ GlobalOptimizationTDM::assembleInteriorPointsTD (unsigned id, int ncps, double w ON_NurbsSurface *nurbs = m_nurbs[id]; NurbsDataSurface *data = m_data[id]; - unsigned nInt = static_cast (m_data[id]->interior.size ()); + auto nInt = static_cast (m_data[id]->interior.size ()); // interior points should lie on surface data->interior_line_start.clear (); @@ -560,7 +560,7 @@ GlobalOptimizationTDM::assembleBoundaryPoints (unsigned id, int ncps, double wei ON_NurbsSurface *nurbs = m_nurbs[id]; NurbsDataSurface *data = m_data[id]; - unsigned nBnd = static_cast (m_data[id]->boundary.size ()); + auto nBnd = static_cast (m_data[id]->boundary.size ()); // interior points should lie on surface data->boundary_line_start.clear (); diff --git a/surface/src/on_nurbs/nurbs_tools.cpp b/surface/src/on_nurbs/nurbs_tools.cpp index b429883ba4a..1da9b42d75b 100644 --- a/surface/src/on_nurbs/nurbs_tools.cpp +++ b/surface/src/on_nurbs/nurbs_tools.cpp @@ -57,12 +57,12 @@ NurbsTools::downsample_random (const vector_vec3d &data1, vector_vec3d &data2, u return; } - unsigned s = unsigned (data1.size ()); + auto s = static_cast(data1.size ()); data2.clear (); for (unsigned i = 0; i < size; i++) { - unsigned rnd = unsigned (s * (double (rand ()) / RAND_MAX)); + auto rnd = static_cast(s * (static_cast(rand ()) / RAND_MAX)); data2.push_back (data1[rnd]); } } @@ -73,13 +73,13 @@ NurbsTools::downsample_random (vector_vec3d &data, unsigned size) if (data.size () <= size && size > 0) return; - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); vector_vec3d data_tmp; for (unsigned i = 0; i < size; i++) { - unsigned rnd = unsigned ((s - 1) * (double (rand ()) / RAND_MAX)); + auto rnd = static_cast((s - 1) * (static_cast(rand ()) / RAND_MAX)); data_tmp.push_back (data[rnd]); } @@ -168,7 +168,7 @@ NurbsTools::computeMean (const vector_vec3d &data) { Eigen::Vector3d u (0.0, 0.0, 0.0); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); double ds = 1.0 / s; for (unsigned i = 0; i < s; i++) @@ -183,7 +183,7 @@ NurbsTools::computeMean (const vector_vec2d &data) Eigen::Vector2d u (0.0, 0.0); std::size_t s = data.size (); - double ds = 1.0 / double (s); + double ds = 1.0 / static_cast(s); for (std::size_t i = 0; i < s; i++) u += (data[i] * ds); @@ -197,7 +197,7 @@ NurbsTools::computeVariance (const Eigen::Vector3d &mean, const vector_vec3d &da Eigen::Vector3d var (0.0, 0.0, 0.0); std::size_t s = data.size (); - double ds = 1.0 / double (s); + double ds = 1.0 / static_cast(s); for (std::size_t i = 0; i < s; i++) { @@ -214,7 +214,7 @@ NurbsTools::computeVariance (const Eigen::Vector2d &mean, const vector_vec2d &da Eigen::Vector2d var (0.0, 0.0); std::size_t s = data.size (); - double ds = 1.0 / double (s); + double ds = 1.0 / static_cast(s); for (std::size_t i = 0; i < s; i++) { @@ -306,7 +306,7 @@ NurbsTools::pca (const vector_vec3d &data, Eigen::Vector3d &mean, Eigen::Matrix3 mean = computeMean (data); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); Eigen::MatrixXd Q (3, s); @@ -344,7 +344,7 @@ NurbsTools::pca (const vector_vec2d &data, Eigen::Vector2d &mean, Eigen::Matrix2 mean = computeMean (data); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); Eigen::MatrixXd Q (2, s); diff --git a/surface/src/on_nurbs/sequential_fitter.cpp b/surface/src/on_nurbs/sequential_fitter.cpp index 9cdb6bf2521..e9eeeb5d6f2 100644 --- a/surface/src/on_nurbs/sequential_fitter.cpp +++ b/surface/src/on_nurbs/sequential_fitter.cpp @@ -385,7 +385,7 @@ SequentialFitter::compute_boundary (const ON_NurbsSurface &nurbs) return nurbs; } - FittingSurface *fitting = new FittingSurface (&m_data, nurbs); + auto *fitting = new FittingSurface (&m_data, nurbs); this->compute_boundary (fitting); @@ -407,7 +407,7 @@ SequentialFitter::compute_interior (const ON_NurbsSurface &nurbs) printf ("[SequentialFitter::compute_interior] Warning, no interior points given: setInterior()\n"); return nurbs; } - FittingSurface *fitting = new FittingSurface (&m_data, nurbs); + auto *fitting = new FittingSurface (&m_data, nurbs); this->compute_interior (fitting); @@ -475,12 +475,12 @@ SequentialFitter::getClosestPointOnNurbs ( ON_NurbsSurface SequentialFitter::grow (float max_dist, float max_angle, unsigned min_length, unsigned max_length) { - unsigned num_bnd = unsigned (this->m_data.boundary_param.size ()); + auto num_bnd = static_cast(this->m_data.boundary_param.size ()); if (num_bnd == 0) throw std::runtime_error ("[SequentialFitter::grow] No boundary given."); - if (unsigned (this->m_data.boundary.size ()) != num_bnd) + if (static_cast(this->m_data.boundary.size ()) != num_bnd) { printf ("[SequentialFitter::grow] %zu %u\n", this->m_data.boundary.size (), num_bnd); throw std::runtime_error ("[SequentialFitter::grow] size of boundary and boundary parameters do not match."); @@ -544,14 +544,14 @@ SequentialFitter::grow (float max_dist, float max_angle, unsigned min_length, un pcl::PointXYZRGB point = m_cloud->at (this->m_boundary_indices->indices[i]); for (unsigned j = min_length; j < max_length; j++) { - int col = int (ri (0) + bni (0) * j); - int row = int (ri (1) + bni (1) * j); + int col = static_cast(ri (0) + bni (0) * j); + int row = static_cast(ri (1) + bni (1) * j); - if (row >= int (m_cloud->height) || row < 0) + if (row >= static_cast(m_cloud->height) || row < 0) { break; } - if (col >= int (m_cloud->width) || col < 0) + if (col >= static_cast(m_cloud->width) || col < 0) { break; } @@ -590,7 +590,7 @@ SequentialFitter::grow (float max_dist, float max_angle, unsigned min_length, un compute_interior (m_nurbs); double int_err (0.0); - double div_err = 1.0 / double (m_data.interior_error.size ()); + double div_err = 1.0 / static_cast(m_data.interior_error.size ()); for (const double &i : m_data.interior_error) { int_err += (i * div_err); @@ -615,7 +615,7 @@ SequentialFitter::PCL2ON (pcl::PointCloud::Ptr &pcl_cloud, con if (!std::isnan (pt.x) && !std::isnan (pt.y) && !std::isnan (pt.z)) { - on_cloud.push_back (Eigen::Vector3d (pt.x, pt.y, pt.z)); + on_cloud.emplace_back(pt.x, pt.y, pt.z); numPoints++; } diff --git a/surface/src/on_nurbs/sparse_mat.cpp b/surface/src/on_nurbs/sparse_mat.cpp index 3c429b04cea..6bf796dcd60 100644 --- a/surface/src/on_nurbs/sparse_mat.cpp +++ b/surface/src/on_nurbs/sparse_mat.cpp @@ -196,7 +196,7 @@ SparseMat::nonzeros () it_row = m_mat.begin (); while (it_row != m_mat.end ()) { - s += int (it_row->second.size ()); + s += static_cast(it_row->second.size ()); ++it_row; } diff --git a/surface/src/on_nurbs/triangulation.cpp b/surface/src/on_nurbs/triangulation.cpp index 86e31e8ddb8..609ef7a62f0 100644 --- a/surface/src/on_nurbs/triangulation.cpp +++ b/surface/src/on_nurbs/triangulation.cpp @@ -77,15 +77,15 @@ Triangulation::createVertices (pcl::PointCloud::Ptr &cloud, float float height, unsigned segX, unsigned segY) { pcl::PointXYZ v; - float dx = width / float (segX); - float dy = height / float (segY); + float dx = width / static_cast(segX); + float dy = height / static_cast(segY); for (unsigned j = 0; j <= segY; j++) { for (unsigned i = 0; i <= segX; i++) { - v.x = x0 + float (i) * dx; - v.y = y0 + float (j) * dy; + v.x = x0 + static_cast(i) * dx; + v.y = y0 + static_cast(j) * dy; v.z = z0; cloud->push_back (v); } @@ -181,7 +181,7 @@ Triangulation::convertSurface2PolygonMesh (const ON_NurbsSurface &nurbs, Polygon pcl::PointCloud::Ptr cloud (new pcl::PointCloud); mesh.polygons.clear (); - createVertices (cloud, float (x0), float (y0), 0.0f, float (w), float (h), resolution, resolution); + createVertices (cloud, static_cast(x0), static_cast(y0), 0.0f, static_cast(w), static_cast(h), resolution, resolution); createIndices (mesh.polygons, 0, resolution, resolution); for (auto &v : *cloud) @@ -189,9 +189,9 @@ Triangulation::convertSurface2PolygonMesh (const ON_NurbsSurface &nurbs, Polygon double point[9]; nurbs.Evaluate (v.x, v.y, 1, 3, point); - v.x = float (point[0]); - v.y = float (point[1]); - v.z = float (point[2]); + v.x = static_cast(point[0]); + v.y = static_cast(point[1]); + v.z = static_cast(point[2]); } toPCLPointCloud2 (*cloud, mesh.cloud); @@ -219,7 +219,7 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, pcl::PointCloud::Ptr cloud (new pcl::PointCloud); std::vector polygons; - createVertices (cloud, float (x0), float (y0), 0.0f, float (w), float (h), resolution, resolution); + createVertices (cloud, static_cast(x0), static_cast(y0), 0.0f, static_cast(w), static_cast(h), resolution, resolution); createIndices (polygons, 0, resolution, resolution); vector_vec2d points (cloud->size (), Eigen::Vector2d ()); @@ -290,8 +290,8 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, { pcl::PointXYZ &v = cloud->at (out_idx[i]); Eigen::Vector2d &pc = out_pc[i]; - v.x = float (pc (0)); - v.y = float (pc (1)); + v.x = static_cast(pc (0)); + v.y = static_cast(pc (1)); } for (auto &v : *cloud) @@ -299,9 +299,9 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, double point[3]; nurbs.Evaluate (v.x, v.y, 0, 3, point); - v.x = float (point[0]); - v.y = float (point[1]); - v.z = float (point[2]); + v.x = static_cast(point[0]); + v.y = static_cast(point[1]); + v.z = static_cast(point[2]); // tu[0] = point[3]; // tu[1] = point[4]; // tu[2] = point[5]; @@ -338,7 +338,7 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, pcl::PointCloud::Ptr cloud (new pcl::PointCloud); std::vector polygons; - createVertices (cloud, float (x0), float (y0), 0.0f, float (w), float (h), resolution, resolution); + createVertices (cloud, static_cast(x0), static_cast(y0), 0.0f, static_cast(w), static_cast(h), resolution, resolution); createIndices (polygons, 0, resolution, resolution); vector_vec2d points (cloud->size (), Eigen::Vector2d ()); @@ -375,8 +375,8 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, params[i] = param; pt_is_in[i] = (z (2) >= 0.0); - end.push_back (Eigen::Vector3d (pc (0), pc (1), 0.0)); - start.push_back (Eigen::Vector3d (vp (0), vp (1), 0.0)); + end.emplace_back(pc (0), pc (1), 0.0); + start.emplace_back(vp (0), vp (1), 0.0); } for (const auto &poly : polygons) @@ -414,8 +414,8 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, { pcl::PointXYZ &v = cloud->at (out_idx[i]); Eigen::Vector2d &pc = out_pc[i]; - v.x = float (pc (0)); - v.y = float (pc (1)); + v.x = static_cast(pc (0)); + v.y = static_cast(pc (1)); } for (auto &v : *cloud) @@ -423,9 +423,9 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, double point[3]; nurbs.Evaluate (v.x, v.y, 0, 3, point); - v.x = float (point[0]); - v.y = float (point[1]); - v.z = float (point[2]); + v.x = static_cast(point[0]); + v.y = static_cast(point[1]); + v.z = static_cast(point[2]); } for (std::size_t i = 0; i < start.size (); i++) @@ -469,7 +469,7 @@ Triangulation::convertSurface2Vertices (const ON_NurbsSurface &nurbs, pcl::Point double y1 = nurbs.Knot (1, nurbs.KnotCount (1) - 1); double h = y1 - y0; - createVertices (cloud, float (x0), float (y0), 0.0f, float (w), float (h), resolution, resolution); + createVertices (cloud, static_cast(x0), static_cast(y0), 0.0f, static_cast(w), static_cast(h), resolution, resolution); createIndices (vertices, 0, resolution, resolution); for (auto &v : *cloud) @@ -564,9 +564,9 @@ Triangulation::convertCurve2PointCloud (const ON_NurbsCurve &curve, const ON_Nur double pp[3]; curve.Evaluate (xi, 0, 2, pp); surf.Evaluate (pp[0], pp[1], 0, 3, p); - pt.x = float (p[0]); - pt.y = float (p[1]); - pt.z = float (p[2]); + pt.x = static_cast(p[0]); + pt.y = static_cast(p[1]); + pt.z = static_cast(p[2]); pt.r = 255; pt.g = 0; pt.b = 0; diff --git a/tracking/include/pcl/tracking/hsv_color_coherence.h b/tracking/include/pcl/tracking/hsv_color_coherence.h index 5d444db9407..c0ca4cb062e 100644 --- a/tracking/include/pcl/tracking/hsv_color_coherence.h +++ b/tracking/include/pcl/tracking/hsv_color_coherence.h @@ -20,13 +20,7 @@ class HSVColorCoherence : public PointCoherence { /** \brief initialize the weights of the computation. weight_, h_weight_, s_weight_ * default to 1.0 and v_weight_ defaults to 0.0. */ - HSVColorCoherence() - : PointCoherence() - , weight_(1.0) - , h_weight_(1.0) - , s_weight_(1.0) - , v_weight_(0.0) - {} + HSVColorCoherence() : PointCoherence() {} /** \brief set the weight of coherence * \param[in] weight the weight of coherence. @@ -101,16 +95,16 @@ class HSVColorCoherence : public PointCoherence { computeCoherence(PointInT& source, PointInT& target) override; /** \brief the weight of coherence (w) */ - double weight_; + double weight_{1.0}; /** \brief the hue weight (w_h) */ - double h_weight_; + double h_weight_{1.0}; /** \brief the saturation weight (w_s) */ - double s_weight_; + double s_weight_{1.0}; /** \brief the value weight (w_v) */ - double v_weight_; + double v_weight_{0.0}; }; } // namespace tracking } // namespace pcl diff --git a/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp b/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp index 29d0fc9b6f8..105e03832d4 100644 --- a/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp +++ b/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp @@ -196,7 +196,7 @@ PyramidalKLTTracker::derivatives(const FloatImage& src, ++trow0; float* trow1 = row1; ++trow1; - const float* src_ptr = &(src[0]); + const float* src_ptr = src.data(); for (int y = 0; y < height; y++) { const float* srow0 = src_ptr + (y > 0 ? y - 1 : height > 1 ? 1 : 0) * width; @@ -486,9 +486,9 @@ PyramidalKLTTracker::spatialGradient( covariance.setZero(); for (int y = 0; y < track_height_; y++) { - const float* img_ptr = &(img[0]) + (y + location[1]) * step + location[0]; - const float* grad_x_ptr = &(grad_x[0]) + (y + location[1]) * step + location[0]; - const float* grad_y_ptr = &(grad_y[0]) + (y + location[1]) * step + location[0]; + const float* img_ptr = img.data() + (y + location[1]) * step + location[0]; + const float* grad_x_ptr = grad_x.data() + (y + location[1]) * step + location[0]; + const float* grad_y_ptr = grad_y.data() + (y + location[1]) * step + location[0]; float* win_ptr = win.data() + y * win.cols(); float* grad_x_win_ptr = grad_x_win.data() + y * grad_x_win.cols(); @@ -527,7 +527,7 @@ PyramidalKLTTracker::mismatchVector( const int step = next.width; b.setZero(); for (int y = 0; y < track_height_; y++) { - const float* next_ptr = &(next[0]) + (y + location[1]) * step + location[0]; + const float* next_ptr = next.data() + (y + location[1]) * step + location[0]; const float* prev_ptr = prev.data() + y * prev.cols(); const float* prev_grad_x_ptr = prev_grad_x.data() + y * prev_grad_x.cols(); const float* prev_grad_y_ptr = prev_grad_y.data() + y * prev_grad_y.cols(); @@ -587,9 +587,9 @@ PyramidalKLTTracker::track( iprev_point[1] = std::floor(prev_pt[1]); if (iprev_point[0] < -track_width_ || - (std::uint32_t)iprev_point[0] >= grad_x.width || + static_cast(iprev_point[0]) >= grad_x.width || iprev_point[1] < -track_height_ || - (std::uint32_t)iprev_point[1] >= grad_y.height) { + static_cast(iprev_point[1]) >= grad_y.height) { if (level == 0) status[ptidx] = -1; continue; @@ -633,8 +633,10 @@ PyramidalKLTTracker::track( for (unsigned int j = 0; j < max_iterations_; j++) { Eigen::Array2i inext_pt = next_pt.floor().cast(); - if (inext_pt[0] < -track_width_ || (std::uint32_t)inext_pt[0] >= next.width || - inext_pt[1] < -track_height_ || (std::uint32_t)inext_pt[1] >= next.height) { + if (inext_pt[0] < -track_width_ || + static_cast(inext_pt[0]) >= next.width || + inext_pt[1] < -track_height_ || + static_cast(inext_pt[1]) >= next.height) { if (level == 0) status[ptidx] = -1; break; @@ -679,9 +681,9 @@ PyramidalKLTTracker::track( inext_point[1] = std::floor(next_point[1]); if (inext_point[0] < -track_width_ || - (std::uint32_t)inext_point[0] >= next.width || + static_cast(inext_point[0]) >= next.width || inext_point[1] < -track_height_ || - (std::uint32_t)inext_point[1] >= next.height) { + static_cast(inext_point[1]) >= next.height) { status[ptidx] = -1; continue; } diff --git a/tracking/include/pcl/tracking/pyramidal_klt.h b/tracking/include/pcl/tracking/pyramidal_klt.h index d5b44908355..bd651e30f92 100644 --- a/tracking/include/pcl/tracking/pyramidal_klt.h +++ b/tracking/include/pcl/tracking/pyramidal_klt.h @@ -85,8 +85,6 @@ class PyramidalKLTTracker : public Tracker { , nb_levels_(nb_levels) , track_width_(tracking_window_width) , track_height_(tracking_window_height) - , threads_(0) - , initialized_(false) { tracker_name_ = "PyramidalKLTTracker"; accuracy_ = 0.1; @@ -418,11 +416,11 @@ class PyramidalKLTTracker : public Tracker { float epsilon_; float max_residue_; /** \brief number of hardware threads */ - unsigned int threads_; + unsigned int threads_{0}; /** \brief intensity accessor */ IntensityT intensity_; /** \brief is the tracker initialized ? */ - bool initialized_; + bool initialized_{false}; /** \brief compute transformation from successfully tracked points */ pcl::TransformationFromCorrespondences transformation_computer_; /** \brief computed transformation between tracked points */ diff --git a/visualization/include/pcl/visualization/vtk/vtkFixedXRenderWindowInteractor.h b/visualization/include/pcl/visualization/vtk/vtkFixedXRenderWindowInteractor.h index 54bac8e7396..1065991b8af 100644 --- a/visualization/include/pcl/visualization/vtk/vtkFixedXRenderWindowInteractor.h +++ b/visualization/include/pcl/visualization/vtk/vtkFixedXRenderWindowInteractor.h @@ -36,8 +36,9 @@ #include "vtkRenderingUIModule.h" // For export macro #include // Needed for X types in the public interface -namespace pcl { class vtkCallbackCommand; + +namespace pcl { class vtkXRenderWindowInteractorInternals; class VTKRENDERINGUI_EXPORT vtkXRenderWindowInteractor : public vtkRenderWindowInteractor diff --git a/visualization/include/pcl/visualization/window.h b/visualization/include/pcl/visualization/window.h index 7db1e4331ed..65f82178905 100644 --- a/visualization/include/pcl/visualization/window.h +++ b/visualization/include/pcl/visualization/window.h @@ -47,9 +47,8 @@ template class vtkSmartPointer; class vtkObject; class vtkRenderWindow; class vtkRenderWindowInteractor; -class vtkCallbackCommand; class vtkRendererCollection; -class PCLVisualizerInteractorStyle; +class vtkCallbackCommand; namespace pcl { @@ -57,6 +56,7 @@ namespace pcl { class MouseEvent; class KeyboardEvent; + class PCLVisualizerInteractorStyle; class PCL_EXPORTS Window {