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; }
public static PlygonSplitUtil.SplitResult split(PolygonList2d polygon, LinePoints2d splitingLine) { return split(new MultiPolygonList2d(polygon), splitingLine); }
public static MultiPolygonList2d[] createMP(PolygonList2d borderPolygon, LinePoints2d[] lines) { MultiPolygonList2d topMP = new MultiPolygonList2d(borderPolygon); MultiPolygonList2d[] mps = new MultiPolygonList2d[lines.length - 1]; for (int i = 1; i < lines.length; i++) { MultiPolygonSplitResult middleSplit = PolygonSplitHelper.splitMultiPolygon(topMP, lines[i]); topMP = middleSplit.getLeftMultiPolygon(); mps[i - 1] = middleSplit.getRightMultiPolygon(); } return mps; }
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); }
@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; }
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 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; }
private static PolygonList2d transformPolygon(PolygonList2d polygon, SimpleMatrix transformLocal) { return new PolygonList2d(TransformationMatrix2d.transformList(polygon.getPoints(), transformLocal)); }
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; }
public MultiPolygonList2d getTopMultiPolygons() { MultiPolygonList2d mp = new MultiPolygonList2d(); Set<PolygonList2d> polygons = mp.getPolygons(); for (SplitPolygon s : this.splitPolygons) { polygons.addAll(s.getTopMultiPolygons().getPolygons()); } return mp; }
public MultiPolygonList2d getBottomMultiPolygons() { MultiPolygonList2d mp = new MultiPolygonList2d(); Set<PolygonList2d> polygons = mp.getPolygons(); for (SplitPolygon s : this.splitPolygons) { polygons.addAll(s.getBottomMultiPolygons().getPolygons()); } return mp; }
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(); }
protected RoofTypeOutput build(List<Point2d> borderList, Double height, Double angle, RoofMaterials roofTextureData) { MeshFactory meshDome = createRoofMesh(roofTextureData); TextureData roofTexture = roofTextureData.getRoof().getTextureData(); PolygonList2d borderPolygon = new PolygonList2d(borderList); // build circle Circle circle = CircleInsidePolygon.iterativeNonConvex(borderPolygon, 0.01); int pIcross = 5; buildRotaryShape(meshDome, borderList, circle.getPoint(), height, pIcross, roofTexture); RoofTypeOutput rto = new RoofTypeOutput(); rto.setHeight(height); rto.setMesh(Arrays.asList(meshDome)); rto.setRoofHooksSpaces(null); rto.setRectangle(RoofTypeUtil.findRectangle(borderList, 0)); return rto; }
private static boolean isWallCounterClockwise(Wall wall) { PolygonList2d wallToPolygon = BuildingUtil.wallToOuterPolygon(wall); if (0.0f < Triangulate.area(wallToPolygon.getPoints())) { return true; } return false; }
@Override protected Bend[] getBends(Map<MeasurementKey, Measurement> measurements, Circle circle) { double ratius = circle.getRadius(); Double h1 = getHeightMeters(measurements, MeasurementKey.HEIGHT_1, ratius * 2.25); Double l1 = getLenghtMetersPersent(measurements, MeasurementKey.LENGTH_1, ratius, ratius); return scaleBends(this.bendsShape, h1, l1); }
public MultiPolygonList2d getTopMultiPolygons() { MultiPolygonList2d mp = new MultiPolygonList2d(); Set<PolygonList2d> polygons = mp.getPolygons(); for (List<Integer> p : this.polygonsRight) { List<Point2d> polygon = makeListFromIndex(this.polygonExtanded, p); PolygonList2d polygonList = new PolygonList2d(polygon); polygons.add(polygonList); } return mp; }
/** * 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; } }
/** * 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; }