| 95 | |
| 96 | |
| 97 | PointLayoutPtr Script::getStructLayout(mxArray* array, LogPtr log) |
| 98 | { |
| 99 | |
| 100 | PointLayoutPtr layout = PointLayoutPtr(new PointLayout()); |
| 101 | std::vector<mxArray*> arrays; |
| 102 | |
| 103 | mxClassID ml_id = mxGetClassID(array); |
| 104 | if (ml_id != mxSTRUCT_CLASS) |
| 105 | throw pdal::pdal_error("Selected array must be a Matlab struct array!"); |
| 106 | |
| 107 | |
| 108 | int numFields = mxGetNumberOfFields(array); |
| 109 | |
| 110 | if (!numFields) |
| 111 | throw pdal::pdal_error("Selected struct array must have fields!"); |
| 112 | |
| 113 | // This needs to skip mxClassID types that |
| 114 | // don't map to PDAL |
| 115 | for (int i=0; i < numFields; ++i) |
| 116 | { |
| 117 | const char* fieldName = mxGetFieldNameByNumber(array, i); |
| 118 | mxArray* f = mxGetFieldByNumber(array, 0, i); |
| 119 | mxClassID mt = mxGetClassID(f); |
| 120 | Dimension::Type pt = Script::getPDALDataType(mt); |
| 121 | if (mt == mxDOUBLE_CLASS || |
| 122 | mt == mxSINGLE_CLASS || |
| 123 | mt == mxINT8_CLASS || |
| 124 | mt == mxUINT8_CLASS || |
| 125 | mt == mxINT16_CLASS || |
| 126 | mt == mxUINT16_CLASS || |
| 127 | mt == mxINT32_CLASS || |
| 128 | mt == mxUINT32_CLASS || |
| 129 | mt == mxINT64_CLASS || |
| 130 | mt == mxUINT64_CLASS ) |
| 131 | { |
| 132 | layout->registerOrAssignDim(fieldName, pt); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | layout->finalize(); |
| 137 | return layout; |
| 138 | } |
| 139 | |
| 140 | |
| 141 | void Script::getMatlabStruct(mxArray* array, PointViewPtr view, const Dimension::IdList& indims, std::string& pdalargs, MetadataNode pdalmetadata, LogPtr log) |
nothing calls this directly
no test coverage detected