private static BuildingPart cloneBuildingPart(BuildingPart bp, Double height) { BuildingPart ret = new BuildingPart(); if (bp.getMaxHeight() == null) { ret.setMaxHeight(bp.getDefaultMaxHeight() + height); } else { ret.setMaxHeight(bp.getMaxHeight() + height); } if (bp.getMinHeight() == null) { ret.setMinHeight(bp.getDefaultMinHeight() + height); } else { ret.setMinHeight(bp.getMinHeight() + height); } ret.setFacadeColor(bp.getFacadeColor()); ret.setFacadeMaterialType(bp.getFacadeMaterialType()); ret.setFloorColor(bp.getFloorColor()); ret.setFloorMaterialType(bp.getFloorMaterialType()); ret.setInlineWalls(bp.getInlineWalls()); ret.setLevelHeight(bp.getLevelHeight()); ret.setMaxLevel(bp.getMaxLevel()); ret.setMinLevel(bp.getMinLevel()); ret.setRoof(bp.getRoof()); ret.setRoofColor(bp.getRoofColor()); ret.setRoofLevels(bp.getRoofLevels()); ret.setRoofMaterialType(bp.getRoofMaterialType()); ret.setWall(bp.getWall()); return ret; }
public static PolygonWithHolesList2d buildingPartToPolygonWithHoles(BuildingPart bp) { PolygonList2d outerPolygon = wallToOuterPolygon(bp.getWall()); List<PolygonList2d> innerList = new ArrayList<PolygonList2d>(); if (bp.getInlineWalls() != null) { for (Wall innerWall : bp.getInlineWalls()) { PolygonList2d innerPolygon = wallToOuterPolygon(innerWall); innerList.add(innerPolygon); } } return new PolygonWithHolesList2d(outerPolygon, innerList); }
/** * @param pOsmPrimitive * @return */ public static BuildingPart parseBuildingPartAttributes(OsmPrimitive pOsmPrimitive) { BuildingPart bp = new BuildingPart(); bp.setMaxHeight(BuildingAttributeParser.parseMaxHeight(pOsmPrimitive)); bp.setMinHeight(BuildingAttributeParser.parseMinHeight(pOsmPrimitive)); bp.setMaxLevel(BuildingAttributeParser.parseMaxLevel(pOsmPrimitive)); bp.setRoofLevels(BuildingAttributeParser.parseRoofLevels(pOsmPrimitive)); bp.setMinLevel(BuildingAttributeParser.parseMinLevel(pOsmPrimitive)); bp.setFacadeMaterialType(BuildingAttributeParser.parseFacadeMaterialName(pOsmPrimitive)); bp.setFacadeColor(BuildingAttributeParser.parseFacadeColor(pOsmPrimitive)); bp.setFloorMaterialType(BuildingAttributeParser.parseFloorMaterialName(pOsmPrimitive)); bp.setFloorColor(BuildingAttributeParser.parseFloorColor(pOsmPrimitive)); bp.setRoofMaterialType(BuildingAttributeParser.parseRoofMaterialName(pOsmPrimitive)); bp.setRoofColor(BuildingAttributeParser.parseRoofColor(pOsmPrimitive)); bp.setContext(pOsmPrimitive.getPrimitiveId()); return bp; }
for (final BuildingPart bp : parts) { PrimitiveId primitive = (PrimitiveId) bp.getContext(); double minHeight = bp.getDefaultMinHeight(); double maxHeight = bp.getDefaultMaxHeight(); Point3d partCenter = new Point3d( // (bounds.getxMax() + bounds.getxMin()) / 2d, // double roofHeight = bp.getRoof().getRoofHeight(); if (parts != null) { for (BuildingPart bp : parts) { List<WallPart> wallParts = bp.getWall().getWallParts(); for (WallPart wp : wallParts) { for (WallNode wn : wp.getNodes()) { bf.addPoint(p.x, bp.getDefaultMinHeight(), -p.y); bf.addPoint(p.x, bp.getDefaultMaxHeight(), -p.y);
private static BuildingPartOutput buildPart(BuildingPart bp, BuildingModel buildingModel, ModelFactory mf, BuildingElementsTextureManager tm) { BuildingPartOutput partOutput = new BuildingPartOutput(); CatchFaceFactory catchFaceFactory = new CatchFaceFactory(mf); Wall w = bp.getWall(); double maxHeight = bp.getDefaultMaxHeight(); double minHeight = bp.getDefaultMinHeight(); WallPart firstWallPart = getFirstWallPart(w); Color facadeColor = takeFacadeColor(buildingModel, bp, w, firstWallPart, tm); Color roofColor = takeRoofColor(buildingModel, bp, w, firstWallPart, tm); TextureData roofTextureData = takeRoofTextureData(buildingModel, bp, w, tm, roofColor != null); // XXX TextureData facadeTextureData = takeFacadeTextureData(buildingModel, bp, w, firstWallPart, tm, facadeColor != null); RoofOutput roofOutput = buildRoof(bp, mf, maxHeight, facadeColor, roofColor, facadeTextureData, roofTextureData); double wallHeight = maxHeight - roofOutput.getHeight(); buildWall(w, minHeight, wallHeight, bp, buildingModel, mf, catchFaceFactory, tm, roofOutput.getHeightCalculator()); buildFloor(bp, buildingModel, mf, tm, roofTextureData, facadeColor, minHeight); if (bp.getInlineWalls() != null) { for (Wall in : bp.getInlineWalls()) { buildWall(in, minHeight, wallHeight, bp, buildingModel, mf, catchFaceFactory, tm, roofOutput.getHeightCalculator()); } } partOutput.setRoofDebug(roofOutput.getDebug()); partOutput.setEdges(roofOutput.getEdges()); return partOutput; }
w.setRoofMaterialType("roof_tiles"); BuildingPart bp = new BuildingPart(); bp.setWall(w); bp.setMaxHeight(height); bp.setRoof(roof);
RoofModel roofModel = buildingPart.getRoof(); && buildingPart.getRoofLevels() != null) { double roofHeight = buildingPart.getDefaultRoofHeight(); if (buildingPart.getRoofLevels() < 1) { roofHeight = 1d;
@Override public void preview(double value) { // sets height to current building part getBuildingPart().getRoof().setRoofHeight(value); if (getBuildingPart().getRoof() instanceof DormerRoofModel) { DormerRoofModel model = (DormerRoofModel) getBuildingPart().getRoof(); if (model.getRoofType() == null || RoofTypeAliasEnum.FLAT.equals(model.getRoofType())) { changeRoofShape = true; model.setRoofType(RoofTypeAliasEnum.GABLED); } } generatePreview(); };
public double getDefaultMaxHeight() { if (maxHeight != null) { return maxHeight; } if (maxLevel != null) { return maxLevel * levelHeight; } return getDefaultMinHeight() + DEFAULT_BUILDING_HEIGHT; }
@Override public void preview(double value) { // sets height to current building part getBuildingPart().setMaxHeight(value); generatePreview(); };
@Override public void beforeProvide(Point3d point) { point.x = (bounds.getxMax() + bounds.getxMin()) / 2d; point.y = bp.getDefaultMaxHeight(); point.z = -(bounds.getyMax() + bounds.getyMin()) / 2d; } };
private Bbox2d calcBounds(BuildingPart bp) { Bbox2d bbox = new Bbox2d(); List<WallPart> wallParts = bp.getWall().getWallParts(); for (WallPart wp : wallParts) { for (WallNode wn : wp.getNodes()) { Point2d p = wn.getPoint(); bbox.addPoint(p); } } return bbox; }
private static Color takeFloorColor(BuildingModel buildingModel, BuildingPart bp, BuildingElementsTextureManager tm) { Color c = null; if (bp.getFloorColor() != null) { c = bp.getFloorColor(); } else if (buildingModel.getFloorColor() != null) { c = buildingModel.getFloorColor(); } return c; }
public static TextureData takeFloorTextureData(BuildingModel buildingModel, BuildingPart bp, BuildingElementsTextureManager tm, boolean colorable) { String mt = null; if (bp.getFloorMaterialType() != null) { mt = bp.getFloorMaterialType(); } else if (buildingModel.getFloorMaterialType() != null) { mt = buildingModel.getFloorMaterialType(); } TextureData td = tm.findTexture(new TextureFindCriteria(Type.FLOOR, mt, null, null, null, colorable)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }
private static Color takeFacadeColor(BuildingModel buildingModel, BuildingPart bp, Wall w, WallPart wp, BuildingElementsTextureManager tm) { Color c = null; if (wp != null && wp.getFacadeColor() != null) { c = wp.getFacadeColor(); } else if (w.getFacadeColor() != null) { c = w.getFacadeColor(); } else if (bp.getFacadeColor() != null) { c = bp.getFacadeColor(); } else if (buildingModel.getFacadeColor() != null) { c = buildingModel.getFacadeColor(); } return c; }
public static TextureData takeFacadeTextureData(BuildingModel buildingModel, BuildingPart bp, Wall w, WallPart wp, BuildingElementsTextureManager tm, boolean colorable) { String mt = null; if (wp != null && wp.getFacadeMaterialType() != null) { mt = wp.getFacadeMaterialType(); } else if (w.getFacadeMaterialType() != null) { mt = w.getFacadeMaterialType(); } else if (bp.getFacadeMaterialType() != null) { mt = bp.getFacadeMaterialType(); } else if (buildingModel.getFacadeMaterialType() != null) { mt = buildingModel.getFacadeMaterialType(); } TextureData td = tm.findTexture(new TextureFindCriteria(Type.FACADE, mt, null, null, null, colorable)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }
/** * @param bp * @param mf * @param maxHeight * @param facadeColor * @param roofColor * @param facadeTextureData * @param roofTextureData * @return */ private static RoofOutput buildRoof(BuildingPart bp, ModelFactory mf, double maxHeight, Color facadeColor, Color roofColor, TextureData facadeTextureData, TextureData roofTextureData) { RoofTextureData rtd = new RoofTextureData(); // XXX fix, currently roof builder support only one texture, fix before // roof builder is changed. rtd.setFacadeColor(facadeColor); rtd.setFacadeTexture(facadeTextureData); rtd.setRoofColor(roofColor); rtd.setRoofTexture(roofTextureData); RoofOutput roofOutput = null; if (bp.getRoof() instanceof DormerRoofModel) { roofOutput = ShapeRoofBuilder.build(bp, maxHeight, mf, rtd); } else if (bp.getRoof() instanceof RoofLinesModel) { roofOutput = RoofLinesBuildier.build(bp, maxHeight, mf, roofTextureData, roofColor); } else { throw new RuntimeException(); } return roofOutput; }