| 1246 | //----------------------------------------------------------------------------- |
| 1247 | template <typename TGrid, typename TInputIdType, bool TInsideOut> |
| 1248 | vtkSmartPointer<vtkUnstructuredGrid> vtkTableBasedClipDataSet::ClipTDataSet( |
| 1249 | TGrid* input, vtkImplicitFunction* implicitFunction, vtkDoubleArray* scalars, double isoValue) |
| 1250 | { |
| 1251 | const auto inputPoints = input->GetPoints(); |
| 1252 | vtkSmartPointer<vtkDoubleArray> clipArray; |
| 1253 | if (implicitFunction) |
| 1254 | { |
| 1255 | clipArray = vtkSmartPointer<vtkDoubleArray>::New(); |
| 1256 | clipArray->SetName("ClipDataSetScalars"); |
| 1257 | clipArray->SetNumberOfComponents(1); |
| 1258 | clipArray->SetNumberOfTuples(inputPoints->GetNumberOfPoints()); |
| 1259 | implicitFunction->FunctionValue(inputPoints->GetData(), clipArray); |
| 1260 | } |
| 1261 | else |
| 1262 | { |
| 1263 | clipArray = scalars; |
| 1264 | } |
| 1265 | // Evaluate points and calculate pointBatches, numberOfKeptPoints, pointsMap using clipArray |
| 1266 | EvaluatePoints<TInputIdType, TInsideOut> evaluatePoints( |
| 1267 | clipArray, isoValue, this->BatchSize, this); |
| 1268 | vtkSMPTools::For(0, evaluatePoints.PointBatches.GetNumberOfBatches(), evaluatePoints); |
| 1269 | const TInputIdType numberOfKeptPoints = evaluatePoints.NumberOfKeptPoints; |
| 1270 | const TableBasedPointBatches& pointBatches = evaluatePoints.PointBatches; |
| 1271 | vtkSmartPointer<vtkAOSDataArrayTemplate<TInputIdType>> pointsMap = evaluatePoints.PointsMap; |
| 1272 | if (implicitFunction && this->GenerateClipScalars) |
| 1273 | { |
| 1274 | input->GetPointData()->AddArray(clipArray); |
| 1275 | input->GetPointData()->SetActiveScalars(clipArray->GetName()); |
| 1276 | } |
| 1277 | // check if there are no kept points |
| 1278 | if (numberOfKeptPoints == 0) |
| 1279 | { |
| 1280 | return vtkSmartPointer<vtkUnstructuredGrid>::New(); |
| 1281 | } |
| 1282 | |
| 1283 | // Evaluate cells and calculate connectivitySize, numberOfOutputCells, numberOfCentroids, |
| 1284 | // cellBatches, cellsCase, edges |
| 1285 | using TEdge = EdgeType<TInputIdType>; |
| 1286 | EvaluateCells<TGrid, TInputIdType, TInsideOut> evaluateCells( |
| 1287 | input, clipArray.Get(), isoValue, this->BatchSize, this); |
| 1288 | vtkSMPTools::For(0, evaluateCells.CellBatches.GetNumberOfBatches(), evaluateCells); |
| 1289 | const vtkIdType connectivitySize = evaluateCells.ConnectivitySize; |
| 1290 | const vtkIdType numberOfOutputCells = evaluateCells.NumberOfOutputCells; |
| 1291 | const vtkIdType numberOfCentroids = evaluateCells.NumberOfCentroids; |
| 1292 | const TableBasedCellBatches& cellBatches = evaluateCells.CellBatches; |
| 1293 | vtkSmartPointer<vtkUnsignedCharArray> cellsCase = evaluateCells.CellsCase; |
| 1294 | std::vector<TEdge> edges = std::move(evaluateCells.Edges); |
| 1295 | std::vector<vtkIdType> unsupportedCells = std::move(evaluateCells.UnsupportedCells); |
| 1296 | |
| 1297 | // Create Edge locator which will be used to define the connectivity of cells |
| 1298 | using TEdgeLocator = EdgeLocatorType<TInputIdType>; |
| 1299 | TEdgeLocator edgeLocator; |
| 1300 | if (!edges.empty()) |
| 1301 | { |
| 1302 | edgeLocator.BuildLocator(static_cast<vtkIdType>(edges.size()), edges.data()); |
| 1303 | } |
| 1304 | const TInputIdType numberOfEdges = edgeLocator.GetNumberOfEdges(); |
| 1305 |
no test coverage detected