Package ch.ethz.inf.se.soj.examples.delaunayrefinement.graph

Examples of ch.ethz.inf.se.soj.examples.delaunayrefinement.graph.Node


 
  @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);
    }
  }
View Full Code Here


    readElements(basename, tuples);
    readPoly(basename, tuples);
  }

  protected Node<Element, Element.Edge> addElement(Element element) {
    Node<Element, Element.Edge> node = new Node(element);
    add (node);
    for (int i = 0; i < element.numEdges(); i++) {
      Element.Edge edge = element.getEdge(i);
      if (!edgeMap.containsKey(edge)) {
        edgeMap.put(edge, node);
      } else {
        node.getLock().lock();
        Node<Element, Element.Edge> other = edgeMap.get(edge);
        other.getLock().lock();
        try {
          node.addEdge(other, edge);
        } finally {
          node.getLock().unlock();
          other.getLock().unlock();
        }
        edgeMap.remove(edge);
      }
    }
View Full Code Here

TOP

Related Classes of ch.ethz.inf.se.soj.examples.delaunayrefinement.graph.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.