| 2088 | //---------------------------------------------------------------------------- |
| 2089 | template <class PointSetT> |
| 2090 | void InitializeBlocksForUnstructuredData(diy::Master& master, std::vector<PointSetT*>& inputs) |
| 2091 | { |
| 2092 | using BlockType = typename ::DataSetTypeToBlockTypeConverter<PointSetT>::BlockType; |
| 2093 | for (int localId = 0; localId < static_cast<int>(inputs.size()); ++localId) |
| 2094 | { |
| 2095 | PointSetT* input = inputs[localId]; |
| 2096 | BlockType* block = master.block<BlockType>(localId); |
| 2097 | typename BlockType::InformationType& information = block->Information; |
| 2098 | information.BoundingBox = vtkBoundingBox(input->GetBounds()); |
| 2099 | |
| 2100 | information.Input = input; |
| 2101 | |
| 2102 | if (vtkUnsignedCharArray* ghostCells = input->GetCellGhostArray()) |
| 2103 | { |
| 2104 | vtkIdType numberOfInputPoints = input->GetNumberOfPoints(); |
| 2105 | vtkIdType numberOfInputCells = input->GetNumberOfCells(); |
| 2106 | |
| 2107 | // We start by remapping ghost points. |
| 2108 | vtkSmartPointer<vtkIdList>& pointIdMap = information.OutputToInputPointIdRedirectionMap; |
| 2109 | pointIdMap = vtkSmartPointer<vtkIdList>::New(); |
| 2110 | pointIdMap->Allocate(numberOfInputPoints); |
| 2111 | |
| 2112 | vtkSmartPointer<vtkIdList>& pointIdInverseMap = |
| 2113 | information.InputToOutputPointIdRedirectionMap; |
| 2114 | pointIdInverseMap = vtkSmartPointer<vtkIdList>::New(); |
| 2115 | pointIdInverseMap->SetNumberOfIds(numberOfInputPoints); |
| 2116 | // We set -1 where input id to input id doesn't map anywhere in the output. This happens |
| 2117 | // for points that are only belonging exclusively to ghost cells. |
| 2118 | pointIdInverseMap->Fill(-1); |
| 2119 | |
| 2120 | vtkNew<vtkIdList> ids; |
| 2121 | auto ghosts = vtk::DataArrayValueRange<1>(ghostCells); |
| 2122 | |
| 2123 | for (vtkIdType pointId = 0; pointId < numberOfInputPoints; ++pointId) |
| 2124 | { |
| 2125 | input->GetPointCells(pointId, ids); |
| 2126 | for (vtkIdType id = 0; id < ids->GetNumberOfIds(); ++id) |
| 2127 | { |
| 2128 | // We are adjacent to a non-ghost cell: keep this point |
| 2129 | if (!(ghosts[ids->GetId(id)] & ::GHOST_CELL_TO_PEEL_IN_UNSTRUCTURED_DATA)) |
| 2130 | { |
| 2131 | pointIdInverseMap->SetId(pointId, pointIdMap->GetNumberOfIds()); |
| 2132 | pointIdMap->InsertNextId(pointId); |
| 2133 | break; |
| 2134 | } |
| 2135 | } |
| 2136 | } |
| 2137 | |
| 2138 | information.NumberOfInputPoints = pointIdMap->GetNumberOfIds(); |
| 2139 | |
| 2140 | vtkSmartPointer<vtkIdList>& cellIdMap = information.OutputToInputCellIdRedirectionMap; |
| 2141 | cellIdMap = vtkSmartPointer<vtkIdList>::New(); |
| 2142 | cellIdMap->Allocate(numberOfInputCells); |
| 2143 | |
| 2144 | for (vtkIdType cellId = 0; cellId < numberOfInputCells; ++cellId) |
| 2145 | { |
| 2146 | if (!(ghosts[cellId] & ::GHOST_CELL_TO_PEEL_IN_UNSTRUCTURED_DATA)) |
| 2147 | { |
no test coverage detected