Skip to content

Commit

Permalink
add Kernel, KernelFactory, and KernelInfo, register kernel plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
chambbj committed Oct 17, 2014
1 parent 4e515a6 commit 4c1bb71
Show file tree
Hide file tree
Showing 31 changed files with 1,922 additions and 156 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,12 @@ option(WITH_PCL_VISUALIZE "Choose if PCL was built with VTK support for visualiz
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)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_definitions("-fvisibility-inlines-hidden")
# 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
64 changes: 30 additions & 34 deletions apps/pdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
* OF SUCH DAMAGE.
****************************************************************************/

#include <pdal/kernel/Kernel.hpp>
#include <pdal/kernel/Kernels.hpp>
#include <pdal/kernel/KernelFactory.hpp>
#include <pdal/pdal_config.hpp>

#include <boost/algorithm/string.hpp>
Expand All @@ -44,25 +45,24 @@ std::string headline("----------------------------------------------------------

void outputVersion()
{
pdal::KernelFactory f;

std::cout << headline << std::endl;
std::cout << "pdal " << "(" << pdal::GetFullVersionString() << ")" << std::endl;
std::cout << headline << std::endl;
std::cout << " available actions: " << std::endl;
std::cout << " - delta" << std::endl;
std::cout << " - diff" << std::endl;
//#ifdef PDAL_HAVE_PCL
// std::cout << " - ground" << std::endl;
//#endif
if (f.getKernelCreator("drivers.ground.kernel"))
std::cout << " - ground" << std::endl;
std::cout << " - info" << std::endl;
//#ifdef PDAL_HAVE_PCL
// std::cout << " - pcl" << std::endl;
//#endif
if (f.getKernelCreator("drivers.pcl.kernel"))
std::cout << " - pcl" << std::endl;
std::cout << " - pipeline" << std::endl;
std::cout << " - random" << std::endl;
std::cout << " - translate" << std::endl;
#ifdef PDAL_HAVE_PCL_VISUALIZE
std::cout << " - view" << std::endl;
#endif
if (f.getKernelCreator("drivers.view.kernel"))
std::cout << " - view" << std::endl;
std::cout << std::endl;
std::cout << "See http://pdal.io/apps.html for more detail";

Expand All @@ -73,6 +73,8 @@ void outputVersion()

int main(int argc, char* argv[])
{
pdal::KernelFactory f;

po::options_description options;
po::positional_options_description positional;
po::variables_map variables;
Expand Down Expand Up @@ -123,62 +125,56 @@ int main(int argc, char* argv[])

if (boost::iequals(action, "translate"))
{
pdal::kernel::Translate app(count, args);
return app.run();
pdal::kernel::Translate app;
return app.run(count, args, "translate");
}

if (boost::iequals(action, "info"))
{
pdal::kernel::Info app(count, args);
return app.run();
pdal::kernel::Info app;
return app.run(count, args, "info");
}

/*
#ifdef PDAL_HAVE_PCL
if (boost::iequals(action, "ground"))
{
pdal::kernel::Ground app(count, args);
return app.run();
pdal::Kernel* app = f.createKernel("drivers.ground.kernel");
return app->run(count, args, "ground");
}

if (boost::iequals(action, "pcl"))
{
pdal::kernel::PCL app(count, args);
return app.run();
pdal::Kernel* app = f.createKernel("drivers.pcl.kernel");
return app->run(count, args, "pcl");
}
#endif
*/

#ifdef PDAL_HAVE_PCL_VISUALIZE
if (boost::iequals(action, "view"))
{
pdal::kernel::View app(count, args);
return app.run();
pdal::Kernel* app = f.createKernel("drivers.view.kernel");
return app->run(count, args, "view");
}
#endif

if (boost::iequals(action, "pipeline"))
{
pdal::kernel::Pipeline app(count, args);
return app.run();
pdal::kernel::Pipeline app;
return app.run(count, args, "pipeline");
}

if (boost::iequals(action, "delta"))
{
pdal::kernel::Delta app(count, args);
return app.run();
pdal::kernel::Delta app;
return app.run(count, args, "delta");
}

if (boost::iequals(action, "diff"))
{
pdal::kernel::Diff app(count, args);
return app.run();
pdal::kernel::Diff app;
return app.run(count, args, "diff");
}

if (boost::iequals(action, "random"))
{
pdal::kernel::Random app(count, args);
return app.run();
pdal::kernel::Random app;
return app.run(count, args, "random");
}

std::cerr << "Action '" << action <<"' not recognized" << std::endl << std::endl;
Expand Down
13 changes: 6 additions & 7 deletions include/pdal/kernel/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
* OF SUCH DAMAGE.
****************************************************************************/

#ifndef INCLUDED_PDAL_KERNEL_APPLICATION_HPP
#define INCLUDED_PDAL_KERNEL_APPLICATION_HPP
#pragma once

#include <pdal/pdal_error.hpp>
#include <pdal/PDALUtils.hpp>
Expand Down Expand Up @@ -69,7 +68,7 @@ class PDAL_DLL Application
{
public:
// call this, to start the machine
int run();
int run(int argc, const char* argv[], const std::string& appName);

bool isDebug() const;
boost::uint32_t getVerboseLevel() const;
Expand All @@ -79,7 +78,8 @@ class PDAL_DLL Application

protected:
// this is protected; your derived class ctor will be the public entry point
Application(int argc, const char* argv[], const std::string& appName);
//Application(int argc, const char* argv[], const std::string& appName);
Application();
~Application();

// implement this, with calls to addOptionSet()
Expand Down Expand Up @@ -122,9 +122,9 @@ class PDAL_DLL Application
std::string m_showOptions;
bool m_showVersion;
bool m_showTime;
const int m_argc;
int m_argc;
const char** m_argv;
const std::string m_appName;
std::string m_appName;
bool m_hardCoreDebug;
std::vector<std::string> m_heartbeat_shell_command;
bool m_reportDebug;
Expand All @@ -149,4 +149,3 @@ class PDAL_DLL Application
};

}} // pdal::kernel
#endif
20 changes: 13 additions & 7 deletions include/pdal/kernel/Delta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
* OF SUCH DAMAGE.
****************************************************************************/

#ifndef INCLUDED_PDAL_KERNEL_DELTA_HPP
#define INCLUDED_PDAL_KERNEL_DELTA_HPP
#pragma once

#include <pdal/Stage.hpp>
#include <pdal/kernel/Kernel.hpp>
#include <pdal/FileUtils.hpp>
#include <pdal/PointBuffer.hpp>
#include <pdal/KDIndex.hpp>
Expand All @@ -51,7 +51,11 @@
#include <boost/accumulators/statistics/count.hpp>
#include <boost/accumulators/statistics/density.hpp>

#include "Application.hpp"
PDAL_C_START

PDAL_DLL void PDALRegister_kernel_delta(void* factory);

PDAL_C_END

namespace pdal { namespace kernel {

Expand Down Expand Up @@ -97,10 +101,14 @@ class PDAL_DLL Point
}
};

class PDAL_DLL Delta : public Application
class PDAL_DLL Delta : public Kernel
{
public:
Delta(int argc, const char* argv[]);
SET_KERNEL_NAME ("drivers.delta.kernel", "Delta Kernel")
SET_KERNEL_LINK ("http://pdal.io/kernels/drivers.delta.kernel.html")
SET_KERNEL_ENABLED (true)

Delta();
int execute(); // overrride

private:
Expand Down Expand Up @@ -133,5 +141,3 @@ class PDAL_DLL Delta : public Application
};

}} // pdal::kernel

#endif
19 changes: 12 additions & 7 deletions include/pdal/kernel/Diff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,32 @@
* OF SUCH DAMAGE.
****************************************************************************/

#ifndef INCLUDED_PDAL_KERNEL_DIFF_HPP
#define INCLUDED_PDAL_KERNEL_DIFF_HPP
#pragma once

#include <pdal/kernel/Kernel.hpp>
#include <pdal/Stage.hpp>
#include <pdal/FileUtils.hpp>
#include <pdal/PointBuffer.hpp>

#include <boost/property_tree/ptree.hpp>

PDAL_C_START

#include "Application.hpp"
PDAL_DLL void PDALRegister_kernel_diff(void* factory);

PDAL_C_END

namespace pdal { namespace kernel {


class PDAL_DLL Diff : public Application
class PDAL_DLL Diff : public Kernel
{
public:
Diff(int argc, const char* argv[]);
SET_KERNEL_NAME ("drivers.diff.kernel", "Diff Kernel")
SET_KERNEL_LINK ("http://pdal.io/kernels/drivers.diff.kernel.html")
SET_KERNEL_ENABLED (true)

Diff();
int execute(); // overrride


Expand All @@ -68,5 +75,3 @@ class PDAL_DLL Diff : public Application
};

}} // pdal::kernel

#endif
16 changes: 12 additions & 4 deletions include/pdal/kernel/Info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#pragma once

#include <pdal/Stage.hpp>
#include <pdal/kernel/Kernel.hpp>
#include <pdal/FileUtils.hpp>
#include <pdal/PointBuffer.hpp>
#include <pdal/filters/Stats.hpp>
Expand All @@ -50,18 +51,25 @@
#include <boost/tokenizer.hpp>

#include "Support.hpp"
#include "Application.hpp"


typedef boost::tokenizer<boost::char_separator<char> > tokenizer;

PDAL_C_START

PDAL_DLL void PDALRegister_kernel_info(void* factory);

PDAL_C_END

namespace pdal { namespace kernel {

class PDAL_DLL Info : public Application
class PDAL_DLL Info : public Kernel
{
public:
Info(int argc, const char* argv[]);
SET_KERNEL_NAME ("drivers.info.kernel", "Info Kernel")
SET_KERNEL_LINK ("http://pdal.io/kernels/drivers.info.kernel.html")
SET_KERNEL_ENABLED (true)

Info();
int execute(); // overrride

private:
Expand Down
Loading

0 comments on commit 4c1bb71

Please sign in to comment.