Debian Codegraph @

sys/Graphics_grey.cpp

raw symbols SCIP
1 /* Graphics_grey.cpp
2 *
3 * Copyright (C) 1992-2008,2011,2012,2015-2020 Paul Boersma
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <stdlib.h>
20 #include "melder.h"cxx . . $ `<file>/melder/melder.h`/
21 #include "Graphics.h"cxx . . $ `<file>/sys/Graphics.h`/
22
23 //#define MAXGREYSIDE 12
24 #define MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`! 1000
25 #define MAXGREYPATHcxx . . $ `sys/Graphics_grey.cpp:25:9`! (2 * MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`! * (MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`! - 1) + 2)
26 #define MAXGREYEDGECONTOURScxx . . $ `sys/Graphics_grey.cpp:26:9`! (2 * (MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`! - 1))
27 #define MAXGREYCLOSEDCONTOURScxx . . $ `sys/Graphics_grey.cpp:27:9`! (MAXGREYPATHcxx . . $ `sys/Graphics_grey.cpp:25:9`! / 4 + 1)
28 #define MAXGREYEDGEPOINTScxx . . $ `sys/Graphics_grey.cpp:28:9`! (4 * MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`!)
29
30 typedef structcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0# {
31 integercxx . . $ integer# numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#numberOfPoints.;
32 integercxx . . $ integer# beginRowcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#beginRow., beginColcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#beginCol., beginOricxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#beginOri.;
33 integercxx . . $ integer# endRowcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#endRow., endColcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#endCol., endOricxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#endOri.;
34 integercxx . . $ integer# lowerGreycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#lowerGrey., upperGreycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#upperGrey.;
35 autoVECcxx . . $ autoVEC# xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#x., ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#y.;
36 } structEdgeContourcxx . . $ structEdgeContour#, *EdgeContourcxx . . $ EdgeContour#;
37
38 static EdgeContourcxx . . $ EdgeContour# EdgeContour_createcxx . . $ EdgeContour_create(51bd6ec73f744311). (integercxx . . $ integer# numberOfPoints) {
39 EdgeContourcxx . . $ EdgeContour# result = Melder_calloccxx . . $ `melder/melder_alloc.h:34:9`! (structEdgeContour, 1);
40 result -> numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#numberOfPoints. = numberOfPoints;
41 result -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#x. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (numberOfPoints);
42 result -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#y. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (numberOfPoints);
43 return result; // LEAK
44 }
45 static void EdgeContour_deletecxx . . $ EdgeContour_delete(15adbf4b7cc6e688). (EdgeContourcxx . . $ EdgeContour# e) {
46 e -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#x.. resetcxx . . $ autovector#reset(ced63f7c635d850d).();
47 Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (e);
48 }
49
50 typedef structcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1# {
51 integercxx . . $ integer# numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#numberOfPoints.;
52 int greycxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#grey., drawncxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#drawn.;
53 double xmincxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#xmin., xmaxcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#xmax., ymincxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#ymin., ymaxcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#ymax.;
54 autoVECcxx . . $ autoVEC# xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#x., ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#y.;
55 } structClosedContourcxx . . $ structClosedContour#, *ClosedContourcxx . . $ ClosedContour#;
56
57 static ClosedContourcxx . . $ ClosedContour# ClosedContour_createcxx . . $ ClosedContour_create(56f46a26b6d1518b). (integercxx . . $ integer# numberOfPoints) {
58 ClosedContourcxx . . $ ClosedContour# result = Melder_calloccxx . . $ `melder/melder_alloc.h:34:9`! (structClosedContour, 1);
59 result -> numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#numberOfPoints. = numberOfPoints;
60 result -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#x. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (numberOfPoints);
61 result -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#y. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (numberOfPoints);
62 return result; // LEAK
63 }
64 static void ClosedContour_deletecxx . . $ ClosedContour_delete(86b4d29d69f52edf). (ClosedContourcxx . . $ ClosedContour# c) {
65 c -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#x.. resetcxx . . $ autovector#reset(ced63f7c635d850d).();
66 Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (c);
67 }
68
69 typedef structcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2# {
70 integercxx . . $ integer# oricxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#ori., iContourcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#iContour., startcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#start., usedAsEntrycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#usedAsEntry., greycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#grey.;
71 double valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val.;
72 } structEdgePointcxx . . $ structEdgePoint#, *EdgePointcxx . . $ EdgePoint#;
73
74 static Graphicscxx . . $ Graphics# theGraphicscxx . . $ theGraphics.;
75 static integercxx . . $ integer# numberOfEdgeContourscxx . . $ numberOfEdgeContours.;
76 static EdgeContourcxx . . $ EdgeContour# *edgeContourscxx . . $ edgeContours.;
77 static integercxx . . $ integer# numberOfEdgePointscxx . . $ numberOfEdgePoints.;
78 static structEdgePointcxx . . $ structEdgePoint# *edgePointscxx . . $ edgePoints.;
79 static integercxx . . $ integer# numberOfClosedContourscxx . . $ numberOfClosedContours.;
80 static ClosedContourcxx . . $ ClosedContour# *closedContourscxx . . $ closedContours.;
81
82 static integercxx . . $ integer# numberOfPointscxx . . $ numberOfPoints.;
83 static integercxx . . $ integer# row1cxx . . $ row1., row2cxx . . $ row2., col1cxx . . $ col1., col2cxx . . $ col2.;
84 static integercxx . . $ integer# iBordercxx . . $ iBorder., numberOfBorderscxx . . $ numberOfBorders.;
85 static autoBOOLMATcxx . . $ autoBOOLMAT# rightcxx . . $ right., belowcxx . . $ below.;
86 static constMATVUcxx . . $ constMATVU# datacxx . . $ data.;
87 static double *bordercxx . . $ border.;
88 static autoVECcxx . . $ autoVEC# xcxx . . $ x., ycxx . . $ y.;
89 static double dxcxx . . $ dx., dycxx . . $ dy., xoffcxx . . $ xoff., yoffcxx . . $ yoff.;
90
91 static int emptycxx . . $ empty(cfe964a60c8b92f5). (integercxx . . $ integer# row, integercxx . . $ integer# col, integercxx . . $ integer# ori)
92 {
93 if (ori == 3) { row ++; ori = 1; }
94 if (ori == 2) { col ++; ori = 4; }
95 if (ori == 1)
96 return (datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col] < bordercxx . . $ border. [iBordercxx . . $ iBorder.]) !=
97 (datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col + 1] < bordercxx . . $ border. [iBordercxx . . $ iBorder.]) &&
98 ! rightcxx . . $ right. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).row - row1cxx . . $ row1. + 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).col - col1cxx . . $ col1. + 1];
99 else /* ori == 4 */
100 return (datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col] < bordercxx . . $ border. [iBordercxx . . $ iBorder.]) !=
101 (datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row + 1] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col] < bordercxx . . $ border. [iBordercxx . . $ iBorder.]) &&
102 ! belowcxx . . $ below. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).row - row1cxx . . $ row1. + 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).col - col1cxx . . $ col1. + 1];
103 }
104 static integercxx . . $ integer# notecxx . . $ note(374fe82c592a17bc). (integercxx . . $ integer# row, integercxx . . $ integer# col, integercxx . . $ integer# ori)
105 {
106 ++ numberOfPointscxx . . $ numberOfPoints.;
107 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (numberOfPoints <= MAXGREYPATHcxx . . $ `sys/Graphics_grey.cpp:25:9`!);
108 if (ori == 3) { row ++; ori = 1; }
109 if (ori == 2) { col ++; ori = 4; }
110 if (ori == 1)
111 {
112 rightcxx . . $ right. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).row - row1cxx . . $ row1. + 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).col - col1cxx . . $ col1. + 1] = true;
113 xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).numberOfPointscxx . . $ numberOfPoints.] = xoffcxx . . $ xoff. + (col + (bordercxx . . $ border. [iBordercxx . . $ iBorder.] - datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col]) /
114 (datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col + 1] - datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col])) * dxcxx . . $ dx.;
115 ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).numberOfPointscxx . . $ numberOfPoints.] = yoffcxx . . $ yoff. + row * dycxx . . $ dy.;
116 }
117 else /* ori == 4 */
118 {
119 belowcxx . . $ below. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).row - row1cxx . . $ row1. + 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).col - col1cxx . . $ col1. + 1] = true;
120 xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).numberOfPointscxx . . $ numberOfPoints.] = xoffcxx . . $ xoff. + col * dxcxx . . $ dx.;
121 ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).numberOfPointscxx . . $ numberOfPoints.] = yoffcxx . . $ yoff. + (row + (bordercxx . . $ border. [iBordercxx . . $ iBorder.] - datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col]) /
122 (datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row + 1] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col] - datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col])) * dycxx . . $ dy.;
123 }
124 return 1;
125 }
126
127 static void fillGreycxx . . $ fillGrey(5c7f5c9024ad8a74). (integercxx . . $ integer# numberOfPoints, constVECVUcxx . . $ constVECVU# const& x, constVECVUcxx . . $ constVECVU# const& y, int igrey)
128 /* "igrey" is in between 1 and numberOfBorders + 1. */
129 {
130 Graphics_setGreycxx . . $ Graphics_setGrey(2514a1c07b6be5e2). (theGraphicscxx . . $ theGraphics., 1.0 - (igrey - 1.0) / numberOfBorderscxx . . $ numberOfBorders.);
131 Graphics_fillAreacxx . . $ Graphics_fillArea(23a712ce109b96e0). (theGraphicscxx . . $ theGraphics., numberOfPoints, & x [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).1], & y [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).1]);
132 }
133
134 static void makeEdgeContourcxx . . $ makeEdgeContour(1accef8d191cd3cf). (integercxx . . $ integer# row0, integercxx . . $ integer# col0, integercxx . . $ integer# ori0) {
135 numberOfPointscxx . . $ numberOfPoints. = 0;
136 integercxx . . $ integer# row = row0, col = col0, ori = ori0;
137 notecxx . . $ note(374fe82c592a17bc). (row0, col0, ori0);
138
139 bool edge = false;
140 do {
141 bool clockwise = ! (ori & 1);
142 do { /* Preference for contours perpendicular to x == y. */
143 ori = (clockwise ? ori : ori + 2) % 4 + 1;
144 } while (! emptycxx . . $ empty(cfe964a60c8b92f5). (row, col, ori));
145 switch (ori) {
146 case 1: edge = row == row1cxx . . $ row1.; break;
147 case 2: edge = col == col2cxx . . $ col2. - 1; break;
148 case 3: edge = row == row2cxx . . $ row2. - 1; break;
149 case 4: edge = col == col1cxx . . $ col1.; break;
150 }
151 if (! edge) {
152 switch (ori) {
153 case 1: row --; break;
154 case 2: col ++; break;
155 case 3: row ++; break;
156 case 4: col --; break;
157 }
158 ori = (ori + 1) % 4 + 1;
159 }
160 notecxx . . $ note(374fe82c592a17bc). (row, col, ori);
161 }
162 while (! edge);
163 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (numberOfEdgeContours < MAXGREYEDGECONTOURScxx . . $ `sys/Graphics_grey.cpp:26:9`! * numberOfBorders);
164
165 EdgeContourcxx . . $ EdgeContour# e = edgeContourscxx . . $ edgeContours. [++ numberOfEdgeContourscxx . . $ numberOfEdgeContours.] = EdgeContour_createcxx . . $ EdgeContour_create(51bd6ec73f744311). (numberOfPointscxx . . $ numberOfPoints.);
166 e -> beginRowcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#beginRow. = row0;
167 e -> beginColcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#beginCol. = col0;
168 e -> beginOricxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#beginOri. = ori0;
169 e -> endRowcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#endRow. = row;
170 e -> endColcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#endCol. = col;
171 e -> endOricxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#endOri. = ori;
172
173 bool up = false;
174 switch (ori0) {
175 case 1: up = datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row0] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col0 + 1] > datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row0] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col0]; break;
176 case 2: up = datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row0 + 1] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col0 + 1] > datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row0] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col0 + 1]; break;
177 case 3: up = datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row0 + 1] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col0] > datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row0 + 1] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col0 + 1]; break;
178 case 4: up = datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row0] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col0] > datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row0 + 1] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col0]; break;
179 }
180 if (up) { e -> lowerGreycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#lowerGrey. = iBordercxx . . $ iBorder.; e -> upperGreycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#upperGrey. = iBordercxx . . $ iBorder. + 1; }
181 else { e -> lowerGreycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#lowerGrey. = iBordercxx . . $ iBorder. + 1; e -> upperGreycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#upperGrey. = iBordercxx . . $ iBorder.; }
182 for (integercxx . . $ integer# iPoint = 1; iPoint <= numberOfPointscxx . . $ numberOfPoints.; iPoint ++) {
183 e -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint];
184 e -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint];
185 }
186 }
187
188 static void makeClosedContourcxx . . $ makeClosedContour(1accef8d191cd3cf). (integercxx . . $ integer# row0, integercxx . . $ integer# col0, integercxx . . $ integer# ori0) {
189 double x1, y1;
190 ClosedContourcxx . . $ ClosedContour# c;
191
192 numberOfPointscxx . . $ numberOfPoints. = 0;
193 integercxx . . $ integer# row = row0, col = col0, ori = ori0;
194 do {
195 bool clockwise = ! (ori & 1);
196 do { /* Preference for contours perpendicular to x == y. */
197 ori = (clockwise ? ori : ori + 2) % 4 + 1;
198 } while (! emptycxx . . $ empty(cfe964a60c8b92f5). (row, col, ori));
199 switch (ori) {
200 case 1: row --; break;
201 case 2: col ++; break;
202 case 3: row ++; break;
203 case 4: col --; break;
204 }
205 ori = (ori + 1) % 4 + 1;
206 notecxx . . $ note(374fe82c592a17bc). (row, col, ori);
207 }
208 while (row != row0 || col != col0 || ori != ori0);
209 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (numberOfClosedContours < MAXGREYCLOSEDCONTOURScxx . . $ `sys/Graphics_grey.cpp:27:9`! * numberOfBorders);
210 c = closedContourscxx . . $ closedContours. [++ numberOfClosedContourscxx . . $ numberOfClosedContours.] = ClosedContour_createcxx . . $ ClosedContour_create(56f46a26b6d1518b). (numberOfPointscxx . . $ numberOfPoints.);
211
212 /* Find a point just inside or outside the contour. */
213 /* Find out whether it is above or below the contour. */
214
215 x1 = xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).numberOfPointscxx . . $ numberOfPoints.];
216 y1 = ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).numberOfPointscxx . . $ numberOfPoints.];
217 bool up = false;
218 if (ori == 3) { row ++; ori = 1; }
219 else if (ori == 2) { col ++; ori = 4; }
220 if (ori == 1) {
221 if (x1 > xoffcxx . . $ xoff. + (col + 0.5) * dxcxx . . $ dx.)
222 x1 -= 0.01 * dxcxx . . $ dx.;
223 else
224 x1 += 0.01 * dxcxx . . $ dx.;
225 up = datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col] + ((x1 - xoffcxx . . $ xoff.) / dxcxx . . $ dx. - col) *
226 (datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col + 1] - datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col]) > bordercxx . . $ border. [iBordercxx . . $ iBorder.];
227 } else { /* ori == 4 */
228 if (y1 > yoffcxx . . $ yoff. + (row + 0.5) * dycxx . . $ dy.)
229 y1 -= 0.01 * dycxx . . $ dy.;
230 else
231 y1 += 0.01 * dycxx . . $ dy.;
232 up = datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col] + ((y1 - yoffcxx . . $ yoff.) / dycxx . . $ dy. - row) *
233 (datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row + 1] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col] - datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col]) > bordercxx . . $ border. [iBordercxx . . $ iBorder.];
234 }
235
236 /* Find out whether the point is inside or outside the contour. */
237
238 if (! NUMrotationsPointInPolygoncxx . . $ NUMrotationsPointInPolygon(95d5ebe59db3a61f). (x1, y1, numberOfPointscxx . . $ numberOfPoints.,
239 xcxx . . $ x..asArgumentToFunctionThatExpectsOneBasedArraycxx . . $ autovector#asArgumentToFunctionThatExpectsOneBasedArray(5a2a78a048fb49a8).(), ycxx . . $ y..asArgumentToFunctionThatExpectsOneBasedArraycxx . . $ autovector#asArgumentToFunctionThatExpectsOneBasedArray(5a2a78a048fb49a8).()))
240 up = ! up;
241
242 double xmin = 1e308, xmax = -1e308, ymin = 1e308, ymax = -1e308;
243 c -> greycxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#grey. = up ? iBordercxx . . $ iBorder. + 1 : iBordercxx . . $ iBorder.;
244 for (int i = 1; i <= numberOfPointscxx . . $ numberOfPoints.; i ++) {
245 c -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
246 c -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
247 if (xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] < xmin) xmin = xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
248 if (xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] > xmax) xmax = xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
249 if (ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] < ymin) ymin = ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
250 if (ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] > ymax) ymax = ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
251 }
252 c -> xmincxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#xmin. = xmin;
253 c -> xmaxcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#xmax. = xmax;
254 c -> ymincxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#ymin. = ymin;
255 c -> ymaxcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#ymax. = ymax;
256 }
257
258 static void smallGreycxx . . $ smallGrey(49f6e7a06ebc5aa8). () {
259 numberOfEdgeContourscxx . . $ numberOfEdgeContours. = 0;
260 numberOfClosedContourscxx . . $ numberOfClosedContours. = 0;
261 for (iBordercxx . . $ iBorder. = 1; iBordercxx . . $ iBorder. <= numberOfBorderscxx . . $ numberOfBorders.; iBordercxx . . $ iBorder. ++) {
262 for (integercxx . . $ integer# row = 1; row <= MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`!; row ++)
263 for (integercxx . . $ integer# col = 1; col <= MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`!; col ++)
264 rightcxx . . $ right. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).row] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).col] = belowcxx . . $ below. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).row] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).col] = false;
265
266 /* Find all the edge contours of this border value. */
267
268 for (integercxx . . $ integer# col = col1cxx . . $ col1.; col < col2cxx . . $ col2.; col ++)
269 if (emptycxx . . $ empty(cfe964a60c8b92f5). (row1cxx . . $ row1., col, 1))
270 makeEdgeContourcxx . . $ makeEdgeContour(1accef8d191cd3cf). (row1cxx . . $ row1., col, 1);
271 for (integercxx . . $ integer# row = row1cxx . . $ row1.; row < row2cxx . . $ row2.; row ++)
272 if (emptycxx . . $ empty(cfe964a60c8b92f5). (row, col2cxx . . $ col2. - 1, 2))
273 makeEdgeContourcxx . . $ makeEdgeContour(1accef8d191cd3cf). (row, col2cxx . . $ col2. - 1, 2);
274 for (integercxx . . $ integer# col = col2cxx . . $ col2. - 1; col >= col1cxx . . $ col1.; col --)
275 if (emptycxx . . $ empty(cfe964a60c8b92f5). (row2cxx . . $ row2. - 1, col, 3))
276 makeEdgeContourcxx . . $ makeEdgeContour(1accef8d191cd3cf). (row2cxx . . $ row2. - 1, col, 3);
277 for (integercxx . . $ integer# row = row2cxx . . $ row2. - 1; row >= row1cxx . . $ row1.; row --)
278 if (emptycxx . . $ empty(cfe964a60c8b92f5). (row, col1cxx . . $ col1., 4))
279 makeEdgeContourcxx . . $ makeEdgeContour(1accef8d191cd3cf). (row, col1cxx . . $ col1., 4);
280
281 /* Find all the closed contours of this border value. */
282
283 for (integercxx . . $ integer# row = row1cxx . . $ row1. + 1; row < row2cxx . . $ row2.; row ++)
284 for (integercxx . . $ integer# col = col1cxx . . $ col1.; col < col2cxx . . $ col2.; col ++)
285 if (emptycxx . . $ empty(cfe964a60c8b92f5). (row, col, 1)) makeClosedContourcxx . . $ makeClosedContour(1accef8d191cd3cf). (row, col, 1);
286 for (integercxx . . $ integer# col = col1cxx . . $ col1. + 1; col < col2cxx . . $ col2.; col ++)
287 for (integercxx . . $ integer# row = row1cxx . . $ row1.; row < row2cxx . . $ row2.; row ++)
288 if (emptycxx . . $ empty(cfe964a60c8b92f5). (row, col, 4)) makeClosedContourcxx . . $ makeClosedContour(1accef8d191cd3cf). (row, col, 4);
289 }
290 numberOfEdgePointscxx . . $ numberOfEdgePoints. = 2 * numberOfEdgeContourscxx . . $ numberOfEdgeContours. + 4;
291 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (numberOfEdgePoints <= MAXGREYEDGEPOINTScxx . . $ `sys/Graphics_grey.cpp:28:9`! * numberOfBorders);
292
293 /* Make a list of all points on the edge. */
294
295 /* The edge points include the four corner points. */
296
297 for (int i = 1; i <= 4; i ++) {
298 EdgePointcxx . . $ EdgePoint# p = & edgePointscxx . . $ edgePoints. [i];
299 p -> oricxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#ori. = i;
300 p -> valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val. = 0;
301 p -> iContourcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#iContour. = 0;
302 p -> startcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#start. = 0;
303 p -> usedAsEntrycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#usedAsEntry. = 0;
304 p -> greycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#grey. = -1;
305 }
306
307 /* The edge points include the first points of the edge contours. */
308
309 for (int i = 1; i <= numberOfEdgeContourscxx . . $ numberOfEdgeContours.; i ++) {
310 EdgeContourcxx . . $ EdgeContour# c = edgeContourscxx . . $ edgeContours. [i];
311 EdgePointcxx . . $ EdgePoint# p = & edgePointscxx . . $ edgePoints. [i + i + 3];
312 switch (p -> oricxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#ori. = c -> beginOricxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#beginOri.) {
313 case 1: p -> valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val. = c -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] - xoffcxx . . $ xoff. - col1cxx . . $ col1. * dxcxx . . $ dx.; break;
314 case 2: p -> valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val. = c -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] - yoffcxx . . $ yoff. - row1cxx . . $ row1. * dycxx . . $ dy.; break;
315 case 3: p -> valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val. = xoffcxx . . $ xoff. + col2cxx . . $ col2. * dxcxx . . $ dx. - c -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]; break;
316 case 4: p -> valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val. = yoffcxx . . $ yoff. + row2cxx . . $ row2. * dycxx . . $ dy. - c -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]; break;
317 }
318 p -> iContourcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#iContour. = i;
319 p -> startcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#start. = 1;
320 p -> usedAsEntrycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#usedAsEntry. = 0;
321 p -> greycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#grey. = c -> lowerGreycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#lowerGrey.;
322 }
323
324 /* The edge points include the last points of the edge contours. */
325
326 for (int i = 1; i <= numberOfEdgeContourscxx . . $ numberOfEdgeContours.; i ++) {
327 EdgeContourcxx . . $ EdgeContour# c = edgeContourscxx . . $ edgeContours. [i];
328 EdgePointcxx . . $ EdgePoint# p = & edgePointscxx . . $ edgePoints. [i + i + 4];
329 switch (p -> oricxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#ori. = c -> endOricxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#endOri.) {
330 case 1: p -> valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val. = c -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).c -> numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#numberOfPoints.] - xoffcxx . . $ xoff. - col1cxx . . $ col1. * dxcxx . . $ dx.; break;
331 case 2: p -> valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val. = c -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).c -> numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#numberOfPoints.] - yoffcxx . . $ yoff. - row1cxx . . $ row1. * dycxx . . $ dy.; break;
332 case 3: p -> valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val. = xoffcxx . . $ xoff. + col2cxx . . $ col2. * dxcxx . . $ dx. - c -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).c -> numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#numberOfPoints.]; break;
333 case 4: p -> valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val. = yoffcxx . . $ yoff. + row2cxx . . $ row2. * dycxx . . $ dy. - c -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).c -> numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#numberOfPoints.]; break;
334 }
335 p -> iContourcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#iContour. = i;
336 p -> startcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#start. = 0;
337 p -> usedAsEntrycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#usedAsEntry. = 0;
338 p -> greycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#grey. = c -> upperGreycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#upperGrey.;
339 }
340
341 /* Sort the list of edge points with keys Ori and Val. */
342 for (int i = 1; i < numberOfEdgePointscxx . . $ numberOfEdgePoints.; i ++) {
343 structEdgePointcxx . . $ structEdgePoint# p;
344 int min = i, j;
345 for (j = i + 1; j <= numberOfEdgePointscxx . . $ numberOfEdgePoints.; j ++)
346 if (edgePointscxx . . $ edgePoints. [min]. oricxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#ori. > edgePointscxx . . $ edgePoints. [j]. oricxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#ori. ||
347 (edgePointscxx . . $ edgePoints. [min]. oricxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#ori. == edgePointscxx . . $ edgePoints. [j]. oricxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#ori. && edgePointscxx . . $ edgePoints. [min]. valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val. > edgePointscxx . . $ edgePoints. [j]. valcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#val.))
348 min = j;
349 p =cxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#`operator=`(573b44e0594695a0). edgePointscxx . . $ edgePoints. [i];
350 edgePointscxx . . $ edgePoints. [i] =cxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#`operator=`(573b44e0594695a0). edgePointscxx . . $ edgePoints. [min];
351 edgePointscxx . . $ edgePoints. [min] =cxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#`operator=`(573b44e0594695a0). p;
352 }
353
354 {
355 for (int edge0 = 1; edge0 <= numberOfEdgePointscxx . . $ numberOfEdgePoints.; edge0 ++)
356 if (edgePointscxx . . $ edgePoints. [edge0].greycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#grey. > -1 && ! edgePointscxx . . $ edgePoints. [edge0].usedAsEntrycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#usedAsEntry.) {
357 int iPoint = 0;
358 int edge1 = edge0;
359 int darkness;
360 do {
361 /*
362 Follow one edge contour.
363 */
364 EdgePointcxx . . $ EdgePoint# p = & edgePointscxx . . $ edgePoints. [edge1];
365 integercxx . . $ integer# iContour = p -> iContourcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#iContour.;
366 EdgeContourcxx . . $ EdgeContour# c = edgeContourscxx . . $ edgeContours. [iContour];
367 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (iContour > 0);
368 darkness = p -> greycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#grey.;
369 p -> usedAsEntrycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#usedAsEntry. = 1;
370 if (p -> startcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#start.) {
371 for (int i = 1; i <= c -> numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#numberOfPoints.; i ++) {
372 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (iPoint < MAXGREYPATHcxx . . $ `sys/Graphics_grey.cpp:25:9`!);
373 xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).++ iPoint] = c -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
374 ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = c -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
375 }
376 for (int i = edge1 + 1; i <= numberOfEdgePointscxx . . $ numberOfEdgePoints.; i ++)
377 if (edgePointscxx . . $ edgePoints. [i].iContourcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#iContour. == iContour)
378 edge1 = i;
379 } else {
380 int edge1dummy = edge1;
381 for (integercxx . . $ integer# i = c -> numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#numberOfPoints.; i >= 1; i --) {
382 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (iPoint < MAXGREYPATHcxx . . $ `sys/Graphics_grey.cpp:25:9`!);
383 xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).++ iPoint] = c -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
384 ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = c -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_0#y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
385 }
386 for (int i = 1; i <= edge1dummy - 1; i ++)
387 if (edgePointscxx . . $ edgePoints. [i].iContourcxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#iContour. == iContour)
388 edge1 = i;
389 }
390 edge1 = edge1 % numberOfEdgePointscxx . . $ numberOfEdgePoints. + 1;
391
392 /*
393 Round some corners.
394 */
395 while (edgePointscxx . . $ edgePoints. [edge1].greycxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#grey. == -1) {
396 ++ iPoint;
397 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (iPoint <= MAXGREYPATHcxx . . $ `sys/Graphics_grey.cpp:25:9`!);
398 switch (edgePointscxx . . $ edgePoints. [edge1].oricxx . . $ $anonymous_type_4abad8dc6b3c1faf_2#ori.) {
399 case 1: xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = xoffcxx . . $ xoff. + col1cxx . . $ col1. * dxcxx . . $ dx.; ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = yoffcxx . . $ yoff. + row1cxx . . $ row1. * dycxx . . $ dy.; break;
400 case 2: xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = xoffcxx . . $ xoff. + col2cxx . . $ col2. * dxcxx . . $ dx.; ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = yoffcxx . . $ yoff. + row1cxx . . $ row1. * dycxx . . $ dy.; break;
401 case 3: xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = xoffcxx . . $ xoff. + col2cxx . . $ col2. * dxcxx . . $ dx.; ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = yoffcxx . . $ yoff. + row2cxx . . $ row2. * dycxx . . $ dy.; break;
402 case 4: xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = xoffcxx . . $ xoff. + col1cxx . . $ col1. * dxcxx . . $ dx.; ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iPoint] = yoffcxx . . $ yoff. + row2cxx . . $ row2. * dycxx . . $ dy.; break;
403 }
404 edge1 = edge1 % numberOfEdgePointscxx . . $ numberOfEdgePoints. + 1;
405 }
406 }
407 while (edge1 != edge0);
408 fillGreycxx . . $ fillGrey(5c7f5c9024ad8a74). (iPoint, xcxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).(), ycxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).(), darkness);
409 }
410 }
411 if (numberOfEdgeContourscxx . . $ numberOfEdgeContours. == 0) {
412 int i = 1;
413 while (i <= numberOfBorderscxx . . $ numberOfBorders. && bordercxx . . $ border. [i] < datacxx . . $ data. [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).row1cxx . . $ row1.] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).col1cxx . . $ col1.])
414 i ++;
415 xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] = xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).4] = xoffcxx . . $ xoff. + col1cxx . . $ col1. * dxcxx . . $ dx.;
416 xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).2] = xcxx . . $ x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).3] = xoffcxx . . $ xoff. + col2cxx . . $ col2. * dxcxx . . $ dx.;
417 ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] = ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).2] = yoffcxx . . $ yoff. + row1cxx . . $ row1. * dycxx . . $ dy.;
418 ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).3] = ycxx . . $ y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).4] = yoffcxx . . $ yoff. + row2cxx . . $ row2. * dycxx . . $ dy.;
419 fillGreycxx . . $ fillGrey(5c7f5c9024ad8a74). (4, xcxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).(), ycxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).(), i);
420 }
421
422 /*
423 Iterate over all the closed contours.
424 Those that are not enclosed by any other contour, are filled first.
425 */
426 {
427 bool found;
428 do {
429 found = false;
430 for (integercxx . . $ integer# i = 1; i <= numberOfClosedContourscxx . . $ numberOfClosedContours.; i ++) {
431 ClosedContourcxx . . $ ClosedContour# ci = closedContourscxx . . $ closedContours. [i];
432 if (! ci -> drawncxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#drawn.) {
433 bool enclosed = false;
434 integercxx . . $ integer# j = 1;
435 while (j <= numberOfClosedContourscxx . . $ numberOfClosedContours. && ! enclosed) {
436 ClosedContourcxx . . $ ClosedContour# cj = closedContourscxx . . $ closedContours. [j];
437 if (! cj -> drawncxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#drawn. && j != i &&
438 ci -> xmincxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#xmin. > cj -> xmincxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#xmin. && ci -> xmaxcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#xmax. < cj -> xmaxcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#xmax. &&
439 ci -> ymincxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#ymin. > cj -> ymincxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#ymin. && ci -> ymaxcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#ymax. < cj -> ymaxcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#ymax.)
440 enclosed = NUMrotationsPointInPolygoncxx . . $ NUMrotationsPointInPolygon(95d5ebe59db3a61f). (ci -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#x. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], ci -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#y. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1],
441 cj -> numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#numberOfPoints.,
442 cj -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#x..asArgumentToFunctionThatExpectsOneBasedArraycxx . . $ autovector#asArgumentToFunctionThatExpectsOneBasedArray(5a2a78a048fb49a8).(),
443 cj -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#y..asArgumentToFunctionThatExpectsOneBasedArraycxx . . $ autovector#asArgumentToFunctionThatExpectsOneBasedArray(5a2a78a048fb49a8).());
444 j ++;
445 }
446 if (! enclosed) {
447 found = true;
448 fillGreycxx . . $ fillGrey(5c7f5c9024ad8a74). (ci -> numberOfPointscxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#numberOfPoints., cicxx . . $ constvectorview#constvectorview(5c6f246bf1d99401). -> xcxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#x..allcxx . . $ autovector#all(a26726dad87555bb).(), cicxx . . $ constvectorview#constvectorview(5c6f246bf1d99401). -> ycxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#y..allcxx . . $ autovector#all(a26726dad87555bb).(), ci -> greycxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#grey.);
449 ci -> drawncxx . . $ $anonymous_type_4abad8dc6b3c1faf_1#drawn. = 1;
450 }
451 }
452 }
453 } while (found);
454 }
455 Graphics_setGreycxx . . $ Graphics_setGrey(2514a1c07b6be5e2). (theGraphicscxx . . $ theGraphics., 0.0);
456 for (int i = 1; i <= numberOfEdgeContourscxx . . $ numberOfEdgeContours.; i ++)
457 EdgeContour_deletecxx . . $ EdgeContour_delete(15adbf4b7cc6e688). (edgeContourscxx . . $ edgeContours. [i]);
458 for (int i = 1; i <= numberOfClosedContourscxx . . $ numberOfClosedContours.; i ++)
459 ClosedContour_deletecxx . . $ ClosedContour_delete(86b4d29d69f52edf). (closedContourscxx . . $ closedContours. [i]);
460 }
461
462 void Graphics_greycxx . . $ Graphics_grey(42c98de22ed1cdd8). (Graphicscxx . . $ Graphics# me, constMATVUcxx . . $ constMATVU# const& z,
463 double x1WC, double x2WC, double y1WC, double y2WC,
464 int _numberOfBorders, double borders [])
465 {
466 if (z.nrowcxx . . $ constmatrixview#nrow. <= 1 || z.ncolcxx . . $ constmatrixview#ncol. <= 1)
467 return;
468
469 /* Static variables. */
470
471 theGraphicscxx . . $ theGraphics. = me;
472 numberOfBorderscxx . . $ numberOfBorders. = _numberOfBorders;
473 datacxx . . $ data. =cxx . . $ constmatrixview#`operator=`(9c957dca798670a4). z;
474 bordercxx . . $ border. = borders;
475 dxcxx . . $ dx. = (x2WC - x1WC) / (z.ncolcxx . . $ constmatrixview#ncol. - 1);
476 dycxx . . $ dy. = (y2WC - y1WC) / (z.nrowcxx . . $ constmatrixview#nrow. - 1);
477 xoffcxx . . $ xoff. = x1WC - dxcxx . . $ dx.;
478 yoffcxx . . $ yoff. = y1WC - dycxx . . $ dy.;
479 if (NUMisEmptycxx . . $ NUMisEmpty(43b61114f729c675). (rightcxx . . $ right..getcxx . . $ automatrix#get(b2b81450b5bdda66).())) {
480 rightcxx . . $ right. =cxx . . $ automatrix#`operator=`(a0f46581f260c488). zero_BOOLMATcxx . . $ zero_BOOLMAT(e9a8779cbc949ca0). (MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`!, MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`!); // BUG memory
481 belowcxx . . $ below. =cxx . . $ automatrix#`operator=`(a0f46581f260c488). zero_BOOLMATcxx . . $ zero_BOOLMAT(e9a8779cbc949ca0). (MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`!, MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`!);
482 xcxx . . $ x. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (MAXGREYPATHcxx . . $ `sys/Graphics_grey.cpp:25:9`!);
483 ycxx . . $ y. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (MAXGREYPATHcxx . . $ `sys/Graphics_grey.cpp:25:9`!);
484 edgeContourscxx . . $ edgeContours. = Melder_calloccxx . . $ `melder/melder_alloc.h:34:9`! (EdgeContour, MAXGREYEDGECONTOURScxx . . $ `sys/Graphics_grey.cpp:26:9`! * numberOfBorders) - 1;
485 closedContourscxx . . $ closedContours. = Melder_calloccxx . . $ `melder/melder_alloc.h:34:9`! (ClosedContour, MAXGREYCLOSEDCONTOURScxx . . $ `sys/Graphics_grey.cpp:27:9`! * numberOfBorders) - 1;
486 edgePointscxx . . $ edgePoints. = Melder_calloccxx . . $ `melder/melder_alloc.h:34:9`! (structEdgePoint, MAXGREYEDGEPOINTScxx . . $ `sys/Graphics_grey.cpp:28:9`! * numberOfBorders);
487 }
488
489 /* The matrix is subdivided into matrices with side MAXGREYSIDE, so that:
490 * 1. All the paths will fit into our memory (we have to remember them all).
491 * 2. The path for filling fits into the PostScript path, which may be max. 1500 points long.
492 */
493 for (row1cxx . . $ row1. = 1; row1cxx . . $ row1. < z.nrowcxx . . $ constmatrixview#nrow.; row1cxx . . $ row1. += MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`! - 1) {
494 row2cxx . . $ row2. = row1cxx . . $ row1. + (MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`! - 1);
495 if (row2cxx . . $ row2. > z.nrowcxx . . $ constmatrixview#nrow.) row2cxx . . $ row2. = z.nrowcxx . . $ constmatrixview#nrow.;
496 for (col1cxx . . $ col1. = 1; col1cxx . . $ col1. < z.ncolcxx . . $ constmatrixview#ncol.; col1cxx . . $ col1. += MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`! - 1) {
497 col2cxx . . $ col2. = col1cxx . . $ col1. + (MAXGREYSIDEcxx . . $ `sys/Graphics_grey.cpp:24:9`! - 1);
498 if (col2cxx . . $ col2. > z.ncolcxx . . $ constmatrixview#ncol.) col2cxx . . $ col2. = z.ncolcxx . . $ constmatrixview#ncol.;
499 smallGreycxx . . $ smallGrey(49f6e7a06ebc5aa8). ();
500 }
501 }
502 }
503
504 /* End of file Graphics_grey.cpp */