@SuppressWarnings("unchecked")
public void update() {
if (centerElement.getDim() == 2) { // we built around a segment
Element ele1 = new Element(center, centerElement.getPoint(0));
Node<Element, Element.Edge> node1 = new Node(ele1);
post.add(node1);
lock(node1);
Element ele2 = new Element(center, centerElement.getPoint(1));
Node<Element, Element.Edge> node2 = new Node(ele2);
post.add(node2);
lock(node2);
}
for (Edge<Element.Edge> conn : connections) {
Element.Edge edge = conn.getData();
Element newElement = new Element(center, edge.getPoint(0), edge.getPoint(1));
Node<Element, Element.Edge> newNode = new Node(newElement);
lock(newNode);
Node<Element, Element.Edge> newConnection;
if (pre.contains(conn.getNode1())) {
newConnection = conn.getNode2();
} else {
newConnection = conn.getNode1();
}
Element.Edge newEdge = newElement.getRelatedEdge(newConnection.getData());
newNode.addEdge(newConnection, newEdge);
for (Node<Element, Element.Edge> node : post) {
Element element = node.getData();
if (element.isRelated(newElement)) {
Element.Edge elementEdge = newElement.getRelatedEdge(element);
newNode.addEdge(node, elementEdge);
}
}
post.add(newNode);
}
}