| 106 | } |
| 107 | |
| 108 | int vtkPDALReader::RequestData(vtkInformation* vtkNotUsed(request), |
| 109 | vtkInformationVector** vtkNotUsed(request), vtkInformationVector* outputVector) |
| 110 | { |
| 111 | try |
| 112 | { |
| 113 | // Get the info object |
| 114 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 115 | |
| 116 | // Get the output |
| 117 | vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 118 | |
| 119 | pdal::StageFactory factory; |
| 120 | std::string driverName = pdal::StageFactory::inferReaderDriver(this->FileName); |
| 121 | if (driverName.empty()) |
| 122 | { |
| 123 | vtkErrorMacro("Cannot infer the reader driver for " << this->FileName); |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | pdal::Option opt_filename("filename", this->FileName); |
| 128 | pdal::Options opts; |
| 129 | opts.add(opt_filename); |
| 130 | pdal::Stage* reader = factory.createStage(driverName); |
| 131 | if (!reader) |
| 132 | { |
| 133 | vtkErrorMacro("Cannot open file " << this->FileName); |
| 134 | return 0; |
| 135 | } |
| 136 | reader->setOptions(opts); |
| 137 | |
| 138 | vtkNew<vtkPolyData> pointsPolyData; |
| 139 | this->ReadPointRecordData(*reader, pointsPolyData); |
| 140 | |
| 141 | // Convert points to verts in output polydata |
| 142 | vtkNew<vtkVertexGlyphFilter> vertexFilter; |
| 143 | vertexFilter->SetInputData(pointsPolyData); |
| 144 | vertexFilter->Update(); |
| 145 | output->ShallowCopy(vertexFilter->GetOutput()); |
| 146 | return VTK_OK; |
| 147 | } |
| 148 | catch (const pdal::pdal_error& e) |
| 149 | { |
| 150 | vtkErrorMacro(<< "PDAL error: " << e.what()); |
| 151 | } |
| 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | //------------------------------------------------------------------------------ |
| 156 | void vtkPDALReader::ReadPointRecordData(pdal::Stage& reader, vtkPolyData* pointsPolyData) |
nothing calls this directly
no test coverage detected