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

Method convertSimpleSubSurfaces

src/energyplus/GeometryTranslator.cpp:948–1341  ·  view source on GitHub ↗

convert simple subsurfaces to detailed in the current system

Source from the content-addressed store, hash-verified

946
947 // convert simple subsurfaces to detailed in the current system
948 bool GeometryTranslator::convertSimpleSubSurfaces() {
949 // Window
950 for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Window)) {
951
952 // find surface
953 OptionalWorkspaceObject surface = oldObject.getTarget(WindowFields::BuildingSurfaceName);
954 if (!surface) {
955 LOG(Error, "Could not find surface");
956 continue;
957 }
958
959 // get transformation from face coordinates to zone
960 Transformation t = Transformation::alignFace(getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, *surface));
961
962 // simple params
963 OptionalDouble x0 = oldObject.getDouble(WindowFields::StartingXCoordinate, true);
964 OptionalDouble z0 = oldObject.getDouble(WindowFields::StartingZCoordinate, true);
965 OptionalDouble length = oldObject.getDouble(WindowFields::Length, true);
966 OptionalDouble height = oldObject.getDouble(WindowFields::Height, true);
967 if (!x0 || !z0 || !length || !height) {
968 LOG(Error, "Missing required fields");
969 continue;
970 }
971
972 // vertices
973 openstudio::Point3dVector faceVertices(4);
974 faceVertices[0] = Point3d(*x0, *z0 + *height, 0.0);
975 faceVertices[1] = Point3d(*x0, *z0, 0.0);
976 faceVertices[2] = Point3d(*x0 + *length, *z0, 0.0);
977 faceVertices[3] = Point3d(*x0 + *length, *z0 + *height, 0.0);
978
979 // transform vertices
980 faceVertices = t * faceVertices;
981
982 // add new object
983 IdfObject newObject(IddObjectType::FenestrationSurface_Detailed);
984
985 // fields which map directly
986 std::vector<std::pair<unsigned, unsigned>> fieldMap{
987 {WindowFields::Name, FenestrationSurface_DetailedFields::Name},
988 {WindowFields::ConstructionName, FenestrationSurface_DetailedFields::ConstructionName},
989 {WindowFields::BuildingSurfaceName, FenestrationSurface_DetailedFields::BuildingSurfaceName},
990 {WindowFields::FrameandDividerName, FenestrationSurface_DetailedFields::FrameandDividerName},
991 {WindowFields::Multiplier, FenestrationSurface_DetailedFields::Multiplier},
992 };
993
994 // copy fields over directly
995 mapFields(oldObject, newObject, fieldMap);
996
997 // set other fields
998 newObject.setString(FenestrationSurface_DetailedFields::SurfaceType, "Window");
999 newObject.setString(FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject, "");
1000 newObject.setString(FenestrationSurface_DetailedFields::ViewFactortoGround, "");
1001 newObject.setDouble(FenestrationSurface_DetailedFields::NumberofVertices, 4);
1002
1003 // swap old object with new one
1004 bool ok = m_workspace.swap(oldObject, newObject);
1005 if (ok) {

Callers

nothing calls this directly

Calls 12

getVerticesFunction · 0.85
mapFieldsFunction · 0.85
setVerticesFunction · 0.85
iddObjectMethod · 0.80
Point3dClass · 0.50
getObjectsByTypeMethod · 0.45
getTargetMethod · 0.45
getDoubleMethod · 0.45
setStringMethod · 0.45
setDoubleMethod · 0.45
swapMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected