| 79 | } |
| 80 | |
| 81 | void DoBenchmark(int edge_cnt_start, int edge_cnt_end, |
| 82 | int increment, bool test_polytree) |
| 83 | { |
| 84 | ClipType ct = ClipType::Intersection; |
| 85 | FillRule fr = FillRule::NonZero;//EvenOdd;//Positive;// |
| 86 | |
| 87 | Paths64 subject, clip, solution; |
| 88 | PolyTree64 polytree; |
| 89 | std::cout << std::endl << "Complex Polygons Benchmark: " << std::endl; |
| 90 | for (int i = edge_cnt_start; i <= edge_cnt_end; i += increment) |
| 91 | { |
| 92 | subject.clear(); |
| 93 | clip.clear(); |
| 94 | subject.push_back(MakeRandomPoly(800, 600, i)); |
| 95 | clip.push_back(MakeRandomPoly(800, 600, i)); |
| 96 | SaveTest( "benchmark_test.txt", false, &subject, nullptr, &clip, 0, 0, ct, fr); |
| 97 | |
| 98 | std::cout << "Edge Count: " << i << " = "; |
| 99 | { |
| 100 | if (test_polytree) |
| 101 | { |
| 102 | polytree.Clear(); |
| 103 | Timer t; |
| 104 | BooleanOp(ct, fr, subject, clip, polytree); |
| 105 | if (!polytree.Count()) break; |
| 106 | } |
| 107 | else |
| 108 | { |
| 109 | Timer t; |
| 110 | solution = BooleanOp(ct, fr, subject, clip); |
| 111 | if (solution.empty()) break; |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | if (test_polytree) solution = PolyTreeToPaths64(polytree); |
| 117 | |
| 118 | SvgWriter svg; |
| 119 | SvgAddSubject(svg, subject, fr); |
| 120 | SvgAddClip(svg, clip, fr); |
| 121 | SvgAddSolution(svg, solution, fr, false); |
| 122 | SvgSaveToFile(svg, "solution3.svg", display_width, display_height, 20); |
| 123 | System("solution3.svg"); |
| 124 | } |
| 125 | |
| 126 | void System(const std::string &filename) |
| 127 | { |
no test coverage detected