-
Notifications
You must be signed in to change notification settings - Fork 347
/
OutRec.java
63 lines (52 loc) · 1.26 KB
/
OutRec.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package org.geogebra.common.util.clipper;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
class OutRec {
int Idx;
boolean isHole;
boolean isOpen;
OutRec firstLeft; // see comments in clipper.pas
OutPt pts;
OutPt bottomPt;
PolyNode polyNode;
public double area() {
OutPt op = pts;
if (op == null) {
return 0;
}
double a = 0;
do {
a = a + (op.prev.getPt().getX() + op.getPt().getX())
* (op.prev.getPt().getY() - op.getPt().getY());
op = op.next;
} while (op != pts);
return a * 0.5;
}
@SuppressFBWarnings(value = "SA_FIELD_SELF_ASSIGNMENT",
justification = "https://github.com/spotbugs/spotbugs/issues/2258")
public void fixHoleLinkage() {
// skip if an outermost polygon or
// already already points to the correct FirstLeft ...
if (firstLeft == null
|| isHole != firstLeft.isHole && firstLeft.pts != null) {
return;
}
OutRec orfl = firstLeft;
while (orfl != null && (orfl.isHole == isHole || orfl.pts == null)) {
orfl = orfl.firstLeft;
}
firstLeft = orfl;
}
public OutPt getPoints() {
return pts;
}
public void setPoints(OutPt pts) {
this.pts = pts;
}
public OutRec parseFirstLeft() {
OutRec ret = this;
while (ret != null && ret.pts == null) {
ret = ret.firstLeft;
}
return ret;
}
}