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

Method translateShadingSurface

src/sdd/MapGeometry.cpp:1599–1732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1597 }
1598
1599 boost::optional<openstudio::model::ModelObject>
1600 ReverseTranslator::translateShadingSurface(const pugi::xml_node& element, openstudio::model::ShadingSurfaceGroup& shadingSurfaceGroup) {
1601 std::vector<openstudio::Point3d> vertices;
1602
1603 UnitSystem siSys(UnitSystem::SI);
1604
1605 pugi::xml_node polyLoopElement = element.child("PolyLp");
1606 if (!polyLoopElement) {
1607 LOG(Error, "ShadingSurface element 'PolyLp' is empty, cannot create ShadingSurface.");
1608 return boost::none;
1609 }
1610
1611 std::vector<pugi::xml_node> cartesianPointElements = makeVectorOfChildren(polyLoopElement, "CartesianPt");
1612 for (std::vector<pugi::xml_node>::size_type i = 0; i < cartesianPointElements.size(); i++) {
1613 std::vector<pugi::xml_node> coordinateElements = makeVectorOfChildren(cartesianPointElements[i], "Coord");
1614 if (coordinateElements.size() != 3) {
1615 LOG(Error, "PolyLp element 'CartesianPt' does not have exactly 3 'Coord' elements, cannot create ShadingSurface.");
1616 return boost::none;
1617 }
1618
1619 /* DLM: there conversions were taking about 75% of the time it takes to convert a large model
1620
1621 // sdd units = ft, os units = m
1622 Quantity xIP(coordinateElements.at(0).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0)));
1623 Quantity yIP(coordinateElements.at(1).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0)));
1624 Quantity zIP(coordinateElements.at(2).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0)));
1625
1626 OptionalQuantity xSI = QuantityConverter::instance().convert(xIP, siSys);
1627 OS_ASSERT(xSI);
1628 OS_ASSERT(xSI->units() == SIUnit(SIExpnt(0,1,0)));
1629
1630 OptionalQuantity ySI = QuantityConverter::instance().convert(yIP, siSys);
1631 OS_ASSERT(ySI);
1632 OS_ASSERT(ySI->units() == SIUnit(SIExpnt(0,1,0)));
1633
1634 OptionalQuantity zSI = QuantityConverter::instance().convert(zIP, siSys);
1635 OS_ASSERT(zSI);
1636 OS_ASSERT(zSI->units() == SIUnit(SIExpnt(0,1,0)));
1637
1638 vertices.push_back(openstudio::Point3d(xSI->value(), ySI->value(), zSI->value()));
1639 */
1640
1641 double x = footToMeter * coordinateElements[0].text().as_double();
1642 double y = footToMeter * coordinateElements[1].text().as_double();
1643 double z = footToMeter * coordinateElements[2].text().as_double();
1644 vertices.push_back(openstudio::Point3d(x, y, z));
1645 }
1646
1647 model::Model model = shadingSurfaceGroup.model();
1648 model::ShadingSurface shadingSurface(vertices, model);
1649 shadingSurface.setShadingSurfaceGroup(shadingSurfaceGroup);
1650
1651 pugi::xml_node nameElement = element.child("Name");
1652 std::string name;
1653 if (!nameElement) {
1654 LOG(Error, "ShadingSurface element 'Name' is empty.")
1655 } else {
1656 name = escapeName(nameElement.text().as_string());

Callers

nothing calls this directly

Calls 15

makeVectorOfChildrenFunction · 0.85
istringEqualFunction · 0.85
numberFunction · 0.85
transmittanceScheduleMethod · 0.80
layersMethod · 0.80
Point3dClass · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
modelMethod · 0.45
setNameMethod · 0.45

Tested by

no test coverage detected