Ejemplo n.º 1
0
  /**
   * splits the facet incident to h and g into two facets with a new diagonal between the two
   * vertices denoted by h and g respectively. The second (new) facet is a copy of the first facet.
   * Returns h->next() after the operation, i.e., the new diagonal. The new face is to the right of
   * the new diagonal, the old face is to the left. The time is proportional to the distance from h
   * to g around the facet.
   */
  public Halfedge splitFacet(Halfedge h, Halfedge g) {
    if (h == null || g == null) throw new Error("splitFacet: null pointer");
    if (h.face != g.face) throw new Error("splitFacet: different incident facets");
    if (h == g || h.next == g || g.next == h) {
      throw new Error("loops and multiple edges are not allowed");
    }

    Halfedge<X> newDiagonal = new Halfedge<X>();
    Halfedge<X> oppositeNewDiagonal = new Halfedge<X>();
    Face<X> newFace = new Face<X>();

    newFace.halfedge = g;
    newDiagonal.opposite = oppositeNewDiagonal;
    oppositeNewDiagonal.opposite = newDiagonal;
    newDiagonal.face = h.face;
    oppositeNewDiagonal.face = newFace;

    // a completer

    Halfedge p = h.next;
    while (p != g) {
      p.face = newFace;
      p = p.next;
    }

    h.next = newDiagonal;
    g.next = oppositeNewDiagonal;
    return newDiagonal;
  }
Ejemplo n.º 2
0
  public Halfedge<X> makeHole(Halfedge h) {
    if (h == null || h.face == null) throw new Error("error making hole: h or h.face null");
    this.facets.remove(h.getFace());

    Halfedge p = h.next;
    h.face = null;
    int cont = 1;
    while (p != h) {
      p.face = null;
      p = p.next;
    }
    return h;
  }
Ejemplo n.º 3
0
  public Halfedge<X> fillHole(Halfedge h) {
    if (h.face != null) throw new Error("error filling hole: h not boundary edge");

    Face<X> newFace = new Face<X>();
    this.facets.add(newFace);
    newFace.setEdge(h);

    Halfedge p = h.next;
    h.face = newFace;
    int cont = 1;
    while (p != h) {
      p.face = newFace;
      p = p.next;
    }
    return h;
  }