MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / convertSimpleSurfaces

Method convertSimpleSurfaces

src/energyplus/GeometryTranslator.cpp:1344–2270  ·  view source on GitHub ↗

convert simple surfaces to detailed in the current system

Source from the content-addressed store, hash-verified

1342
1343 // convert simple surfaces to detailed in the current system
1344 bool GeometryTranslator::convertSimpleSurfaces(const CoordinateChange& coordChange) {
1345
1346 // building transformation
1347 Transformation buildingTransformation = this->buildingTransformation();
1348
1349 // Wall::Detailed
1350 for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Wall_Detailed)) {
1351
1352 // find zone
1353 OptionalWorkspaceObject zone = oldObject.getTarget(Wall_DetailedFields::ZoneName);
1354 if (!zone) {
1355 LOG(Error, "Could not find zone");
1356 continue;
1357 }
1358
1359 // get transformation
1360 Transformation t;
1361 if (coordChange == CoordinateChange::AbsoluteToRelative) {
1362 Transformation zoneTransformation = this->zoneTransformation(*zone);
1363 t = zoneTransformation.inverse() * buildingTransformation.inverse();
1364 } else if (coordChange == CoordinateChange::RelativeToAbsolute) {
1365 Transformation zoneTransformation = this->zoneTransformation(*zone);
1366 t = buildingTransformation * zoneTransformation;
1367 }
1368
1369 // get vertices
1370 Point3dVector vertices = t * getVertices(Wall_DetailedFields::NumberofVertices + 1, oldObject);
1371
1372 // new object
1373 IdfObject newObject(IddObjectType::BuildingSurface_Detailed);
1374
1375 // fields which map directly
1376 std::vector<std::pair<unsigned, unsigned>> fieldMap{
1377 {Wall_DetailedFields::Name, BuildingSurface_DetailedFields::Name},
1378 {Wall_DetailedFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName},
1379 {Wall_DetailedFields::ZoneName, BuildingSurface_DetailedFields::ZoneName},
1380 {Wall_DetailedFields::OutsideBoundaryCondition, BuildingSurface_DetailedFields::OutsideBoundaryCondition},
1381 {Wall_DetailedFields::OutsideBoundaryConditionObject, BuildingSurface_DetailedFields::OutsideBoundaryConditionObject},
1382 {Wall_DetailedFields::SunExposure, BuildingSurface_DetailedFields::SunExposure},
1383 {Wall_DetailedFields::WindExposure, BuildingSurface_DetailedFields::WindExposure},
1384 {Wall_DetailedFields::ViewFactortoGround, BuildingSurface_DetailedFields::ViewFactortoGround},
1385 {Wall_DetailedFields::NumberofVertices, BuildingSurface_DetailedFields::NumberofVertices},
1386 };
1387
1388 // copy fields over directly
1389 mapFields(oldObject, newObject, fieldMap);
1390
1391 // set other fields
1392 newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Wall");
1393
1394 // swap old object with new one
1395 bool ok = m_workspace.swap(oldObject, newObject);
1396 if (ok) {
1397 OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed);
1398 // set vertices
1399 setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices);
1400 } else {
1401 LOG(Error, "Workspace object swap failed");

Callers

nothing calls this directly

Calls 15

zoneTransformationMethod · 0.95
getVerticesFunction · 0.85
mapFieldsFunction · 0.85
setVerticesFunction · 0.85
inverseMethod · 0.80
iddObjectMethod · 0.80
getObjectsByTypeMethod · 0.45
getTargetMethod · 0.45
setStringMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected