diff --git a/tests/data/refs/voronoi2svg__083b27d59093207e6210e1001eb9d5df.out b/tests/data/refs/voronoi2svg__083b27d59093207e6210e1001eb9d5df.out new file mode 100644 index 0000000000000000000000000000000000000000..db6ced981ac9279855586836faea7c472a6d40d6 --- /dev/null +++ b/tests/data/refs/voronoi2svg__083b27d59093207e6210e1001eb9d5df.out @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/test_voronoi2svg.py b/tests/test_voronoi2svg.py index f32d80824e8ad77f5318001d925285c100bca6c5..0c27e5d6146b8e568778bcc7f572e0ebca4b3654 100644 --- a/tests/test_voronoi2svg.py +++ b/tests/test_voronoi2svg.py @@ -7,11 +7,19 @@ class TestVoronoi2svgBasic(ComparisonMixin, TestCase): effect_class = Voronoi compare_filters = [CompareOrderIndependentStyle()] comparisons = [ - ("--id=c1", "--id=c2", "--id=c3", "--id=p1", "--id=p2", "--id=s1", "--id=u1", - "--diagram-type=Both", "--clip-box=Automatic from seeds", "--show-clip-box=True"), + ("--id=c1", "--id=c2", "--id=c3", "--id=p1", "--id=p2", "--id=s1", "--id=u1", + "--diagram-type=Both", "--clip-box=Automatic from seeds", "--show-clip-box=True"), - ("--id=c1", "--id=c2", "--id=c3", "--id=p1", "--id=p2", "--id=s1", "--diagram-type=Voronoi", "--clip-box=Page"), + ("--id=c1", "--id=c2", "--id=c3", "--id=p1", "--id=p2", "--id=s1", "--diagram-type=Voronoi", + "--clip-box=Page"), - ("--id=r1", "--id=r3", "--id=c1", "--id=c3", "--id=s1", "--diagram-type=Both", - "--delaunay-fill-options=delaunay-fill"), + ("--id=r1", "--id=r3", "--id=c1", "--id=c3", "--id=s1", "--diagram-type=Both", + "--delaunay-fill-options=delaunay-fill"), + ] +class TestVoronoi2svgmm(ComparisonMixin, TestCase): + """Test voronoi for mm based documents (https://gitlab.com/inkscape/extensions/-/issues/403)""" + effect_class = Voronoi + compare_file = "svg/interp_shapes.svg" + comparisons = [ + tuple(f"--id=path{i}" for i in range(1, 11)) + ("--diagram-type=Voronoi", "--clip-box=Page") ] diff --git a/voronoi.py b/voronoi.py index 874064587e0148a7f1ef79b74a06a2abf4b68863..f7d8703f8dff1bd21d29d6899f97de98687ece02 100755 --- a/voronoi.py +++ b/voronoi.py @@ -783,6 +783,7 @@ def computeVoronoiDiagram(points): the indices of the vetices at the end of the edge. If v1 or v2 is -1, the line extends to infinity. """ + Edge.EDGE_NUM = 0 siteList = SiteList(points) context = Context() voronoi(siteList, context) @@ -795,6 +796,7 @@ def computeDelaunayTriangulation(points): Returns a list of 3-tuples: the indices of the points that form a Delaunay triangle. """ + Edge.EDGE_NUM = 0 siteList = SiteList(points) context = Context() context.triangulate = True diff --git a/voronoi2svg.py b/voronoi2svg.py index e949a145a914ea1c086e56b228eab3dca1f4d828..c8888d59b07e2b2b6f0687fc14d050d72d06b34a 100755 --- a/voronoi2svg.py +++ b/voronoi2svg.py @@ -214,9 +214,8 @@ class Voronoi(inkex.EffectExtension): # Clipbox is the box to which the Voronoi diagram is restricted if self.options.clip_box == 'Page': - svg = self.document.getroot() - width = self.svg.unittouu(svg.get('width')) - height = self.svg.unittouu(svg.get('height')) + width = self.svg.viewbox_width + height = self.svg.viewbox_height clip_box = (0, width, 0, height) else: clip_box = (group_bbox.left,