From: Magnus Jacobsson Date: Wed, 14 Sep 2022 19:58:57 +0000 (+0200) Subject: shapes: star_inside: fix clipping of edge at node outline X-Git-Tag: 7.0.0~21^2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23e08ef13bde482d56bb40f0eb32507422b961cd;p=graphviz shapes: star_inside: fix clipping of edge at node outline Take node penwidth into account when doing the clipping of the 'star' shape. This causes the clipping to occur at the visible node outline instead of at the "ideal" bounding box which does not take node penwidth into account. For the star shape, this fixes the second part of arrow not respecting penwidth. Similar fixes need to be applied to fix the second part for other node shapes. The test_max_edge_node_overlap_node_shapes test case now succeeds, so the expectancy that it should fail is removed. Towards https://gitlab.com/graphviz/graphviz/-/issues/372. --- diff --git a/lib/common/shapes.c b/lib/common/shapes.c index 0f595308f..41b68e001 100644 --- a/lib/common/shapes.c +++ b/lib/common/shapes.c @@ -4002,10 +4002,16 @@ static bool star_inside(inside_t * inside_context, pointf p) vertex = poly->vertices; sides = poly->sides; - /* index to outer-periphery */ - outp = (poly->peripheries - 1) * sides; - if (outp < 0) - outp = 0; + const double penwidth = late_int(n, N_penwidth, DEFAULT_NODEPENWIDTH, MIN_NODEPENWIDTH); + if (poly->peripheries >= 1 && penwidth > 0) { + /* index to outline, i.e., the outer-periphery with penwidth taken into account */ + outp = (poly->peripheries + 1 - 1) * sides; + } else { + /* index to outer-periphery */ + outp = (poly->peripheries - 1) * sides; + if (outp < 0) + outp = 0; + } lastn = n; } diff --git a/tests/test_max_edge_node_overlap_polygon_node_shapes.cpp b/tests/test_max_edge_node_overlap_polygon_node_shapes.cpp index 182666e56..6095e82b8 100644 --- a/tests/test_max_edge_node_overlap_polygon_node_shapes.cpp +++ b/tests/test_max_edge_node_overlap_polygon_node_shapes.cpp @@ -4,10 +4,9 @@ #include "test_edge_node_overlap_utilities.h" #include "test_utilities.h" -TEST_CASE( - "Maximum edge and node overlap for polygon node shapes", - "[!shouldfail] Test that an edge connected to a polygon based node does " - "not overlap that node, regardless of the node shape") { +TEST_CASE("Maximum edge and node overlap for polygon node shapes", + "Test that an edge connected to a polygon based node does not " + "overlap that node, regardless of the node shape") { const auto shape = GENERATE(from_range(node_shapes_consisting_of_polygon)); INFO("Node shape: " << shape);