Search in sources :

Example 16 with DirectedEdge

use of com.revolsys.geometry.geomgraph.DirectedEdge in project com.revolsys.open by revolsys.

the class RightmostEdgeFinder method findEdge.

public void findEdge(final List<DirectedEdge> dirEdgeList) {
    /**
     * Check all forward DirectedEdges only.  This is still general,
     * because each edge has a forward DirectedEdge.
     */
    for (final DirectedEdge de : dirEdgeList) {
        if (de.isForward()) {
            checkForRightmostCoordinate(de);
        }
    }
    /**
     * If the rightmost point is a node, we need to identify which of
     * the incident edges is rightmost.
     */
    Assert.isTrue(this.minIndex != 0 || this.minCoord.equalsVertex(this.minDe.getX1(), this.minDe.getY1()), "inconsistency in rightmost processing");
    if (this.minIndex == 0) {
        findRightmostEdgeAtNode();
    } else {
        findRightmostEdgeAtVertex();
    }
    /**
     * now check that the extreme side is the R side.
     * If not, use the sym instead.
     */
    this.orientedDe = this.minDe;
    final int rightmostSide = getRightmostSide(this.minDe, this.minIndex);
    if (rightmostSide == Position.LEFT) {
        this.orientedDe = this.minDe.getSym();
    }
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Point(com.revolsys.geometry.model.Point)

Example 17 with DirectedEdge

use of com.revolsys.geometry.geomgraph.DirectedEdge in project com.revolsys.open by revolsys.

the class OverlayOp method cancelDuplicateResultEdges.

/**
 * If both a dirEdge and its sym are marked as being in the result, cancel
 * them out.
 */
private void cancelDuplicateResultEdges() {
    // (they "cancel each other out")
    for (final DirectedEdge de : this.graph.getEdgeEnds()) {
        final DirectedEdge sym = de.getSym();
        if (de.isInResult() && sym.isInResult()) {
            de.setInResult(false);
            sym.setInResult(false);
        }
    }
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge)

Example 18 with DirectedEdge

use of com.revolsys.geometry.geomgraph.DirectedEdge in project com.revolsys.open by revolsys.

the class BufferSubgraph method computeDepths.

/**
 * Compute depths for all dirEdges via breadth-first traversal of nodes in graph
 * @param startEdge edge to start processing with
 */
// <FIX> MD - use iteration & queue rather than recursion, for speed and
// robustness
private void computeDepths(final DirectedEdge startEdge) {
    final Set<Node> nodesVisited = new HashSet<>();
    final LinkedList<Node> nodeQueue = new LinkedList<>();
    final Node startNode = startEdge.getNode();
    nodeQueue.addLast(startNode);
    nodesVisited.add(startNode);
    startEdge.setVisited(true);
    while (!nodeQueue.isEmpty()) {
        // System.out.println(nodes.size() + " queue: " + nodeQueue.size());
        final Node n = nodeQueue.removeFirst();
        nodesVisited.add(n);
        // compute depths around node, starting at this edge since it has depths
        // assigned
        computeNodeDepth(n);
        // unless the node has been visited already
        for (final Object element : (DirectedEdgeStar) n.getEdges()) {
            final DirectedEdge de = (DirectedEdge) element;
            final DirectedEdge sym = de.getSym();
            if (sym.isVisited()) {
                continue;
            }
            final Node adjNode = sym.getNode();
            if (!nodesVisited.contains(adjNode)) {
                nodeQueue.addLast(adjNode);
                nodesVisited.add(adjNode);
            }
        }
    }
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) DirectedEdgeStar(com.revolsys.geometry.geomgraph.DirectedEdgeStar) Node(com.revolsys.geometry.geomgraph.Node) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 19 with DirectedEdge

use of com.revolsys.geometry.geomgraph.DirectedEdge in project com.revolsys.open by revolsys.

the class BufferSubgraph method copySymDepths.

private void copySymDepths(final DirectedEdge de) {
    final DirectedEdge sym = de.getSym();
    sym.setDepth(Position.LEFT, de.getDepth(Position.RIGHT));
    sym.setDepth(Position.RIGHT, de.getDepth(Position.LEFT));
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge)

Example 20 with DirectedEdge

use of com.revolsys.geometry.geomgraph.DirectedEdge in project com.revolsys.open by revolsys.

the class BufferSubgraph method computeNodeDepth.

private void computeNodeDepth(final Node n) {
    // find a visited dirEdge to start at
    DirectedEdge startEdge = null;
    for (final Object element : (DirectedEdgeStar) n.getEdges()) {
        final DirectedEdge de = (DirectedEdge) element;
        if (de.isVisited() || de.getSym().isVisited()) {
            startEdge = de;
            break;
        }
    }
    // only compute string append if assertion would fail
    if (startEdge == null) {
        throw new TopologyException("unable to find edge to compute depths at POINT(" + n.getX() + " " + n.getY() + ")");
    }
    ((DirectedEdgeStar) n.getEdges()).computeDepths(startEdge);
    // copy depths to sym edges
    for (final Object element : (DirectedEdgeStar) n.getEdges()) {
        final DirectedEdge de = (DirectedEdge) element;
        de.setVisited(true);
        copySymDepths(de);
    }
}
Also used : DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) DirectedEdgeStar(com.revolsys.geometry.geomgraph.DirectedEdgeStar) TopologyException(com.revolsys.geometry.model.TopologyException)

Aggregations

DirectedEdge (com.revolsys.geometry.geomgraph.DirectedEdge)23 Point (com.revolsys.geometry.model.Point)8 Edge (com.revolsys.geometry.geomgraph.Edge)7 ArrayList (java.util.ArrayList)6 DirectedEdgeStar (com.revolsys.geometry.geomgraph.DirectedEdgeStar)5 Node (com.revolsys.geometry.geomgraph.Node)5 List (java.util.List)3 Label (com.revolsys.geometry.geomgraph.Label)2 TopologyException (com.revolsys.geometry.model.TopologyException)2 MaximalEdgeRing (com.revolsys.geometry.operation.overlay.MaximalEdgeRing)2 EdgeRing (com.revolsys.geometry.geomgraph.EdgeRing)1 LineString (com.revolsys.geometry.model.LineString)1 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)1 LineSegment (com.revolsys.geometry.model.segment.LineSegment)1 LineSegmentDouble (com.revolsys.geometry.model.segment.LineSegmentDouble)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1