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; }
/** * 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; }
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; }
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))); } }
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(); }
private static boolean isWallCounterClockwise(Wall wall) { PolygonList2d wallToPolygon = BuildingUtil.wallToOuterPolygon(wall); if (0.0f < Triangulate.area(wallToPolygon.getPoints())) { return true; } return false; }
private static PolygonList2d transformPolygon(PolygonList2d polygon, SimpleMatrix transformLocal) { return new PolygonList2d(TransformationMatrix2d.transformList(polygon.getPoints(), transformLocal)); }
public static PlygonSplitUtil.SplitResult split(MultiPolygonList2d multiPolygon, LinePoints2d splittingLine) { final List<List<Point2d>> leftPolygons = new ArrayList<List<Point2d>>(); final List<List<Point2d>> rightPolygons = new ArrayList<List<Point2d>>(); for (PolygonList2d polygon : multiPolygon.getPolygons()) { // FIXME XXX holes are missing! SplitResult split = PlygonSplitUtil.split(polygon.getPoints(), splittingLine); leftPolygons.addAll(split.getLeftPolygons()); rightPolygons.addAll(split.getRightPolygons()); } return new PlygonSplitUtil.SplitResult(leftPolygons, rightPolygons); }
private void calcDistances(SkeletonOutput sk, Map<Point2d, Double> distance) { for (EdgeOutput edgeOutput : sk.getEdgeOutputs()) { PolygonList2d polygon = edgeOutput.getPolygon(); LineSegment2d edge = sk.getEdges().get(polygon); List<Point2d> points = polygon.getPoints(); calcDistance(edge, points, distance); } }
private boolean isComplex(PolygonWithHolesList2d buildingPolygon, DormerRoofModel roof) { if (roof.getDirection() != null) { return false; } if (roof.getOrientation() != null) { return false; } if (buildingPolygon.getInner() != null && buildingPolygon.getInner().size() > 0) { // has any holes return true; } List<Point2d> points = buildingPolygon.getOuter().getPoints(); RectanglePointVector2d orientedBBox = RectangleUtil.findRectangleContur(points); double orientedBBoxArea = orientedBBox.getHeight() * orientedBBox.getWidth(); float polygonArea = Math.abs(PolygonUtil.area(points)); return orientedBBoxArea > polygonArea * 1.2; }
@Override public RoofTypeOutput buildRoof(Point2d startPoint, PolygonWithHolesList2d buildingPolygon, DormerRoofModel roof, double height, RoofMaterials roofTextureData) { SimpleMatrix transformLocal = TransformationMatrix2d.tranA(-startPoint.x, -startPoint.y); List<Point2d> polygon = buildingPolygon.getOuter().getPoints(); polygon = TransformationMatrix2d.transformList(polygon, transformLocal); Double h1 = null; Double angle = null; Measurement measurement = roof.getMeasurements().get(MeasurementKey.HEIGHT_1); if (isUnit(measurement, MeasurementUnit.DEGREES)) { angle = measurement.getValue(); } else { h1 = getHeightMeters(roof.getMeasurements(), MeasurementKey.HEIGHT_1, DEFAULT_ROOF_HEIGHT); } RoofTypeOutput rto = build(polygon, h1, angle, roofTextureData); SimpleMatrix transformGlobal = TransformationMatrix3d.tranA(startPoint.x, height - rto.getHeight(), -startPoint.y); rto.setTransformationMatrix(transformGlobal); return rto; }
@Override public RoofTypeOutput buildRoof(Point2d pStartPoint, PolygonWithHolesList2d buildingPolygon, DormerRoofModel pRoof, double height, RoofMaterials roofTextureData) { SimpleMatrix transformLocal = TransformationMatrix2d.tranA(-pStartPoint.x, -pStartPoint.y); List<Point2d> polygon = buildingPolygon.getOuter().getPoints(); polygon = TransformationMatrix2d.transformList(polygon, transformLocal); Double h1 = null; Double angle = null; Measurement measurement = pRoof.getMeasurements().get(MeasurementKey.HEIGHT_1); if (isUnit(measurement, MeasurementUnit.DEGREES)) { angle = measurement.getValue(); } else { h1 = getHeightMeters(pRoof.getMeasurements(), MeasurementKey.HEIGHT_1, DEFAULT_ROOF_HEIGHT); } RoofTypeOutput rto = build(polygon, h1, angle, roofTextureData); SimpleMatrix transformGlobal = TransformationMatrix3d.tranA(pStartPoint.x, height - rto.getHeight(), -pStartPoint.y); rto.setTransformationMatrix(transformGlobal); return rto; }
List<Point2d> pBorderList = buildingPolygon.getOuter().getPoints();
rectangleContur = rectToList(RectangleUtil.findRectangleContur(outerPolygon.getPoints())); rectangleContur = findStartPoint(startPoint, rectangleContur); Vector2d alignedDirection = RectangleTypeRoofUtil.snapsDirectionToOutline(direction.getDirection(), outerPolygon); rectangleContur = calcRectangle(outerPolygon.getPoints(), alignedDirection); rectangleContur = calcRectangle(outerPolygon.getPoints(), direction.getDirection());
List<Point2d> polygon = buildingPolygon.getOuter().getPoints();
List<Point2d> outlineList = buildingPolygon.getOuter().getPoints();
@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; }
TextureData roofTexture = roofTextureData.getRoof().getTextureData(); List<Point2d> pBorderList = buildingPolygon.getOuter().getPoints(); PolygonList2d borderPolygon = new PolygonList2d(pBorderList);
List<Point2d> outlineList = buildingPolygon.getOuter().getPoints();