Skip to content

Commit

Permalink
matlab cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Jun 28, 2017
1 parent 23a0b2f commit 0abebe8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
5 changes: 2 additions & 3 deletions doc/stages/filters.matlab.rst
Expand Up @@ -69,8 +69,7 @@ source
add_dimension
The name of a dimension to add to the pipeline that does not already exist.

pdalargs
A JSON dictionary of items you wish to pass into the modules globals as the
``pdalargs`` object.
struct
Array structure name to read [OPTIONAL, defaults ``PDAL``]

.. _Matlab: https://www.mathworks.com/products/matlab.html
3 changes: 3 additions & 0 deletions doc/stages/writers.matlab.rst
Expand Up @@ -42,3 +42,6 @@ filename

output_dims
Dimensions to include in the output file [OPTIONAL, defaults to all available dimensions]

struct
Array structure name to read [OPTIONAL, defaults ``PDAL``]
18 changes: 6 additions & 12 deletions plugins/matlab/filters/MatlabFilter.cpp
Expand Up @@ -59,11 +59,8 @@ std::string MatlabFilter::getName() const { return s_info.name; }
void MatlabFilter::addArgs(ProgramArgs& args)
{
args.add("source", "Matlab script to run", m_script.m_source);
args.add("script", "File containing script to run", m_script.m_scriptFilename);
args.add("module", "Matlab module containing the function to run",
m_script.m_module);
args.add("function", "Function to call", m_script.m_function);
args.add("add_dimension", "Dimensions to add", m_addDimensions);
args.add("struct", "Matlab struct array to read", m_structName, "PDAL");
args.add("pdalargs", "Dictionary to add to module globals when calling function", m_pdalargs);
}

Expand All @@ -79,11 +76,6 @@ void MatlabFilter::ready(PointTableRef table)
{
if (m_script.m_source.empty())
m_script.m_source = FileUtils::readFileIntoString(m_script.m_scriptFilename);
// static_cast<plang::Environment*>(plang::Environment::get())->set_stdout(log()->getLogStream());
// m_script = new plang::Script(m_source, m_module, m_function);
// m_pythonMethod = new plang::Invocation(*m_script);
// m_pythonMethod->compile();
// m_totalMetadata = table.metadata();
}


Expand All @@ -102,17 +94,19 @@ PointViewSet MatlabFilter::run(PointViewPtr view)
Dimension::IdList dims;

mxArray* matlabData = mlang::Script::setMatlabStruct(view, dims, log());
if (engPutVariable(engine, "PDAL", matlabData))
if (engPutVariable(engine, m_structName.c_str(), matlabData))
{
throwError("Could not push PDAL struct to Matlab");
std::ostringstream oss;
oss << "Could not push '" << m_structName << "' struct to Matlab";
throwError(oss.str());
}

engEvalString(engine, m_script.m_source.c_str());

std::string noise(m_MatlabOutputBuffer.get(), strlen(m_MatlabOutputBuffer.get()));
log()->get(LogLevel::Debug) << "filters.matlab " << noise << std::endl;

matlabData = engGetVariable(engine, "PDAL");
matlabData = engGetVariable(engine, m_structName.c_str());
if (!matlabData)
throwError("No 'PDAL' variable is available in Matlab scope!");

Expand Down
1 change: 1 addition & 0 deletions plugins/matlab/filters/MatlabFilter.hpp
Expand Up @@ -71,6 +71,7 @@ class PDAL_DLL MatlabFilter : public Filter

MetadataNode m_totalMetadata;
Json::Value m_pdalargs;
std::string m_structName;

};

Expand Down
2 changes: 0 additions & 2 deletions plugins/matlab/filters/Script.hpp
Expand Up @@ -63,8 +63,6 @@ class PDAL_DLL Script

std::string m_source;
std::string m_scriptFilename;
std::string m_module;
std::string m_function;

private:

Expand Down

0 comments on commit 0abebe8

Please sign in to comment.