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

Method simplifyFace

src/utilities/floorspace/FSModel.cpp:610–652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

608}
609
610void FSSpace::simplifyFace(const FSGeometry& geometry) {
611 Point3dVector faceVertices;
612 for (const auto& edgeRef : m_face->edgeRefs()) {
613 const FSVertex& vertex = edgeRef.getNextVertex();
614 faceVertices.emplace_back(Point3d(vertex.x(), vertex.y(), 0));
615 }
616
617 // Simplify and keep inline vertices, the count should be the same
618 // but if the vertex order has changed then there were overlapping
619 // edges. If this is the case then a new face and new edges are created
620 Point3dVector simplifiedVertices = simplify(faceVertices, false, 0.01);
621 if (!circularEqual(simplifiedVertices, faceVertices)) {
622
623 // Now simplify and remove inline vertices giviong us a cleanpolygon to work with
624 simplifiedVertices = simplify(faceVertices, true, 0.01);
625 // If the number of vertices has changed then we will create new edges
626 // based on the simplified vertices
627 if (simplifiedVertices.size() != faceVertices.size()) {
628 std::vector<FSEdgeReference> edgeRefs;
629 // Create new edges for the face
630 for (unsigned i = 0; i < simplifiedVertices.size(); i++) {
631 const Point3d& p1 = simplifiedVertices[i];
632 const Point3d& p2 = simplifiedVertices[(i + 1) % simplifiedVertices.size()];
633
634 auto v1 = geometry.vertex(p1);
635 auto v2 = geometry.vertex(p2);
636 if (v1.has_value() && v2.has_value()) {
637 //boost::optional<FSEdge> edge = geometry.getEdge(*v1, *v2);
638 //if (edge == boost::none)
639 // edge = FSEdge (*v1, *v2);
640 //edgeRefs.emplace_back(FSEdgeReference(*edge, 1));
641 FSEdge edge(*v1, *v2);
642 edgeRefs.emplace_back(std::move(edge), 1);
643 }
644 }
645
646 // Update the face
647 m_face->setEdgeRefs(std::move(edgeRefs));
648 }
649 // Get a list of windows and doors that were associated with the old edges
650 // Remap these windows and doors to the new edges
651 }
652}
653
654///////////////////////////////////////////////////////////////////////////////////
655

Callers

nothing calls this directly

Calls 10

simplifyFunction · 0.85
circularEqualFunction · 0.85
edgeRefsMethod · 0.80
getNextVertexMethod · 0.80
vertexMethod · 0.80
setEdgeRefsMethod · 0.80
Point3dClass · 0.70
xMethod · 0.45
yMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected