| 119 | } |
| 120 | |
| 121 | boost::optional<model::ModelObject> ReverseTranslator::translateBuilding(const pugi::xml_node& element, openstudio::model::Model& model) { |
| 122 | openstudio::model::Building building = model.getUniqueModelObject<openstudio::model::Building>(); |
| 123 | |
| 124 | pugi::xml_node nameElement = element.child("Name"); |
| 125 | |
| 126 | // http://code.google.com/p/cbecc/issues/detail?id=378 |
| 127 | // The angle between the model Y-Axis and True North, measured clockwise from the model Y-Axis in Degrees. |
| 128 | pugi::xml_node northAngleElement = element.child("NAng"); |
| 129 | // The angle between True North and the the model Y-Axis, measured clockwise from True North in Degrees. |
| 130 | pugi::xml_node buildingAzimuthElement = element.child("BldgAz"); // this corresponds to Building::North Axis |
| 131 | |
| 132 | // TODO: do we want to check if key Name is present or whether Name is not an empty string? |
| 133 | if (!nameElement) { |
| 134 | LOG(Error, "Bldg element 'Name' is empty.") |
| 135 | } else { |
| 136 | std::string bldgname = nameElement.text().as_string(); |
| 137 | if (bldgname.empty()) { |
| 138 | LOG(Error, "Bldg element 'Name' is empty.") |
| 139 | } else { |
| 140 | building.setName(escapeName(bldgname)); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | if (buildingAzimuthElement) { |
| 145 | double buildingAzimuth = normalizeAngle0to360(buildingAzimuthElement.text().as_double()); |
| 146 | building.setNorthAxis(buildingAzimuth); |
| 147 | } else if (northAngleElement) { |
| 148 | // use NAng for backwards compatibility with SDD's only having NAng |
| 149 | double northAngle = normalizeAngle0to360(northAngleElement.text().as_double()); |
| 150 | double buildingAzimuth = 360.0 - northAngle; |
| 151 | building.setNorthAxis(buildingAzimuth); |
| 152 | } |
| 153 | |
| 154 | // translate shadingSurfaces |
| 155 | std::vector<pugi::xml_node> exteriorShadingElements = makeVectorOfChildren(element, "ExtShdgObj"); |
| 156 | if (!exteriorShadingElements.empty()) { |
| 157 | model::ShadingSurfaceGroup shadingSurfaceGroup(model); |
| 158 | shadingSurfaceGroup.setName("Building ShadingGroup"); |
| 159 | shadingSurfaceGroup.setShadingSurfaceType("Building"); |
| 160 | for (std::vector<pugi::xml_node>::size_type i = 0; i < exteriorShadingElements.size(); ++i) { |
| 161 | if (exteriorShadingElements[i].parent() == element) { |
| 162 | boost::optional<model::ModelObject> exteriorShading = translateShadingSurface(exteriorShadingElements[i], shadingSurfaceGroup); |
| 163 | if (!exteriorShading) { |
| 164 | LOG(Error, "Failed to translate 'ExtShdgObj' element " << i); |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | std::vector<pugi::xml_node> thermalZoneElements = makeVectorOfChildren(element, "ThrmlZn"); |
| 171 | |
| 172 | // It **Must** to be recursive here, since Spc lives inside Story and there are multiple stories |
| 173 | std::vector<pugi::xml_node> spaceElements = makeVectorOfChildrenRecursive(element, "Spc"); |
| 174 | |
| 175 | std::vector<pugi::xml_node> buildingStoryElements = makeVectorOfChildren(element, "Story"); |
| 176 | |
| 177 | // OR: |
| 178 | /* |
nothing calls this directly
no test coverage detected