Exemplo n.º 1
0
 internal void DepositDeferredSimplex(DeferredSimplex <VERTEX> face)
 {
     face.Face    = null;
     face.Pivot   = null;
     face.OldFace = null;
     DeferredSimplexStack.Push(face);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new deferred face.
        /// </summary>
        private DeferredSimplex <VERTEX> MakeDeferredFace(SimplexWrap <VERTEX> face, int faceIndex, SimplexWrap <VERTEX> pivot, int pivotIndex, SimplexWrap <VERTEX> oldFace)
        {
            DeferredSimplex <VERTEX> ret = Buffer.ObjectManager.GetDeferredSimplex();

            ret.Face       = face;
            ret.FaceIndex  = faceIndex;
            ret.Pivot      = pivot;
            ret.PivotIndex = pivotIndex;
            ret.OldFace    = oldFace;
            return(ret);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Commits a cone and adds a vertex to the convex hull.
        /// </summary>
        private void CommitCone()
        {
            // Add the current vertex.
            Vertices.Add(Buffer.CurrentVertex);

            // Fill the adjacency.
            for (int i = 0; i < Buffer.ConeFaceBuffer.Count; i++)
            {
                DeferredSimplex <VERTEX> face         = Buffer.ConeFaceBuffer[i];
                SimplexWrap <VERTEX>     newFace      = face.Face;
                SimplexWrap <VERTEX>     adjacentFace = face.Pivot;
                SimplexWrap <VERTEX>     oldFace      = face.OldFace;
                int orderedPivotIndex = face.FaceIndex;
                newFace.AdjacentFaces[orderedPivotIndex]    = adjacentFace;
                adjacentFace.AdjacentFaces[face.PivotIndex] = newFace;

                // let there be a connection.
                for (int j = 0; j < Dimension; j++)
                {
                    if (j == orderedPivotIndex)
                    {
                        continue;
                    }

                    SimplexConnector <VERTEX> connector = Buffer.ObjectManager.GetConnector();
                    connector.Update(newFace, j, Dimension);
                    ConnectFace(connector);
                }

                // This could slightly help...
                if (adjacentFace.VerticesBeyond.Count < oldFace.VerticesBeyond.Count)
                {
                    FindBeyondVertices(newFace, adjacentFace.VerticesBeyond, oldFace.VerticesBeyond);
                }

                else
                {
                    FindBeyondVertices(newFace, oldFace.VerticesBeyond, adjacentFace.VerticesBeyond);
                }

                // This face will definitely lie on the hull
                if (newFace.VerticesBeyond.Count == 0)
                {
                    Buffer.ConvexSimplexs.Add(newFace);
                    Buffer.UnprocessedFaces.Remove(newFace);
                    Buffer.ObjectManager.DepositVertexBuffer(newFace.VerticesBeyond);
                    newFace.VerticesBeyond = Buffer.EmptyBuffer;
                }

                else // Add the face to the list
                {
                    Buffer.UnprocessedFaces.Add(newFace);
                }

                // recycle the object.
                Buffer.ObjectManager.DepositDeferredSimplex(face);
            }

            // Recycle the affected faces.
            for (int fIndex = 0; fIndex < Buffer.AffectedFaceBuffer.Count; fIndex++)
            {
                var face = Buffer.AffectedFaceBuffer[fIndex];
                Buffer.UnprocessedFaces.Remove(face);
                Buffer.ObjectManager.DepositFace(face);
            }
        }