Пример #1
0
  /**
   * Inserted edges are checked to see if an identical edge already exists. If so, the edge is not
   * inserted, but its label is merged with the existing edge.
   */
  protected void insertUniqueEdge(Edge e) {
    // <FIX> MD 8 Oct 03  speed up identical edge lookup
    // fast lookup
    Edge existingEdge = edgeList.findEqualEdge(e);

    // If an identical edge already exists, simply update its label
    if (existingEdge != null) {
      Label existingLabel = existingEdge.getLabel();

      Label labelToMerge = e.getLabel();
      // check if new edge is in reverse direction to existing edge
      // if so, must flip the label before merging it
      if (!existingEdge.isPointwiseEqual(e)) {
        labelToMerge = new Label(e.getLabel());
        labelToMerge.flip();
      }
      existingLabel.merge(labelToMerge);

      // compute new depth delta of sum of edges
      int mergeDelta = depthDelta(labelToMerge);
      int existingDelta = existingEdge.getDepthDelta();
      int newDelta = existingDelta + mergeDelta;
      existingEdge.setDepthDelta(newDelta);
    } else { // no matching existing edge was found
      // add this new edge to the list of edges in this graph
      // e.setName(name + edges.size());
      edgeList.add(e);
      e.setDepthDelta(depthDelta(e.getLabel()));
    }
  }
Пример #2
0
 /** Compute the change in depth as an edge is crossed from R to L */
 private static int depthDelta(Label label) {
   int lLoc = label.getLocation(0, Position.LEFT);
   int rLoc = label.getLocation(0, Position.RIGHT);
   if (lLoc == Location.INTERIOR && rLoc == Location.EXTERIOR) return 1;
   else if (lLoc == Location.EXTERIOR && rLoc == Location.INTERIOR) return -1;
   return 0;
 }
Пример #3
0
 /**
  * The location for a given eltIndex for a node will be one of { null, INTERIOR, BOUNDARY }. A
  * node may be on both the boundary and the interior of a geometry; in this case, the rule is that
  * the node is considered to be in the boundary. The merged location is the maximum of the two
  * input values.
  */
 int computeMergedLocation(Label label2, int eltIndex) {
   int loc = Location.NONE;
   loc = label.getLocation(eltIndex);
   if (!label2.isNull(eltIndex)) {
     int nLoc = label2.getLocation(eltIndex);
     if (loc != Location.BOUNDARY) loc = nLoc;
   }
   return loc;
 }