| 243 | } |
| 244 | |
| 245 | int RequestData(vtkInformation* vtkNotUsed(request), vtkInformationVector** inputVector, |
| 246 | vtkInformationVector* outputVector) override |
| 247 | { |
| 248 | const double lineDistance = |
| 249 | std::sqrt(vtkMath::Distance2BetweenPoints(this->P1.GetData(), this->P2.GetData())); |
| 250 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 251 | vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 252 | |
| 253 | // Iterate on all inputs to : |
| 254 | // - construct the array of valid inputs |
| 255 | // - compute the total number of input points |
| 256 | // - construct the structure of point data |
| 257 | size_t totalNumberOfPoints = 0; |
| 258 | std::vector<vtkPolyData*> inputs; |
| 259 | std::vector<vtkDoubleArray*> lengthArrays; |
| 260 | vtkNew<vtkPointData> outputPD; |
| 261 | for (int cc = 0; cc < inputVector[0]->GetNumberOfInformationObjects(); cc++) |
| 262 | { |
| 263 | vtkPolyData* input = vtkPolyData::GetData(inputVector[0], cc); |
| 264 | auto* inputPd = input->GetPointData(); |
| 265 | auto* arclength = vtkDoubleArray::SafeDownCast(inputPd->GetArray("arc_length")); |
| 266 | for (int i = 0; i < inputPd->GetNumberOfArrays(); ++i) |
| 267 | { |
| 268 | auto* inputArray = inputPd->GetAbstractArray(i); |
| 269 | const char* name = inputArray->GetName(); |
| 270 | if (inputArray != arclength && !outputPD->GetAbstractArray(name)) |
| 271 | { |
| 272 | auto newArray = vtk::TakeSmartPointer(inputArray->NewInstance()); |
| 273 | newArray->SetName(name); |
| 274 | newArray->SetNumberOfComponents(inputArray->GetNumberOfComponents()); |
| 275 | outputPD->AddArray(newArray); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | if (input->GetNumberOfPoints() == 0 || !arclength) |
| 280 | { |
| 281 | continue; |
| 282 | } |
| 283 | |
| 284 | totalNumberOfPoints += input->GetNumberOfPoints(); |
| 285 | inputs.push_back(input); |
| 286 | lengthArrays.push_back(arclength); |
| 287 | } |
| 288 | |
| 289 | if (inputs.empty()) |
| 290 | { |
| 291 | vtkNew<vtkPoints> outputPoints; |
| 292 | outputPoints->InsertNextPoint(this->P1.GetData()); |
| 293 | outputPoints->InsertNextPoint(this->P2.GetData()); |
| 294 | vtkNew<vtkCharArray> validPointMask; |
| 295 | validPointMask->SetName("vtkValidPointMask"); |
| 296 | validPointMask->InsertNextValue(0); |
| 297 | validPointMask->InsertNextValue(0); |
| 298 | vtkNew<vtkDoubleArray> arclength; |
| 299 | arclength->SetName("arc_length"); |
| 300 | arclength->InsertNextValue(0.0); |
| 301 | arclength->InsertNextValue(lineDistance); |
| 302 | vtkNew<vtkPolyLineSource> polylineSource; |
no test coverage detected