private static PolygonList2d transformPolygon(PolygonList2d polygon, SimpleMatrix transformLocal) { return new PolygonList2d(TransformationMatrix2d.transformList(polygon.getPoints(), transformLocal)); }
private static MultiPolygonList2d toMultiPolygon(List<List<Point2d>> leftPolygons) { List<PolygonList2d> polygons = new ArrayList<PolygonList2d>(); for (List<Point2d> polygon : leftPolygons) { polygons.add(new PolygonList2d(polygon)); } return new MultiPolygonList2d(polygons); }
private static List<List<Point2d>> toList(MultiPolygonList2d pPolygon) { List<List<Point2d>> ret = new ArrayList<List<Point2d>>(); for (PolygonList2d polygon : pPolygon.getPolygons()) { List<Point2d> poly = polygon.getPoints(); ret.add(poly); } return ret; }
/** * Create roof surface polygons. * * @param outlinePolygon * @param middlePoint * @return */ private MultiPolygonList2d[] createMP(List<Point2d> outlinePolygon, Point2d middlePoint) { int size = outlinePolygon.size(); MultiPolygonList2d[] ret = new MultiPolygonList2d[size]; for (int i = 0; i < size; i++) { Point2d p1 = outlinePolygon.get(i); Point2d p2 = outlinePolygon.get((i + 1) % size); ret[i] = new MultiPolygonList2d(new PolygonList2d(p1, p2, middlePoint)); } return ret; } }
/** * Splits polygon by lines. Adds extra points in crossing places. * * @param polygon * polygon to split by lines * @param lines * lines to split polygon * @return polygon with extra points on crossing places */ public static List<Point2d> splitBorder(PolygonList2d polygon, LinePoints2d... lines) { List<Point2d> splitPolygon = new ArrayList<Point2d>(polygon.getPoints()); for (LinePoints2d line : lines) { splitPolygon = EnrichPolygonalChainUtil.enrichClosedPolygonalChainByLineCrossing(splitPolygon, line); } return splitPolygon; }
List<Point2d> pBorderList = buildingPolygon.getOuter().getPoints(); PolygonList2d borderPolygon = new PolygonList2d(pBorderList); MultiPolygonList2d topMP = new MultiPolygonList2d(borderPolygon);
private List<Point2d> calsHookPoints(List<Point2d> points, Integer numOfTrees) { double area = Math.abs(Triangulate.area(points)); if (numOfTrees == null) { // 1 tree on 100 square meters numOfTrees = (int) Math.round(area / 100d); } if (numOfTrees > 1000) { // XXX numOfTrees = 1000; } PolygonList2d polygon = new PolygonList2d(points); return monteCarloHookGenerator(polygon, numOfTrees); }
private List<List<Point2d>> innerLists(PolygonWithHolesList2d buildingPolygon) { List<List<Point2d>> ret = new ArrayList<List<Point2d>>(); if (buildingPolygon.getInner() == null) { return ret; } for (PolygonList2d p : buildingPolygon.getInner()) { ret.add(p.getPoints()); } return ret; }
@Override public RoofTypeOutput buildRoof(Point2d pStartPoint, PolygonWithHolesList2d buildingPolygon, DormerRoofModel pRoof, double height, RoofMaterials roofTextureData) { List<Point2d> pPolygon = buildingPolygon.getOuter().getPoints(); SimpleMatrix transformLocal = TransformationMatrix2d.tranA(-pStartPoint.x, -pStartPoint.y); pPolygon = TransformationMatrix2d.transformList(pPolygon, transformLocal); // rectangleContur = // TransformationMatrix2d.transformArray(rectangleContur, // transformLocal); PolygonList2d borderPolygon = new PolygonList2d(pPolygon); Circle circle = CircleInsidePolygon.iterativeNonConvex(borderPolygon, 0.01); int isection = getIsection(pRoof.getRoofTypeParameter()); boolean soft = isSoft(pRoof.getRoofTypeParameter()); Bend[] bends = getBends(pRoof.getMeasurements(), circle); RoofTypeOutput rto = build(pPolygon, circle.getPoint(), bends, isection, soft, roofTextureData); SimpleMatrix transformGlobal = TransformationMatrix3d.tranA(pStartPoint.x, height - rto.getHeight(), -pStartPoint.y); rto.setTransformationMatrix(transformGlobal); return rto; }
/** * Create roof surface polygons. * * @param outlineConvexHull * @param outlineList * @param outlinePolygon * @param middlePoint * @return */ private MultiPolygonList2d[] createMP(List<Point2d> outlineConvexHull, List<Point2d> outlineList, Point2d middlePoint) { MultiPolygonList2d outlineMultiPolygon = new MultiPolygonList2d(new PolygonList2d(outlineList)); int size = outlineConvexHull.size(); MultiPolygonList2d[] ret = new MultiPolygonList2d[size]; for (int i = 0; i < size; i++) { Point2d p1 = outlineConvexHull.get(i); Point2d p2 = outlineConvexHull.get((i + 1) % size); ret[i] = intersectionOfLeftSideOfMultipleCuts(outlineMultiPolygon, p2, middlePoint, p1); } return ret; }
private static Polygon convert(PolygonList2d polygon) { return new Polygon(polygon.getPoints().stream() .map(p -> new PolygonPoint(p.x, p.y)).collect(Collectors.toCollection(ArrayList<PolygonPoint>::new))); } }
TextureData roofTexture = roofTextureData.getRoof().getTextureData(); List<Point2d> pBorderList = buildingPolygon.getOuter().getPoints(); PolygonList2d borderPolygon = new PolygonList2d(pBorderList);
private static PolygonList2d wallPartsToPolygon(List<WallPart> wallParts) { List<Point2d> points = new ArrayList<Point2d>(); for (WallPart p : wallParts) { if (points.size() > 0 && p.getNodes().size() > 0) { Point2d lastAdded = points.get(points.size() - 1); Point2d newToAdd = p.getNodes().get(0).point; if (lastAdded.equals(newToAdd)) { points.remove(points.size() - 1); } } for (WallNode n : p.getNodes()) { points.add(n.point); } } // if (points.size() > 1) { if (points.get(0).equals(points.get(points.size()-1))) { points.remove(points.size()-1); } else { throw new IllegalArgumentException("wall is not closed!!!"); } return new PolygonList2d(points); }
private String debugPolygon(PolygonWithHolesList2d buildingTransformed) { StringBuffer sb = new StringBuffer(); sb.append("** Debug for polygon **\n"); List<Point2d> outer = buildingTransformed.getOuter().getPoints(); sb.append("List<Point2d> polygon = new ArrayList<Point2d>();\n"); for (Point2d p : outer) { sb.append("polygon.add(new Point2d(" + p.x + ", " + p.y + "));\n"); } List<List<Point2d>> inners = PolygonWithHolesList2dUtil.getListOfHolePoints(buildingTransformed); int holeCount = 0; for (List<Point2d> polygonList2d : inners) { holeCount++; sb.append("\nList<Point2d> hole" + holeCount + " = new ArrayList<Point2d>();\n"); for (Point2d p : polygonList2d) { sb.append("hole" + holeCount + ".add(new Point2d(" + p.x + ", " + p.y + "));\n"); } } sb.append("****"); return sb.toString(); }
TextureData roofTexture = roofTextureData.getRoof().getTextureData(); List<Point2d> pBorderList = buildingPolygon.getOuter().getPoints(); PolygonList2d borderPolygon = new PolygonList2d(pBorderList);
public MultiPolygonList2d getBottomMultiPolygons() { MultiPolygonList2d mp = new MultiPolygonList2d(); Set<PolygonList2d> polygons = mp.getPolygons(); for (List<Integer> p : this.polygonsLeft) { List<Point2d> polygon = makeListFromIndex(this.polygonExtanded, p); PolygonList2d polygonList = new PolygonList2d(polygon); polygons.add(polygonList); } return mp; }
private static boolean isWallCounterClockwise(Wall wall) { PolygonList2d wallToPolygon = BuildingUtil.wallToOuterPolygon(wall); if (0.0f < Triangulate.area(wallToPolygon.getPoints())) { return true; } return false; }
PolygonList2d poly = new PolygonList2d(vbl, vbr, vtr, vtl); Iterable<Point2d> trianglePoint = new SimpleTriangulateInterable(polygon.getPoints());