|
15 | 15 | import org.locationtech.jts.geom.Envelope;
|
16 | 16 | import org.locationtech.jts.geom.Geometry;
|
17 | 17 | import org.locationtech.jts.geom.Location;
|
18 |
| -import org.locationtech.jts.geom.prep.PreparedGeometry; |
19 |
| -import org.locationtech.jts.geom.prep.PreparedGeometryFactory; |
20 | 18 | import org.locationtech.jts.operation.distance.IndexedFacetDistance;
|
21 |
| -import org.locationtech.jts.util.GeometricShapeFactory; |
22 | 19 | import org.tinfour.common.IIncrementalTin;
|
23 | 20 | import org.tinfour.common.SimpleTriangle;
|
24 | 21 | import org.tinfour.common.Vertex;
|
@@ -287,28 +284,21 @@ public static List<PVector> frontChainPack(PShape shape, double radiusMin, doubl
|
287 | 284 | IndexedPointInAreaLocator pointLocator;
|
288 | 285 |
|
289 | 286 | final FrontChainPacker packer = new FrontChainPacker((float) e.getWidth(), (float) e.getHeight(), (float) radiusMin,
|
290 |
| - (float) radiusMax, (float) e.getMinX(), (float) e.getMinY()); |
| 287 | + (float) radiusMax, (float) e.getMinX(), (float) e.getMinY(), seed); |
291 | 288 |
|
292 | 289 | if (radiusMin == radiusMax) {
|
293 | 290 | // if every circle same radius, use faster contains check
|
294 | 291 | pointLocator = new IndexedPointInAreaLocator(g.buffer(radiusMax));
|
295 | 292 | packer.getCircles().removeIf(p -> pointLocator.locate(PGS.coordFromPVector(p)) == Location.EXTERIOR);
|
296 | 293 | } else {
|
297 | 294 | pointLocator = new IndexedPointInAreaLocator(g);
|
298 |
| - final PreparedGeometry cache = PreparedGeometryFactory.prepare(g); |
299 |
| - final GeometricShapeFactory circleFactory = new GeometricShapeFactory(); |
300 |
| - circleFactory.setNumPoints(8); // approximate circles using octagon for intersects check |
| 295 | + IndexedFacetDistance distance = new IndexedFacetDistance(g); |
301 | 296 | packer.getCircles().removeIf(p -> {
|
302 | 297 | // first test whether shape contains circle center point (somewhat faster)
|
303 | 298 | if (pointLocator.locate(PGS.coordFromPVector(p)) != Location.EXTERIOR) {
|
304 | 299 | return false;
|
305 | 300 | }
|
306 |
| - |
307 |
| - // if center point not in circle, check whether circle overlaps with shape using |
308 |
| - // intersects() (somewhat slower) |
309 |
| - circleFactory.setCentre(PGS.coordFromPVector(p)); |
310 |
| - circleFactory.setSize(p.z * 2); // set diameter |
311 |
| - return !cache.intersects(circleFactory.createCircle()); |
| 301 | + return !distance.isWithinDistance(PGS.pointFromPVector(p), p.z * 0.666); |
312 | 302 | });
|
313 | 303 | }
|
314 | 304 |
|
|
0 commit comments