From cb872a5bff9c59b69d0d1461bb73592e3d30cc24 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 11 Mar 2020 14:45:58 +0100 Subject: [PATCH] Miirror SVG output to account for coordinate systems --- src/serializers/SvgSerializer.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/serializers/SvgSerializer.cpp b/src/serializers/SvgSerializer.cpp index d8a6958369..20fe38ac0c 100644 --- a/src/serializers/SvgSerializer.cpp +++ b/src/serializers/SvgSerializer.cpp @@ -52,6 +52,8 @@ #include #include +#include + #include "../ifcparse/IfcGlobalId.h" #include "SvgSerializer.h" @@ -310,7 +312,16 @@ void SvgSerializer::write(const IfcGeom::BRepElement* o) path_object& p = start_path(storey, nameElement(o)); + // SVG has a coordinate system with the origin in the *upper*-left corner + // therefore we mirror the shape along the XZ-plane. TopoDS_Shape compound = o->geometry().as_compound(); + gp_Trsf trsf; + trsf.SetMirror(gp_Ax2(gp::Origin(), gp::DY())); + BRepBuilderAPI_Transform make_transform(compound, trsf); + make_transform.Build(); + // When determinant < 0, copy is implied and the input is not mutated. + compound = make_transform.Shape(); + TopoDS_Iterator it(compound); // Iterate over components of compound to have better chance of matching section edges to closed wires