Skip to content

Commit

Permalink
Merge pull request #4262 from larshg/pr/n4096_VTK9.0
Browse files Browse the repository at this point in the history
Add support for VTK 9
  • Loading branch information
larshg authored Feb 16, 2021
2 parents 8416607 + a774332 commit e0a2e7b
Show file tree
Hide file tree
Showing 81 changed files with 1,125 additions and 646 deletions.
2 changes: 0 additions & 2 deletions 2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ set(impl_incs
)

if(${VTK_FOUND})
set(VTK_USE_FILE "${VTK_USE_FILE}" CACHE INTERNAL "VTK_USE_FILE")
include("${VTK_USE_FILE}")
set(VTK_IO_TARGET_LINK_LIBRARIES vtkCommon vtkWidgets vtkIO vtkImaging)
endif()

Expand Down
74 changes: 4 additions & 70 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,81 +366,15 @@ endif()
option(WITH_QT "Build QT Front-End" TRUE)
if(WITH_QT)
find_package(Qt5 COMPONENTS Concurrent OpenGL Widgets QUIET)
if(Qt5_FOUND)
message(STATUS "Found Qt5 version: ${Qt5_VERSION}")
endif()
endif()

# Find VTK
option(WITH_VTK "Build VTK-Visualizations" TRUE)
if(WITH_VTK AND NOT ANDROID)
set(PCL_VTK_COMPONENTS
vtkChartsCore
vtkCommonCore
vtkCommonDataModel
vtkCommonExecutionModel
vtkFiltersCore
vtkFiltersExtraction
vtkFiltersModeling
vtkImagingCore
vtkImagingSources
vtkInteractionStyle
vtkInteractionWidgets
vtkIOCore
vtkIOGeometry
vtkIOImage
vtkIOLegacy
vtkIOPLY
vtkRenderingAnnotation
vtkRenderingLOD
vtkViewsContext2D
)
find_package(VTK COMPONENTS ${PCL_VTK_COMPONENTS})
if(VTK_FOUND AND ("${VTK_VERSION}" VERSION_LESS 6.2))
message(WARNING "The minimum required version of VTK is 6.2, but found ${VTK_VERSION}")
set(VTK_FOUND FALSE)
endif()

if(VTK_FOUND)
if(NOT DEFINED VTK_RENDERING_BACKEND)
# On old VTK versions this variable does not exist. In this case it is
# safe to assume OpenGL backend
set(VTK_RENDERING_BACKEND "OpenGL")
endif()
list(APPEND PCL_VTK_COMPONENTS vtkRenderingContext${VTK_RENDERING_BACKEND})

if(WITH_QT)
if(";${VTK_MODULES_ENABLED};" MATCHES ";vtkGUISupportQt;" AND ";${VTK_MODULES_ENABLED};" MATCHES ";vtkRenderingQt;")
set(QVTK_FOUND ON)
list(APPEND PCL_VTK_COMPONENTS vtkRenderingQt vtkGUISupportQt)
else()
unset(QVTK_FOUND)
endif()
endif()

find_package(VTK COMPONENTS ${PCL_VTK_COMPONENTS})

message(STATUS "VTK_MAJOR_VERSION ${VTK_MAJOR_VERSION}, rendering backend: ${VTK_RENDERING_BACKEND}")
if(PCL_SHARED_LIBS OR (NOT (PCL_SHARED_LIBS) AND NOT (VTK_BUILD_SHARED_LIBS)))
if(VTK_USE_FILE)
include(${VTK_USE_FILE})
endif()
message(STATUS "VTK found (include: ${VTK_INCLUDE_DIRS}, libs: ${VTK_LIBRARIES}")
if(APPLE)
option(VTK_USE_COCOA "Use Cocoa for VTK render windows" ON)
mark_as_advanced(VTK_USE_COCOA)
endif()
if(${VTK_RENDERING_BACKEND} STREQUAL "OpenGL")
set(VTK_RENDERING_BACKEND_OPENGL_VERSION "1")
message(DEPRECATION "The rendering backend OpenGL is deprecated and not available anymore since VTK 8.2."
"Please switch to the OpenGL2 backend instead, which is available since VTK 6.2."
"Support of the deprecated backend will be dropped with PCL 1.13.")
elseif(${VTK_RENDERING_BACKEND} STREQUAL "OpenGL2")
set(VTK_RENDERING_BACKEND_OPENGL_VERSION "2")
endif()
else()
set(VTK_FOUND OFF)
message("Warning: You are to build PCL in STATIC but VTK is SHARED!")
message("Warning: VTK disabled!")
endif()
endif()
include("${PCL_SOURCE_DIR}/cmake/pcl_find_vtk.cmake")
else()
set(VTK_FOUND OFF)
endif()
Expand Down
1 change: 0 additions & 1 deletion apps/3d_rec_framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ if(NOT VTK_FOUND)
else()
set(DEFAULT TRUE)
set(REASON)
include("${VTK_USE_FILE}")
endif()

# OpenNI found?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#pragma once

#include <pcl/visualization/vtk/pcl_vtk_compatibility.h>

#include <vtkCellArray.h>
#include <vtkPLYReader.h>
#include <vtkPolyData.h>
Expand Down Expand Up @@ -72,7 +74,7 @@ randPSurface(vtkPolyData* polydata,

double A[3], B[3], C[3];
vtkIdType npts = 0;
vtkIdType* ptIds = nullptr;
vtkCellPtsPtr ptIds = nullptr;
polydata->GetCellPoints(el, npts, ptIds);

if (ptIds == nullptr)
Expand All @@ -96,7 +98,9 @@ uniform_sampling(const vtkSmartPointer<vtkPolyData>& polydata,
double p1[3], p2[3], p3[3], totalArea = 0;
std::vector<double> cumulativeAreas(cells->GetNumberOfCells(), 0);
std::size_t i = 0;
vtkIdType npts = 0, *ptIds = nullptr;
vtkIdType npts = 0;
vtkCellPtsPtr ptIds = nullptr;

for (cells->InitTraversal(); cells->GetNextCell(npts, ptIds); i++) {
polydata->GetPoint(ptIds[0], p1);
polydata->GetPoint(ptIds[1], p2);
Expand Down
48 changes: 33 additions & 15 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ if(LIBUSB_1_FOUND)
endif()

if(VTK_FOUND)
include("${VTK_USE_FILE}")

set(incs "include/pcl/${SUBSYS_NAME}/render_views_tesselated_sphere.h")
set(srcs "src/render_views_tesselated_sphere.cpp")

Expand All @@ -60,6 +58,10 @@ if(VTK_FOUND)
if(QHULL_FOUND)
PCL_ADD_EXECUTABLE(pcl_pcd_select_object_plane COMPONENT ${SUBSYS_NAME} SOURCES src/pcd_select_object_plane.cpp)
target_link_libraries(pcl_pcd_select_object_plane pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_features pcl_surface)
#TODO: Update when CMAKE 3.10 is available
if(NOT (${VTK_VERSION} VERSION_LESS 9.0))
target_link_libraries(pcl_pcd_select_object_plane VTK::FiltersGeometry)
endif()
endif()

PCL_ADD_EXECUTABLE(pcl_pcd_organized_edge_detection COMPONENT ${SUBSYS_NAME} SOURCES src/pcd_organized_edge_detection.cpp)
Expand All @@ -74,17 +76,25 @@ if(VTK_FOUND)
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)

if(Qt5_FOUND AND QVTK_FOUND)
if(Qt5_FOUND AND HAVE_QVTK)
# Manual registration demo
QT5_WRAP_UI(manual_registration_ui src/manual_registration/manual_registration.ui)
QT5_WRAP_CPP(manual_registration_moc include/pcl/apps/manual_registration.h OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
PCL_ADD_EXECUTABLE(pcl_manual_registration COMPONENT ${SUBSYS_NAME} SOURCES ${manual_registration_ui} ${manual_registration_moc} src/manual_registration/manual_registration.cpp BUNDLE)
target_link_libraries(pcl_manual_registration pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface Qt5::Widgets)
#TODO: Update when CMAKE 3.10 is available
if(NOT (${VTK_VERSION} VERSION_LESS 9.0))
target_link_libraries(pcl_manual_registration VTK::GUISupportQt)
endif()

QT5_WRAP_UI(pcd_video_player_ui src/pcd_video_player/pcd_video_player.ui)
QT5_WRAP_CPP(pcd_video_player_moc include/pcl/apps/pcd_video_player.h OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
PCL_ADD_EXECUTABLE(pcl_pcd_video_player COMPONENT ${SUBSYS_NAME} SOURCES ${pcd_video_player_ui} ${pcd_video_player_moc} src/pcd_video_player/pcd_video_player.cpp BUNDLE)
target_link_libraries(pcl_pcd_video_player pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface Qt5::Widgets)
#TODO: Update when CMAKE 3.10 is available
if(NOT (${VTK_VERSION} VERSION_LESS 9.0))
target_link_libraries(pcl_pcd_video_player VTK::GUISupportQt)
endif()
endif()

if(WITH_OPENNI)
Expand Down Expand Up @@ -138,18 +148,26 @@ 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 ${VTK_LIBRARIES})

if(Qt5_FOUND AND QVTK_FOUND)
# OpenNI Passthrough application demo
QT5_WRAP_UI(openni_passthrough_ui src/openni_passthrough.ui)
QT5_WRAP_CPP(openni_passthrough_moc include/pcl/apps/openni_passthrough.h OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
PCL_ADD_EXECUTABLE(pcl_openni_passthrough COMPONENT ${SUBSYS_NAME} SOURCES ${openni_passthrough_ui} ${openni_passthrough_moc} src/openni_passthrough.cpp)
target_link_libraries(pcl_openni_passthrough pcl_common pcl_io pcl_filters pcl_visualization Qt5::Widgets)

# OpenNI Organized Connected Component application demo
QT5_WRAP_UI(organized_segmentation_demo_ui src/organized_segmentation_demo.ui)
QT5_WRAP_CPP(organized_segmentation_demo_moc include/pcl/apps/organized_segmentation_demo.h OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
PCL_ADD_EXECUTABLE(pcl_organized_segmentation_demo COMPONENT ${SUBSYS_NAME} SOURCES ${organized_segmentation_demo_ui} ${organized_segmentation_demo_moc} src/organized_segmentation_demo.cpp BUNDLE)
target_link_libraries(pcl_organized_segmentation_demo pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface Qt5::Widgets)
if(Qt5_FOUND AND HAVE_QVTK)
# OpenNI Passthrough application demo
QT5_WRAP_UI(openni_passthrough_ui src/openni_passthrough.ui)
QT5_WRAP_CPP(openni_passthrough_moc include/pcl/apps/openni_passthrough.h OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
PCL_ADD_EXECUTABLE(pcl_openni_passthrough COMPONENT ${SUBSYS_NAME} SOURCES ${openni_passthrough_ui} ${openni_passthrough_moc} src/openni_passthrough.cpp)
target_link_libraries(pcl_openni_passthrough pcl_common pcl_io pcl_filters pcl_visualization Qt5::Widgets)
#TODO: Update when CMAKE 3.10 is available
if(NOT (${VTK_VERSION} VERSION_LESS 9.0))
target_link_libraries(pcl_openni_passthrough VTK::GUISupportQt)
endif()

# OpenNI Organized Connected Component application demo
QT5_WRAP_UI(organized_segmentation_demo_ui src/organized_segmentation_demo.ui)
QT5_WRAP_CPP(organized_segmentation_demo_moc include/pcl/apps/organized_segmentation_demo.h OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
PCL_ADD_EXECUTABLE(pcl_organized_segmentation_demo COMPONENT ${SUBSYS_NAME} SOURCES ${organized_segmentation_demo_ui} ${organized_segmentation_demo_moc} src/organized_segmentation_demo.cpp BUNDLE)
target_link_libraries(pcl_organized_segmentation_demo pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface Qt5::Widgets)
#TODO: Update when CMAKE 3.10 is available
if(NOT (${VTK_VERSION} VERSION_LESS 9.0))
target_link_libraries(pcl_organized_segmentation_demo VTK::GUISupportQt)
endif()
endif()

if(QHULL_FOUND)
Expand Down
14 changes: 10 additions & 4 deletions apps/cloud_composer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ if(NOT VTK_FOUND)
else()
set(DEFAULT TRUE)
set(REASON)
include("${VTK_USE_FILE}")
endif()

# QT5 Found?
Expand All @@ -27,7 +26,7 @@ elseif(NOT ${DEFAULT} STREQUAL "AUTO_OFF")
endif()

# QVTK?
if(NOT QVTK_FOUND)
if(NOT HAVE_QVTK)
set(DEFAULT AUTO_OFF)
set(REASON "Cloud composer requires QVTK")
elseif(NOT ${DEFAULT} STREQUAL "AUTO_OFF")
Expand All @@ -41,7 +40,7 @@ if("${DEFAULT}" STREQUAL "TRUE")
endif()

PCL_SUBSUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSUBSYS_NAME}" "${SUBSUBSYS_DESC}" ${DEFAULT} "${REASON}")
PCL_SUBSUBSYS_DEPEND(build "${SUBSYS_NAME}" "${SUBSUBSYS_NAME}" DEPS ${SUBSUBSYS_DEPS})
PCL_SUBSUBSYS_DEPEND(build "${SUBSYS_NAME}" "${SUBSUBSYS_NAME}" DEPS ${SUBSUBSYS_DEPS} EXT_DEPS vtk)

PCL_ADD_DOC(${SUBSUBSYS_NAME})

Expand Down Expand Up @@ -92,7 +91,14 @@ set(PCL_LIB_TYPE_ORIGIN ${PCL_LIB_TYPE})
set(PCL_LIB_TYPE STATIC)
QT5_WRAP_CPP(INTERFACE_HEADERS_MOC ${INTERFACE_HEADERS} OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
PCL_ADD_LIBRARY(pcl_cc_tool_interface COMPONENT ${SUBSUBSYS_NAME} SOURCES ${INTERFACE_HEADERS} ${INTERFACE_SOURCES} ${INTERFACE_HEADERS_MOC})
target_link_libraries(pcl_cc_tool_interface pcl_common pcl_filters pcl_search pcl_visualization ${VTK_LIBRARIES} Qt5::Widgets)

set(vtk_libs ${VTK_LIBRARIES})
#TODO: Update when CMAKE 3.10 is available
if (NOT (${VTK_VERSION} VERSION_LESS 9.0))
set(vtk_libs VTK::GUISupportQt)
endif()
target_link_libraries(pcl_cc_tool_interface pcl_common pcl_filters pcl_search pcl_visualization Qt5::Widgets ${vtk_libs})

set(PCL_LIB_TYPE ${PCL_LIB_TYPE_ORIGIN})

if(APPLE)
Expand Down
16 changes: 13 additions & 3 deletions apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@
#include <vtkEventQtSlotConnect.h>

#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/visualization/qvtk_compatibility.h>
#include <pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h>


#include <vtkSmartPointer.h>
#include <vtkOrientationMarkerWidget.h>
#include <vtkAxesActor.h>
#include <vtkVersion.h>

class QItemSelection;
class QStandardItem;

Expand All @@ -67,11 +74,12 @@ namespace pcl

void
setModel (ProjectModel* new_model);

ProjectModel*
getModel () const { return model_; }

QVTKWidget*
getQVTK() const {return qvtk_; }
PCLQVTKWidget*
getQVTK() const { return qvtk_; }

pcl::visualization::PCLVisualizer::Ptr
getPCLVisualizer () const { return vis_; }
Expand Down Expand Up @@ -141,7 +149,9 @@ namespace pcl

pcl::visualization::PCLVisualizer::Ptr vis_;
ProjectModel* model_;
QVTKWidget* qvtk_;

PCLQVTKWidget* qvtk_;

vtkSmartPointer<InteractorStyleSwitch> style_switch_;

vtkSmartPointer<vtkOrientationMarkerWidget> axes_widget_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@
#include <QDebug>

#include <pcl/apps/cloud_composer/items/cloud_composer_item.h>

#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/PCLPointCloud2.h>
#include <pcl/memory.h>
#include <pcl/pcl_macros.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/search/kdtree.h>
#include <pcl/visualization/point_cloud_geometry_handlers.h>
#include <pcl/visualization/point_cloud_color_handlers.h>
#include <pcl/visualization/pcl_visualizer.h>


//Typedefs to make things sane
using GeometryHandler = pcl::visualization::PointCloudGeometryHandler<pcl::PCLPointCloud2>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@
#include <pcl/features/fpfh.h>

#include <pcl/apps/cloud_composer/items/cloud_composer_item.h>
#include <pcl/visualization/qvtk_compatibility.h>
#include <pcl/visualization/pcl_plotter.h>

class QVTKWidget;

namespace pcl
{
namespace cloud_composer
Expand Down Expand Up @@ -74,7 +73,7 @@ namespace pcl
pcl::PointCloud<pcl::FPFHSignature33>::Ptr fpfh_ptr_;
double radius_;
pcl::visualization::PCLPlotter::Ptr plot_;
QVTKWidget *qvtk_;
PCLQVTKWidget* qvtk_;
QWidget *hist_page_;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

#include <pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h>

#include <vtkInteractorStyleTrackballActor.h>

namespace pcl
{
namespace cloud_composer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@

#include <QMap>

#include <pcl/visualization/vtk.h>
#include <pcl/visualization/interactor_style.h>
#include <pcl/visualization/common/actor_map.h>
#include <pcl/visualization/common/ren_win_interact_map.h>
#include <pcl/visualization/pcl_visualizer.h>

#include <vtkSmartPointer.h>
#include <vtkAreaPicker.h>
#include <vtkPointPicker.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCommand.h>
#include <vtkRendererCollection.h>
#include <vtkInteractorStyle.h>

class QVTKWidget;

namespace pcl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

#pragma once

#include <pcl/visualization/vtk.h>
#include <pcl/apps/cloud_composer/items/cloud_item.h>

namespace pcl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@

#include <pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h>

#include <vtkSmartPointer.h>
#include <vtkRendererCollection.h>
#include <vtkInteractorStyleRubberBandPick.h>

namespace pcl
{
namespace cloud_composer
Expand Down
Loading

0 comments on commit e0a2e7b

Please sign in to comment.