------------------------------------------------------------------------------
| 40 | |
| 41 | //------------------------------------------------------------------------------ |
| 42 | int vtkPointSetStreamer::RequestData( |
| 43 | vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 44 | { |
| 45 | // get the input |
| 46 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 47 | vtkPointSet* input = vtkPointSet::GetData(inInfo); |
| 48 | |
| 49 | // get the output |
| 50 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 51 | vtkPolyData* output = vtkPolyData::GetData(outInfo); |
| 52 | |
| 53 | if (!input || input->GetNumberOfCells() == 0) |
| 54 | { |
| 55 | vtkErrorMacro("No input or empty input."); |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | // build the locator if needed |
| 60 | this->PointLocator->SetNumberOfPointsPerBucket(this->NumberOfPointsPerBucket); |
| 61 | this->PointLocator->SetDataSet(input); |
| 62 | this->PointLocator->BuildLocator(); |
| 63 | |
| 64 | // get the number of buckets |
| 65 | this->NumberOfBuckets = this->PointLocator->GetNumberOfBuckets(); |
| 66 | |
| 67 | // get the points in the bucket |
| 68 | vtkNew<vtkIdList> pointIds; |
| 69 | this->PointLocator->GetBucketIds(this->BucketId, pointIds); |
| 70 | |
| 71 | vtkIdType numberOfPointsInBucket = pointIds->GetNumberOfIds(); |
| 72 | if (numberOfPointsInBucket == 0) |
| 73 | { |
| 74 | return 1; |
| 75 | } |
| 76 | |
| 77 | // copy the points and point data |
| 78 | vtkNew<vtkPoints> points; |
| 79 | points->SetDataType(input->GetPoints()->GetDataType()); |
| 80 | points->SetNumberOfPoints(numberOfPointsInBucket); |
| 81 | |
| 82 | vtkPointData* inputPD = input->GetPointData(); |
| 83 | vtkPointData* outputPD = output->GetPointData(); |
| 84 | outputPD->CopyAllocate(inputPD, numberOfPointsInBucket); |
| 85 | outputPD->SetNumberOfTuples(numberOfPointsInBucket); |
| 86 | |
| 87 | double point[3]; |
| 88 | vtkIdType id; |
| 89 | for (vtkIdType i = 0; i < numberOfPointsInBucket; ++i) |
| 90 | { |
| 91 | id = pointIds->GetId(i); |
| 92 | input->GetPoint(id, point); |
| 93 | points->SetPoint(i, point); |
| 94 | outputPD->CopyData(inputPD, id, i); |
| 95 | } |
| 96 | output->SetPoints(points); |
| 97 | |
| 98 | // create the original point ids array |
| 99 | vtkNew<vtkIdTypeArray> originalIds; |
nothing calls this directly
no test coverage detected