------------------------------------------------------------------------------
| 251 | |
| 252 | //------------------------------------------------------------------------------ |
| 253 | int vtkParticlePathFilter::Finalize( |
| 254 | vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 255 | { |
| 256 | int retVal = this->Superclass::Finalize(request, inputVector, outputVector); |
| 257 | |
| 258 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 259 | auto output = vtkPolyData::SafeDownCast(vtkDataObject::GetData(outInfo)); |
| 260 | output->Initialize(); |
| 261 | |
| 262 | if (!this->Points->GetNumberOfPoints()) |
| 263 | { |
| 264 | // Nothing to do in this process |
| 265 | return retVal; |
| 266 | } |
| 267 | |
| 268 | std::size_t nPoints = 0; |
| 269 | for (auto& pair : this->Paths) |
| 270 | { |
| 271 | nPoints += pair.second.size(); |
| 272 | } |
| 273 | |
| 274 | vtkNew<vtkPoints> points; |
| 275 | points->SetNumberOfPoints(nPoints); |
| 276 | |
| 277 | vtkNew<vtkIdList> mapping; |
| 278 | mapping->SetNumberOfIds(points->GetNumberOfPoints()); |
| 279 | vtkIdType i = -1; |
| 280 | |
| 281 | // We create a mapping from the indexing in Points to the polydata we actually want to output. |
| 282 | for (auto& pair : this->Paths) |
| 283 | { |
| 284 | const auto& path = pair.second; |
| 285 | for (vtkIdType pointId : path) |
| 286 | { |
| 287 | mapping->SetId(++i, pointId); |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | output->GetPointData()->CopyAllocate(this->Points->GetPointData(), mapping->GetNumberOfIds()); |
| 292 | output->GetPointData()->CopyData(this->Points->GetPointData(), mapping); |
| 293 | points->GetData()->InsertTuplesStartingAt(0, mapping, this->Points->GetPoints()->GetData()); |
| 294 | output->SetPoints(points); |
| 295 | |
| 296 | vtkNew<vtkCellArray> verts, lines; |
| 297 | |
| 298 | FillCellArrays(verts, lines, this->Paths); |
| 299 | |
| 300 | output->SetVerts(verts); |
| 301 | output->SetLines(lines); |
| 302 | |
| 303 | return retVal; |
| 304 | } |
| 305 | |
| 306 | VTK_ABI_NAMESPACE_END |
nothing calls this directly
no test coverage detected