Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/PDAL/PDAL
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Mar 11, 2015
2 parents dda5b19 + 315d255 commit e2bf2e4
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 120 deletions.
39 changes: 10 additions & 29 deletions plugins/pcl/kernel/GroundKernel.cpp
Expand Up @@ -108,35 +108,16 @@ void GroundKernel::addSwitches()
addPositionalSwitch("output", 1);
}

std::shared_ptr<Stage> GroundKernel::makeReader(Options readerOptions)
{
if (isDebug())
{
readerOptions.add<bool>("debug", true);
uint32_t verbosity(getVerboseLevel());
if (!verbosity)
verbosity = 1;

readerOptions.add<uint32_t>("verbose", verbosity);
readerOptions.add<std::string>("log", "STDERR");
}

std::shared_ptr<Stage> stage = KernelSupport::makeReader(m_inputFile);
stage->setOptions(readerOptions);

return stage;
}

int GroundKernel::execute()
{
PointContext ctx;

Options readerOptions;
readerOptions.add<std::string>("filename", m_inputFile);
readerOptions.add<bool>("debug", isDebug());
readerOptions.add<uint32_t>("verbose", getVerboseLevel());
setCommonOptions(readerOptions);

std::unique_ptr<Stage> readerStage = makeReader(readerOptions);
Stage& readerStage(Kernel::makeReader(m_inputFile));
readerStage.setOptions(readerOptions);

Options groundOptions;
groundOptions.add<double>("maxWindowSize", m_maxWindowSize);
Expand All @@ -150,28 +131,28 @@ int GroundKernel::execute()
StageFactory f;
std::unique_ptr<Stage> groundStage(f.createStage("filters.ground"));
groundStage->setOptions(groundOptions);
groundStage->setInput(*readerStage);
groundStage->setInput(readerStage);

// setup the Writer and write the results
Options writerOptions;
writerOptions.add<std::string>("filename", m_outputFile);
setCommonOptions(writerOptions);

std::shared_ptr<Stage> writer(KernelSupport::makeWriter(m_outputFile, groundStage));
writer->setOptions(writerOptions);
Stage& writer(Kernel::makeWriter(m_outputFile, *groundStage));
writer.setOptions(writerOptions);

std::vector<std::string> cmd = getProgressShellCommand();
UserCallback *callback =
cmd.size() ? (UserCallback *)new ShellScriptCallback(cmd) :
(UserCallback *)new HeartbeatCallback();

writer->setUserCallback(callback);
writer.setUserCallback(callback);

for (const auto& pi: getExtraStageOptions())
{
std::string name = pi.first;
Options options = pi.second;
std::vector<std::shared_ptr<Stage> > stages = writer->findStage(name);
std::vector<Stage*> stages = writer.findStage(name);
for (const auto& s : stages)
{
Options opts = s->getOptions();
Expand All @@ -181,11 +162,11 @@ int GroundKernel::execute()
}
}

writer->prepare(ctx);
writer.prepare(ctx);

// process the data, grabbing the PointBufferSet for visualization of the
// resulting PointBuffer
PointBufferSet pbSetOut = writer->execute(ctx);
PointBufferSet pbSetOut = writer.execute(ctx);

if (isVisualize())
visualize(*pbSetOut.begin());
Expand Down
44 changes: 12 additions & 32 deletions plugins/pcl/kernel/PCLKernel.cpp
Expand Up @@ -96,42 +96,23 @@ void PCLKernel::addSwitches()
addPositionalSwitch("pcl", 1);
}

std::shared_ptr<Stage> PCLKernel::makeReader(Options readerOptions)
{
if (isDebug())
{
readerOptions.add<bool>("debug", true);
uint32_t verbosity(getVerboseLevel());
if (!verbosity)
verbosity = 1;

readerOptions.add<uint32_t>("verbose", verbosity);
readerOptions.add<std::string>("log", "STDERR");
}

std::shared_ptr<Stage> stage = KernelSupport::makeReader(m_inputFile);
stage->setOptions(readerOptions);

return stage;
}


int PCLKernel::execute()
{
PointContext ctx;

Options readerOptions;
readerOptions.add<std::string>("filename", m_inputFile);
readerOptions.add<bool>("debug", isDebug());
readerOptions.add<uint32_t>("verbose", getVerboseLevel());
setCommonOptions(readerOptions);

std::shared_ptr<Stage> readerStage = makeReader(readerOptions);
Stage& readerStage(Kernel::makeReader(m_inputFile));
readerStage.setOptions(readerOptions);

// go ahead and prepare/execute on reader stage only to grab input
// PointBufferSet, this makes the input PointBuffer available to both the
// processing pipeline and the visualizer
readerStage->prepare(ctx);
PointBufferSet pbSetIn = readerStage->execute(ctx);
readerStage.prepare(ctx);
PointBufferSet pbSetIn = readerStage.execute(ctx);

// the input PointBufferSet will be used to populate a BufferReader that is
// consumed by the processing pipeline
Expand All @@ -145,7 +126,7 @@ int PCLKernel::execute()
pclOptions.add<uint32_t>("verbose", getVerboseLevel());

std::shared_ptr<Stage> pclStage(new PCLBlock());
pclStage->setInput(bufferReader);
pclStage->setInput(*bufferReader);
pclStage->setOptions(pclOptions);

// the PCLBlock stage consumes the BufferReader rather than the
Expand All @@ -165,20 +146,19 @@ int PCLKernel::execute()
cmd.size() ? (UserCallback *)new ShellScriptCallback(cmd) :
(UserCallback *)new HeartbeatCallback();

std::shared_ptr<Stage>
writer(KernelSupport::makeWriter(m_outputFile, pclStage));
Stage& writer(Kernel::makeWriter(m_outputFile, *pclStage));

// Some options are inferred by makeWriter based on filename
// (compression, driver type, etc).
writer->setOptions(writerOptions+writer->getOptions());
writer.setOptions(writerOptions+writer.getOptions());

writer->setUserCallback(callback);
writer.setUserCallback(callback);

for (const auto& pi : getExtraStageOptions())
{
std::string name = pi.first;
Options options = pi.second;
std::vector<std::shared_ptr<Stage> > stages = writer->findStage(name);
std::vector<Stage *> stages = writer.findStage(name);
for (const auto& s : stages)
{
Options opts = s->getOptions();
Expand All @@ -188,11 +168,11 @@ int PCLKernel::execute()
}
}

writer->prepare(ctx);
writer.prepare(ctx);

// process the data, grabbing the PointBufferSet for visualization of the
// resulting PointBuffer
PointBufferSet pbSetOut = writer->execute(ctx);
PointBufferSet pbSetOut = writer.execute(ctx);

if (isVisualize())
visualize(*pbSetOut.begin());
Expand Down
1 change: 1 addition & 0 deletions plugins/pcl/kernel/PCLKernel.hpp
Expand Up @@ -52,6 +52,7 @@ class PDAL_DLL PCLKernel : public Kernel
void addSwitches();
void validateSwitches();

std::unique_ptr<PipelineManager> m_manager;
std::shared_ptr<Stage> makeReader(Options readerOptions);

std::string m_inputFile;
Expand Down
45 changes: 13 additions & 32 deletions plugins/pcl/kernel/SmoothKernel.cpp
Expand Up @@ -84,42 +84,23 @@ void SmoothKernel::addSwitches()
addPositionalSwitch("output", 1);
}

std::shared_ptr<Stage> SmoothKernel::makeReader(Options readerOptions)
{
if (isDebug())
{
readerOptions.add("debug", true);
uint32_t verbosity(getVerboseLevel());
if (!verbosity)
verbosity = 1;

readerOptions.add("verbose", verbosity);
readerOptions.add("log", "STDERR");
}

std::shared_ptr<Stage> stage = KernelSupport::makeReader(m_inputFile);
stage->setOptions(readerOptions);

return stage;
}


int SmoothKernel::execute()
{
PointContext ctx;

Options readerOptions;
readerOptions.add("filename", m_inputFile);
readerOptions.add("debug", isDebug());
readerOptions.add("verbose", getVerboseLevel());
setCommonOptions(readerOptions);

std::shared_ptr<Stage> readerStage = makeReader(readerOptions);
Stage& readerStage(Kernel::makeReader(m_inputFile));
readerStage.setOptions(readerOptions);

// go ahead and prepare/execute on reader stage only to grab input
// PointBufferSet, this makes the input PointBuffer available to both the
// processing pipeline and the visualizer
readerStage->prepare(ctx);
PointBufferSet pbSetIn = readerStage->execute(ctx);
readerStage.prepare(ctx);
PointBufferSet pbSetIn = readerStage.execute(ctx);

// the input PointBufferSet will be used to populate a BufferReader that is
// consumed by the processing pipeline
Expand All @@ -144,30 +125,30 @@ int SmoothKernel::execute()

std::shared_ptr<Stage> smoothStage(new PCLBlock());
smoothStage->setOptions(smoothOptions);
smoothStage->setInput(bufferReader);
smoothStage->setInput(*bufferReader);

Options writerOptions;
writerOptions.add("filename", m_outputFile);
setCommonOptions(writerOptions);

std::shared_ptr<Stage> writer(KernelSupport::makeWriter(m_outputFile, smoothStage));
writer->setOptions(writerOptions);
Stage& writer(Kernel::makeWriter(m_outputFile, *smoothStage));
writer.setOptions(writerOptions);

std::vector<std::string> cmd = getProgressShellCommand();
UserCallback *callback =
cmd.size() ? (UserCallback *)new ShellScriptCallback(cmd) :
(UserCallback *)new HeartbeatCallback();

writer->setUserCallback(callback);
writer.setUserCallback(callback);

std::map<std::string, Options> extra_opts = getExtraStageOptions();
std::map<std::string, Options>::iterator pi;
for (pi = extra_opts.begin(); pi != extra_opts.end(); ++pi)
{
std::string name = pi->first;
Options options = pi->second;
std::vector<std::shared_ptr<Stage> > stages = writer->findStage(name);
std::vector<std::shared_ptr<Stage> >::iterator s;
std::vector<Stage*> stages = writer.findStage(name);
std::vector<Stage*>::iterator s;
for (s = stages.begin(); s != stages.end(); ++s)
{
Options opts = (*s)->getOptions();
Expand All @@ -178,11 +159,11 @@ int SmoothKernel::execute()
}
}

writer->prepare(ctx);
writer.prepare(ctx);

// process the data, grabbing the PointBufferSet for visualization of the
// resulting PointBuffer
PointBufferSet pbSetOut = writer->execute(ctx);
PointBufferSet pbSetOut = writer.execute(ctx);

if (isVisualize())
visualize(*pbSetOut.begin());
Expand Down
31 changes: 6 additions & 25 deletions plugins/pcl/kernel/ViewKernel.cpp
Expand Up @@ -154,37 +154,18 @@ void ViewKernel::addSwitches()
addPositionalSwitch("input", 1);
}

std::shared_ptr<Stage> ViewKernel::makeReader(Options readerOptions)
{
if (isDebug())
{
readerOptions.add<bool>("debug", true);
uint32_t verbosity(getVerboseLevel());
if (!verbosity)
verbosity = 1;

readerOptions.add<uint32_t>("verbose", verbosity);
readerOptions.add<std::string>("log", "STDERR");
}

std::shared_ptr<Stage> stage(KernelSupport::makeReader(m_inputFile));
stage->setOptions(readerOptions);

return stage;
}


int ViewKernel::execute()
{
Options readerOptions;
readerOptions.add<std::string>("filename", m_inputFile);
readerOptions.add<bool>("debug", isDebug());
readerOptions.add<uint32_t>("verbose", getVerboseLevel());
setCommonOptions(readerOptions);

Stage& readerStage(Kernel::makeReader(m_inputFile));
readerStage.setOptions(readerOptions);

std::shared_ptr<Stage> readerStage(makeReader(readerOptions));
PointContext ctx;
readerStage->prepare(ctx);
PointBufferSet pbSetIn = readerStage->execute(ctx);
readerStage.prepare(ctx);
PointBufferSet pbSetIn = readerStage.execute(ctx);

PointBufferPtr buf = *pbSetIn.begin();
if (m_pointIndexes.size())
Expand Down
13 changes: 11 additions & 2 deletions src/Kernel.cpp
Expand Up @@ -419,10 +419,19 @@ void Kernel::addSwitchSet(po::options_description* options)

void Kernel::setCommonOptions(Options &options)
{
options.add("debug", m_isDebug);
options.add("verbose", m_verboseLevel);
options.add("visualize", m_visualize);

if (m_isDebug)
{
options.add("debug", true);
uint32_t verbosity(m_verboseLevel);
if (!verbosity)
verbosity = 1;

options.add("verbose", verbosity);
options.add("log", "STDERR");
}

boost::char_separator<char> sep(",| ");

if (m_variablesMap.count("scale"))
Expand Down

0 comments on commit e2bf2e4

Please sign in to comment.