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

Function DeepCopyInputAndAllocateGhosts

Parallel/DIY/vtkDIYGhostUtilities.cxx:4730–4805  ·  view source on GitHub ↗

----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

4728
4729//----------------------------------------------------------------------------
4730void DeepCopyInputAndAllocateGhosts(
4731 ::UnstructuredGridBlock* block, vtkUnstructuredGrid* input, vtkUnstructuredGrid* output)
4732{
4733 using BlockType = ::UnstructuredGridBlock;
4734 using BlockStructureType = typename BlockType::BlockStructureType;
4735 using BlockInformationType = typename BlockType::InformationType;
4736
4737 BlockInformationType& info = block->Information;
4738
4739 vtkIdType numberOfPoints = info.NumberOfInputPoints;
4740 vtkIdType numberOfCells = info.NumberOfInputCells;
4741
4742 vtkIdType connectivitySize = info.InputConnectivitySize;
4743 vtkIdType facesSize = info.InputFacesSize;
4744 vtkIdType facesNum = info.InputNumberOfFaces;
4745
4746 for (auto& pair : block->BlockStructures)
4747 {
4748 BlockStructureType& blockStructure = pair.second;
4749 if (blockStructure.GhostPoints)
4750 {
4751 numberOfPoints += blockStructure.GhostPoints->GetNumberOfPoints() -
4752 static_cast<vtkIdType>(blockStructure.RedirectionMapForDuplicatePointIds.size());
4753 }
4754 numberOfCells += blockStructure.ReceiveBuffer.Types->GetNumberOfValues();
4755 connectivitySize +=
4756 blockStructure.ReceiveBuffer.CellArray->GetConnectivityArray()->GetNumberOfValues();
4757 vtkCellArray* faces = blockStructure.ReceiveBuffer.Faces;
4758 facesSize += faces ? faces->GetConnectivityArray()->GetNumberOfValues() : 0;
4759 facesNum += faces ? faces->GetOffsetsArray()->GetNumberOfValues() - 1 : 0;
4760 }
4761
4762 vtkPoints* inputPoints = input->GetPoints();
4763 vtkNew<vtkPoints> outputPoints;
4764 if (inputPoints)
4765 {
4766 outputPoints->SetDataType(inputPoints->GetDataType());
4767 }
4768 outputPoints->SetNumberOfPoints(numberOfPoints);
4769 output->SetPoints(outputPoints);
4770
4771 vtkNew<vtkCellArray> outputCellArray;
4772
4773 vtkNew<vtkUnsignedCharArray> types;
4774 types->SetNumberOfValues(numberOfCells);
4775
4776 vtkSmartPointer<vtkCellArray> outputFaces = nullptr;
4777 vtkSmartPointer<vtkCellArray> outputFaceLocations = nullptr;
4778
4779 if (facesSize)
4780 {
4781 outputFaces = vtkSmartPointer<vtkCellArray>::New();
4782 outputFaces->AllocateExact(facesNum, facesSize);
4783 outputFaces->GetConnectivityArray()->SetNumberOfTuples(facesSize);
4784 outputFaces->GetOffsetsArray()->SetNumberOfTuples(facesNum + 1);
4785 outputFaceLocations = vtkSmartPointer<vtkCellArray>::New();
4786 outputFaceLocations->AllocateExact(numberOfCells, facesNum);
4787 outputFaceLocations->GetConnectivityArray()->SetNumberOfTuples(facesNum);

Calls 15

CloneUnstructuredGridFunction · 0.85
ClonePolyDataFunction · 0.85
GetConnectivityArrayMethod · 0.80
ConvertTo32BitStorageMethod · 0.80
SetPolyhedralCellsMethod · 0.80
SetPolysMethod · 0.80
SetStripsMethod · 0.80
SetLinesMethod · 0.80
NewFunction · 0.50
GetNumberOfPointsMethod · 0.45
sizeMethod · 0.45
GetNumberOfValuesMethod · 0.45

Tested by

no test coverage detected