@Override protected void processEdge(Edge edge, Node source) { if (MapSequence.fromMap(getDfsState()).get(edge.getOpposite(source)) == Dfs.BEFORE) { myOuterFace.addLast(new Dart(edge, source)); } else { SetSequence.fromSet(myBackEdges).addElement(edge); } }
private void restoreEdge(EmbeddedGraph embeddedGraph, Edge removedEdge) { MapSequence.fromMap(mySplittedEdges) .put(removedEdge, ListSequence.fromList(new ArrayList<Edge>())); Graph graph = embeddedGraph.getGraph(); DualGraph dualGraph = new DualGraph(embeddedGraph); List<Node> newNodes = ListSequence.fromList(new ArrayList<Node>()); for (Node node : ListSequence.fromList(removedEdge.getAdjacentNodes())) { Node newNode = dualGraph.createDummyNode(); for (Edge nodeEdge : ListSequence.fromList(node.getEdges(Edge.Direction.BOTH))) { for (Face face : ListSequence.fromList(embeddedGraph.getAdjacentFaces(nodeEdge))) { dualGraph.connect(newNode, MapSequence.fromMap(dualGraph.getNodesMap()).get(face)); } } ListSequence.fromList(newNodes).addElement(newNode); } List<Edge> path = ShortestPath.getPath( dualGraph, ListSequence.fromList(newNodes).getElement(0), ListSequence.fromList(newNodes).getElement(1), Edge.Direction.BOTH); List<Node> nodePath = ListSequence.fromList(new ArrayList<Node>()); List<Face> facePath = ListSequence.fromList(new ArrayList<Face>()); ListSequence.fromList(nodePath) .addElement(ListSequence.fromList(removedEdge.getAdjacentNodes()).getElement(0)); Node cur = ListSequence.fromList(newNodes).getElement(0); for (Edge edge : ListSequence.fromList(path)) { Edge realEdge = MapSequence.fromMap(dualGraph.getEdgesMap()).get(edge); if (embeddedGraph.getAdjacentFaces(realEdge) != null) { ListSequence.fromList(nodePath) .addElement( split(embeddedGraph, MapSequence.fromMap(dualGraph.getEdgesMap()).get(edge))); } cur = edge.getOpposite(cur); Face curFace = MapSequence.fromMap(dualGraph.getFacesMap()).get(cur); if (curFace != null) { ListSequence.fromList(facePath).addElement(curFace); } } ListSequence.fromList(nodePath) .addElement(ListSequence.fromList(removedEdge.getAdjacentNodes()).getElement(1)); for (int i = 0; i < ListSequence.fromList(nodePath).count() - 1; i++) { Edge newEdge = graph.connect( ListSequence.fromList(nodePath).getElement(i), ListSequence.fromList(nodePath).getElement(i + 1)); ListSequence.fromList(MapSequence.fromMap(mySplittedEdges).get(removedEdge)) .addElement(newEdge); splitFace(embeddedGraph, ListSequence.fromList(facePath).getElement(i), newEdge); } }