Esempio n. 1
0
  public void findEdge(List dirEdgeList) {
    /**
     * Check all forward DirectedEdges only. This is still general, because each edge has a forward
     * DirectedEdge.
     */
    for (Iterator i = dirEdgeList.iterator(); i.hasNext(); ) {
      DirectedEdge de = (DirectedEdge) i.next();
      if (!de.isForward()) continue;
      checkForRightmostCoordinate(de);
    }

    /**
     * If the rightmost point is a node, we need to identify which of the incident edges is
     * rightmost.
     */
    Assert.isTrue(
        minIndex != 0 || minCoord.equals(minDe.getCoordinate()),
        "inconsistency in rightmost processing");
    if (minIndex == 0) {
      findRightmostEdgeAtNode();
    } else {
      findRightmostEdgeAtVertex();
    }
    /** now check that the extreme side is the R side. If not, use the sym instead. */
    orientedDe = minDe;
    int rightmostSide = getRightmostSide(minDe, minIndex);
    if (rightmostSide == Position.LEFT) {
      orientedDe = minDe.getSym();
    }
  }
Esempio n. 2
0
 private void findRightmostEdgeAtVertex() {
   /**
    * The rightmost point is an interior vertex, so it has a segment on either side of it. If these
    * segments are both above or below the rightmost point, we need to determine their relative
    * orientation to decide which is rightmost.
    */
   Coordinate[] pts = minDe.getEdge().getCoordinates();
   Assert.isTrue(
       minIndex > 0 && minIndex < pts.length,
       "rightmost point expected to be interior vertex of edge");
   Coordinate pPrev = pts[minIndex - 1];
   Coordinate pNext = pts[minIndex + 1];
   int orientation = CGAlgorithms.computeOrientation(minCoord, pNext, pPrev);
   boolean usePrev = false;
   // both segments are below min point
   if (pPrev.y < minCoord.y
       && pNext.y < minCoord.y
       && orientation == CGAlgorithms.COUNTERCLOCKWISE) {
     usePrev = true;
   } else if (pPrev.y > minCoord.y
       && pNext.y > minCoord.y
       && orientation == CGAlgorithms.CLOCKWISE) {
     usePrev = true;
   }
   // if both segments are on the same side, do nothing - either is safe
   // to select as a rightmost segment
   if (usePrev) {
     minIndex = minIndex - 1;
   }
 }