Skip to content

Commit 2de877e

Browse files
authored
[gpad] restore previous if-check
1 parent 2ddc995 commit 2de877e

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

graf2d/gpad/src/TPad.cxx

+40-40
Original file line numberDiff line numberDiff line change
@@ -1016,56 +1016,56 @@ Int_t TPad::ClipPolygon(Int_t n, Double_t *x, Double_t *y, Int_t nn, Double_t *x
10161016
if (nc > 0) {
10171017
x1 = xc[nc - 1];
10181018
y1 = yc[nc - 1];
1019-
}
1020-
nc2 = 0;
1021-
for (i = 0; i < nc; i++) {
1022-
x2 = xc[i]; y2 = yc[i];
1023-
if (x1 == x2) {
1024-
slope = 0;
1025-
} else {
1026-
slope = (y2-y1)/(x2-x1);
1027-
}
1028-
if (x1 <= xclipr) {
1029-
if (x2 > xclipr) {
1030-
xc2[nc2] = xclipr; yc2[nc2++] = slope*(xclipr-x1)+y1;
1019+
nc2 = 0;
1020+
for (i = 0; i < nc; i++) {
1021+
x2 = xc[i]; y2 = yc[i];
1022+
if (x1 == x2) {
1023+
slope = 0;
10311024
} else {
1032-
xc2[nc2] = x2; yc2[nc2++] = y2;
1025+
slope = (y2-y1)/(x2-x1);
10331026
}
1034-
} else {
1035-
if (x2 <= xclipr) {
1036-
xc2[nc2] = xclipr; yc2[nc2++] = slope*(xclipr-x1)+y1;
1037-
xc2[nc2] = x2; yc2[nc2++] = y2;
1027+
if (x1 <= xclipr) {
1028+
if (x2 > xclipr) {
1029+
xc2[nc2] = xclipr; yc2[nc2++] = slope*(xclipr-x1)+y1;
1030+
} else {
1031+
xc2[nc2] = x2; yc2[nc2++] = y2;
1032+
}
1033+
} else {
1034+
if (x2 <= xclipr) {
1035+
xc2[nc2] = xclipr; yc2[nc2++] = slope*(xclipr-x1)+y1;
1036+
xc2[nc2] = x2; yc2[nc2++] = y2;
1037+
}
10381038
}
1039+
x1 = x2; y1 = y2;
10391040
}
1040-
x1 = x2; y1 = y2;
1041-
}
10421041

1043-
// Clip against the bottom boundary
1044-
if (nc2 > 0) {
1045-
x1 = xc2[nc2 - 1];
1046-
y1 = yc2[nc2 - 1];
1047-
}
1048-
nc = 0;
1049-
for (i = 0; i < nc2; i++) {
1050-
x2 = xc2[i]; y2 = yc2[i];
1051-
if (y1 == y2) {
1052-
slope = 0;
1053-
} else {
1054-
slope = (x2-x1)/(y2-y1);
1042+
// Clip against the bottom boundary
1043+
if (nc2 > 0) {
1044+
x1 = xc2[nc2 - 1];
1045+
y1 = yc2[nc2 - 1];
10551046
}
1056-
if (y1 >= yclipb) {
1057-
if (y2 < yclipb) {
1058-
xc[nc] = x1+(yclipb-y1)*slope; yc[nc++] = yclipb;
1047+
nc = 0;
1048+
for (i = 0; i < nc2; i++) {
1049+
x2 = xc2[i]; y2 = yc2[i];
1050+
if (y1 == y2) {
1051+
slope = 0;
10591052
} else {
1060-
xc[nc] = x2; yc[nc++] = y2;
1053+
slope = (x2-x1)/(y2-y1);
10611054
}
1062-
} else {
1063-
if (y2 >= yclipb) {
1064-
xc[nc] = x1+(yclipb-y1)*slope; yc[nc++] = yclipb;
1065-
xc[nc] = x2; yc[nc++] = y2;
1055+
if (y1 >= yclipb) {
1056+
if (y2 < yclipb) {
1057+
xc[nc] = x1+(yclipb-y1)*slope; yc[nc++] = yclipb;
1058+
} else {
1059+
xc[nc] = x2; yc[nc++] = y2;
1060+
}
1061+
} else {
1062+
if (y2 >= yclipb) {
1063+
xc[nc] = x1+(yclipb-y1)*slope; yc[nc++] = yclipb;
1064+
xc[nc] = x2; yc[nc++] = y2;
1065+
}
10661066
}
1067+
x1 = x2; y1 = y2;
10671068
}
1068-
x1 = x2; y1 = y2;
10691069
}
10701070

10711071
if (nc < 3)

0 commit comments

Comments
 (0)