private boolean buildingIsIsolated(Building position) { Graph graph = world.getPlatoonAgent().getPathPlanner().getGraph(); for (Entrance entrance : world.getMrlBuilding(position.getID()).getEntrances()) { if (graph.getNodeBetweenAreas(position.getID(), entrance.getID(), null).isPassable()) { return false; } } return true; }
/** * this method calculates the border entities, using entities and convexHull of the entities * * @param convex is the convex of all Entities * @param entities are the self entities * @param scale is the scale for making smaller convex hull */ public Set<EntityID> getBorderEntities(ConvexHull convex, Set<EntityID> entities, double scale) { if (scale >= 1.0) { System.err.println( "scale should not be over 1.0! check it in border entities, border entities doesn't work now!"); return null; } Building building; Polygon convexObject = convex.convex(); Set<EntityID> borderEntities = new FastSet<EntityID>(); if (convexObject.npoints == 0) { // I don't know why this happens, report me if this error writes usually! TODO check // this if something comes wrong here System.out.println("Something gone wrong in setting border entities for Firebrigade!!!"); return null; } Polygon smallBorderPolygon = scalePolygon(convexObject, scale); // Polygon bigBorderPolygon = scalePolygon(convexObject, 1.1); if (MRLConstants.LAUNCH_VIEWER) { // MrlConvexHullLayer.BIG_Whole_BORDER_HULL = convex; // MrlConvexHullLayer.SMALL_Whole_BORDER_HULL = smallBorderPolygon; } for (EntityID entityID : entities) { StandardEntity entity = world.getEntity(entityID); if (entity instanceof Refuge) continue; if (!(entity instanceof Building)) continue; building = (Building) entity; int vertexes[] = building.getApexList(); for (int i = 0; i < vertexes.length; i += 2) { if ((convexObject.contains(vertexes[i], vertexes[i + 1])) && !(smallBorderPolygon.contains(vertexes[i], vertexes[i + 1]))) { borderEntities.add(building.getID()); break; } } } return borderEntities; }
@Override protected void paintShape(Building b, Polygon shape, Graphics2D g) { if (StaticViewProperties.selectedObject != null) { BURNING_BUILDINGS.clear(); List<MrlBuilding> buildings = null; try { buildings = Collections.synchronizedList( BURNING_BUILDINGS_MAP.get(StaticViewProperties.selectedObject.getID())); } catch (NullPointerException ignored) { } if (buildings != null) { showRealFieriness = true; for (MrlBuilding bb : buildings) { // if (bb.getEstimatedFieryness() > 0 && // b.equals(bb.getSelfBuilding())) { if (bb.getSelfBuilding().isFierynessDefined() && bb.getSelfBuilding().getFieryness() > 0 && b.equals(bb.getSelfBuilding())) { drawBurningBuildings(bb, shape, g); BURNING_BUILDINGS.add(bb.getSelfBuilding().getID()); return; } // else if (bb.isProbablyOnFire() && b.equals(bb.getSelfBuilding())) { // g.setColor(PROB); // g.fill(shape); // return; // } } } else { showRealFieriness = false; } } }
/** this function calculate Cluster Total area */ private void calculateArea() { for (Building building : buildings) { totalArea += building.getTotalArea(); } }