From e84128a4136c4b0218b39076b21ef4a2cdd30836 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Wed, 21 Aug 2019 19:56:25 -0300 Subject: [PATCH] Arch: Optimization in SVG generation code --- src/Mod/Arch/ArchSectionPlane.py | 37 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index f914df47d7..6744bcc4bb 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -380,22 +380,6 @@ def getSVG(source, svgcache = None source.Proxy.shapecache = None - if hasattr(source.Proxy,"shapecache") and source.Proxy.shapecache: - vshapes = source.Proxy.shapecache[0] - hshapes = source.Proxy.shapecache[1] - sshapes = source.Proxy.shapecache[2] - cutface = source.Proxy.shapecache[3] - cutvolume = source.Proxy.shapecache[4] - invcutvolume = source.Proxy.shapecache[5] - objectSshapes = source.Proxy.shapecache[6] - else: - if showFill: - vshapes,hshapes,sshapes,cutface,cutvolume,invcutvolume,objectSshapes = getCutShapes(objs,cutplane,onlySolids,clip,joinArch,showHidden,True) - else: - vshapes,hshapes,sshapes,cutface,cutvolume,invcutvolume = getCutShapes(objs,cutplane,onlySolids,clip,joinArch,showHidden) - objectSshapes = [] - source.Proxy.shapecache = [vshapes,hshapes,sshapes,cutface,cutvolume,invcutvolume,objectSshapes] - # generating SVG if renderMode in ["Coin",2]: # render using a coin viewer @@ -440,6 +424,23 @@ def getSVG(source, source.Proxy.svgcache = [svgcache,renderMode,showHidden,showFill,fillSpaces,joinArch] else: # Wireframe (0) mode + + if hasattr(source,"Proxy") and hasattr(source.Proxy,"shapecache") and source.Proxy.shapecache: + vshapes = source.Proxy.shapecache[0] + hshapes = source.Proxy.shapecache[1] + sshapes = source.Proxy.shapecache[2] + cutface = source.Proxy.shapecache[3] + cutvolume = source.Proxy.shapecache[4] + invcutvolume = source.Proxy.shapecache[5] + objectSshapes = source.Proxy.shapecache[6] + else: + if showFill: + vshapes,hshapes,sshapes,cutface,cutvolume,invcutvolume,objectSshapes = getCutShapes(objs,cutplane,onlySolids,clip,joinArch,showHidden,True) + else: + vshapes,hshapes,sshapes,cutface,cutvolume,invcutvolume = getCutShapes(objs,cutplane,onlySolids,clip,joinArch,showHidden) + objectSshapes = [] + source.Proxy.shapecache = [vshapes,hshapes,sshapes,cutface,cutvolume,invcutvolume,objectSshapes] + if not svgcache: svgcache = "" # render using the Drawing module @@ -501,6 +502,10 @@ def getSVG(source, if not techdraw: svg += '' + if not cutface: + # if we didn't calculate anything better, use the cutplane... + cutface = cutplane + # filter out spaces not cut by the source plane if cutface and spaces: spaces = [s for s in spaces if s.Shape.BoundBox.intersect(cutface.BoundBox)]