| 1032 | } |
| 1033 | |
| 1034 | void |
| 1035 | XdmfArray::populateItem(const std::map<std::string, std::string> & itemProperties, |
| 1036 | const std::vector<shared_ptr<XdmfItem> > & childItems, |
| 1037 | const XdmfCoreReader * const reader) |
| 1038 | { |
| 1039 | // This inserts any XdmfInformation in childItems into the object. |
| 1040 | XdmfItem::populateItem(itemProperties, childItems, reader); |
| 1041 | |
| 1042 | bool filled = false; |
| 1043 | |
| 1044 | // Check for Function |
| 1045 | std::map<std::string, std::string>::const_iterator itemType = |
| 1046 | itemProperties.find("ItemType"); |
| 1047 | |
| 1048 | if (itemType != itemProperties.end()) { |
| 1049 | if (itemType->second.compare("Function") == 0) { |
| 1050 | std::map<std::string, std::string>::const_iterator expressionLocation = |
| 1051 | itemProperties.find("Function"); |
| 1052 | if (expressionLocation == itemProperties.end()) { |
| 1053 | XdmfError::message(XdmfError::FATAL, |
| 1054 | "'Function' not found in itemProperties for Function" |
| 1055 | " ItemType in XdmfArray::populateItem"); |
| 1056 | } |
| 1057 | std::string expression = expressionLocation->second; |
| 1058 | |
| 1059 | // Convert from old format to new Variable format |
| 1060 | // $X -> ValX |
| 1061 | size_t loc = expression.find("$"); |
| 1062 | |
| 1063 | while (loc != std::string::npos) { |
| 1064 | expression.replace(loc, 1, "Val"); |
| 1065 | loc = expression.find("$", loc); |
| 1066 | } |
| 1067 | |
| 1068 | // Create Variable list |
| 1069 | |
| 1070 | std::map<std::string, shared_ptr<XdmfArray> > variableMap; |
| 1071 | |
| 1072 | unsigned int variableIndex = 0; |
| 1073 | for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter = |
| 1074 | childItems.begin(); |
| 1075 | iter != childItems.end(); |
| 1076 | ++iter) { |
| 1077 | if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) { |
| 1078 | std::stringstream variableKey; |
| 1079 | variableKey << "Val" << variableIndex; |
| 1080 | variableMap[variableKey.str()] = array; |
| 1081 | variableIndex++; |
| 1082 | } |
| 1083 | } |
| 1084 | |
| 1085 | shared_ptr<XdmfFunction> function = XdmfFunction::New(expression, variableMap); |
| 1086 | |
| 1087 | this->setReference(function); |
| 1088 | this->setReadMode(XdmfArray::Reference); |
| 1089 | filled = true; |
| 1090 | } |
| 1091 | else if (itemType->second.compare("HyperSlab") == 0) { |
nothing calls this directly
no test coverage detected