----------------------------------------------------------------------------
| 130 | |
| 131 | //---------------------------------------------------------------------------- |
| 132 | bool vtkConduitSource::GeneratePartitionedDataSetCollection(vtkDataObject* output) |
| 133 | { |
| 134 | vtkNew<vtkPartitionedDataSetCollection> pdc_output; |
| 135 | const auto& pdc_node = this->Internals->Node; |
| 136 | const auto count = pdc_node.number_of_children(); |
| 137 | pdc_output->SetNumberOfPartitionedDataSets(static_cast<unsigned int>(count)); |
| 138 | |
| 139 | std::map<std::string, unsigned int> name_map; |
| 140 | for (conduit_index_t cc = 0; cc < count; ++cc) |
| 141 | { |
| 142 | const auto& child = pdc_node.child(cc); |
| 143 | auto pd = pdc_output->GetPartitionedDataSet(static_cast<unsigned int>(cc)); |
| 144 | assert(pd != nullptr); |
| 145 | if (!vtkConduitToDataObject::FillPartitionedDataSet(pd, child)) |
| 146 | { |
| 147 | vtkLogF(ERROR, "Failed reading mesh '%s'", child.name().c_str()); |
| 148 | output->Initialize(); |
| 149 | return false; |
| 150 | } |
| 151 | |
| 152 | // set the mesh name. |
| 153 | pdc_output->GetMetaData(cc)->Set(vtkCompositeDataSet::NAME(), child.name().c_str()); |
| 154 | name_map[child.name()] = static_cast<unsigned int>(cc); |
| 155 | |
| 156 | // set field data. |
| 157 | if (child.has_path("state/fields")) |
| 158 | { |
| 159 | vtkConduitToDataObject::AddFieldData(pd, child["state/fields"]); |
| 160 | } |
| 161 | // fields may be located in node at same level as state |
| 162 | if (child.has_path("fields")) |
| 163 | { |
| 164 | vtkConduitToDataObject::AddFieldData(pd, child["fields"]); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | if (this->Internals->AssemblyNodeValid) |
| 169 | { |
| 170 | vtkNew<vtkDataAssembly> assembly; |
| 171 | std::function<void(int, const conduit_cpp::Node&)> helper; |
| 172 | helper = [&name_map, &assembly, &helper](int parent, const conduit_cpp::Node& node) |
| 173 | { |
| 174 | if (node.dtype().is_object()) |
| 175 | { |
| 176 | for (conduit_index_t cc = 0; cc < node.number_of_children(); ++cc) |
| 177 | { |
| 178 | auto child = node.child(cc); |
| 179 | auto nodeName = vtkDataAssembly::MakeValidNodeName(child.name().c_str()); |
| 180 | auto childId = assembly->AddNode(nodeName.c_str(), parent); |
| 181 | assembly->SetAttribute(childId, "label", child.name().c_str()); |
| 182 | helper(childId, child); |
| 183 | } |
| 184 | } |
| 185 | else if (node.dtype().is_list()) |
| 186 | { |
| 187 | for (conduit_index_t cc = 0; cc < node.number_of_children(); ++cc) |
| 188 | { |
| 189 | auto child = node.child(cc); |
no test coverage detected