| 1754 | } |
| 1755 | |
| 1756 | void SvgSerializer::draw_hlr(const gp_Pln& pln, const drawing_key& drawing_name) { |
| 1757 | auto hlr_items = (drawing_name.first ? this->storey_hlr.find(drawing_name.first)->second : *hlr).build(); |
| 1758 | |
| 1759 | for (auto& p : hlr_items) { |
| 1760 | const TopoDS_Shape& hlr_compound_unmirrored = p.second; |
| 1761 | |
| 1762 | if (!hlr_compound_unmirrored.IsNull()) { |
| 1763 | // Compound 3D curves for mirroring to work |
| 1764 | ShapeFix_Edge sfe; |
| 1765 | TopExp_Explorer exp(hlr_compound_unmirrored, TopAbs_EDGE); |
| 1766 | for (; exp.More(); exp.Next()) { |
| 1767 | sfe.FixAddCurve3d(TopoDS::Edge(exp.Current())); |
| 1768 | } |
| 1769 | |
| 1770 | // Mirror to match SVG coord system. |
| 1771 | // @todo this is very wasteful. We better do the Y-mirror in the SVG writing and |
| 1772 | // not on the TopoDS_Shape input. |
| 1773 | |
| 1774 | TopoDS_Shape hlr_compound; |
| 1775 | if (drawing_name.first == nullptr) { |
| 1776 | gp_Trsf trsf_mirror; |
| 1777 | if (!mirror_y_) { |
| 1778 | trsf_mirror.SetMirror(gp_Ax2(gp::Origin(), gp::DY())); |
| 1779 | } |
| 1780 | if (mirror_x_) { |
| 1781 | gp_Trsf mirror_x; |
| 1782 | mirror_x.SetMirror(gp_Ax2(gp::Origin(), gp::DX())); |
| 1783 | trsf_mirror.PreMultiply(mirror_x); |
| 1784 | } |
| 1785 | BRepBuilderAPI_Transform make_transform_mirror(hlr_compound_unmirrored, trsf_mirror, true); |
| 1786 | make_transform_mirror.Build(); |
| 1787 | hlr_compound = make_transform_mirror.Shape(); |
| 1788 | } else { |
| 1789 | // In case of building storey-based floor plan the mirroring has already |
| 1790 | // been taken into account before projection. |
| 1791 | hlr_compound = hlr_compound_unmirrored; |
| 1792 | } |
| 1793 | |
| 1794 | exp.Init(hlr_compound, TopAbs_EDGE); |
| 1795 | BRep_Builder B; |
| 1796 | path_object* po; |
| 1797 | std::string name; |
| 1798 | if (p.first) { |
| 1799 | name = nameElement(p.first); |
| 1800 | boost::replace_all(name, "class=\"", "class=\"projection "); |
| 1801 | } else { |
| 1802 | name = "class=\"projection\""; |
| 1803 | } |
| 1804 | if (drawing_name.first) { |
| 1805 | po = &start_path(pln, drawing_name.first, name); |
| 1806 | } else { |
| 1807 | po = &start_path(pln, drawing_name.second, name); |
| 1808 | } |
| 1809 | for (; exp.More(); exp.Next()) { |
| 1810 | TopoDS_Wire w; |
| 1811 | B.MakeWire(w); |
| 1812 | B.Add(w, exp.Current()); |
| 1813 | write(*po, w); |