Example #1
0
  /**
   * creates a new triangle facet within the hole incident to h by connecting the tip of h with two
   * new halfedges and a new vertex. Returns the halfedge of the new edge that is incident to the
   * new facet and the new vertex.
   */
  public Halfedge<X> addTriangleToBorder(Halfedge h, X point) {
    if (h.face != null) throw new Error("no border edge");
    System.out.println("adding triangle to " + h);

    Face<X> newFace = new Face<X>();
    Vertex<X> newVertex = new Vertex<X>(point);
    Halfedge<X> hPrev = new Halfedge<X>();
    Halfedge<X> hNext = new Halfedge<X>();
    Halfedge<X> hPrevOpp = new Halfedge<X>();
    Halfedge<X> hNextOpp = new Halfedge<X>();

    // setting the new face
    newFace.setEdge(h);
    // setting hPrev (halfedge preceding h in the new face)
    hPrev.setFace(newFace);
    hPrev.setVertex(h.getOpposite().getVertex());
    hPrev.setPrev(hNext);
    hPrev.setNext(h);
    hPrev.setOpposite(hPrevOpp);
    // setting hNext (halfedge following h in the new face)
    hNext.setFace(newFace);
    hNext.setVertex(newVertex);
    hNext.setPrev(h);
    hNext.setNext(hPrev);
    hNext.setOpposite(hNextOpp);
    // setting hPrevOpp (new boundary halfedge)
    hPrevOpp.setFace(null);
    hPrevOpp.setVertex(newVertex);
    hPrevOpp.setPrev(h.getPrev());
    hPrevOpp.setNext(hNextOpp);
    hPrevOpp.setOpposite(hPrev);
    // setting hNextOpp (the other new boundary halfedge)
    hNextOpp.setFace(null);
    hNextOpp.setVertex(h.getVertex());
    hNextOpp.setPrev(hPrevOpp);
    hNextOpp.setNext(h.getNext());
    hNextOpp.setOpposite(hNext);
    // updating old boundary halfedge informations
    h.setFace(newFace);
    h.setPrev(hPrev);
    h.setNext(hNext);
    // setting newVertex
    newVertex.setEdge(hPrev); // LCA: a controler si c'est hPrev ou hNext

    // adding new facet, vertex and the four halfedges
    this.vertices.add(newVertex);
    this.facets.add(newFace);
    this.halfedges.add(hPrev);
    this.halfedges.add(hNext);
    this.halfedges.add(hPrevOpp);
    this.halfedges.add(hNextOpp);

    return hNext;
  }
Example #2
0
  /**
   * a triangle with border edges is added to the polyhedral surface. Returns a non-border halfedge
   * of the triangle.
   */
  public Halfedge<X> makeTriangle(X p1, X p2, X p3) {
    Face<X> newFace = new Face<X>();
    Vertex<X> newVertex1 = new Vertex<X>(p1);
    Vertex<X> newVertex2 = new Vertex<X>(p2);
    Vertex<X> newVertex3 = new Vertex<X>(p3);
    Halfedge<X> e1 = new Halfedge<X>();
    Halfedge<X> e2 = new Halfedge<X>();
    Halfedge<X> e3 = new Halfedge<X>();
    Halfedge<X> e1Opp = new Halfedge<X>();
    Halfedge<X> e2Opp = new Halfedge<X>();
    Halfedge<X> e3Opp = new Halfedge<X>();

    // setting the new face
    newFace.setEdge(e1);
    // setting the new vertices (LCA: a' controler)
    newVertex1.setEdge(e2);
    newVertex2.setEdge(e3);
    newVertex3.setEdge(e1);
    // setting e1
    e1.setFace(newFace);
    e1.setVertex(newVertex1);
    e1.setPrev(e3);
    e1.setNext(e2);
    e1.setOpposite(e1Opp);
    // setting e2
    e2.setFace(newFace);
    e2.setVertex(newVertex2);
    e2.setPrev(e1);
    e2.setNext(e3);
    e2.setOpposite(e2Opp);
    // setting e3
    e3.setFace(newFace);
    e3.setVertex(newVertex3);
    e3.setPrev(e2);
    e3.setNext(e1);
    e3.setOpposite(e3Opp);
    // setting e1Opp (boundary halfedge opposite to e1)
    e1Opp.setFace(null);
    e1Opp.setVertex(newVertex3);
    e1Opp.setPrev(e2Opp);
    e1Opp.setNext(e3Opp);
    e1Opp.setOpposite(e1);
    // setting e2Opp (boundary halfedge opposite to e2)
    e2Opp.setFace(null);
    e2Opp.setVertex(newVertex1);
    e2Opp.setPrev(e3Opp);
    e2Opp.setNext(e1Opp);
    e2Opp.setOpposite(e2);
    // setting e3Opp (boundary halfedge opposite to e3)
    e3Opp.setFace(null);
    e3Opp.setVertex(newVertex2);
    e3Opp.setPrev(e1Opp);
    e3Opp.setNext(e2Opp);
    e3Opp.setOpposite(e3);

    this.facets.add(newFace);
    this.vertices.add(newVertex1);
    this.vertices.add(newVertex2);
    this.vertices.add(newVertex3);
    this.halfedges.add(e1);
    this.halfedges.add(e1Opp);
    this.halfedges.add(e2);
    this.halfedges.add(e2Opp);
    this.halfedges.add(e3);
    this.halfedges.add(e3Opp);

    return e1;
  }