MCPcopy Create free account
hub / github.com/PDAL/PDAL / run

Method run

plugins/matlab/filters/MatlabFilter.cpp:83–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81
82
83PointViewSet MatlabFilter::run(PointViewPtr view)
84{
85 log()->get(LogLevel::Debug) << "filters.matlab " << m_script <<
86 " processing " << view->size() << " points." << std::endl;
87
88 int logBufferSize(4096);
89 std::unique_ptr<char[]> buf(new char[logBufferSize]);
90 m_MatlabOutputBuffer.swap(buf);
91
92 Engine* engine = mlang::Environment::get()->m_engine;
93 engOutputBuffer(engine, m_MatlabOutputBuffer.get(), logBufferSize);
94
95 Dimension::IdList dims;
96
97 mxArray* matlabData = mlang::Script::setMatlabStruct(view, dims, m_pdalargs, m_tableMetadata, log());
98 if (engPutVariable(engine, m_structName.c_str(), matlabData))
99 {
100 std::ostringstream oss;
101 oss << "Could not push '" << m_structName << "' struct to Matlab";
102 throwError(oss.str());
103 }
104
105 engEvalString(engine, m_script.m_source.c_str());
106
107 std::string noise(m_MatlabOutputBuffer.get(), strlen(m_MatlabOutputBuffer.get()));
108 log()->get(LogLevel::Debug) << "filters.matlab " << noise << std::endl;
109
110 matlabData = engGetVariable(engine, m_structName.c_str());
111 if (!matlabData)
112 throwError("No 'PDAL' variable is available in Matlab scope!");
113
114 PointViewSet viewSet;
115
116 std::string logicalDimensionName = m_script.getLogicalMask(matlabData, log());
117 if (logicalDimensionName.size())
118 {
119 PointViewPtr outview = view->makeNew();
120
121 mxArray* f = mxGetField(matlabData, 0, logicalDimensionName.c_str());
122 if (!f)
123 {
124 std::ostringstream oss;
125 oss << "Unable to fetch mask dimension '" << logicalDimensionName << "'";
126 throwError(oss.str());
127 }
128
129 mxLogical* logical = mxGetLogicals(f);
130 if (!logical)
131 {
132 std::ostringstream oss;
133 oss << "Unable to fetch logical mask for dimension '" << logicalDimensionName << "'";
134 throwError(oss.str());
135 }
136
137 char *ok = (char *)logical;
138 for (PointId idx = 0; idx < view->size(); ++idx)
139 if (*ok++)
140 outview->appendPoint(*view, idx);

Callers

nothing calls this directly

Calls 9

swapMethod · 0.80
strMethod · 0.80
getLogicalMaskMethod · 0.80
appendPointMethod · 0.80
logFunction · 0.50
getFunction · 0.50
getMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected