boolean isCurrentArea = true;
int countPoints = 0;
boolean curArea = false;
boolean addArea = false;
IntersectPoint point = intersectPoints[0];
resultRules[resultRulesPos] = PathIterator.SEG_MOVETO;
resultOffsets[resultRulesPos++] = resultCoordPos;
do {
resultCoords[resultCoordPos++] = point.getX();
resultCoords[resultCoordPos++] = point.getY();
resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
resultOffsets[resultRulesPos++] = resultCoordPos - 2;
int curIndex = point.getEndIndex(true);
if ((curIndex < 0) ||
(area.isVertex(coords[2 * curIndex], coords[2 * curIndex + 1]) &&
crossHelper.containsPoint(new double[] {coords[2 * curIndex],
coords[2 * curIndex + 1]}) &&
(coords[2 * curIndex] != point.getX() ||
coords[2 * curIndex + 1] != point.getY()))) {
isCurrentArea = !isCurrentArea;
} else if (area.containsExact(coords[2 * curIndex],
coords[2 * curIndex + 1]) > 0) {
isCurrentArea = false;
} else {
isCurrentArea = true;
}
if (countPoints >= intersectPoints.length) {
isCurrentArea = !isCurrentArea;
}
if (isCurrentArea) {
curArea = true;
} else {
addArea = true;
}
IntersectPoint nextPoint = (isCurrentArea) ?
getNextIntersectPoint(intersectPoints, point, isCurrentArea):
getPrevIntersectPoint(intersectPoints, point, isCurrentArea);
double[] coords = (isCurrentArea) ? this.coords : area.coords;
int offset = (isCurrentArea) ? 2 * point.getEndIndex(isCurrentArea):
2 * nextPoint.getEndIndex(isCurrentArea);
if ((offset > 0) &&
(((isCurrentArea) &&
(nextPoint.getBegIndex(isCurrentArea) <
point.getEndIndex(isCurrentArea))) ||
((!isCurrentArea) &&
(nextPoint.getEndIndex(isCurrentArea) <
nextPoint.getBegIndex(isCurrentArea))))) {
int coordSize = (isCurrentArea) ? this.coordsSize :
area.coordsSize;
int length = coordSize - offset;
if (isCurrentArea) {
System.arraycopy(coords, offset,
resultCoords, resultCoordPos, length);
} else {
double[] temp = new double[length];
System.arraycopy(coords, offset, temp, 0, length);
reverseCopy(temp);
System.arraycopy(temp, 0,
resultCoords, resultCoordPos, length);
}
for (int i = 0; i < length / 2; i++) {
resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
resultOffsets[resultRulesPos++] = resultCoordPos;
resultCoordPos += 2;
}
offset = 0;
}
if (offset >= 0) {
int length = (isCurrentArea) ?
2 * nextPoint.getBegIndex(isCurrentArea) - offset + 2:
2 * point.getBegIndex(isCurrentArea) - offset + 2;
if (isCurrentArea) {
System.arraycopy(coords, offset,
resultCoords, resultCoordPos, length);