@Override protected void postProcess(Sector.Triangle[] triangles) { if (show.contains("triangles")) { int i = 0; for (Sector.Triangle t : triangles) { GeoPoint[] trianglePoints = t.getPoints('A'); double x = 0, y = 0; int l = trianglePoints.length; double[] points = new double[l * 2 + 2]; for (int j = 0; j <= l; j++) { Point p = trianglePoints[j % l].toPoint(1000.0); points[j * 2] = p.x; points[j * 2 + 1] = p.z; if (j < l) { x += p.x; y += p.z; } } x /= l; y /= l; for (int j = 0; j <= l; j++) { points[j * 2] = points[j * 2] * 0.95 + x * 0.05; points[j * 2 + 1] = points[j * 2 + 1] * 0.95 + y * 0.05; } Color color = t.inverted ? triangleInverted : triangleNormal; out.addLine(color, points); if (show.contains("labels")) { out.addLabel(color, "" + i, x, y); } i++; } } super.postProcess(triangles); }
protected void stitchNeighbors(Set<Sector> neighbors, GeoPoint center) { assert gatedAssertion( neighbors.size() == 6 || neighbors.size() == 5 && countDistinctGlobalSectors(neighbors) == 5); if (!sector.equals(neighbors.iterator().next())) { return; } Map<GeoPoint, GeoPoint> nextPoints = new HashMap<GeoPoint, GeoPoint>(); Sector second = null; for (Sector s : neighbors) { char vertex = s.getVertex(center); Sector.Triangle cornerTriangle = s.getCornerTriangle(vertex); GeoPoint[] geoPoints = cornerTriangle.getPoints(vertex); nextPoints.put(geoPoints[1], geoPoints[2]); if (second == null && countShared(s.points, sector.points) == 1) { second = s; } } assert gatedAssertion(second != null); if (second != null) { GeoPoint[] acre = new GeoPoint[nextPoints.size()]; GeoPoint point = nextPoints.values().iterator().next(); for (int idx = 0; idx < nextPoints.size(); idx++) { assert !Arrays.asList(acre).contains(point); acre[idx] = point; point = nextPoints.get(point); assert gatedAssertion(point != null); if (point == null) { return; } } Sector[] others = new Sector[neighbors.size() - 2]; int idx = 0; for (Sector s : neighbors) { if (s != sector && s != second) { others[idx++] = s; } } Acre newAcre = new Acre(1, sector, second, Arrays.asList(others), center, acre); CartographicElementView cartographicElementView = getFor(subdivisions); for (Sector s : neighbors) { char vertex = s.getVertex(center); assert vertex == 'A' || vertex == 'B' || vertex == 'C'; Edge e = Edge.values()[vertex - 'A']; List<Acre> vertexAcre = cartographicElementView.get( s.getSharedAcres(), CartographicElementView.Position.Vertex, e, false); assert vertexAcre.size() == 1; assert vertexAcre.get(0) == null; vertexAcre.set(0, newAcre); } consume(newAcre); } }