Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit 27fce7f

Browse files
authored
Merge branch 'master' into cleanups
2 parents 52cb5d0 + 32d1c13 commit 27fce7f

5 files changed

Lines changed: 23 additions & 19 deletions

File tree

Clipper/src/de/lighti/clipper/ClipperOffset.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void clear() {
109109

110110
private void doMiter( int j, int k, double r ) {
111111
final double q = delta / r;
112-
destPoly.add( new LongPoint( (int) Math.round( srcPoly.get( j ).getX() + (normals.get( k ).getX() + normals.get( j ).getX()) * q ), (int) Math
112+
destPoly.add( new LongPoint( Math.round( srcPoly.get( j ).getX() + (normals.get( k ).getX() + normals.get( j ).getX()) * q ), Math
113113
.round( srcPoly.get( j ).getY() + (normals.get( k ).getY() + normals.get( j ).getY()) * q ) ) );
114114
}
115115

@@ -171,7 +171,7 @@ else if (arcTolerance > Math.abs( delta ) * DEFAULT_ARC_TOLERANCE) {
171171
if (node.getJoinType() == JoinType.ROUND) {
172172
double X = 1.0, Y = 0.0;
173173
for (int j = 1; j <= steps; j++) {
174-
destPoly.add( new LongPoint( (int) Math.round( srcPoly.get( 0 ).getX() + X * delta ), (int) Math.round( srcPoly.get( 0 ).getY() + Y
174+
destPoly.add( new LongPoint( Math.round( srcPoly.get( 0 ).getX() + X * delta ), Math.round( srcPoly.get( 0 ).getY() + Y
175175
* delta ) ) );
176176
final double X2 = X;
177177
X = X * cos - sin * Y;
@@ -181,7 +181,7 @@ else if (arcTolerance > Math.abs( delta ) * DEFAULT_ARC_TOLERANCE) {
181181
else {
182182
double X = -1.0, Y = -1.0;
183183
for (int j = 0; j < 4; ++j) {
184-
destPoly.add( new LongPoint( (int) Math.round( srcPoly.get( 0 ).getX() + X * delta ), (int) Math.round( srcPoly.get( 0 ).getY() + Y
184+
destPoly.add( new LongPoint( Math.round( srcPoly.get( 0 ).getX() + X * delta ), Math.round( srcPoly.get( 0 ).getY() + Y
185185
* delta ) ) );
186186
if (X < 0) {
187187
X = 1;
@@ -245,10 +245,10 @@ else if (node.getEndType() == EndType.CLOSED_LINE) {
245245
LongPoint pt1;
246246
if (node.getEndType() == EndType.OPEN_BUTT) {
247247
final int j = len - 1;
248-
pt1 = new LongPoint( (int) Math.round( srcPoly.get( j ).getX() + normals.get( j ).getX() * delta ), (int) Math.round( srcPoly.get( j )
248+
pt1 = new LongPoint( Math.round( srcPoly.get( j ).getX() + normals.get( j ).getX() * delta ), Math.round( srcPoly.get( j )
249249
.getY() + normals.get( j ).getY() * delta ), 0 );
250250
destPoly.add( pt1 );
251-
pt1 = new LongPoint( (int) Math.round( srcPoly.get( j ).getX() - normals.get( j ).getX() * delta ), (int) Math.round( srcPoly.get( j )
251+
pt1 = new LongPoint( Math.round( srcPoly.get( j ).getX() - normals.get( j ).getX() * delta ), Math.round( srcPoly.get( j )
252252
.getY() - normals.get( j ).getY() * delta ), 0 );
253253
destPoly.add( pt1 );
254254
}
@@ -278,10 +278,10 @@ else if (node.getEndType() == EndType.CLOSED_LINE) {
278278
}
279279

280280
if (node.getEndType() == EndType.OPEN_BUTT) {
281-
pt1 = new LongPoint( (int) Math.round( srcPoly.get( 0 ).getX() - normals.get( 0 ).getX() * delta ), (int) Math.round( srcPoly.get( 0 )
281+
pt1 = new LongPoint( Math.round( srcPoly.get( 0 ).getX() - normals.get( 0 ).getX() * delta ), Math.round( srcPoly.get( 0 )
282282
.getY() - normals.get( 0 ).getY() * delta ) );
283283
destPoly.add( pt1 );
284-
pt1 = new LongPoint( (int) Math.round( srcPoly.get( 0 ).getX() + normals.get( 0 ).getX() * delta ), (int) Math.round( srcPoly.get( 0 )
284+
pt1 = new LongPoint( Math.round( srcPoly.get( 0 ).getX() + normals.get( 0 ).getX() * delta ), Math.round( srcPoly.get( 0 )
285285
.getY() + normals.get( 0 ).getY() * delta ) );
286286
destPoly.add( pt1 );
287287
}
@@ -306,12 +306,12 @@ private void doRound( int j, int k ) {
306306

307307
double X = normals.get( k ).getX(), Y = normals.get( k ).getY(), X2;
308308
for (int i = 0; i < steps; ++i) {
309-
destPoly.add( new LongPoint( (int) Math.round( srcPoly.get( j ).getX() + X * delta ), (int) Math.round( srcPoly.get( j ).getY() + Y * delta ) ) );
309+
destPoly.add( new LongPoint( Math.round( srcPoly.get( j ).getX() + X * delta ), Math.round( srcPoly.get( j ).getY() + Y * delta ) ) );
310310
X2 = X;
311311
X = X * cos - sin * Y;
312312
Y = X2 * sin + Y * cos;
313313
}
314-
destPoly.add( new LongPoint( (int) Math.round( srcPoly.get( j ).getX() + normals.get( j ).getX() * delta ), (int) Math.round( srcPoly.get( j ).getY()
314+
destPoly.add( new LongPoint( Math.round( srcPoly.get( j ).getX() + normals.get( j ).getX() * delta ), Math.round( srcPoly.get( j ).getY()
315315
+ normals.get( j ).getY() * delta ) ) );
316316
}
317317

@@ -323,8 +323,8 @@ private void doSquare( int j, int k ) {
323323
final double sjx = srcPoly.get( j ).getX();
324324
final double sjy = srcPoly.get( j ).getY();
325325
final double dx = Math.tan( Math.atan2( inA, nkx * njx + nky * njy ) / 4 );
326-
destPoly.add( new LongPoint( (int) Math.round( sjx + delta * (nkx - nky * dx) ), (int) Math.round( sjy + delta * (nky + nkx * dx) ), 0 ) );
327-
destPoly.add( new LongPoint( (int) Math.round( sjx + delta * (njx + njy * dx) ), (int) Math.round( sjy + delta * (njy - njx * dx) ), 0 ) );
326+
destPoly.add( new LongPoint( Math.round( sjx + delta * (nkx - nky * dx) ), Math.round( sjy + delta * (nky + nkx * dx) ), 0 ) );
327+
destPoly.add( new LongPoint( Math.round( sjx + delta * (njx + njy * dx) ), Math.round( sjy + delta * (njy - njx * dx) ), 0 ) );
328328
}
329329

330330
//------------------------------------------------------------------------------
@@ -438,7 +438,7 @@ private void offsetPoint( int j, int[] kV, JoinType jointype ) {
438438
final double cosA = nkx * njx + njy * nky;
439439
if (cosA > 0) // angle ==> 0 degrees
440440
{
441-
destPoly.add( new LongPoint( (int) Math.round( sjx + nkx * delta ), (int) Math.round( sjy + nky * delta ), 0 ) );
441+
destPoly.add( new LongPoint( Math.round( sjx + nkx * delta ), Math.round( sjy + nky * delta ), 0 ) );
442442
return;
443443
}
444444
//else angle ==> 180 degrees
@@ -451,9 +451,9 @@ else if (inA < -1.0) {
451451
}
452452

453453
if (inA * delta < 0) {
454-
destPoly.add( new LongPoint( (int) Math.round( sjx + nkx * delta ), (int) Math.round( sjy + nky * delta ) ) );
454+
destPoly.add( new LongPoint( Math.round( sjx + nkx * delta ), Math.round( sjy + nky * delta ) ) );
455455
destPoly.add( srcPoly.get( j ) );
456-
destPoly.add( new LongPoint( (int) Math.round( sjx + njx * delta ), (int) Math.round( sjy + njy * delta ) ) );
456+
destPoly.add( new LongPoint( Math.round( sjx + njx * delta ), Math.round( sjy + njy * delta ) ) );
457457
}
458458
else {
459459
switch (jointype) {

Clipper/src/de/lighti/clipper/DefaultClipper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.Collections;
99
import java.util.Comparator;
1010
import java.util.List;
11+
import java.util.logging.Level;
1112
import java.util.logging.Logger;
1213

1314
public class DefaultClipper extends ClipperBase {
@@ -703,8 +704,10 @@ private Path.OutPt addOutPt(Edge e, LongPoint pt ) {
703704
//OutRec.Pts is the 'Left-most' point & OutRec.Pts.Prev is the 'Right-most'
704705
final Path.OutPt op = outRec.getPoints();
705706
final boolean ToFront = e.side == Edge.Side.LEFT;
706-
LOGGER.finest( "op=" + Path.OutPt.getPointCount( op ) );
707-
LOGGER.finest( ToFront + " " + pt + " " + op.getPt() );
707+
if (LOGGER.isLoggable( Level.FINEST )) {
708+
LOGGER.finest( "op=" + Path.OutPt.getPointCount( op ) );
709+
LOGGER.finest( ToFront + " " + pt + " " + op.getPt() );
710+
}
708711
if (ToFront && pt.equals( op.getPt() )) {
709712
return op;
710713
}

Clipper/src/de/lighti/clipper/Edge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static long topX(Edge edge, long currentY ) {
4848
if (currentY == edge.getTop().getY()) {
4949
return edge.getTop().getX();
5050
}
51-
return (int) (edge.getBot().getX() + Math.round( edge.deltaX * (currentY - edge.getBot().getY()) ));
51+
return edge.getBot().getX() + Math.round( edge.deltaX * (currentY - edge.getBot().getY()) );
5252
}
5353

5454
private final LongPoint bot;

Clipper/src/de/lighti/clipper/PolyNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import java.util.Collections;
99
import java.util.List;
1010

11-
class PolyNode {
11+
public class PolyNode {
12+
1213
enum NodeType {
1314
ANY, OPEN, CLOSED
1415
}

Clipper/src/de/lighti/clipper/PolyTree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6-
class PolyTree extends PolyNode {
6+
public class PolyTree extends PolyNode {
77
private final List<PolyNode> allPolys = new ArrayList<PolyNode>();
88

99
public void Clear() {

0 commit comments

Comments
 (0)