----------------------------------------------------------------------------
| 467 | |
| 468 | //---------------------------------------------------------------------------- |
| 469 | int vtkCleanUnstructuredGrid::RequestData(vtkInformation* vtkNotUsed(request), |
| 470 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 471 | { |
| 472 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 473 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 474 | |
| 475 | vtkDataSet* input = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 476 | vtkUnstructuredGrid* output = |
| 477 | vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 478 | |
| 479 | if (input->GetNumberOfCells() == 0) |
| 480 | { |
| 481 | // set up a ugrid with same data arrays as input, but |
| 482 | // no points, cells or data. |
| 483 | output->Allocate(1); |
| 484 | output->GetPointData()->CopyAllocate(input->GetPointData(), VTK_CELL_SIZE); |
| 485 | output->GetCellData()->CopyAllocate(input->GetCellData(), 1); |
| 486 | vtkNew<vtkPoints> pts; |
| 487 | output->SetPoints(pts); |
| 488 | return 1; |
| 489 | } |
| 490 | |
| 491 | output->GetPointData()->CopyAllocate(input->GetPointData()); |
| 492 | output->GetCellData()->PassData(input->GetCellData()); |
| 493 | |
| 494 | // First, create a new points array that eliminate duplicate points. |
| 495 | // Also create a mapping from the old point id to the new. |
| 496 | vtkNew<vtkPoints> newPts; |
| 497 | |
| 498 | // Set the desired precision for the points in the output. |
| 499 | if (this->OutputPointsPrecision == vtkAlgorithm::DEFAULT_PRECISION) |
| 500 | { |
| 501 | // The logical behaviour would be to use the data type from the input. |
| 502 | // However, input is a vtkDataSet, which has no point data type; only the |
| 503 | // derived class vtkPointSet has a vtkPoints attribute, so only for that |
| 504 | // the logical practice can be applied, while for others (currently |
| 505 | // vtkImageData and vtkRectilinearGrid) the data type is the default |
| 506 | // for vtkPoints - which is VTK_FLOAT. |
| 507 | vtkPointSet* ps = vtkPointSet::SafeDownCast(input); |
| 508 | if (ps) |
| 509 | { |
| 510 | newPts->SetDataType(ps->GetPoints()->GetDataType()); |
| 511 | } |
| 512 | } |
| 513 | else if (this->OutputPointsPrecision == vtkAlgorithm::SINGLE_PRECISION) |
| 514 | { |
| 515 | newPts->SetDataType(VTK_FLOAT); |
| 516 | } |
| 517 | else if (this->OutputPointsPrecision == vtkAlgorithm::DOUBLE_PRECISION) |
| 518 | { |
| 519 | newPts->SetDataType(VTK_DOUBLE); |
| 520 | } |
| 521 | |
| 522 | vtkIdType num = input->GetNumberOfPoints(); |
| 523 | vtkIdType id; |
| 524 | vtkIdType newId; |
| 525 | std::vector<vtkIdType> ptMap(num); |
| 526 | double pt[3]; |
nothing calls this directly
no test coverage detected