------------------------------------------------------------------------------
| 1327 | |
| 1328 | //------------------------------------------------------------------------------ |
| 1329 | void vtkUnstructuredGrid::ShallowCopy(vtkDataObject* dataObject) |
| 1330 | { |
| 1331 | vtkUnstructuredGrid* grid = vtkUnstructuredGrid::SafeDownCast(dataObject); |
| 1332 | if (this == grid) |
| 1333 | { |
| 1334 | return; |
| 1335 | } |
| 1336 | this->Superclass::ShallowCopy(dataObject); |
| 1337 | if (grid) |
| 1338 | { |
| 1339 | // I do not know if this is correct but. |
| 1340 | // ^ I really hope this comment lives for another 20 years. |
| 1341 | |
| 1342 | this->Connectivity = grid->Connectivity; |
| 1343 | this->Types = grid->Types; |
| 1344 | this->DistinctCellTypes = nullptr; |
| 1345 | this->DistinctCellTypesUpdateMTime = 0; |
| 1346 | this->Faces = grid->Faces; |
| 1347 | this->FaceLocations = grid->FaceLocations; |
| 1348 | |
| 1349 | if (grid->Links) |
| 1350 | { |
| 1351 | this->Links = vtkSmartPointer<vtkAbstractCellLinks>::Take(grid->Links->NewInstance()); |
| 1352 | this->Links->SetDataSet(this); |
| 1353 | this->Links->ShallowCopy(grid->Links); |
| 1354 | } |
| 1355 | else |
| 1356 | { |
| 1357 | this->Links = nullptr; |
| 1358 | } |
| 1359 | } |
| 1360 | else if (vtkUnstructuredGridBase* ugb = vtkUnstructuredGridBase::SafeDownCast(dataObject)) |
| 1361 | { |
| 1362 | bool isNewAlloc = false; |
| 1363 | if (!this->Connectivity || !this->Types) |
| 1364 | { |
| 1365 | this->AllocateEstimate(ugb->GetNumberOfCells(), ugb->GetMaxCellSize()); |
| 1366 | isNewAlloc = true; |
| 1367 | } |
| 1368 | |
| 1369 | // The source object has vtkUnstructuredGrid topology, but a different |
| 1370 | // cell implementation. Deep copy the cells, and shallow copy the rest: |
| 1371 | auto cellIter = vtkSmartPointer<vtkCellIterator>::Take(ugb->NewCellIterator()); |
| 1372 | for (cellIter->InitTraversal(); !cellIter->IsDoneWithTraversal(); cellIter->GoToNextCell()) |
| 1373 | { |
| 1374 | this->InsertNextCell(cellIter->GetCellType(), cellIter->GetNumberOfPoints(), |
| 1375 | cellIter->GetPointIds()->GetPointer(0), cellIter->GetCellFaces()); |
| 1376 | } |
| 1377 | |
| 1378 | if (isNewAlloc) |
| 1379 | { |
| 1380 | this->Squeeze(); |
| 1381 | } |
| 1382 | } |
| 1383 | } |
| 1384 | |
| 1385 | //------------------------------------------------------------------------------ |
| 1386 | void vtkUnstructuredGrid::DeepCopy(vtkDataObject* dataObject) |
no test coverage detected