Last active
June 17, 2023 23:52
-
-
Save matlabbe/f3ba9366eb91e1b855dadd2ddce5746d to your computer and use it in GitHub Desktop.
Patch for PCL 1.11.1 to add vtk support in ios build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index e5aa7f40a..13fb3b874 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -370,7 +370,7 @@ endif() | |
# Find VTK | |
option(WITH_VTK "Build VTK-Visualizations" TRUE) | |
-if(WITH_VTK AND NOT ANDROID) | |
+if(WITH_VTK) | |
set(PCL_VTK_COMPONENTS | |
vtkChartsCore | |
vtkCommonCore | |
@@ -393,12 +393,25 @@ if(WITH_VTK AND NOT ANDROID) | |
vtkViewsContext2D | |
) | |
find_package(VTK COMPONENTS ${PCL_VTK_COMPONENTS}) | |
+ if(NOT VTK_FOUND AND APPLE) | |
+ # find vtk.framework | |
+ find_library(VTK_LIBRARY vtk) | |
+ MARK_AS_ADVANCED (VTK_LIBRARY) | |
+ IF(VTK_LIBRARY) | |
+ SET(VTK_FOUND true) | |
+ SET(VTK_LIBRARIES ${VTK_LIBRARY}) | |
+ SET(VTK_INCLUDE_DIRS ${VTK_LIBRARY}/Headers) | |
+ SET(VTK_MAJOR_VERSION 8) | |
+ SET(VTK_MINOR_VERSION 2) | |
+ SET(VTK_VERSION "8.2.0") | |
+ SET(VTK_RENDERING_BACKEND "OpenGL2") | |
+ ENDIF(VTK_LIBRARY) | |
+ endif(NOT VTK_FOUND AND APPLE) | |
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(VTK_FOUND AND WITH_QT) | |
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 | |
@@ -422,7 +435,7 @@ if(WITH_VTK AND NOT ANDROID) | |
if(VTK_USE_FILE) | |
include(${VTK_USE_FILE}) | |
endif() | |
- message(STATUS "VTK found (include: ${VTK_INCLUDE_DIRS}, libs: ${VTK_LIBRARIES}") | |
+ 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) | |
@@ -445,7 +458,6 @@ else() | |
set(VTK_FOUND OFF) | |
endif() | |
- | |
#Find PCAP | |
option(WITH_PCAP "pcap file capabilities in Velodyne HDL driver" TRUE) | |
if(WITH_PCAP) | |
diff --git a/PCLConfig.cmake.in b/PCLConfig.cmake.in | |
index 349ad7c4c..f0b7c9830 100644 | |
--- a/PCLConfig.cmake.in | |
+++ b/PCLConfig.cmake.in | |
@@ -246,12 +246,26 @@ macro(find_VTK) | |
else() | |
set(VTK_DIR "${PCL_ROOT}/3rdParty/VTK/lib/vtk-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@" CACHE PATH "The directory containing VTKConfig.cmake") | |
endif() | |
- elseif(NOT VTK_DIR AND NOT ANDROID) | |
- set(VTK_DIR "@VTK_DIR@" CACHE PATH "The directory containing VTKConfig.cmake") | |
+ elseif(NOT VTK_DIR)# AND NOT ANDROID) | |
+ set(VTK_DIR "@VTK_DIR@")# CACHE PATH "The directory containing VTKConfig.cmake") | |
endif() | |
- if(NOT ANDROID) | |
+ #if(NOT ANDROID) | |
find_package(VTK ${QUIET_} COMPONENTS ${PCL_VTK_COMPONENTS}) | |
- endif() | |
+ if(NOT VTK_FOUND AND APPLE) | |
+ # find vtk.framework | |
+ find_library(VTK_LIBRARY vtk) | |
+ MARK_AS_ADVANCED (VTK_LIBRARY) | |
+ IF(VTK_LIBRARY) | |
+ SET(VTK_FOUND true) | |
+ SET(VTK_LIBRARIES ${VTK_LIBRARY}) | |
+ SET(VTK_INCLUDE_DIRS ${VTK_LIBRARY}/Headers) | |
+ SET(VTK_MAJOR_VERSION 8) | |
+ SET(VTK_MINOR_VERSION 2) | |
+ SET(VTK_VERSION "8.2.0") | |
+ SET(VTK_RENDERING_BACKEND "OpenGL2") | |
+ ENDIF(VTK_LIBRARY) | |
+ endif(NOT VTK_FOUND AND APPLE) | |
+ #endif() | |
endmacro() | |
macro(find_libusb) | |
diff --git a/io/CMakeLists.txt b/io/CMakeLists.txt | |
index f23497100..2b12459a2 100644 | |
--- a/io/CMakeLists.txt | |
+++ b/io/CMakeLists.txt | |
@@ -179,22 +179,22 @@ if(LIBUSB_1_FOUND) | |
) | |
endif() | |
-if(VTK_FOUND AND NOT ANDROID) | |
- set(VTK_IO_INCLUDES | |
- "include/pcl/${SUBSYS_NAME}/vtk_lib_io.h" | |
- "include/pcl/${SUBSYS_NAME}/png_io.h" | |
- ) | |
- set(VTK_IO_INCLUDES_IMPL | |
- "include/pcl/${SUBSYS_NAME}/impl/vtk_lib_io.hpp" | |
- ) | |
- set(VTK_IO_SOURCE | |
- src/vtk_lib_io.cpp | |
- src/png_io.cpp | |
- ) | |
- set(VTK_IO_TARGET_LINK_LIBRARIES vtkCommon vtkWidgets vtkIO vtkImaging vtkHybrid vtkGraphics vtkRendering vtkFiltering vtkVolumeRendering) | |
+#if(VTK_FOUND AND NOT ANDROID) | |
+# set(VTK_IO_INCLUDES | |
+# "include/pcl/${SUBSYS_NAME}/vtk_lib_io.h" | |
+# "include/pcl/${SUBSYS_NAME}/png_io.h" | |
+# ) | |
+# set(VTK_IO_INCLUDES_IMPL | |
+# "include/pcl/${SUBSYS_NAME}/impl/vtk_lib_io.hpp" | |
+# ) | |
+# set(VTK_IO_SOURCE | |
+# src/vtk_lib_io.cpp | |
+# src/png_io.cpp | |
+# ) | |
+# set(VTK_IO_TARGET_LINK_LIBRARIES vtkCommon vtkWidgets vtkIO vtkImaging vtkHybrid vtkGraphics vtkRendering vtkFiltering vtkVolumeRendering) | |
# Indicates that we can rely on VTK to be present | |
- set(VTK_DEFINES -DPCL_BUILT_WITH_VTK) | |
-endif() | |
+# set(VTK_DEFINES -DPCL_BUILT_WITH_VTK) | |
+#endif() | |
set(PLY_SOURCES src/ply/ply_parser.cpp) | |
set(PLY_INCLUDES | |
@@ -228,6 +228,7 @@ set(srcs | |
src/auto_io.cpp | |
src/io_exception.cpp | |
${VTK_IO_SOURCE} | |
+ ${PLY_SOURCES} | |
${OPENNI_GRABBER_SOURCES} | |
${OPENNI2_GRABBER_SOURCES} | |
${IMAGE_SOURCES} | |
@@ -279,6 +280,7 @@ set(incs | |
"include/pcl/${SUBSYS_NAME}/point_cloud_image_extractors.h" | |
"include/pcl/${SUBSYS_NAME}/io_exception.h" | |
${VTK_IO_INCLUDES} | |
+ ${PLY_INCLUDES} | |
${OPENNI_GRABBER_INCLUDES} | |
${OPENNI2_GRABBER_INCLUDES} | |
${IMAGE_INCLUDES} | |
diff --git a/surface/CMakeLists.txt b/surface/CMakeLists.txt | |
index e5e423113..27e957d90 100644 | |
--- a/surface/CMakeLists.txt | |
+++ b/surface/CMakeLists.txt | |
@@ -28,7 +28,9 @@ if(QHULL_FOUND) | |
) | |
endif() | |
-if(VTK_FOUND AND NOT ANDROID) | |
+if(VTK_FOUND) | |
+ message(STATUS "Building with vtk_smoothing support! includes=${VTK_INCLUDE_DIRS}") | |
+ include_directories(${VTK_INCLUDE_DIRS}) | |
set(VTK_SMOOTHING_INCLUDES | |
"include/pcl/${SUBSYS_NAME}/vtk_smoothing/vtk.h" | |
"include/pcl/${SUBSYS_NAME}/vtk_smoothing/vtk_utils.h" | |
@@ -175,7 +177,7 @@ if(BUILD_surface_on_nurbs) | |
PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/on_nurbs" ${ON_NURBS_INCLUDES}) | |
endif() | |
-if(VTK_FOUND AND NOT ANDROID) | |
+if(VTK_FOUND) | |
PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/vtk_smoothing" ${VTK_SMOOTHING_INCLUDES}) | |
endif() | |
if(WIN32) | |
diff --git a/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp b/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp | |
index e8fae9698..6eaa55467 100644 | |
--- a/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp | |
+++ b/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp | |
@@ -251,9 +251,9 @@ namespace pcl | |
template<class T> | |
SparseMatrix<T>& SparseMatrix<T>::operator *= (const T& V) | |
{ | |
- for (int i=0; i<this->Rows(); i++) | |
+ for (int i=0; i<rows; i++) | |
{ | |
- for(int ii=0;ii<m_ppElements[i].size();i++){m_ppElements[i][ii].Value*=V;} | |
+ for(int ii=0;ii<rowSizes[i];ii++){m_ppElements[i][ii].Value*=V;} | |
} | |
return *this; | |
} | |
@@ -261,12 +261,12 @@ namespace pcl | |
template<class T> | |
SparseMatrix<T> SparseMatrix<T>::Multiply( const SparseMatrix<T>& M ) const | |
{ | |
- SparseMatrix<T> R( this->Rows(), M.Columns() ); | |
- for(int i=0; i<R.Rows(); i++){ | |
- for(int ii=0;ii<m_ppElements[i].size();ii++){ | |
+ SparseMatrix<T> R( rows, M._maxEntriesPerRow ); | |
+ for(int i=0; i<R.rows; i++){ | |
+ for(int ii=0;ii<rowSizes[i];ii++){ | |
int N=m_ppElements[i][ii].N; | |
T Value=m_ppElements[i][ii].Value; | |
- for(int jj=0;jj<M.m_ppElements[N].size();jj++){ | |
+ for(int jj=0;jj<M.rowSizes[N];jj++){ | |
R(i,M.m_ppElements[N][jj].N) += Value * M.m_ppElements[N][jj].Value; | |
} | |
} | |
@@ -320,11 +320,11 @@ namespace pcl | |
template<class T> | |
SparseMatrix<T> SparseMatrix<T>::Transpose() const | |
{ | |
- SparseMatrix<T> M( this->Columns(), this->Rows() ); | |
+ SparseMatrix<T> M( _maxEntriesPerRow, rows ); | |
- for (int i=0; i<this->Rows(); i++) | |
+ for (int i=0; i<rows; i++) | |
{ | |
- for(int ii=0;ii<m_ppElements[i].size();ii++){ | |
+ for(int ii=0;ii<rowSizes[i];ii++){ | |
M(m_ppElements[i][ii].N,i) = m_ppElements[i][ii].Value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment