Skip to content

Instantly share code, notes, and snippets.

@matlabbe
Last active January 4, 2022 03:31
Show Gist options
  • Save matlabbe/41812e50e459b2f27b331a2343569e5d to your computer and use it in GitHub Desktop.
Save matlabbe/41812e50e459b2f27b331a2343569e5d to your computer and use it in GitHub Desktop.
Patch for PCL 1.8.0 to add vtk support in android build
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e5fd763e3..49472ce66 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -358,7 +358,7 @@ endif(WITH_QT)
# Find VTK
option(WITH_VTK "Build VTK-Visualizations" TRUE)
-if(WITH_VTK AND NOT ANDROID)
+if(WITH_VTK)
find_package(VTK)
if(VTK_FOUND)
if(NOT DEFINED VTK_RENDERING_BACKEND)
@@ -395,10 +395,10 @@ if(WITH_VTK AND NOT ANDROID)
message ("Warning: VTK disabled!")
endif ()
endif(VTK_FOUND)
-else(WITH_VTK AND NOT ANDROID)
+else(WITH_VTK)
set(VTK_FOUND OFF)
set(HAVE_VTK OFF)
-endif(WITH_VTK AND NOT ANDROID)
+endif(WITH_VTK)
#Find PCAP
diff --git a/PCLConfig.cmake.in b/PCLConfig.cmake.in
index 994d20e5d..5936ebd76 100644
--- a/PCLConfig.cmake.in
+++ b/PCLConfig.cmake.in
@@ -459,15 +459,15 @@ macro(find_VTK)
else()
set(VTK_DIR "${PCL_ROOT}/3rdParty/VTK/lib/vtk-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@")
endif()
- elseif(NOT VTK_DIR AND NOT ANDROID)
- set(VTK_DIR "@VTK_DIR@")
- endif(PCL_ALL_IN_ONE_INSTALLER AND NOT ANDROID)
- if(NOT ANDROID)
+ elseif(NOT VTK_DIR)# AND NOT ANDROID)
+ set(VTK_DIR "@VTK_DIR@")# CACHE PATH "The directory containing VTKConfig.cmake")
+ endif()
+ #if(NOT ANDROID)
find_package(VTK ${QUIET_})
if (VTK_FOUND)
set(VTK_LIBRARIES "@VTK_LIBRARIES@")
endif(VTK_FOUND)
- endif()
+ #endif()
endmacro(find_VTK)
macro(find_libusb)
diff --git a/common/include/pcl/common/impl/bivariate_polynomial.hpp b/common/include/pcl/common/impl/bivariate_polynomial.hpp
index 5a979d8ad..7099e8ea1 100644
--- a/common/include/pcl/common/impl/bivariate_polynomial.hpp
+++ b/common/include/pcl/common/impl/bivariate_polynomial.hpp
@@ -267,7 +267,7 @@ pcl::operator<< (std::ostream& os, const pcl::BivariatePolynomialT<real>& p)
template<typename real> void
pcl::BivariatePolynomialT<real>::writeBinary (std::ostream& os) const
{
- os.write (reinterpret_cast<char*> (&degree), sizeof (int));
+ os.write (reinterpret_cast<const char*> (&degree), sizeof (int));
unsigned int paramCnt = getNoOfParametersFromDegree (this->degree);
os.write (reinterpret_cast<char*> (this->parameters), paramCnt * sizeof (real));
}
diff --git a/io/CMakeLists.txt b/io/CMakeLists.txt
index c10be950b..43cf7c087 100644
--- a/io/CMakeLists.txt
+++ b/io/CMakeLists.txt
@@ -218,6 +218,7 @@ if(build)
src/auto_io.cpp
src/io_exception.cpp
${VTK_IO_SOURCE}
+ ${PLY_SOURCES}
${OPENNI_GRABBER_SOURCES}
${OPENNI2_GRABBER_SOURCES}
${IMAGE_SOURCES}
@@ -266,6 +267,7 @@ if(build)
"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/segmentation/include/pcl/segmentation/plane_coefficient_comparator.h b/segmentation/include/pcl/segmentation/plane_coefficient_comparator.h
index 9c9481372..23d5b0aff 100644
--- a/segmentation/include/pcl/segmentation/plane_coefficient_comparator.h
+++ b/segmentation/include/pcl/segmentation/plane_coefficient_comparator.h
@@ -141,7 +141,7 @@ namespace pcl
const std::vector<float>&
getPlaneCoeffD () const
{
- return (plane_coeff_d_);
+ return *(plane_coeff_d_);
}
/** \brief Set the tolerance in radians for difference in normal direction between neighboring points, to be considered part of the same plane.
diff --git a/surface/CMakeLists.txt b/surface/CMakeLists.txt
index 9e35440f1..53152df88 100644
--- a/surface/CMakeLists.txt
+++ b/surface/CMakeLists.txt
@@ -25,7 +25,8 @@ if(build)
)
endif(QHULL_FOUND)
- if (VTK_FOUND AND NOT ANDROID)
+ if (VTK_FOUND)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(VTK_USE_FILE "${VTK_USE_FILE}" CACHE INTERNAL "VTK_USE_FILE")
include("${VTK_USE_FILE}")
@@ -175,9 +176,9 @@ if(build)
PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/on_nurbs" ${ON_NURBS_INCLUDES})
endif(BUILD_surface_on_nurbs)
- if (VTK_FOUND AND NOT ANDROID)
+ if (VTK_FOUND)
PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/vtk_smoothing" ${VTK_SMOOTHING_INCLUDES})
- endif (VTK_FOUND AND NOT ANDROID)
+ endif (VTK_FOUND)
if(WIN32)
target_link_libraries("${LIB_NAME}" Rpcrt4.lib)
endif(WIN32)
diff --git a/surface/src/vtk_smoothing/vtk_utils.cpp b/surface/src/vtk_smoothing/vtk_utils.cpp
index ed8dc770e..f575a2817 100644
--- a/surface/src/vtk_smoothing/vtk_utils.cpp
+++ b/surface/src/vtk_smoothing/vtk_utils.cpp
@@ -49,6 +49,11 @@
#include <vtkPointData.h>
#include <vtkFloatArray.h>
+#ifdef vtkGenericDataArray_h
+#define SetTupleValue SetTypedTuple
+#define InsertNextTupleValue InsertNextTypedTuple
+#define GetTupleValue GetTypedTuple
+#endif
//////////////////////////////////////////////////////////////////////////////////////////////
int
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment