------------------------------------------------------------------------------
| 315 | |
| 316 | //------------------------------------------------------------------------------ |
| 317 | int vtkContourLoopExtraction::RequestData(vtkInformation* vtkNotUsed(request), |
| 318 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 319 | { |
| 320 | // get the info objects |
| 321 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 322 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 323 | |
| 324 | // get the input and output |
| 325 | vtkPolyData* input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 326 | vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 327 | |
| 328 | // Initialize and check data |
| 329 | vtkDebugMacro(<< "Loop extraction..."); |
| 330 | |
| 331 | vtkPoints* points = input->GetPoints(); |
| 332 | vtkIdType numPts; |
| 333 | if (!points || (numPts = input->GetNumberOfPoints()) < 1) |
| 334 | { |
| 335 | vtkErrorMacro("Input contains no points"); |
| 336 | return 1; |
| 337 | } |
| 338 | |
| 339 | vtkCellArray* lines = input->GetLines(); |
| 340 | vtkIdType numLines = lines->GetNumberOfCells(); |
| 341 | if (numLines < 1) |
| 342 | { |
| 343 | vtkErrorMacro("Input contains no lines"); |
| 344 | return 1; |
| 345 | } |
| 346 | |
| 347 | vtkPointData* inPD = input->GetPointData(); |
| 348 | |
| 349 | vtkDataArray* scalars = nullptr; |
| 350 | if (this->ScalarThresholding) |
| 351 | { |
| 352 | scalars = inPD->GetScalars(); |
| 353 | } |
| 354 | |
| 355 | // Prepare output |
| 356 | output->SetPoints(points); |
| 357 | vtkSmartPointer<vtkCellArray> outLines; |
| 358 | vtkSmartPointer<vtkCellArray> outPolys; |
| 359 | |
| 360 | if (this->OutputMode == VTK_OUTPUT_POLYLINES || this->OutputMode == VTK_OUTPUT_BOTH) |
| 361 | { |
| 362 | outLines.TakeReference(vtkCellArray::New()); |
| 363 | output->SetLines(outLines); |
| 364 | } |
| 365 | if (this->OutputMode == VTK_OUTPUT_POLYGONS || this->OutputMode == VTK_OUTPUT_BOTH) |
| 366 | { |
| 367 | outPolys.TakeReference(vtkCellArray::New()); |
| 368 | output->SetPolys(outPolys); |
| 369 | } |
| 370 | output->GetPointData()->PassData(inPD); |
| 371 | |
| 372 | // Create a clean polydata containing only line segments and without other |
| 373 | // topological types. This simplifies the filter. |
| 374 | vtkIdType npts; |
nothing calls this directly
no test coverage detected