| 16 | { |
| 17 | |
| 18 | bool PutArray(vtkDataArray* array, const std::string& arrayRole, nlohmann::json& jSpec, |
| 19 | const std::unordered_map<vtkAbstractArray*, vtkStringToken>& arrayLocations) |
| 20 | { |
| 21 | std::string arrayGroup; |
| 22 | std::string arrayName; |
| 23 | auto it = arrayLocations.find(array); |
| 24 | if (it != arrayLocations.end()) |
| 25 | { |
| 26 | if (!it->second.Data().empty()) |
| 27 | { |
| 28 | arrayGroup = it->second.Data(); |
| 29 | } |
| 30 | else |
| 31 | { |
| 32 | std::ostringstream groupId; |
| 33 | groupId << it->second.Data(); |
| 34 | arrayGroup = groupId.str(); |
| 35 | } |
| 36 | } |
| 37 | arrayName = array ? array->GetName() : ""; |
| 38 | if (!arrayGroup.empty() && !arrayName.empty()) |
| 39 | { |
| 40 | jSpec[arrayRole] = nlohmann::json::array({ arrayGroup, arrayName }); |
| 41 | } |
| 42 | else |
| 43 | { |
| 44 | vtkGenericWarningMacro("No array group contains array " << array << " or array is null."); |
| 45 | return false; |
| 46 | } |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | bool FetchArray(vtkDataArray*& array, const std::string& arrayName, const nlohmann::json& jSpec, |
| 51 | vtkCellGrid* grid, bool mandatory = true) |