MCPcopy Create free account
hub / github.com/Kitware/VTK / RequestData

Method RequestData

Filters/GeometryPreview/vtkPointSetStreamer.cxx:42–118  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

40
41//------------------------------------------------------------------------------
42int 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;

Callers

nothing calls this directly

Calls 15

GetInformationObjectMethod · 0.80
GetNumberOfBucketsMethod · 0.80
SetVertsMethod · 0.80
GetDataFunction · 0.50
copyFunction · 0.50
GetNumberOfCellsMethod · 0.45
SetDataSetMethod · 0.45
BuildLocatorMethod · 0.45
GetBucketIdsMethod · 0.45
GetNumberOfIdsMethod · 0.45
SetDataTypeMethod · 0.45
GetDataTypeMethod · 0.45

Tested by

no test coverage detected