From ce970792bad4229e42cc2cb131002c5aab238ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Granskogen=20Bj=C3=B8rnstad?= Date: Thu, 23 Nov 2017 11:10:41 +0100 Subject: [PATCH] SvgSerializer: Support full circles and ellipses Use and to create a valid SVG for these geometries. Limit to only the *first* edge. I am not sure whether there are scenarios with multiple edges like this: 1. One or more straight line pieces or arc segments 2. A full closed circle 3. More straight lines or arc segments If there is, we are keeping the original behavior here. --- src/ifcconvert/SvgSerializer.cpp | 64 ++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/src/ifcconvert/SvgSerializer.cpp b/src/ifcconvert/SvgSerializer.cpp index df6471735a..a2998d05b1 100644 --- a/src/ifcconvert/SvgSerializer.cpp +++ b/src/ifcconvert/SvgSerializer.cpp @@ -27,6 +27,8 @@ #include #include +#include +#include #include #include #include @@ -76,10 +78,64 @@ void SvgSerializer::write(path_object& p, const TopoDS_Wire& wire) { bool conical = (ty == STANDARD_TYPE(Geom_Circle) || ty == STANDARD_TYPE(Geom_Ellipse)); bool closed = ALMOST_THE_SAME(u1 + PI2, u2); if (conical && closed) { - std::stringstream ss; - ss << "Full circles and ellipses currently not supported (id " - << p.first << ")"; - Logger::Warning(ss.str()); + if (first) { + if (ty == STANDARD_TYPE(Geom_Circle)) { + Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(curve); + double r = circle->Radius(); + gp_Circ c = circle->Circ(); + gp_Pnt center = c.Location(); + path.add(" Elips(); + gp_Pnt center = e.Location(); + + // Write the ellipse with major radius along X axis: + path.add(" (id " + << p.first << ")"; + Logger::Warning(ss.str()); + } } const bool reversed = edge.Orientation() == TopAbs_REVERSED;