]> granicus.if.org Git - graphviz/commitdiff
tests: test_edge_node_overlap_utilities: check max edge stem/arrow overlap
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Wed, 14 Sep 2022 09:45:52 +0000 (11:45 +0200)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Tue, 20 Sep 2022 15:53:06 +0000 (17:53 +0200)
tests/test_edge_node_overlap_utilities.cpp
tests/test_edge_node_overlap_utilities.h
tests/test_max_edge_node_overlap_polygon_node_shapes.cpp
tests/test_max_edge_node_overlap_simple.cpp
tests/test_min_edge_node_overlap_polygon_node_shapes.cpp
tests/test_min_edge_node_overlap_simple.cpp
tests/test_min_edge_stem_arrow_overlap_simple.cpp

index 3be32b9f7e8d4b73863b4a7a8f8598f781893d3f..5bbd75c7c1742919956d1ecc31db3a01d0c6887c 100644 (file)
@@ -274,6 +274,15 @@ static bool check_analyzed_svg(SVGAnalyzer &svg_analyzer,
     const auto edge_stem_arrowhead_overlap =
         overlap_in_rank_direction(overlap_bbox, rankdir);
 
+    // check maximum overlap of edge stem and arrowhead
+    if (check_options.check_max_edge_stem_arrow_overlap) {
+      const auto max_edge_stem_arrowhead_overlap =
+          check_options.max_edge_stem_arrow_overlap;
+      DO_CHECK(edge_stem_arrowhead_overlap <=
+               max_edge_stem_arrowhead_overlap +
+                   check_options.svg_rounding_error * 2);
+    }
+
     // check minimum overlap of edge stem and arrowhead
     if (check_options.check_min_edge_stem_arrow_overlap) {
       const auto min_edge_stem_arrowhead_overlap =
@@ -295,6 +304,15 @@ static bool check_analyzed_svg(SVGAnalyzer &svg_analyzer,
     const auto edge_stem_arrowtail_overlap =
         overlap_in_rank_direction(overlap_bbox, rankdir);
 
+    // check maximum overlap of edge stem and arrowtail
+    if (check_options.check_max_edge_stem_arrow_overlap) {
+      const auto max_edge_stem_arrowtail_overlap =
+          check_options.max_edge_stem_arrow_overlap;
+      DO_CHECK(edge_stem_arrowtail_overlap <=
+               max_edge_stem_arrowtail_overlap +
+                   check_options.svg_rounding_error * 2);
+    }
+
     // check minimum overlap of edge stem and arrowtail
     if (check_options.check_min_edge_stem_arrow_overlap) {
       const auto min_edge_stem_arrowtail_overlap =
@@ -384,10 +402,14 @@ void test_edge_node_overlap(const graph_options &graph_options,
           tc_check_options.check_max_edge_node_overlap,
       .check_min_edge_node_overlap =
           tc_check_options.check_min_edge_node_overlap,
+      .check_max_edge_stem_arrow_overlap =
+          tc_check_options.check_max_edge_stem_arrow_overlap,
       .check_min_edge_stem_arrow_overlap =
           tc_check_options.check_min_edge_stem_arrow_overlap,
       .max_node_edge_overlap = graphviz_bezier_clip_margin,
       .min_node_edge_overlap = 0,
+      .max_edge_stem_arrow_overlap =
+          graph_options.edge_penwidth / 2 + graphviz_bezier_clip_margin,
       .min_edge_stem_arrow_overlap = 0,
       .svg_rounding_error = graphviz_max_svg_rounding_error,
   };
index ea509caf71a2ea8917468487308f01e6cff8a182..03b7690648caf54ec1b77511d5f457279f0d91fe 100644 (file)
@@ -9,6 +9,9 @@ struct tc_check_options {
   bool check_max_edge_node_overlap = true;
   /// whether to check that there is enough overlap
   bool check_min_edge_node_overlap = true;
+  /// whether to check that there is not too much overlap between edge stem and
+  /// arrow
+  bool check_max_edge_stem_arrow_overlap = true;
   /// whether to check that there is enough overlap between edge stem and arrow
   bool check_min_edge_stem_arrow_overlap = true;
 };
@@ -18,12 +21,17 @@ struct check_options {
   bool check_max_edge_node_overlap = true;
   /// whether to check that there is enough overlap
   bool check_min_edge_node_overlap = true;
+  /// whether to check that there is not too much overlap between edge stem and
+  /// arrow
+  bool check_max_edge_stem_arrow_overlap = true;
   /// whether to check that there is enough overlap between edge stem and arrow
   bool check_min_edge_stem_arrow_overlap = true;
   /// maximum allowed overlap between edge and node
   double max_node_edge_overlap;
   /// minimum required overlap between edge and node
   double min_node_edge_overlap;
+  /// maximum allowed overlap between edge stem and arrow
+  double max_edge_stem_arrow_overlap;
   /// minimum required overlap between edge stem and arrow
   double min_edge_stem_arrow_overlap;
   /// rounding error caused by limited precision in SVG attribute values
index b48ba659a0993858f743343024653167778a54e9..2a20a0d6ae05af5bbfe7af0f4fde9c15747a38b5 100644 (file)
@@ -21,6 +21,7 @@ TEST_CASE(
   const tc_check_options check_options = {
       .check_max_edge_node_overlap = true,
       .check_min_edge_node_overlap = false,
+      .check_max_edge_stem_arrow_overlap = false,
       .check_min_edge_stem_arrow_overlap = false,
   };
 
index 380850a182244b601b8ba5fb7084d85930e443fa..a632ff89381a3125a5afa848b1d9e4ecbe8ce83d 100644 (file)
@@ -15,10 +15,11 @@ TEST_CASE("Maximum edge node overlap",
       .edge_penwidth = 2,
   };
 
-  const tc_check_options check_options = {.check_max_edge_node_overlap = true,
-                                          .check_min_edge_node_overlap = false,
-                                          .check_min_edge_stem_arrow_overlap =
-                                              false};
+  const tc_check_options check_options = {
+      .check_max_edge_node_overlap = true,
+      .check_min_edge_node_overlap = false,
+      .check_max_edge_stem_arrow_overlap = false,
+      .check_min_edge_stem_arrow_overlap = false};
 
   const auto filename_base = AUTO_NAME();
 
index 0dd6783c0b8e92cb996e088887e843a09b71e2a7..7115e8a90c5c2696c77d903443cbe792e63745d1 100644 (file)
@@ -20,6 +20,7 @@ TEST_CASE("Minimum edge and node overlap for polygon node shapes",
   const tc_check_options check_options = {
       .check_max_edge_node_overlap = false,
       .check_min_edge_node_overlap = true,
+      .check_max_edge_stem_arrow_overlap = false,
       .check_min_edge_stem_arrow_overlap = false,
   };
 
index 9a7b9b9a45bf2254e46768abcea742f7d0e5c312..6b13ce913cbac886919dc4d695171142332c3ce5 100644 (file)
@@ -14,10 +14,11 @@ TEST_CASE("Minimum edge node overlap",
       .edge_penwidth = 2,
   };
 
-  const tc_check_options check_options = {.check_max_edge_node_overlap = false,
-                                          .check_min_edge_node_overlap = true,
-                                          .check_min_edge_stem_arrow_overlap =
-                                              false};
+  const tc_check_options check_options = {
+      .check_max_edge_node_overlap = false,
+      .check_min_edge_node_overlap = true,
+      .check_max_edge_stem_arrow_overlap = false,
+      .check_min_edge_stem_arrow_overlap = false};
 
   const auto filename_base = AUTO_NAME();
 
index d08a2130ca2b21c12d8a4a73c26051c9be52f815..527d757dea0640d856e29dd2dbe440432e83b9ff 100644 (file)
@@ -14,10 +14,11 @@ TEST_CASE("Minimum edge stem and arrow overlap",
       .edge_penwidth = 2,
   };
 
-  const tc_check_options check_options = {.check_max_edge_node_overlap = false,
-                                          .check_min_edge_node_overlap = false,
-                                          .check_min_edge_stem_arrow_overlap =
-                                              true};
+  const tc_check_options check_options = {
+      .check_max_edge_node_overlap = false,
+      .check_min_edge_node_overlap = false,
+      .check_max_edge_stem_arrow_overlap = false,
+      .check_min_edge_stem_arrow_overlap = true};
 
   const auto filename_base = AUTO_NAME();