Example #1
0
        public override List <BoxGeneric> GetSortedList()
        {
            // first sort by Z
            BoxComparerZ boxComparerZ = new BoxComparerZ();

            Boxes.Sort(boxComparerZ);

            List <BoxGeneric> sortedList = new List <BoxGeneric>();

            if (Boxes.Count == 0)
            {
                return(sortedList);
            }

            // build same Z layers
            int               index    = 0;
            double            zCurrent = Boxes[index].PtMin.Z;
            List <BoxGeneric> tempList = new List <BoxGeneric>();

            while (index < Boxes.Count)
            {
                if (Math.Abs(zCurrent - Boxes[index].PtMin.Z) < _epsilon)
                {
                    tempList.Add(Boxes[index]);
                }
                else
                {
                    // sort layer
                    SortLayer(ref tempList);
                    // add to sorted list
                    sortedList.AddRange(tempList);
                    // start new layer
                    zCurrent = Boxes[index].PtMin.Z;
                    tempList.Clear();
                    tempList.Add(Boxes[index]);
                }
                ++index;
            }
            // processing last layer
            SortLayer(ref tempList);
            sortedList.AddRange(tempList);

            return(sortedList);
        }
Example #2
0
        public List <Box> GetSortedList()
        {
            // first sort by Z
            BoxComparerZ boxComparerZ = new BoxComparerZ();

            _boxes.Sort(boxComparerZ);

            List <Box> _sortedList = new List <Box>();

            if (_boxes.Count == 0)
            {
                return(_sortedList);
            }

            // build same Z layers
            int        index    = 0;
            double     zCurrent = _boxes[index].ZMin;
            List <Box> tempList = new List <Box>();

            while (index < _boxes.Count)
            {
                if (Math.Abs(zCurrent - _boxes[index].ZMin) < _epsilon)
                {
                    tempList.Add(_boxes[index]);
                }
                else
                {
                    // sort layer
                    SortLayer(ref tempList);
                    // add to sorted list
                    _sortedList.AddRange(tempList);
                    // start new layer
                    zCurrent = _boxes[index].ZMin;
                    tempList.Clear();
                    tempList.Add(_boxes[index]);
                }
                ++index;
            }
            // processing last layer
            SortLayer(ref tempList);
            _sortedList.AddRange(tempList);

            return(_sortedList);
        }