| 59 | using ElementMapType = std::unordered_map<std::string, std::shared_ptr<ProjectElement>>; |
| 60 | |
| 61 | void ProcessElement(const std::string& elementUID, vtkPartitionedDataSetCollection* output, |
| 62 | vtkDataArraySelection* selection, bool writeOutTextures, bool columnMajorOrdering) |
| 63 | { |
| 64 | const auto& element = this->ProjectFile->JSONRoot()[elementUID]; |
| 65 | if (element.isNull() || !element.isObject()) |
| 66 | { |
| 67 | vtkGenericWarningMacro(<< "element is null or not an object"); |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | std::string name; |
| 72 | helper::GetStringValue(element["name"], name); |
| 73 | if (!selection->ArrayIsEnabled(name.c_str())) |
| 74 | { |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | std::pair<ElementMapType::iterator, bool> elementResult; |
| 79 | |
| 80 | double globalOrigin[3]; |
| 81 | helper::GetPointFromJSON(this->ProjectFile->JSONRoot()[this->UID]["origin"], globalOrigin); |
| 82 | |
| 83 | if (element.isMember("subtype") && element["subtype"].isString()) |
| 84 | { |
| 85 | auto subtype = getElementTypeFromSubtype(element["subtype"]); |
| 86 | switch (subtype) |
| 87 | { |
| 88 | case ElementTypes::PointSetElement: |
| 89 | elementResult = this->Elements.insert( |
| 90 | std::make_pair(name, std::make_shared<PointSetElement>(elementUID, globalOrigin))); |
| 91 | break; |
| 92 | case ElementTypes::LineSetElement: |
| 93 | elementResult = this->Elements.insert( |
| 94 | std::make_pair(name, std::make_shared<LineSetElement>(elementUID, globalOrigin))); |
| 95 | break; |
| 96 | case ElementTypes::SurfaceElement: |
| 97 | elementResult = this->Elements.insert( |
| 98 | std::make_pair(name, std::make_shared<SurfaceElement>(elementUID, globalOrigin))); |
| 99 | break; |
| 100 | case ElementTypes::VolumeElement: |
| 101 | elementResult = this->Elements.insert( |
| 102 | std::make_pair(name, std::make_shared<VolumeElement>(elementUID, globalOrigin))); |
| 103 | break; |
| 104 | default: |
| 105 | vtkGenericWarningMacro(<< "subtype " << element["subtype"].asString() |
| 106 | << " is not a valid type"); |
| 107 | return; |
| 108 | } |
| 109 | |
| 110 | vtkSmartPointer<vtkPartitionedDataSet> partitionedDS = |
| 111 | vtkSmartPointer<vtkPartitionedDataSet>::New(); |
| 112 | elementResult.first->second->ProcessJSON( |
| 113 | this->ProjectFile, element, partitionedDS, writeOutTextures, columnMajorOrdering); |
| 114 | // names in vtkDataAssembly CANNOT contain spaces or parenthesis |
| 115 | vtksys::SystemTools::ReplaceString(name, " ", "_"); |
| 116 | vtksys::SystemTools::ReplaceString(name, "(", "_"); |
| 117 | vtksys::SystemTools::ReplaceString(name, ")", "_"); |
| 118 | // also dashes are supposed to be fine to use in names, but there's a bug, |
nothing calls this directly
no test coverage detected