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); }
/** * 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; } }
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); }
/** * 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 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 static PolygonList2d transformPolygon(PolygonList2d polygon, SimpleMatrix transformLocal) { return new PolygonList2d(TransformationMatrix2d.transformList(polygon.getPoints(), transformLocal)); }
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 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; }
List<PolygonWithHolesList2d> getMultiPolygonWithHolesWay(Way way, Perspective perspective) { List<PolygonWithHolesList2d> ret = new ArrayList<PolygonWithHolesList2d>(); List<Point2d> poly = new ArrayList<Point2d>(); int size = way.getNodesCount(); if (size > 0) { if (way.getNode(0).equals(way.getNode(way.getNodesCount() - 1))) { size--; } for (int i = 0; i < size; i++) { Point2d p = perspective.calcPoint(way.getNode(i)); poly.add(p); } ret.add(new PolygonWithHolesList2d(new PolygonList2d(poly), null)); } return ret; }
private static PolygonList2d parse(List<ReversableWay> outer, Perspective pPerspective) { List<Point2d> poly = new ArrayList<Point2d>(); for (ReversableWay rw : outer) { Way way = rw.getWay(); int size = way.getNodesCount(); if (size > 0) { if (!rw.isReversed()) { // do not take the last node, it is either first of next way or first of first way for (int i = 0; i < size - 1; i++) { Point2d p = pPerspective.calcPoint(way.getNode(i)); poly.add(p); } } else { // do not take the last node, it is either first of next way or first of first way for (int i = size - 1; i > 0; i--) { Point2d p = pPerspective.calcPoint(way.getNode(i)); poly.add(p); } } } } return new PolygonList2d(poly); }
private static Collection<? extends PolygonList2d> createUnderRoofPolygons(Point2d startPoint, Point2d endPoint, double wallHeight2, HeightCalculator roofHeightCalculator) { List<PolygonList2d> ret = new ArrayList<PolygonList2d>(); List<SegmentHeight> heightSegments = roofHeightCalculator.height(startPoint, endPoint); double distance = 0; for (SegmentHeight segmentHeight : heightSegments) { double segmentDistance = segmentHeight.getBegin().distance(segmentHeight.getEnd()); double leftHeight = segmentHeight.getBeginHeight(); double rightHeight = segmentHeight.getEndHeight(); boolean shrinkLeft = equal(wallHeight2, leftHeight); boolean shrinkRight = equal(wallHeight2, rightHeight); if (shrinkLeft && shrinkRight) { /* * Same height of begin end and desired height so no point to * generate empty size polygon. */ continue; } Point2d bottomLeft = new Point2d(distance, wallHeight2); Point2d bottomRight = new Point2d(distance + segmentDistance, wallHeight2); Point2d topRight = new Point2d(distance + segmentDistance, rightHeight); Point2d topLeft = new Point2d(distance, leftHeight); ret.add(new PolygonList2d(bottomLeft, bottomRight, topRight, topLeft)); distance += segmentDistance; } return ret; }
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; }
protected RoofTypeOutput build(List<Point2d> borderList, Double height, Double angle, RoofMaterials roofTextureData) { MeshFactory meshDome = createRoofMesh(roofTextureData); MeshFactory meshRoof = createRoofMesh(roofTextureData); TextureData roofTexture = roofTextureData.getRoof().getTextureData(); PolygonList2d borderPolygon = new PolygonList2d(borderList); buildFlatRoof(borderPolygon, meshRoof, roofTexture); // build circle Circle circle = CircleInsidePolygon.iterativeNonConvex(borderPolygon, 0.01); circle.setRadius(Math.min(height, circle.getRadius())); int pIcross = 5; int pIsection = 9; buildRotaryShape(meshDome, circle, pIcross, pIsection, true); RoofTypeOutput rto = new RoofTypeOutput(); rto.setHeight(circle.getRadius()); rto.setMesh(Arrays.asList(meshDome, meshRoof)); rto.setRoofHooksSpaces(null); rto.setRectangle(RoofTypeUtil.findRectangle(borderList, 0)); return rto; }
PolygonList2d borderPolygon = new PolygonList2d(pBorderList); MultiPolygonList2d topMP = new MultiPolygonList2d(borderPolygon);
protected RoofTypeOutput build(List<Point2d> borderList, Point2d point, Bend[] bends, int sectionCount, boolean pSoft, RoofMaterials roofTextureData) { MeshFactory meshBorder = createFacadeMesh(roofTextureData); MeshFactory meshRoof = createRoofMesh(roofTextureData); TextureData roofTexture = roofTextureData.getRoof().getTextureData(); PolygonList2d borderPolygon = new PolygonList2d(borderList); RoofType5v6.buildFlatRoof(borderPolygon, meshRoof, roofTexture); double height = bends[bends.length - 1].getHeight(); Point2d[] crossSection = new Point2d[bends.length]; crossSection[0] = new Point2d(bends[0].getRadius(), 0); crossSection[crossSection.length - 1] = new Point2d(0, height); for (int i = 1; i < bends.length; i++) { crossSection[i] = new Point2d(bends[i].getRadius(), bends[i].getHeight()); } RoofType5v6.buildRotaryShape(meshRoof, point, sectionCount, crossSection, pSoft); RoofTypeOutput rto = new RoofTypeOutput(); rto.setHeight(height); rto.setMesh(Arrays.asList(meshBorder, meshRoof)); rto.setRoofHooksSpaces(null); rto.setRectangle(RoofTypeUtil.findRectangle(borderList, 0)); return rto; }
@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; }
PolygonList2d borderPolygon = new PolygonList2d(pBorderList);
PolygonList2d borderPolygon = new PolygonList2d(pBorderList);
PolygonList2d borderPolygon = new PolygonList2d(outline);
PolygonList2d borderPolygon = new PolygonList2d(outline);