| 6429 | //------------------------------------------------------------------------------ |
| 6430 | |
| 6431 | void vtkBoxClipDataSet::ClipBoxInOut0D(vtkGenericCell* cell, vtkIncrementalPointLocator* locator, |
| 6432 | vtkCellArray** verts, vtkPointData* inPD, vtkPointData** outPD, vtkCellData* inCD, |
| 6433 | vtkIdType cellId, vtkCellData** outCD) |
| 6434 | { |
| 6435 | vtkIdType cellType = cell->GetCellType(); |
| 6436 | vtkIdList* cellIds = cell->GetPointIds(); |
| 6437 | vtkCellArray* arrayvert = vtkCellArray::New(); |
| 6438 | vtkPoints* cellPts = cell->GetPoints(); |
| 6439 | vtkIdType npts = cellPts->GetNumberOfPoints(); |
| 6440 | std::vector<vtkIdType> cellptId(npts); |
| 6441 | vtkIdType iid; |
| 6442 | const vtkIdType* v_id = nullptr; |
| 6443 | vtkIdType ptId; |
| 6444 | vtkIdType ptsvert = 1; |
| 6445 | |
| 6446 | int i; |
| 6447 | |
| 6448 | double v[3]; |
| 6449 | |
| 6450 | for (i = 0; i < npts; i++) |
| 6451 | { |
| 6452 | cellptId[i] = cellIds->GetId(i); |
| 6453 | } |
| 6454 | |
| 6455 | // Convert all 0d cells to single vert. |
| 6456 | this->CellGrid(cellType, npts, cellptId.data(), arrayvert); |
| 6457 | |
| 6458 | unsigned int totalnewvert = arrayvert->GetNumberOfCells(); |
| 6459 | for (unsigned int idlinenew = 0; idlinenew < totalnewvert; idlinenew++) |
| 6460 | { |
| 6461 | arrayvert->GetNextCell(ptsvert, v_id); |
| 6462 | |
| 6463 | // One way or another, we are adding the point. |
| 6464 | ptId = cellIds->GetId(v_id[0]); |
| 6465 | cellPts->GetPoint(v_id[0], v); |
| 6466 | |
| 6467 | if (locator->InsertUniquePoint(v, iid)) |
| 6468 | { |
| 6469 | outPD[0]->CopyData(inPD, ptId, iid); |
| 6470 | outPD[1]->CopyData(inPD, ptId, iid); |
| 6471 | } |
| 6472 | |
| 6473 | // Clipping verts is easy. Either it is inside the box or it isn't. |
| 6474 | if ((v[0] >= this->BoundBoxClip[0][0]) && (v[0] <= this->BoundBoxClip[0][1]) && |
| 6475 | (v[1] >= this->BoundBoxClip[1][0]) && (v[1] <= this->BoundBoxClip[1][1]) && |
| 6476 | (v[2] >= this->BoundBoxClip[2][0]) && (v[2] <= this->BoundBoxClip[2][1])) |
| 6477 | { |
| 6478 | // Vert is inside. |
| 6479 | int newCellId = verts[0]->InsertNextCell(1, &iid); |
| 6480 | outCD[0]->CopyData(inCD, cellId, newCellId); |
| 6481 | } |
| 6482 | else |
| 6483 | { |
| 6484 | // Vert is outside. |
| 6485 | int newCellId = verts[1]->InsertNextCell(1, &iid); |
| 6486 | outCD[1]->CopyData(inCD, cellId, newCellId); |
| 6487 | } |
| 6488 | } |
no test coverage detected