コード例 #1
0
ファイル: Graphics3D.cs プロジェクト: ed152/StackBuilder
 public void AddBox(BoxGeneric box)
 {
     if (!box.IsValid)
     {
         throw new GraphicsException("Box is invalid and cannot be drawn!");
     }
     Boxes.Add(box);
 }
コード例 #2
0
ファイル: BoxelOrderer.cs プロジェクト: ed152/StackBuilder
        private void SortLayer(ref List <BoxGeneric> layerList)
        {
            foreach (var b in layerList)
            {
                b.ApplyElong(-TuneParam);
            }

            // build y list
            List <double> yList = new List <double>();

            foreach (BoxGeneric b in layerList)
            {
                if (!yList.Contains(b.PtMin.Y))
                {
                    yList.Add(b.PtMin.Y);
                }
                if (!yList.Contains(b.PtMax.Y))
                {
                    yList.Add(b.PtMax.Y);
                }
            }
            yList.Sort();
            if (Direction.Y < 0)
            {
                yList.Reverse();
            }

            List <BoxGeneric> treeList = new List <BoxGeneric>();
            List <BoxGeneric> resList  = new List <BoxGeneric>();

            // sweep stage
            foreach (double y in yList)
            {
                // clean treelist
                if (Direction.Y > 0.0)
                {
                    CleanByYMax(treeList, y);
                    // add new
                    List <BoxGeneric> listYMin = GetByYMin(layerList, y);

                    foreach (var by in listYMin)
                    {
                        treeList.Add(by);
                        if (Direction.X > 0.0)
                        {
                            treeList.Sort(new BoxComparerXMin(Direction));
                        }
                        else
                        {
                            treeList.Sort(new BoxComparerXMax(Direction));
                        }

                        // find successor of by
                        int id = treeList.FindIndex(delegate(BoxGeneric b) { return(b.PickId == by.PickId); });
                        BoxGeneric successor = null;
                        if (id < treeList.Count - 1)
                        {
                            successor = treeList[id + 1];
                        }

                        // insert by
                        if (null == successor)
                        {
                            resList.Add(by);
                        }
                        else
                        {
                            int idBefore = resList.FindIndex(delegate(BoxGeneric b) { return(b.PickId == successor.PickId); });
                            resList.Insert(idBefore, by);
                        }
                    }
                }
                else
                {
                    CleanByYMin(treeList, y);
                    // add new
                    List <BoxGeneric> listYMax = GetByYMax(layerList, y);

                    foreach (var by in listYMax)
                    {
                        treeList.Add(by);
                        if (Direction.X > 0.0)
                        {
                            treeList.Sort(new BoxComparerXMin(Direction));
                        }
                        else
                        {
                            treeList.Sort(new BoxComparerXMax(Direction));
                        }

                        // find successor of by
                        int id = treeList.FindIndex(delegate(BoxGeneric b) { return(b.PickId == by.PickId); });
                        BoxGeneric successor = null;
                        if (id < treeList.Count - 1)
                        {
                            successor = treeList[id + 1];
                        }

                        // insert by
                        if (null == successor)
                        {
                            resList.Add(by);
                        }
                        else
                        {
                            int idBefore = resList.FindIndex(delegate(BoxGeneric b) { return(b.PickId == successor.PickId); });
                            resList.Insert(idBefore, by);
                        }
                    }
                }
            }

            layerList.Clear();
            resList.Reverse();
            layerList.AddRange(resList);

            foreach (var b in layerList)
            {
                b.ApplyElong(TuneParam);
            }
        }
コード例 #3
0
ファイル: BoxelOrderer.cs プロジェクト: ed152/StackBuilder
 public void Add(BoxGeneric b)
 {
     Boxes.Add(b);
 }