Skip to content

Commit 3494e64

Browse files
committed
fix dce adding spurious closing vertex
1 parent 939856f commit 3494e64

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main/java/micycle/pgs/PGS_Transformation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public static PShape align(PShape alignShape, PShape baseShape, double alignment
486486
}
487487

488488
// both shapes need same vertex quantity
489-
final int vertices = Math.min(alignShape.getVertexCount(), baseShape.getVertexCount()) - 1;
489+
final int vertices = Math.min(alignShape.getVertexCount(), baseShape.getVertexCount());
490490
PShape sourceShapeT = alignShape;
491491
PShape transformShapeT = baseShape;
492492
if (alignShape.getVertexCount() > vertices) {

src/main/java/micycle/pgs/commons/DiscreteCurveEvolution.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ public interface DCETerminationCallback {
9797
*/
9898
public static Coordinate[] process(LineString lineString, DCETerminationCallback terminationCallback) {
9999
final boolean closed = lineString.isClosed();
100-
final Coordinate[] coords = lineString.getCoordinates();
100+
Coordinate[] coords = lineString.getCoordinates();
101+
if (closed && coords.length > 2) {
102+
Coordinate[] newCoords = new Coordinate[coords.length - 1];
103+
System.arraycopy(coords, 0, newCoords, 0, coords.length - 1);
104+
coords = newCoords;
105+
}
101106

102107
/*
103108
* Initialise kinks (initially unlinked to each other), then link each one to

0 commit comments

Comments
 (0)