SVG export: improve performance (#26149)
* SVG export: use a set to match edges instead of a list Lookup in edge list becomes O(1), significantly improving SVG export speed * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1052,10 +1052,20 @@ def get_svg(
|
||||
pathname="%s_w%04d" % (obj.Name, i),
|
||||
)
|
||||
wiredEdges.extend(w.Edges)
|
||||
|
||||
if len(wiredEdges) != len(obj.Shape.Edges):
|
||||
fill = "none" # Required if obj has a face. Edges processed here have no face.
|
||||
|
||||
def get_edge_descriptor(edge):
|
||||
return (
|
||||
str(edge.Curve),
|
||||
str(edge.Vertexes[0].Point),
|
||||
str(edge.Vertexes[-1].Point),
|
||||
)
|
||||
|
||||
wiredEdgesSet = set([get_edge_descriptor(e) for e in wiredEdges])
|
||||
for i, e in enumerate(obj.Shape.Edges):
|
||||
if DraftGeomUtils.findEdge(e, wiredEdges) is None:
|
||||
if get_edge_descriptor(e) not in wiredEdgesSet:
|
||||
svg += get_path(
|
||||
obj,
|
||||
plane,
|
||||
|
||||
Reference in New Issue
Block a user