Esempio n. 1
0
        // ******************************************************************
        public ConvexHull(PointArrayManipulationType pointArrayManipulationType, IReadOnlyList <Point> listOfPoint, bool shouldCloseTheGraph = true, int initialResultGuessSize = 0)
        {
            _pointArrayManipulationType = pointArrayManipulationType;

            Init(listOfPoint, shouldCloseTheGraph, initialResultGuessSize);

            ArrayInsertImmutableDelegate      arrayInsertImmutable      = null;
            ArrayRemoveRangeImmutableDelegate arrayRemoveRangeImmutable = null;

            ArrayInsertDelegate      arrayInsert      = null;
            ArrayRemoveRangeDelegate arrayRemoveRange = null;

            switch (pointArrayManipulationType)
            {
            case PointArrayManipulationType.ArrayCopy:
                arrayInsert      = General.ArrayUtil.InsertItem <Point>;
                arrayRemoveRange = General.ArrayUtil.RemoveRange <Point>;
                break;

            //case PointArrayManipulationType.BufferCopy:
            //	arrayInsert = ConvexHullHelper.PointArrayUtil.InsertItemBuffer;
            //	arrayRemoveRange = ConvexHullHelper.PointArrayUtil.RemoveRangeBuffer;
            //	break;
            case PointArrayManipulationType.UnsafeCMemCopy:
                arrayInsert      = Unsafe.PointArrayUtilUnsafe.InsertItem;
                arrayRemoveRange = Unsafe.PointArrayUtilUnsafe.RemoveRange;
                break;

            case PointArrayManipulationType.ArrayCopyImmutable:
                arrayInsertImmutable      = General.ArrayUtil.ImmutableInsertItem <Point>;
                arrayRemoveRangeImmutable = General.ArrayUtil.ImmutableRemoveRange <Point>;
                break;

            default:
                throw new ArgumentException("Invalid PointArrayManipulationType");
            }

            List <Quadrant> quadrants = new List <Quadrant>();

            quadrants.Add(_q1);
            quadrants.Add(_q2);
            quadrants.Add(_q3);
            quadrants.Add(_q4);

            foreach (var q in quadrants)
            {
                if (arrayInsertImmutable != null)
                {
                    q.ArrayInsertImmutable      = arrayInsertImmutable;
                    q.ArrayRemoveRangeImmutable = arrayRemoveRangeImmutable;

                    arrayInsert      = q.ArrayInsertImmutableProxy;
                    arrayRemoveRange = q.ArrayRemoveRangeImmutableProxy;
                }

                q.ArrayInsert      = arrayInsert;
                q.ArrayRemoveRange = arrayRemoveRange;
            }
        }
Esempio n. 2
0
 // ******************************************************************
 public ConvexHull(PointArrayManipulationType pointArrayManipulationType, IReadOnlyList <Point> listOfPoint, bool shouldCloseTheGraph = true, int initialResultGuessSize = 0)
 {
     Init(listOfPoint, shouldCloseTheGraph, initialResultGuessSize);
 }