d3ru / eggbotcode

Automatically exported from code.google.com/p/eggbotcode
0 stars 0 forks source link

Multi-layer plotting is very slow #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Reported by multiple users:
On complex files with multiple layers, it takes too long (minutes, sometimes) 
to begin plotting. 

The Eggbot Plot extension reads through the whole Inkscape file and starts 
plotting when it gets to the right layer.    And, once it finishes the correct 
layer, it scans through the rest of the layers until it reaches the end of the 
file.    This process can take a while, particularly if the file is very 
complex. 

Original issue reported on code.google.com by windell@oskay.net on 23 Apr 2011 at 8:37

GoogleCodeExporter commented 9 years ago
I was initially concerned that each and every path had to be evaluated in order 
to keep track of the last position for purposes of knowing the "current point" 
for paths which begin relative to the current point.  However, it appears that 
Inkscape at least always interprets a relative start to a new path as being 
relative to (0,0) + any current coordinate system transformations.  [Note that 
the SVG spec is very weak on this point and indeed the section on Paths refers 
to the "current point" a lot but nowhere in the entire specification is there a 
formal definition of how it is maintained, what its default is, etc.]

Given Inkscape's behavior, I believe it is okay to skip processing entire 
layers.  However, we do need to track any transformations in the ancestor 
elements of the group containing each target layer.  Thus, we could probably 
use an XPath to find the target layer(s), walk the XML tree back to the root, 
and then follow the path back down, tracking the transforms on the descent.  
Alternatively, when we hit a group <g> which is a layer but isn't a layer we 
care about, then we can simply skip to the next sibling element in the XML 
document tree thus bypassing that entire layer.  This is a less radical 
departure from how the code currently functions and my recommendation for the 
first attempt.  Note that this also simplifies the layer plotting: we'd no 
longer need to have test self.plotCurrentLayer here and there.  Instead, we 
simply wouldn't descend the XML document tree for groups which aren't the 
correct layer thus obviating the need entirely for self.plotCurrentLayer.

BUT, there's an issue associated with doing resumes.  If we use this strategy, 
the node count will be different then when we process the entire document.  As 
such, part of saving the node count / last path data will also need to save the 
layer info from the layers Tab.  A resume operation will then need to take into 
account layer selection.  (Note, we don't want to use the value from the layer 
tab when they click Apply on the Resume tab: the user may have pause the plot, 
accidentally changed the value on the Layer tab, then switched to the Resume 
tab and then clicked Apply.)

I don't know that we want to bite this change off if the goal is for a new 
release by, say, 21 May.

Original comment by newman.d...@gmail.com on 4 May 2011 at 3:15

GoogleCodeExporter commented 9 years ago
>  Instead, we simply wouldn't descend the XML document tree for groups which 
aren't the correct layer thus obviating the need entirely for 
self.plotCurrentLayer.

I take that back: we'd still need the boolean self.plotCurrentLayer so as to 
prevent plotting material which is not in any layer.  We could still skip 
descending into layers we don't care about.  But we'd still need a switch to 
enable plotting when we descend into a layer we care about and then disable the 
plotting when we leave that layer.

Original comment by newman.d...@gmail.com on 4 May 2011 at 5:45

GoogleCodeExporter commented 9 years ago
>As such, part of saving the node count / last path data will also need to save 
the layer info from the layers Tab.  A resume operation will then need to take 
into account layer selection. 

I believe that this *is* how it is currently implemented.  If the initial plot 
was from the Layers tab, then *that* layer selection is saved in the Inkscape 
document with the other save/resume data.  When resuming, it continues that 
same layer that it was printing before.    If the initial plot was from the 
main tab (plotting all layers), then it resumes printing all layers when 
resuming.

Original comment by windell@oskay.net on 4 May 2011 at 10:22

GoogleCodeExporter commented 9 years ago

Original comment by windell@oskay.net on 15 Dec 2014 at 10:00