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

Method splitSurfaceForSubSurfaces

src/model/Surface.cpp:1723–1891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1721 };
1722
1723 std::vector<Surface> Surface_Impl::splitSurfaceForSubSurfaces() {
1724 std::vector<Surface> result;
1725
1726 double expand = 0.0254;
1727 double tol = 0.01; // should be less than expand
1728
1729 // has to be a wall
1730 if (!istringEqual(this->surfaceType(), "Wall")) {
1731 return result;
1732 }
1733
1734 // can't have adjacent surface
1735 if (this->adjacentSurface()) {
1736 return result;
1737 }
1738
1739 std::vector<SubSurface> subSurfaces = this->subSurfaces();
1740 if (subSurfaces.empty()) {
1741 // nothing to do
1742 return result;
1743 }
1744
1745 Point3dVector vertices = this->vertices();
1746 Transformation transformation = Transformation::alignFace(vertices);
1747 Transformation inverseTransformation = transformation.inverse();
1748 Point3dVector faceVertices = inverseTransformation * vertices;
1749
1750 if (faceVertices.size() < 3) {
1751 return result;
1752 }
1753
1754 // boost polygon wants vertices in clockwise order, faceVertices must be reversed
1755 std::reverse(faceVertices.begin(), faceVertices.end());
1756
1757 // new coordinate system has z' in direction of outward normal, y' is up
1758 //double xmin = std::numeric_limits<double>::max();
1759 //double xmax = std::numeric_limits<double>::min();
1760 double ymin = std::numeric_limits<double>::max();
1761 double ymax = std::numeric_limits<double>::min();
1762 for (const Point3d& faceVertex : faceVertices) {
1763 //xmin = std::min(xmin, faceVertex.x());
1764 //xmax = std::max(xmax, faceVertex.x());
1765 ymin = std::min(ymin, faceVertex.y());
1766 ymax = std::max(ymax, faceVertex.y());
1767 }
1768 if (ymin > ymax) {
1769 return result;
1770 }
1771
1772 // create a mask for each sub surface
1773 std::vector<Point3dVector> masks;
1774 std::map<Handle, Point3dVector> handleToFaceVertexMap;
1775 for (const SubSurface& subSurface : subSurfaces) {
1776
1777 Point3dVector subSurfaceFaceVertices = inverseTransformation * subSurface.vertices();
1778 if (subSurfaceFaceVertices.size() < 3) {
1779 continue;
1780 }

Callers 1

TEST_FFunction · 0.80

Calls 15

surfaceTypeMethod · 0.95
adjacentSurfaceMethod · 0.95
subSurfacesMethod · 0.95
cloneMethod · 0.95
istringEqualFunction · 0.85
reverseFunction · 0.85
joinAllFunction · 0.85
intersectFunction · 0.85
PolygonAreaGreaterClass · 0.85
pointInPolygonFunction · 0.85
inverseMethod · 0.80
beginMethod · 0.80

Tested by 1

TEST_FFunction · 0.64