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

Method setMatlabStruct

plugins/matlab/filters/Script.cpp:218–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218mxArray* Script::setMatlabStruct(PointViewPtr view, const Dimension::IdList& indims, const std::string& pdalargs, MetadataNode mdataNode, LogPtr log)
219{
220
221 std::vector<mxArray*> arrays;
222 std::vector<std::string> dimNames;
223
224 Dimension::IdList dims;
225 if (!indims.size())
226 dims = view->dims();
227 else
228 dims = indims;
229
230 mwSize mdims[2] = {0, 0};
231 mdims[0] = view->size();
232 mdims[1] = 1;
233
234 std::stringstream dimensionsString;
235 for (auto d: dims)
236 {
237 std::string dimName = Dimension::name(d);
238 mxArray* array = mxCreateNumericArray( 2,
239 mdims,
240 (mxClassID)mlang::Script::getMatlabDataType(view->dimType(d)),
241 (mxComplexity)0);
242 arrays.push_back(array);
243 dimNames.push_back(dimName);
244 }
245
246 // Matlab is column-major
247 for (size_t j = 0; j < dims.size(); ++j)
248 {
249 Dimension::Id id = dims[j];
250 Dimension::Type t = view->dimType(id);
251 mxArray* array = arrays[j];
252 char* pointsPtr = (char*)mxGetData(array);
253
254 for (point_count_t i = 0; i < view->size(); ++i)
255 {
256 view->getField(pointsPtr, id, t, i);
257 pointsPtr += view->dimSize(id);
258 }
259 }
260
261 // Push the dimension names into a char**
262 auto convert = [](std::string& s)
263 {
264 return s.c_str();
265 };
266 //
267 // Going into a 1x1 struct
268 mdims[0] = 1;
269 mdims[1] = 1;
270
271
272 std::vector<const char*> fieldNames;
273
274 // Metadata
275 //

Callers

nothing calls this directly

Calls 15

transformFunction · 0.85
toJSONFunction · 0.85
getFieldMethod · 0.80
dimSizeMethod · 0.80
strMethod · 0.80
getWKTMethod · 0.80
getHorizontalMethod · 0.80
getVerticalMethod · 0.80
nameFunction · 0.50
sizeMethod · 0.45
dimTypeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected