Exemplo n.º 1
0
        private static void ComputeVertexCuttingTop(Cutting cutting, ref List<Vertex> listVertex, ref List<int> listVertexIndex)
        {
            if (cutting.Cuttings.Count == 0 && !cutting.IsEmpty)
            {

                float d = 40f;
                float height = 0f;
                if (cutting.ParentFolding != null)
                    height = cutting.ParentFolding.Height / d;

                float deep = 0f;

                if (cutting.ParentFolding != null)
                    deep = -cutting.ParentFolding.RecFaceWithoutDelta.Top / d + height;

                //--- 1
                Vertex vertex = new Vertex();

                vertex.X = cutting.Rectangle.Right / d;
                vertex.Z = deep;
                vertex.Y = -cutting.Rectangle.Top / d - deep;

                int index = AddVertexToList(ref listVertex, vertex);

                listVertexIndex.Add(index);
                //---

                //--- 2
                vertex = new Vertex();

                vertex.X = cutting.Rectangle.Left / d;
                vertex.Z = deep;
                vertex.Y = -cutting.Rectangle.Top / d - deep;

                index = AddVertexToList(ref listVertex, vertex);

                listVertexIndex.Add(index);
                //---

                //--- 3
                vertex = new Vertex();

                vertex.X = cutting.Rectangle.Left / d;
                vertex.Z = deep;
                vertex.Y = -cutting.Rectangle.Bottom / d - deep;

                index = AddVertexToList(ref listVertex, vertex);

                listVertexIndex.Add(index);
                //---

                //--- 4
                vertex = new Vertex();

                vertex.X = cutting.Rectangle.Right / d;
                vertex.Z = deep;
                vertex.Y = -cutting.Rectangle.Bottom / d - deep;

                index = AddVertexToList(ref listVertex, vertex);

                listVertexIndex.Add(index);
                //---
            }
            else
            {
                foreach (Cutting cuttingChild in cutting.Cuttings)
                {
                    ComputeVertexCuttingTop(cuttingChild, ref listVertex, ref listVertexIndex);
                }
            }
        }
Exemplo n.º 2
0
        private static int AddVertexToList(ref List<Vertex> listVertex, Vertex vertex)
        {
            int index = listVertex.FindIndex(v => v.X == vertex.X && v.Y == vertex.Y && v.Z == vertex.Z);

            if (index == -1)
            {
                listVertex.Add(vertex);
                index = listVertex.Count - 1;
            }

            return index;
        }