Ejemplo n.º 1
0
        public GeoSegment3 Pop()
        {
            GeoSegment3 first = mEdgeStack[0];

            mEdgeStack.RemoveAt(0);
            return(first);
        }
Ejemplo n.º 2
0
        public void Push(GeoSegment3 edge)
        {
            int index = mEdgeStack.FindIndex(delegate(GeoSegment3 p) { return(p.Equal(edge)); });

            if (index == -1)
            {
                mEdgeStack.Add(edge);
            }
            else
            {
                mEdgeStack.RemoveAt(index);
            }
        }
Ejemplo n.º 3
0
        private void Build()
        {
            Vector3 min;
            Vector3 max;
            Vector3 fathestPoint;

            FindOnce(out min, out max, out fathestPoint);
            // make two sides faces
            QHullTrianglePlanePoints facePositive = new QHullTrianglePlanePoints(min, max, fathestPoint);
            QHullTrianglePlanePoints faceNegative = new QHullTrianglePlanePoints(min, fathestPoint, max);

            // split all Points into two sides faces
            SaveOnce(facePositive, faceNegative);
            // save the face
            mTrianglePlanePoints.Add(facePositive);
            mTrianglePlanePoints.Add(faceNegative);
            // travel
            int step = 0;

            while (step < mTrianglePlanePoints.Count)
            {
                QHullTrianglePlanePoints trianglePlanePointsLoop1 = mTrianglePlanePoints[step++];
                if (trianglePlanePointsLoop1.mIsDelete || trianglePlanePointsLoop1.IsEmpty())
                {
                    continue;
                }
                fathestPoint = trianglePlanePointsLoop1.mFathestPoint;
                int size = mTrianglePlanePoints.Count;
                QHullEdgeBounding edgeStack      = new QHullEdgeBounding();
                List <Vector3>    tempPointsList = new List <Vector3>();
                for (int i = 0; i < size; ++i)
                {
                    QHullTrianglePlanePoints trianglePlanePointsLoop2 = mTrianglePlanePoints[i];
                    if (!trianglePlanePointsLoop2.mIsDelete && trianglePlanePointsLoop2.Inside(fathestPoint))
                    {
                        trianglePlanePointsLoop2.mIsDelete = true;
                        // save the face edges
                        Vector3[] planePoints = trianglePlanePointsLoop2.mTrianglePlane.mVertexPoints;
                        edgeStack.Push(planePoints[0], planePoints[1]);
                        edgeStack.Push(planePoints[1], planePoints[2]);
                        edgeStack.Push(planePoints[2], planePoints[0]);
                        // save the face retaining points
                        if (!trianglePlanePointsLoop2.IsEmpty())
                        {
                            int tempSize = trianglePlanePointsLoop2.mPointsList.Count;
                            for (int j = 0; j < tempSize; ++j)
                            {
                                tempPointsList.Add(trianglePlanePointsLoop2.mPointsList[j]);
                            }
                            trianglePlanePointsLoop2.mPointsList.Clear();
                        }
                    }
                }
                while (!edgeStack.IsEmpty())
                {
                    GeoSegment3 edge = edgeStack.Pop();
                    QHullTrianglePlanePoints newTrianglePlanePs = new QHullTrianglePlanePoints(edge.mP1, edge.mP2, fathestPoint);
                    List <Vector3>           tempPointsList2    = new List <Vector3>();
                    for (int k = 0; k < tempPointsList.Count; ++k)
                    {
                        Vector3 point = tempPointsList[k];
                        if (!newTrianglePlanePs.AddPoint(point))
                        {
                            tempPointsList2.Add(point);
                        }
                    }
                    // add the new trianglePlane
                    mTrianglePlanePoints.Add(newTrianglePlanePs);
                    // reset, save points
                    tempPointsList = tempPointsList2;
                }
                // clear the points
                tempPointsList.Clear();
            }
        }
Ejemplo n.º 4
0
 public bool Equal(GeoSegment3 other)
 {
     return((mP1 == other.mP1 && mP2 == other.mP2) || (mP1 == other.mP2 && mP2 == other.mP1));
 }