* Sets source and target too.
* @param f face to split
* @return new faces array generated
*/
public Face[] faceTravel(Face f) {
Face resLeft = new Face(f.getGraph());
Face resRight = new Face(f.getGraph());
GraphHelper.instanceCopy(f, resRight);
int route = f.getVertices()
.size() / 2;
SimpleVertex prev = null;
SimpleVertex curr = (SimpleVertex) f.getVertices()
.get(0);
gd.setSource(curr);
resLeft.addVertex(curr);
while (route > 0) {
ListIterator li = curr.getEdges()
.listIterator();
while (li.hasNext()) {
SimpleEdge element = (SimpleEdge) li.next();
if ((f.getEdges()
.indexOf(element) != -1) && (element.getAnother(curr) != prev)) {
prev = curr;
curr = element.getAnother(curr);
resLeft.addVertex(curr);
resLeft.addEdge(element);
route--;
break;
}
}
}
gd.setTarget(curr);
resRight.removeVertices(resLeft.getVertices());
resRight.removeEdges(resLeft.getEdges());
resRight.addVertex(gd.getSource());
resRight.addVertex(gd.getTarget());
return new Face[] { resLeft, resRight };
}