| 104 | } |
| 105 | |
| 106 | bool vtkCellGridIOQuery::InsertCellTypeAttributeInfo(vtkCellGrid* grid, |
| 107 | const vtkCellAttribute::CellTypeInfo& cellTypeInfo, nlohmann::json& jsonInfo, |
| 108 | vtkStringToken cellTypeName) |
| 109 | { |
| 110 | (void)grid; |
| 111 | bool ok = true; |
| 112 | nlohmann::json jCellTypeInfo; |
| 113 | nlohmann::json jCellBlock; |
| 114 | nlohmann::json arraysByRole; |
| 115 | for (const auto& entry : cellTypeInfo.ArraysByRole) |
| 116 | { |
| 117 | auto groupIt = this->ArrayLocations.find(entry.second); |
| 118 | if (groupIt == this->ArrayLocations.end()) |
| 119 | { |
| 120 | ok = false; |
| 121 | std::string name = entry.second ? entry.second->GetName() : "null"; |
| 122 | vtkWarningMacro("Unmanaged array " << entry.second << " (" << name << ") in role " |
| 123 | << entry.first.Data() << " skipped."); |
| 124 | continue; |
| 125 | } |
| 126 | arraysByRole[entry.first.Data()] = |
| 127 | nlohmann::json::array({ groupIt->second.Data(), entry.second->GetName() }); |
| 128 | } |
| 129 | jCellBlock = { { "function-space", cellTypeInfo.FunctionSpace.Data() }, |
| 130 | { "basis", cellTypeInfo.Basis.Data() }, { "order", cellTypeInfo.Order } }; |
| 131 | if (!arraysByRole.empty()) |
| 132 | { |
| 133 | jCellBlock["arrays"] = arraysByRole; |
| 134 | } |
| 135 | if (cellTypeInfo.DOFSharing.IsValid()) |
| 136 | { |
| 137 | jCellBlock["dof-sharing"] = cellTypeInfo.DOFSharing.Data(); |
| 138 | } |
| 139 | jCellTypeInfo[cellTypeName.Data()] = jCellBlock; |
| 140 | jsonInfo["cell-info"] = jCellTypeInfo; |
| 141 | return ok; |
| 142 | } |
| 143 | |
| 144 | nlohmann::json& vtkCellGridIOQuery::AddMetadataEntry(vtkStringToken cellTypeName) |
| 145 | { |