Skip to content

Commit f264a50

Browse files
committed
additional fixes in Simplify and Cut
1 parent c171c80 commit f264a50

File tree

9 files changed

+462
-448
lines changed

9 files changed

+462
-448
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<mkdir dir="${dir.result.today}/xml" />
5858

5959
<junit fork="yes" printsummary="withOutAndErr" haltonfailure="no" haltonerror="no">
60-
<jvmarg value="-Xss2m" />
60+
<jvmarg value="-ea" />
6161
<classpath refid="project.classpath" />
6262
<sysproperty key="dir.report.test" value="${dir.result.today}" />
6363
<sysproperty key="arcgis.version.target" value="10.2" />

src/main/java/com/esri/core/geometry/Cracker.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
package com.esri.core.geometry;
2525

26-
import java.util.Arrays;
2726

2827
/**
2928
* Implementation for the segment cracking.
@@ -33,11 +32,9 @@
3332
*/
3433
class Cracker {
3534
private EditShape m_shape;
36-
private Envelope2D m_extent;
3735
private ProgressTracker m_progress_tracker;
3836
private NonSimpleResult m_non_simple_result;
3937
private double m_tolerance;
40-
private double m_tolerance_cluster;
4138
private Treap m_sweep_structure;
4239
private SweepComparator m_sweep_comparator;
4340
private boolean m_bAllowCoincident;
@@ -51,7 +48,6 @@ boolean crackBruteForce_() {
5148
seg_1_env.setEmpty();
5249
Envelope2D seg_2_env = new Envelope2D();
5350
seg_2_env.setEmpty();
54-
boolean b_needs_filter = false;
5551
boolean assume_intersecting = false;
5652
Point helper_point = new Point();
5753
SegmentIntersector segment_intersector = new SegmentIntersector();
@@ -80,7 +76,6 @@ boolean crackBruteForce_() {
8076
if (seg_1.isDegenerate(m_tolerance))// do not crack with
8177
// degenerate segments
8278
{
83-
b_needs_filter = true;
8479
continue;
8580
}
8681
}
@@ -108,7 +103,6 @@ boolean crackBruteForce_() {
108103
if (seg_2.isDegenerate(m_tolerance))// do not crack with
109104
// degenerate segments
110105
{
111-
b_needs_filter = true;
112106
continue;
113107
}
114108
}
@@ -192,7 +186,6 @@ boolean crackBruteForce_() {
192186
// degenerate
193187
// segments
194188
{
195-
b_needs_filter = true;
196189
break;
197190
}
198191
}
@@ -442,8 +435,6 @@ static boolean execute(EditShape shape, Envelope2D extent,
442435
Cracker cracker = new Cracker(progress_tracker);
443436
cracker.m_shape = shape;
444437
cracker.m_tolerance = tolerance;
445-
cracker.m_tolerance_cluster = -1;
446-
cracker.m_extent = extent;
447438
// Use brute force for smaller shapes, and a planesweep for bigger
448439
// shapes.
449440
boolean b_cracked = false;
@@ -469,11 +460,9 @@ static boolean needsCracking(boolean allowCoincident, EditShape shape, double to
469460
if (!canBeCracked(shape))
470461
return false;
471462

472-
Envelope2D shape_env = shape.getEnvelope2D();
473463
Cracker cracker = new Cracker(progress_tracker);
474464
cracker.m_shape = shape;
475465
cracker.m_tolerance = tolerance;
476-
cracker.m_extent = shape_env;
477466
cracker.m_bAllowCoincident = allowCoincident;
478467
if (cracker.needsCrackingImpl_()) {
479468
if (result != null)
@@ -485,12 +474,10 @@ static boolean needsCracking(boolean allowCoincident, EditShape shape, double to
485474
Transformation2D transform = new Transformation2D();
486475
transform.setSwapCoordinates();
487476
shape.applyTransformation(transform);
488-
transform.transform(shape_env);
489477

490478
cracker = new Cracker(progress_tracker);
491479
cracker.m_shape = shape;
492480
cracker.m_tolerance = tolerance;
493-
cracker.m_extent = shape_env;
494481
cracker.m_bAllowCoincident = allowCoincident;
495482
boolean b_res = cracker.needsCrackingImpl_();
496483

src/main/java/com/esri/core/geometry/EditShape.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,11 +1475,12 @@ int insertClosedPath_(int geometry, int before_path, int first_vertex, int check
14751475
int path = insertPath(geometry, -1);
14761476
int path_size = 0;
14771477
int vertex = first_vertex;
1478-
contains_checked_vertex[0] = false;
1478+
boolean contains = false;
1479+
14791480
while(true)
14801481
{
14811482
if (vertex == checked_vertex)
1482-
contains_checked_vertex[0] = true;
1483+
contains = true;
14831484

14841485
setPathToVertex_(vertex, path);
14851486
path_size++;
@@ -1493,12 +1494,17 @@ int insertClosedPath_(int geometry, int before_path, int first_vertex, int check
14931494

14941495
setClosedPath(path, true);
14951496
setPathSize_(path, path_size);
1496-
if (contains_checked_vertex[0])
1497+
if (contains)
14971498
first_vertex = checked_vertex;
14981499

14991500
setFirstVertex_(path, first_vertex);
15001501
setLastVertex_(path, getPrevVertex(first_vertex));
15011502
setRingAreaValid_(path, false);
1503+
1504+
if (contains_checked_vertex != null) {
1505+
contains_checked_vertex[0] = contains;
1506+
}
1507+
15021508
return path;
15031509
}
15041510

src/main/java/com/esri/core/geometry/OperatorIntersectionCursor.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,7 @@ Geometry tryFastIntersectPolylinePolygon_(Polyline polyline, Polygon polygon) {
606606
resSeg.getStartXY(), tolerance) != 1) {
607607
if (analyseClipSegment_(polygon, resSeg,
608608
tolerance) != 1) {
609-
assert (false);// something went wrong.
610-
return null;
609+
return null; //someting went wrong we'll falback to slower but robust planesweep code.
611610
}
612611
}
613612

@@ -667,9 +666,7 @@ Geometry tryFastIntersectPolylinePolygon_(Polyline polyline, Polygon polygon) {
667666
// be
668667
// inside.
669668
if (clipStatus < 0) {
670-
assert (clipStatus >= 0);// E-mail the repro case to
671-
// the Geometry team to
672-
// investigate.
669+
assert (clipStatus >= 0);
673670
return null;// something goes wrong, resort to
674671
// planesweep
675672
}

src/main/java/com/esri/core/geometry/RelationalOperations.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,15 @@ private static boolean polygonEqualsPolygon_(Polygon polygon_a,
894894
progress_tracker))
895895
return true;
896896

897-
return linearPathEqualsLinearPath_(polygon_a, polygon_b, tolerance);
897+
double length_a = polygon_a.calculateLength2D();
898+
double length_b = polygon_b.calculateLength2D();
899+
int max_vertices = Math.max(polygon_a.getPointCount(),
900+
polygon_b.getPointCount());
901+
902+
if (Math.abs(length_a - length_b) > max_vertices * 4.0 * tolerance)
903+
return false;
904+
905+
return linearPathEqualsLinearPath_(polygon_a, polygon_b, tolerance, true);
898906
}
899907

900908
// Returns true if polygon_a is disjoint from polygon_b.
@@ -1264,7 +1272,7 @@ private static boolean polygonEqualsEnvelope_(Polygon polygon_a,
12641272
Polygon polygon_b = new Polygon();
12651273
polygon_b.addEnvelope(envelope_b, false);
12661274

1267-
return linearPathEqualsLinearPath_(polygon_a, polygon_b, tolerance);
1275+
return linearPathEqualsLinearPath_(polygon_a, polygon_b, tolerance, true);
12681276
}
12691277

12701278
// Returns true if polygon_a is disjoint from envelope_b.
@@ -1520,7 +1528,7 @@ private static boolean polylineEqualsPolyline_(Polyline polyline_a,
15201528
progress_tracker))
15211529
return true;
15221530

1523-
return linearPathEqualsLinearPath_(polyline_a, polyline_b, tolerance);
1531+
return linearPathEqualsLinearPath_(polyline_a, polyline_b, tolerance, false);
15241532
}
15251533

15261534
// Returns true if polyline_a is disjoint from polyline_b.
@@ -1633,7 +1641,7 @@ private static boolean polylineContainsPolyline_(Polyline polyline_a,
16331641
false) == Relation.disjoint)
16341642
return false;
16351643

1636-
return linearPathWithinLinearPath_(polyline_b, polyline_a, tolerance);
1644+
return linearPathWithinLinearPath_(polyline_b, polyline_a, tolerance, false);
16371645
}
16381646

16391647
// Returns true if polyline_a is disjoint from point_b.
@@ -2127,7 +2135,7 @@ private static boolean polylineContainsEnvelope_(Polyline polyline_a,
21272135
polyline_b.startPath(p);
21282136
envelope_b.queryCornerByVal(2, p);
21292137
polyline_b.lineTo(p);
2130-
return linearPathWithinLinearPath_(polyline_b, polyline_a, tolerance);
2138+
return linearPathWithinLinearPath_(polyline_b, polyline_a, tolerance, false);
21312139
}
21322140

21332141
// Returns true if polyline_a crosses envelope_b.
@@ -3405,16 +3413,16 @@ private static boolean multiPointIntersectsMultiPoint_(
34053413

34063414
// Returns true if multipathA equals multipathB.
34073415
private static boolean linearPathEqualsLinearPath_(MultiPath multipathA,
3408-
MultiPath multipathB, double tolerance) {
3409-
return linearPathWithinLinearPath_(multipathA, multipathB, tolerance)
3416+
MultiPath multipathB, double tolerance, boolean bEnforceOrientation) {
3417+
return linearPathWithinLinearPath_(multipathA, multipathB, tolerance, bEnforceOrientation)
34103418
&& linearPathWithinLinearPath_(multipathB, multipathA,
3411-
tolerance);
3419+
tolerance, bEnforceOrientation);
34123420
}
34133421

34143422
// Returns true if the segments of multipathA are within the segments of
34153423
// multipathB.
34163424
private static boolean linearPathWithinLinearPath_(MultiPath multipathA,
3417-
MultiPath multipathB, double tolerance) {
3425+
MultiPath multipathB, double tolerance, boolean bEnforceOrientation) {
34183426
boolean bWithin = true;
34193427
double[] scalarsA = new double[2];
34203428
double[] scalarsB = new double[2];
@@ -3485,7 +3493,7 @@ private static boolean linearPathWithinLinearPath_(MultiPath multipathA,
34853493
int result = segmentA.intersect(segmentB, null, scalarsA,
34863494
scalarsB, tolerance);
34873495

3488-
if (result == 2) {
3496+
if (result == 2 && (!bEnforceOrientation || scalarsB[0] <= scalarsB[1])) {
34893497
double scalar_a_0 = scalarsA[0];
34903498
double scalar_a_1 = scalarsA[1];
34913499
double scalar_b_0 = scalarsB[0];
@@ -3515,7 +3523,7 @@ private static boolean linearPathWithinLinearPath_(MultiPath multipathA,
35153523
result = segmentA.intersect(segmentB, null,
35163524
scalarsA, scalarsB, tolerance);
35173525

3518-
if (result == 2) {
3526+
if (result == 2 && (!bEnforceOrientation || scalarsB[0] <= scalarsB[1])) {
35193527
scalar_a_0 = scalarsA[0];
35203528
scalar_a_1 = scalarsA[1];
35213529

@@ -3533,7 +3541,7 @@ private static boolean linearPathWithinLinearPath_(MultiPath multipathA,
35333541
null, scalarsA, scalarsB,
35343542
tolerance);
35353543

3536-
if (result == 2) {
3544+
if (result == 2 && (!bEnforceOrientation || scalarsB[0] <= scalarsB[1])) {
35373545
scalar_a_0 = scalarsA[0];
35383546
scalar_a_1 = scalarsA[1];
35393547

@@ -3642,15 +3650,15 @@ private static boolean linearPathOverlapsLinearPath_(MultiPath multipathA,
36423650

36433651
if (bIntAExtB && !bIntBExtA)
36443652
return !linearPathWithinLinearPath_(multipathB, multipathA,
3645-
tolerance);
3653+
tolerance, false);
36463654

36473655
if (bIntBExtA && !bIntAExtB)
36483656
return !linearPathWithinLinearPath_(multipathA, multipathB,
3649-
tolerance);
3657+
tolerance, false);
36503658

3651-
return !linearPathWithinLinearPath_(multipathA, multipathB, tolerance)
3659+
return !linearPathWithinLinearPath_(multipathA, multipathB, tolerance, false)
36523660
&& !linearPathWithinLinearPath_(multipathB, multipathA,
3653-
tolerance);
3661+
tolerance, false);
36543662
}
36553663

36563664
// Returns true the dimension of intersection of _multipathA and

0 commit comments

Comments
 (0)