예제 #1
0
        private bool doAdjacentMerge(Face face, int mergeType)
        {
            HalfEdge hedge = face.he0;

            bool convex = true;

            do
            {
                Face   oppFace = hedge.oppositeFace();
                bool   merge = false;
                double dist1, dist2;

                if (mergeType == NONCONVEX)
                { // then merge faces if they are definitively non-convex
                    if (oppFaceDistance(hedge) > -tolerance ||
                        oppFaceDistance(hedge.opposite) > -tolerance)
                    {
                        merge = true;
                    }
                }
                else // mergeType == NONCONVEX_WRT_LARGER_FACE
                { // merge faces if they are parallel or non-convex
                    // wrt to the larger face; otherwise, just mark
                    // the face non-convex for the second pass.
                    if (face.area > oppFace.area)
                    {
                        if ((dist1 = oppFaceDistance(hedge)) > -tolerance)
                        {
                            merge = true;
                        }
                        else if (oppFaceDistance(hedge.opposite) > -tolerance)
                        {
                            convex = false;
                        }
                    }
                    else
                    {
                        if (oppFaceDistance(hedge.opposite) > -tolerance)
                        {
                            merge = true;
                        }
                        else if (oppFaceDistance(hedge) > -tolerance)
                        {
                            convex = false;
                        }
                    }
                }

                if (merge)
                {
                    if (debug)
                    {
                        Console.WriteLine(
                            "  merging " + face.getVertexString() + "  and  " +
                            oppFace.getVertexString());
                    }

                    int numd = face.mergeAdjacentFace(hedge, discardedFaces);
                    for (int i = 0; i < numd; i++)
                    {
                        deleteFacePoints(discardedFaces[i], face);
                    }
                    if (debug)
                    {
                        Console.WriteLine(
                            "  result: " + face.getVertexString());
                    }
                    return(true);
                }
                hedge = hedge.next;
            }while (hedge != face.he0);
            if (!convex)
            {
                face.mark = Face.NON_CONVEX;
            }
            return(false);
        }
예제 #2
0
 protected double oppFaceDistance(HalfEdge he)
 {
     return(he.face.distanceToPlane(he.opposite.face.getCentroid()));
 }
예제 #3
0
 /**
  * Sets the value of the next edge adjacent
  * (counter-clockwise) to this one within the triangle.
  *
  * @param edge next adjacent edge */
 public void setNext(HalfEdge edge)
 {
     next = edge;
 }
예제 #4
0
 /**
  * Sets the value of the previous edge adjacent (clockwise) to
  * this one within the triangle.
  *
  * @param edge previous adjacent edge */
 public void setPrev(HalfEdge edge)
 {
     prev = edge;
 }
예제 #5
0
 /**
  * Sets the half-edge opposite to this half-edge.
  *
  * @param edge opposite half-edge
  */
 public void setOpposite(HalfEdge edge)
 {
     opposite      = edge;
     edge.opposite = this;
 }