Skip to content

Commit

Permalink
PCL unit tests pass with a warning if PCL plugins are not installed -…
Browse files Browse the repository at this point in the history
… though we should still move PCL tests to the plugin folder
  • Loading branch information
chambbj committed Oct 20, 2014
1 parent 305f6bf commit 6fba905
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 52 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Expand Up @@ -269,15 +269,11 @@ endif(Boost_FOUND)
#------------------------------------------------------------------------------

option(WITH_PCL "Choose if PCL support should be built" FALSE)
option(WITH_PCL_VISUALIZE "Choose if PCL was built with VTK support for visualization" FALSE)
if(WITH_PCL)
find_package(PCL 1.7)
if(PCL_FOUND)
include_directories(${PCL_INCLUDE_DIRS})
set(PDAL_HAVE_PCL 1)
if(WITH_PCL_VISUALIZE)
set(PDAL_HAVE_PCL_VISUALIZE 1)
endif()
set(WITH_PCL_TEST 1)
# PCL's configuration clobbers Boost find_package - do it again
find_package(Boost 1.52 COMPONENTS program_options thread iostreams filesystem system unit_test_framework random)
Expand Down
1 change: 0 additions & 1 deletion pdal_defines.h.in
Expand Up @@ -38,7 +38,6 @@
#cmakedefine PDAL_HAVE_ORACLE
#cmakedefine PDAL_HAVE_P2G
#cmakedefine PDAL_HAVE_PCL
#cmakedefine PDAL_HAVE_PCL_VISUALIZE
#cmakedefine PDAL_HAVE_PYTHON
#cmakedefine PDAL_HAVE_SQLITE
#cmakedefine PDAL_HAVE_GREYHOUND
Expand Down
21 changes: 8 additions & 13 deletions plugins/pcl/CMakeLists.txt
Expand Up @@ -8,10 +8,9 @@
# This is because it's presence must still be known to several
# downstream files (keep reading).
#
# 2. pdal_defines.h.in is configured to broadcast PDAL_HAVE_PCL and
# PDAL_HAVE_PCL_VISUALIZATION.
# 2. pdal_defines.h.in is configured to broadcast PDAL_HAVE_PCL.
#
# As with #1, these are used downstream.
# As with #1, this used downstream.
#
# 3. src/pdal_config.cpp sets the PCL version in getVersionString(), which
# in turn requires pcl/pcl_config.h.
Expand All @@ -22,18 +21,14 @@
# two point buffers.
#
# This is currently disabled (commented out), and should be somehow
# fully integrated as a plugin behavior. When enabled, this is done
# conditionally if PDAL_HAVE_PCL_VISUALIZATION is set.
# fully integrated as a plugin behavior.
#
# 5. PCL is still linked into libpdalcpp via src/CMakeLists.txt.
# 5. PCL unit tests still live within main test directory.
#
# Conditional on PDAL_HAVE_PCL.
#
# 6. PCL unit tests still live within main test directory. We should be
# able to move plugin tests to plugin directories without too much
# hassle.
#
# Conditional on PDAL_HAVE_PCL.
# We should be able to move plugin tests to plugin directories without
# too much hassle. PCL unit tests will pass with a warning if the PCL
# plugins are not installed in PDAL_DRIVER_PATH (just assumes you didn't
# intend to test with PCL support).
#

include_directories(${PROJECT_SOURCE_DIR}/include)
Expand Down
4 changes: 0 additions & 4 deletions src/CMakeLists.txt
Expand Up @@ -794,10 +794,6 @@ if (WITH_PYTHON)
target_link_libraries(${PDAL_LIB_NAME} ${PDAL_LINKAGE} "${PYTHON_LIBRARY}")
endif()

#if (PDAL_HAVE_PCL)
# target_link_libraries(${PDAL_LIB_NAME} ${PDAL_LINKAGE} ${PCL_LIBRARIES})
#endif()

if (WITH_LIBXML2)
target_link_libraries(${PDAL_LIB_NAME} ${PDAL_LINKAGE} ${LIBXML2_LIBRARIES})
endif()
Expand Down
7 changes: 0 additions & 7 deletions src/kernel/Kernel.cpp
Expand Up @@ -46,13 +46,6 @@

#include <pdal/drivers/buffer/BufferReader.hpp>

//#ifdef PDAL_HAVE_PCL_VISUALIZE
//#include <boost/thread/thread.hpp>
//#include <pcl/io/pcd_io.h>
//#include <pcl/visualization/pcl_visualizer.h>
//#include <pdal/PCLConversions.hpp>
//#endif

#include <vector>

#include <boost/tokenizer.hpp>
Expand Down
19 changes: 10 additions & 9 deletions test/unit/CMakeLists.txt
Expand Up @@ -139,16 +139,17 @@ if (WITH_NITRO)
ENDFOREACH(file)
endif (WITH_NITRO)

if (WITH_PCL AND WITH_PCL_TEST)
set(PDAL_PCL_TEST_CPP
filters/PCLBlockFilterTest.cpp
)

FOREACH(file ${PDAL_PCL_TEST_CPP})
SET(PDAL_UNITTEST_TEST_SRC "${PDAL_UNITTEST_TEST_SRC};${file}"
CACHE INTERNAL "source files for test")
ENDFOREACH(file)
endif (WITH_PCL AND WITH_PCL_TEST)
# Removed WITH_PCL/WITH_PCL_TEST conditional - StageFactory now tests for PCL
# internally. This will eventually be moved to plugins/pcl/test.
set(PDAL_PCL_TEST_CPP
filters/PCLBlockFilterTest.cpp
)

FOREACH(file ${PDAL_PCL_TEST_CPP})
SET(PDAL_UNITTEST_TEST_SRC "${PDAL_UNITTEST_TEST_SRC};${file}"
CACHE INTERNAL "source files for test")
ENDFOREACH(file)

if (WITH_HDF5)
set(PDAL_ICEBRIDGE_TEST_CPP
Expand Down
34 changes: 20 additions & 14 deletions test/unit/filters/PCLBlockFilterTest.cpp
Expand Up @@ -45,24 +45,30 @@

BOOST_AUTO_TEST_SUITE(PCLBlockFilterTest)

#ifdef PDAL_HAVE_PCL

using namespace pdal;


BOOST_AUTO_TEST_CASE(PCLBlockFilterTest_example_passthrough_xml)
{
PipelineManager pipeline;
PipelineReader pipelineReader(pipeline);
pipelineReader.readPipeline(Support::datapath("filters/pcl/passthrough.xml"));
StageFactory f;
StageFactory::FilterCreator* fc = f.getFilterCreator("filters.pclblock");
if (fc)
{
BOOST_CHECK(fc);

PipelineManager pipeline;
PipelineReader pipelineReader(pipeline);
pipelineReader.readPipeline(Support::datapath("filters/pcl/passthrough.xml"));

pipeline.execute();
PointContext ctx = pipeline.context();
pipeline.execute();
PointContext ctx = pipeline.context();

PointBufferSet pbSet = pipeline.buffers();
BOOST_CHECK_EQUAL(pbSet.size(), 1);
PointBufferPtr buf = *pbSet.begin();
BOOST_CHECK_EQUAL(buf->size(), 81);
PointBufferSet pbSet = pipeline.buffers();
BOOST_CHECK_EQUAL(pbSet.size(), 1);
PointBufferPtr buf = *pbSet.begin();
BOOST_CHECK_EQUAL(buf->size(), 81);
}
BOOST_WARN_MESSAGE(fc, "PCLBlock Filter appears to be missing. Is it installed, with PDAL_DRIVER_PATH set?");
}


Expand Down Expand Up @@ -93,9 +99,10 @@ static void test_filter(const std::string& jsonFile,

StageFactory f;
StageFactory::FilterCreator* fc = f.getFilterCreator("filters.pclblock");
BOOST_CHECK(fc);
if (fc)
{
BOOST_CHECK(fc);

Stage* pcl_block = fc();
pcl_block->setOptions(filter_options);
pcl_block->setInput(&reader);
Expand All @@ -108,6 +115,7 @@ static void test_filter(const std::string& jsonFile,
PointBufferPtr buf = *pbSet.begin();
BOOST_CHECK_EQUAL(buf->size(), expectedPointCount);
}
BOOST_WARN_MESSAGE(fc, "PCLBlock Filter appears to be missing. Is it installed, with PDAL_DRIVER_PATH set?");
}


Expand Down Expand Up @@ -248,6 +256,4 @@ BOOST_AUTO_TEST_CASE(PCLBlockFilterTest_filter_VoxelGrid)
test_filter("filters/pcl/filter_VoxelGrid.json", 81);
}

#endif // PDAL_HAVE_PCL

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 6fba905

Please sign in to comment.