Пример #1
0
 // Morteza2011*****************************************************************
 public void setExpandedBlock(boolean isNewBlockade) {
   SOSArea area = new SOSArea(getEdges());
   ArrayList<Blockade> b = new ArrayList<Blockade>();
   b.add(this);
   area.setReachablityBlockades(b);
   if (isNewBlockade)
     expandedBlock =
         ExpandBlockade.expandBlock(
             area,
             ReachablityConstants.BLOCK_EXPAND_WIDTH
                 + getPosition().getExtraDistanceForNewExpand());
   else expandedBlock = ExpandBlockade.expandBlock(area, ReachablityConstants.BLOCK_EXPAND_WIDTH);
 }
Пример #2
0
  // Morteza2011*****************************************************************
  public static SOSArea merge(
      StandardEntity a, SOSArea blockade1, SOSArea blockade2, short mergedNumber) {

    ArrayList<Edge> edgeList1 = new ArrayList<Edge>(blockade1.getEdges());
    ArrayList<Edge> edgeList2 = new ArrayList<Edge>(blockade2.getEdges());
    Pair<ArrayList<Edge>, ArrayList<Edge>> newEdges = splitEdges(edgeList1, edgeList2);
    removeExtraEdges(newEdges.first(), blockade2.getShape());
    removeExtraEdges(newEdges.second(), blockade1.getShape());
    try {
      ArrayList<SOSArea> sortedEdges = sortEdges(a, newEdges.first(), newEdges.second(), false);
      SOSArea finalMergedArea;
      if (sortedEdges.size() > 1) finalMergedArea = removeHoles(sortedEdges);
      else if (sortedEdges.size() == 1) finalMergedArea = sortedEdges.get(0);
      else {
        return reMerge(blockade1, blockade2);
      }
      finalMergedArea.setEdges(verifyEdgesAfterMerge(finalMergedArea.getEdges()));
      finalMergedArea.setReachablityBlockades(blockade1.getReachablityBlockades());
      finalMergedArea.addReachablityBlockades(blockade2.getReachablityBlockades());
      return finalMergedArea;
    } catch (ReachablityException e) {
    }
    return reMerge(blockade1, blockade2);
  }