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

Method ClipBoxInOut0D

Filters/General/vtkBoxClipDataSet.cxx:6431–6490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6429//------------------------------------------------------------------------------
6430
6431void 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 }

Callers 1

RequestDataMethod · 0.95

Calls 15

CellGridMethod · 0.95
DeleteMethod · 0.65
NewFunction · 0.50
GetCellTypeMethod · 0.45
GetPointIdsMethod · 0.45
GetPointsMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetIdMethod · 0.45
dataMethod · 0.45
GetNumberOfCellsMethod · 0.45
GetNextCellMethod · 0.45
GetPointMethod · 0.45

Tested by

no test coverage detected