MCPcopy Create free account
hub / github.com/AngusJohnson/Clipper2 / LoadTestNum

Method LoadTestNum

CSharp/Utils/ClipFileIO/Clipper.FileIO.cs:76–180  ·  view source on GitHub ↗
(string filename, int num,
      Paths64? subj, Paths64? subj_open, Paths64? clip,
      out ClipType ct, out FillRule fillRule, out long area, out int count, out string caption)

Source from the content-addressed store, hash-verified

74 //------------------------------------------------------------------------------
75
76 public static bool LoadTestNum(string filename, int num,
77 Paths64? subj, Paths64? subj_open, Paths64? clip,
78 out ClipType ct, out FillRule fillRule, out long area, out int count, out string caption)
79 {
80 if (subj == null) subj = new Paths64(); else subj.Clear();
81 if (subj_open == null) subj_open = new Paths64(); else subj_open.Clear();
82 if (clip == null) clip = new Paths64(); else clip.Clear();
83 ct = ClipType.Intersection;
84 fillRule = FillRule.EvenOdd;
85 bool result = false;
86 if (num < 1) num = 1;
87 caption = "";
88 area = 0;
89 count = 0;
90 StreamReader reader;
91 try
92 {
93 reader = new StreamReader(filename);
94 }
95 catch
96 {
97 return false;
98 }
99 while (true)
100 {
101 string? s = reader.ReadLine();
102 if (s == null) break;
103
104 if (s.IndexOf("CAPTION: ", StringComparison.Ordinal) == 0)
105 {
106 num--;
107 if (num != 0) continue;
108 caption = s.Substring(9);
109 result = true;
110 continue;
111 }
112
113 if (num > 0) continue;
114
115 if (s.IndexOf("CLIPTYPE: ", StringComparison.Ordinal) == 0)
116 {
117 if (s.IndexOf("INTERSECTION", StringComparison.Ordinal) > 0) ct = ClipType.Intersection;
118 else if (s.IndexOf("UNION", StringComparison.Ordinal) > 0) ct = ClipType.Union;
119 else if (s.IndexOf("DIFFERENCE", StringComparison.Ordinal) > 0) ct = ClipType.Difference;
120 else ct = ClipType.Xor;
121 continue;
122 }
123
124 if (s.IndexOf("FILLTYPE: ", StringComparison.Ordinal) == 0 ||
125 s.IndexOf("FILLRULE: ", StringComparison.Ordinal) == 0)
126 {
127 if (s.IndexOf("EVENODD", StringComparison.Ordinal) > 0) fillRule = FillRule.EvenOdd;
128 else if (s.IndexOf("POSITIVE", StringComparison.Ordinal) > 0) fillRule = FillRule.Positive;
129 else if (s.IndexOf("NEGATIVE", StringComparison.Ordinal) > 0) fillRule = FillRule.Negative;
130 else fillRule = FillRule.NonZero;
131 continue;
132 }
133

Callers 3

TestOpenPathsMethod · 0.80
TestClosedPathsMethod · 0.80
TestPolytree2Method · 0.80

Calls 2

ClearMethod · 0.45
AddMethod · 0.45

Tested by 3

TestOpenPathsMethod · 0.64
TestClosedPathsMethod · 0.64
TestPolytree2Method · 0.64