------------------------------------------------------------------------------
| 445 | |
| 446 | //------------------------------------------------------------------------------ |
| 447 | void vtkProjectSphereFilter::SplitCell(vtkPointSet* input, vtkPointSet* output, |
| 448 | vtkIdType inputCellId, vtkIncrementalPointLocator* locator, vtkCellArray* connectivity, |
| 449 | int splitSide) |
| 450 | { |
| 451 | // i screw up the canonical ordering of the cell but apparently this |
| 452 | // gets fixed by vtkCell::Clip(). |
| 453 | vtkCell* cell = input->GetCell(inputCellId); |
| 454 | vtkNew<vtkDoubleArray> cellScalars; |
| 455 | cellScalars->SetNumberOfTuples(cell->GetNumberOfPoints()); |
| 456 | double coord[3]; |
| 457 | for (vtkIdType pt = 0; pt < cell->GetNumberOfPoints(); pt++) |
| 458 | { |
| 459 | output->GetPoint(cell->GetPointId(pt), coord); |
| 460 | if (splitSide == 0 && coord[0] > this->SplitLongitude + 180.) |
| 461 | { |
| 462 | coord[0] -= 360.; |
| 463 | } |
| 464 | else if (splitSide == 1 && coord[0] < this->SplitLongitude + 180.) |
| 465 | { |
| 466 | coord[0] += 360.; |
| 467 | } |
| 468 | cellScalars->SetValue(pt, coord[0]); |
| 469 | cell->GetPoints()->SetPoint(pt, coord); |
| 470 | } |
| 471 | vtkIdType numberOfCells = output->GetNumberOfCells(); |
| 472 | double splitLocation = (splitSide == 0 ? -180. : 180.); |
| 473 | cell->Clip(splitLocation, cellScalars.GetPointer(), locator, connectivity, output->GetPointData(), |
| 474 | output->GetPointData(), input->GetCellData(), inputCellId, output->GetCellData(), splitSide); |
| 475 | // if the grid was an unstructured grid we have to update the cell |
| 476 | // types and locations for the created cells. |
| 477 | if (vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast(output)) |
| 478 | { |
| 479 | this->SetCellInformation(ugrid, cell, output->GetNumberOfCells() - numberOfCells); |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | //------------------------------------------------------------------------------ |
| 484 | void vtkProjectSphereFilter::SetCellInformation( |
no test coverage detected