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();
}
}
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);
}
}
}
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);
}
}
}
}
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));
}
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);
}
}
Aggregations