コード例 #1
0
ファイル: QuickHullAlgorithm.cs プロジェクト: vnmone/vvvv-sdk
        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
ファイル: QuickHullAlgorithm.cs プロジェクト: vnmone/vvvv-sdk
 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;
 }