------------------------------------------------------------------------------
| 154 | |
| 155 | //------------------------------------------------------------------------------ |
| 156 | void vtkPDALReader::ReadPointRecordData(pdal::Stage& reader, vtkPolyData* pointsPolyData) |
| 157 | { |
| 158 | vtkNew<vtkPoints> points; |
| 159 | points->SetDataTypeToDouble(); |
| 160 | pointsPolyData->SetPoints(points); |
| 161 | pdal::PointTable table; |
| 162 | reader.prepare(table); |
| 163 | pdal::PointViewSet pointViewSet = reader.execute(table); |
| 164 | |
| 165 | // If ApplyOffset is true, try to read LAS header offsets from PDAL metadata |
| 166 | double ox = 0.0, oy = 0.0, oz = 0.0; |
| 167 | if (this->ApplyOffset) |
| 168 | { |
| 169 | auto offsets = this->GetLasOffsets(&reader); |
| 170 | ox = offsets[0]; |
| 171 | oy = offsets[1]; |
| 172 | oz = offsets[2]; |
| 173 | } |
| 174 | |
| 175 | pdal::PointViewPtr pointView = *pointViewSet.begin(); |
| 176 | points->SetNumberOfPoints(pointView->size()); |
| 177 | pdal::Dimension::IdList dims = pointView->dims(); |
| 178 | std::vector<vtkDoubleArray*> doubleArray(dims.size(), nullptr); |
| 179 | std::vector<vtkFloatArray*> floatArray(dims.size(), nullptr); |
| 180 | std::vector<vtkTypeUInt8Array*> uInt8Array(dims.size(), nullptr); |
| 181 | std::vector<vtkTypeUInt16Array*> uInt16Array(dims.size(), nullptr); |
| 182 | std::vector<vtkTypeUInt32Array*> uInt32Array(dims.size(), nullptr); |
| 183 | std::vector<vtkTypeUInt64Array*> uInt64Array(dims.size(), nullptr); |
| 184 | std::vector<vtkTypeInt8Array*> int8Array(dims.size(), nullptr); |
| 185 | std::vector<vtkTypeInt16Array*> int16Array(dims.size(), nullptr); |
| 186 | std::vector<vtkTypeInt32Array*> int32Array(dims.size(), nullptr); |
| 187 | std::vector<vtkTypeInt64Array*> int64Array(dims.size(), nullptr); |
| 188 | vtkTypeUInt16Array* colorArray = nullptr; |
| 189 | // check if we have a color field, and create the required array |
| 190 | bool hasCoords = false, hasColor = false, hasRed = false, hasGreen = false, hasBlue = false; |
| 191 | for (size_t i = 0; i < dims.size(); ++i) |
| 192 | { |
| 193 | pdal::Dimension::Id dimensionId = dims[i]; |
| 194 | switch (dimensionId) |
| 195 | { |
| 196 | case pdal::Dimension::Id::X: |
| 197 | case pdal::Dimension::Id::Y: |
| 198 | case pdal::Dimension::Id::Z: |
| 199 | hasCoords = true; |
| 200 | break; |
| 201 | case pdal::Dimension::Id::Red: |
| 202 | hasRed = true; |
| 203 | break; |
| 204 | case pdal::Dimension::Id::Green: |
| 205 | hasGreen = true; |
| 206 | break; |
| 207 | case pdal::Dimension::Id::Blue: |
| 208 | hasBlue = true; |
| 209 | break; |
| 210 | default: |
| 211 | continue; |
| 212 | } |
| 213 | } |
no test coverage detected