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

Commit 32d1c13

Browse files
authored
Merge pull request #1 from dmac000/master
fixes by dmac000
2 parents 11d5fbf + 4ecb94f commit 32d1c13

5 files changed

Lines changed: 22 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
@@ -113,7 +113,7 @@ public void clear() {
113113

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

@@ -175,7 +175,7 @@ else if (arcTolerance > Math.abs( delta ) * DEFAULT_ARC_TOLERANCE) {
175175
if (node.getJoinType() == JoinType.ROUND) {
176176
double X = 1.0, Y = 0.0;
177177
for (int j = 1; j <= steps; j++) {
178-
destPoly.add( new LongPoint( (int) Math.round( srcPoly.get( 0 ).getX() + X * delta ), (int) Math.round( srcPoly.get( 0 ).getY() + Y
178+
destPoly.add( new LongPoint( Math.round( srcPoly.get( 0 ).getX() + X * delta ), Math.round( srcPoly.get( 0 ).getY() + Y
179179
* delta ) ) );
180180
final double X2 = X;
181181
X = X * cos - sin * Y;
@@ -185,7 +185,7 @@ else if (arcTolerance > Math.abs( delta ) * DEFAULT_ARC_TOLERANCE) {
185185
else {
186186
double X = -1.0, Y = -1.0;
187187
for (int j = 0; j < 4; ++j) {
188-
destPoly.add( new LongPoint( (int) Math.round( srcPoly.get( 0 ).getX() + X * delta ), (int) Math.round( srcPoly.get( 0 ).getY() + Y
188+
destPoly.add( new LongPoint( Math.round( srcPoly.get( 0 ).getX() + X * delta ), Math.round( srcPoly.get( 0 ).getY() + Y
189189
* delta ) ) );
190190
if (X < 0) {
191191
X = 1;
@@ -249,10 +249,10 @@ else if (node.getEndType() == EndType.CLOSED_LINE) {
249249
LongPoint pt1;
250250
if (node.getEndType() == EndType.OPEN_BUTT) {
251251
final int j = len - 1;
252-
pt1 = new LongPoint( (int) Math.round( srcPoly.get( j ).getX() + normals.get( j ).getX() * delta ), (int) Math.round( srcPoly.get( j )
252+
pt1 = new LongPoint( Math.round( srcPoly.get( j ).getX() + normals.get( j ).getX() * delta ), Math.round( srcPoly.get( j )
253253
.getY() + normals.get( j ).getY() * delta ), 0 );
254254
destPoly.add( pt1 );
255-
pt1 = new LongPoint( (int) Math.round( srcPoly.get( j ).getX() - normals.get( j ).getX() * delta ), (int) Math.round( srcPoly.get( j )
255+
pt1 = new LongPoint( Math.round( srcPoly.get( j ).getX() - normals.get( j ).getX() * delta ), Math.round( srcPoly.get( j )
256256
.getY() - normals.get( j ).getY() * delta ), 0 );
257257
destPoly.add( pt1 );
258258
}
@@ -282,10 +282,10 @@ else if (node.getEndType() == EndType.CLOSED_LINE) {
282282
}
283283

284284
if (node.getEndType() == EndType.OPEN_BUTT) {
285-
pt1 = new LongPoint( (int) Math.round( srcPoly.get( 0 ).getX() - normals.get( 0 ).getX() * delta ), (int) Math.round( srcPoly.get( 0 )
285+
pt1 = new LongPoint( Math.round( srcPoly.get( 0 ).getX() - normals.get( 0 ).getX() * delta ), Math.round( srcPoly.get( 0 )
286286
.getY() - normals.get( 0 ).getY() * delta ) );
287287
destPoly.add( pt1 );
288-
pt1 = new LongPoint( (int) Math.round( srcPoly.get( 0 ).getX() + normals.get( 0 ).getX() * delta ), (int) Math.round( srcPoly.get( 0 )
288+
pt1 = new LongPoint( Math.round( srcPoly.get( 0 ).getX() + normals.get( 0 ).getX() * delta ), Math.round( srcPoly.get( 0 )
289289
.getY() + normals.get( 0 ).getY() * delta ) );
290290
destPoly.add( pt1 );
291291
}
@@ -310,12 +310,12 @@ private void doRound( int j, int k ) {
310310

311311
double X = normals.get( k ).getX(), Y = normals.get( k ).getY(), X2;
312312
for (int i = 0; i < steps; ++i) {
313-
destPoly.add( new LongPoint( (int) Math.round( srcPoly.get( j ).getX() + X * delta ), (int) Math.round( srcPoly.get( j ).getY() + Y * delta ) ) );
313+
destPoly.add( new LongPoint( Math.round( srcPoly.get( j ).getX() + X * delta ), Math.round( srcPoly.get( j ).getY() + Y * delta ) ) );
314314
X2 = X;
315315
X = X * cos - sin * Y;
316316
Y = X2 * sin + Y * cos;
317317
}
318-
destPoly.add( new LongPoint( (int) Math.round( srcPoly.get( j ).getX() + normals.get( j ).getX() * delta ), (int) Math.round( srcPoly.get( j ).getY()
318+
destPoly.add( new LongPoint( Math.round( srcPoly.get( j ).getX() + normals.get( j ).getX() * delta ), Math.round( srcPoly.get( j ).getY()
319319
+ normals.get( j ).getY() * delta ) ) );
320320
}
321321

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

334334
//------------------------------------------------------------------------------
@@ -442,7 +442,7 @@ private void offsetPoint( int j, int[] kV, JoinType jointype ) {
442442
final double cosA = nkx * njx + njy * nky;
443443
if (cosA > 0) // angle ==> 0 degrees
444444
{
445-
destPoly.add( new LongPoint( (int) Math.round( sjx + nkx * delta ), (int) Math.round( sjy + nky * delta ), 0 ) );
445+
destPoly.add( new LongPoint( Math.round( sjx + nkx * delta ), Math.round( sjy + nky * delta ), 0 ) );
446446
return;
447447
}
448448
//else angle ==> 180 degrees
@@ -455,9 +455,9 @@ else if (inA < -1.0) {
455455
}
456456

457457
if (inA * delta < 0) {
458-
destPoly.add( new LongPoint( (int) Math.round( sjx + nkx * delta ), (int) Math.round( sjy + nky * delta ) ) );
458+
destPoly.add( new LongPoint( Math.round( sjx + nkx * delta ), Math.round( sjy + nky * delta ) ) );
459459
destPoly.add( srcPoly.get( j ) );
460-
destPoly.add( new LongPoint( (int) Math.round( sjx + njx * delta ), (int) Math.round( sjy + njy * delta ) ) );
460+
destPoly.add( new LongPoint( Math.round( sjx + njx * delta ), Math.round( sjy + njy * delta ) ) );
461461
}
462462
else {
463463
switch (jointype) {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Collections;
55
import java.util.Comparator;
66
import java.util.List;
7+
import java.util.logging.Level;
78
import java.util.logging.Logger;
89

910
import de.lighti.clipper.Path.Join;
@@ -707,8 +708,10 @@ private Path.OutPt addOutPt( Edge e, LongPoint pt ) {
707708
//OutRec.Pts is the 'Left-most' point & OutRec.Pts.Prev is the 'Right-most'
708709
final Path.OutPt op = outRec.getPoints();
709710
final boolean ToFront = e.side == Edge.Side.LEFT;
710-
LOGGER.finest( "op=" + Path.OutPt.getPointCount( op ) );
711-
LOGGER.finest( ToFront + " " + pt + " " + op.getPt() );
711+
if (LOGGER.isLoggable( Level.FINEST )) {
712+
LOGGER.finest( "op=" + Path.OutPt.getPointCount( op ) );
713+
LOGGER.finest( ToFront + " " + pt + " " + op.getPt() );
714+
}
712715
if (ToFront && pt.equals( op.getPt() )) {
713716
return op;
714717
}

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import de.lighti.clipper.Clipper.JoinType;
99
import de.lighti.clipper.Point.LongPoint;
1010

11-
class PolyNode {
11+
public class PolyNode {
1212
enum NodeType {
1313
ANY, OPEN, CLOSED
1414
}

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)