| 1599 | } |
| 1600 | |
| 1601 | std::vector<SubSurface> Surface_Impl::applyViewAndDaylightingGlassRatios( |
| 1602 | double viewGlassToWallRatio, double daylightingGlassToWallRatio, double desiredViewGlassSillHeight, double desiredDaylightingGlassHeaderHeight, |
| 1603 | double exteriorShadingProjectionFactor, double interiorShelfProjectionFactor, const boost::optional<ConstructionBase>& viewGlassConstruction, |
| 1604 | const boost::optional<ConstructionBase>& daylightingGlassConstruction) { |
| 1605 | std::vector<SubSurface> result; |
| 1606 | |
| 1607 | // has to be a wall |
| 1608 | if (!istringEqual(this->surfaceType(), "Wall")) { |
| 1609 | return result; |
| 1610 | } |
| 1611 | |
| 1612 | // surface cannot have any non-window sub surfaces |
| 1613 | for (const SubSurface& subSurface : this->subSurfaces()) { |
| 1614 | if (istringEqual(subSurface.subSurfaceType(), "FixedWindow") || istringEqual(subSurface.subSurfaceType(), "OperableWindow")) { |
| 1615 | continue; |
| 1616 | } |
| 1617 | return result; |
| 1618 | } |
| 1619 | |
| 1620 | Point3dVector vertices = this->vertices(); |
| 1621 | Point3dVector viewVertices; |
| 1622 | Point3dVector daylightingVertices; |
| 1623 | Point3dVector exteriorShadingVertices; |
| 1624 | Point3dVector interiorShelfVertices; |
| 1625 | bool test = openstudio::applyViewAndDaylightingGlassRatios(viewGlassToWallRatio, daylightingGlassToWallRatio, desiredViewGlassSillHeight, |
| 1626 | desiredDaylightingGlassHeaderHeight, exteriorShadingProjectionFactor, |
| 1627 | interiorShelfProjectionFactor, vertices, viewVertices, daylightingVertices, |
| 1628 | exteriorShadingVertices, interiorShelfVertices); |
| 1629 | |
| 1630 | if (!test) { |
| 1631 | return result; |
| 1632 | } |
| 1633 | |
| 1634 | // everything ok, remove all windows |
| 1635 | for (SubSurface& subSurface : this->subSurfaces()) { |
| 1636 | if (istringEqual(subSurface.subSurfaceType(), "FixedWindow") || istringEqual(subSurface.subSurfaceType(), "OperableWindow")) { |
| 1637 | subSurface.remove(); |
| 1638 | } |
| 1639 | } |
| 1640 | |
| 1641 | // add a new window |
| 1642 | Model model = this->model(); |
| 1643 | auto thisSurface = this->getObject<Surface>(); |
| 1644 | boost::optional<Space> space = this->space(); |
| 1645 | |
| 1646 | boost::optional<SubSurface> viewWindow; |
| 1647 | if (!viewVertices.empty()) { |
| 1648 | viewWindow = SubSurface(viewVertices, model); |
| 1649 | result.push_back(*viewWindow); |
| 1650 | viewWindow->setSurface(thisSurface); |
| 1651 | |
| 1652 | if (viewGlassConstruction) { |
| 1653 | viewWindow->setConstruction(*viewGlassConstruction); |
| 1654 | } |
| 1655 | } |
| 1656 | |
| 1657 | boost::optional<SubSurface> daylightingWindow; |
| 1658 | if (!daylightingVertices.empty()) { |