Example #1
0
        public void triangulate(FaceList newFaces, double minArea)
        {
            HalfEdge hedge;

            if (numVertices() < 4)
            {
                return;
            }

            Vertex v0       = he0.head();
            Face   prevFace = null;

            hedge = he0.next;
            HalfEdge oppPrev = hedge.opposite;
            Face     face0   = null;

            for (hedge = hedge.next; hedge != he0.prev; hedge = hedge.next)
            {
                Face face =
                    createTriangle(v0, hedge.prev.head(), hedge.head(), minArea);
                face.he0.next.setOpposite(oppPrev);
                face.he0.prev.setOpposite(hedge.opposite);
                oppPrev = face.he0;
                newFaces.add(face);
                if (face0 == null)
                {
                    face0 = face;
                }
            }
            hedge = new HalfEdge(he0.prev.prev.head(), this);
            hedge.setOpposite(oppPrev);

            hedge.prev      = he0;
            hedge.prev.next = hedge;

            hedge.next      = he0.prev;
            hedge.next.prev = hedge;

            computeNormalAndCentroid(minArea);
            checkConsistency();

            for (Face face = face0; face != null; face = face.next)
            {
                face.checkConsistency();
            }
        }
Example #2
0
 protected void setHull(double[] coords, int nump, int[][] faceIndices, int numf)
 {
     initBuffers(nump);
     setPoints(coords, nump);
     computeMaxAndMin();
     for (int i = 0; i < numf; i++)
     {
         Face     face = Face.create(pointBuffer, faceIndices[i]);
         HalfEdge he   = face.he0;
         do
         {
             HalfEdge heOpp = findHalfEdge(he.head(), he.tail());
             if (heOpp != null)
             {
                 he.setOpposite(heOpp);
             }
             he = he.next;
         }while (he != face.he0);
         faces.Add(face);
     }
 }