Exemple #1
0
        private void PrepareToAddPoints(
            int count,
            bool isStroked,
            bool isSmoothJoin,
            MIL_SEGMENT_TYPE segmentType)
        {
            Debug.Assert(_figures != null);
            Debug.Assert(_currentFigure != null);

            Debug.Assert(count != 0);

            if (_currentSegmentType != segmentType ||
                _currentSegmentIsStroked != isStroked ||
                _currentSegmentIsSmoothJoin != isSmoothJoin)
            {
                FinishSegment();

                _currentSegmentType         = segmentType;
                _currentSegmentIsStroked    = isStroked;
                _currentSegmentIsSmoothJoin = isSmoothJoin;
            }

            if (_currentSegmentPoints == null)
            {
                _currentSegmentPoints = new PointCollection();
            }
        }
        private void GenericPolyTo(IList <Point> points, MIL_SEGMENT_TYPE segmentType)
        {
            int count = points.Count;

            PrepareToAddPoints(count, segmentType);

            for (int i = 0; i < count; ++i)
            {
                _currentSegment !.Points.Add(points[i]);
            }
        }
        private void PrepareToAddPoints(int count, MIL_SEGMENT_TYPE segmentType)
        {
            Debug.Assert(_currentFigure != null);
            Debug.Assert(count != 0);

            if (_currentSegment != null && _currentSegment.Type != segmentType)
            {
                FinishSegment();
            }

            if (_currentSegment == null)
            {
                _currentSegment = new PathSegmentInfo(segmentType, count);
            }
        }
Exemple #4
0
        private void GenericPolyTo(IList <Point> points,
                                   bool isStroked,
                                   bool isSmoothJoin,
                                   MIL_SEGMENT_TYPE segmentType)
        {
            Debug.Assert(points != null);

            int count = points.Count;

            PrepareToAddPoints(count, isStroked, isSmoothJoin, segmentType);

            for (int i = 0; i < count; ++i)
            {
                _currentSegmentPoints.Add(points[i]);
            }
        }
        unsafe private void GenericPolyTo(Point *points,
                                          int count,
                                          bool isStroked,
                                          bool isSmoothJoin,
                                          bool hasCurves,
                                          MIL_SEGMENT_TYPE segmentType)
        {
            Debug.Assert(points != null);
            Debug.Assert(count > 0);

            if (_currentPathFigureDataOffset == -1)
            {
                throw new InvalidOperationException(SR.Get(SRID.StreamGeometry_NeedBeginFigure));
            }

            GenericPolyToHelper(isStroked, isSmoothJoin, hasCurves, segmentType);

            AppendData((byte *)points, sizeof(Point) * count);
            _currentPolySegmentData.Count += (uint)count;
        }
        private void GenericPolyTo(IList <Point> points,
                                   bool isStroked,
                                   bool isSmoothJoin,
                                   bool hasCurves,
                                   int pointCountMultiple,
                                   MIL_SEGMENT_TYPE segmentType)
        {
            if (_currentPathFigureDataOffset == -1)
            {
                throw new InvalidOperationException(SR.Get(SRID.StreamGeometry_NeedBeginFigure));
            }

            if (points == null)
            {
                return;
            }

            int count = points.Count;

            count -= count % pointCountMultiple;

            if (count <= 0)
            {
                return;
            }

            GenericPolyToHelper(isStroked, isSmoothJoin, hasCurves, segmentType);

            for (int i = 0; i < count; i++)
            {
                Point p = points[i];

                unsafe
                {
                    AppendData((byte *)&p, sizeof(Point));
                }

                _currentPolySegmentData.Count++;
            }
        }
        private void GenericPolyTo(IList<Point> points,
                                   bool isStroked, 
                                   bool isSmoothJoin,
                                   MIL_SEGMENT_TYPE segmentType) 
        { 
            Debug.Assert(_figures != null);
            Debug.Assert(_currentFigure != null); 

            int count = points.Count;

            Debug.Assert(points != null); 
            Debug.Assert(count != 0);
 
            if (_currentSegmentType != segmentType || 
                _currentSegmentIsStroked != isStroked ||
                _currentSegmentIsSmoothJoin != isSmoothJoin) 
            {
                FinishSegment();

                _currentSegmentType = segmentType; 
                _currentSegmentIsStroked = isStroked;
                _currentSegmentIsSmoothJoin = isSmoothJoin; 
            } 

            if (_currentSegmentPoints == null) 
            {
                _currentSegmentPoints = new PointCollection();
            }
 
            for (int i = 0; i < count; ++i)
            { 
                _currentSegmentPoints.Add(points[i]); 
            }
        } 
        private void GenericPolyToHelper(bool isStroked, bool isSmoothJoin, bool hasCurves, MIL_SEGMENT_TYPE segmentType)
        {
            // Do we need to finish the old segment?
            // Yes, if there is an old segment and if its type or flags are different from
            // the new segment.
            if ((_currentPolySegmentDataOffset != -1) &&
                (
                    (_currentPolySegmentData.Type != segmentType) ||
                    (((_currentPolySegmentData.Flags & MILCoreSegFlags.SegIsAGap) == 0) != isStroked) ||
                    (((_currentPolySegmentData.Flags & MILCoreSegFlags.SegSmoothJoin) != 0) != isSmoothJoin)
                )
                )
            {
                FinishSegment();
            }

            // Do we need to start a new segment?
            if (_currentPolySegmentDataOffset == -1)
            {
                MIL_SEGMENT_POLY tempSegment;
                int oldOffset = _currOffset;

                unsafe
                {
                    AppendData((byte *)&tempSegment, sizeof(MIL_SEGMENT_POLY));
                }

                _currentPolySegmentDataOffset    = oldOffset;
                _currentPolySegmentData.Type     = segmentType;
                _currentPolySegmentData.Flags   |= isStroked ? 0 : MILCoreSegFlags.SegIsAGap;
                _currentPolySegmentData.Flags   |= hasCurves ? MILCoreSegFlags.SegIsCurved : 0;
                _currentPolySegmentData.Flags   |= isSmoothJoin ? MILCoreSegFlags.SegSmoothJoin : 0;
                _currentPolySegmentData.BackSize = _lastSegmentSize;
            }

            // Assert that everything is ready to go
            Debug.Assert((_currentPolySegmentDataOffset != -1) &&
                         (_currentPolySegmentData.Type == segmentType) &&
                         (((_currentPolySegmentData.Flags & MILCoreSegFlags.SegIsAGap) == 0) == isStroked) &&
                         (((_currentPolySegmentData.Flags & MILCoreSegFlags.SegSmoothJoin) != 0) == isSmoothJoin));
        }
        private void GenericPolyTo(IList<Point> points, 
                                   bool isStroked,
                                   bool isSmoothJoin, 
                                   bool hasCurves, 
                                   int pointCountMultiple,
                                   MIL_SEGMENT_TYPE segmentType) 
        {
            if (_currentPathFigureDataOffset == -1)
            {
                throw new InvalidOperationException(SR.Get(SRID.StreamGeometry_NeedBeginFigure)); 
            }
 
            if (points == null) 
            {
                return; 
            }

            int count = points.Count;
            count -= count % pointCountMultiple; 

            if (count <= 0) 
            { 
                return;
            } 

            // Do we need to finish the old segment?
            // Yes, if there is an old segment and if its type or flags are different from
            // the new segment. 
            if ( (_currentPolySegmentDataOffset != -1) &&
                 ( 
                   (_currentPolySegmentData.Type != segmentType) || 
                   ( ((_currentPolySegmentData.Flags & MILCoreSegFlags.SegIsAGap) == 0) != isStroked ) ||
                   ( ((_currentPolySegmentData.Flags & MILCoreSegFlags.SegSmoothJoin) != 0) != isSmoothJoin ) 
                 )
               )
            {
                FinishSegment(); 
            }
 
            // Do we need to start a new segment? 
            if (_currentPolySegmentDataOffset == -1)
            { 
                MIL_SEGMENT_POLY tempSegment;
                int oldOffset = _currOffset;

                unsafe 
                {
                    AppendData((byte*)&tempSegment, sizeof(MIL_SEGMENT_POLY)); 
                } 

                _currentPolySegmentDataOffset = oldOffset; 
                _currentPolySegmentData.Type = segmentType;
                _currentPolySegmentData.Flags |= isStroked ? 0 : MILCoreSegFlags.SegIsAGap;
                _currentPolySegmentData.Flags |= hasCurves ? MILCoreSegFlags.SegIsCurved : 0;
                _currentPolySegmentData.Flags |= isSmoothJoin ? MILCoreSegFlags.SegSmoothJoin : 0; 
                _currentPolySegmentData.BackSize = _lastSegmentSize;
            } 
 
            // Assert that everything is ready to go
            Debug.Assert((_currentPolySegmentDataOffset != -1) && 
                         (_currentPolySegmentData.Type == segmentType) &&
                         (((_currentPolySegmentData.Flags & MILCoreSegFlags.SegIsAGap) == 0) == isStroked) &&
                         (((_currentPolySegmentData.Flags & MILCoreSegFlags.SegSmoothJoin) != 0) == isSmoothJoin));
 
            for (int i = 0; i < count; i++)
            { 
                Point p = points[i]; 

                unsafe 
                {
                    AppendData((byte*)&p, sizeof(Point));
                }
 
                _currentPolySegmentData.Count++;
            } 
        } 
        private void PrepareToAddPoints(
                                   int count,
                                   bool isStroked,
                                   bool isSmoothJoin,
                                   MIL_SEGMENT_TYPE segmentType)
        {
            Debug.Assert(_figures != null);
            Debug.Assert(_currentFigure != null);

            Debug.Assert(count != 0);

            if (_currentSegmentType != segmentType ||
                _currentSegmentIsStroked != isStroked ||
                _currentSegmentIsSmoothJoin != isSmoothJoin)
            {
                FinishSegment();

                _currentSegmentType = segmentType;
                _currentSegmentIsStroked = isStroked;
                _currentSegmentIsSmoothJoin = isSmoothJoin;
            }

            if (_currentSegmentPoints == null)
            {
                _currentSegmentPoints = new PointCollection();
            }
        }
        private void GenericPolyTo(IList<Point> points,
                                   bool isStroked, 
                                   bool isSmoothJoin,
                                   MIL_SEGMENT_TYPE segmentType)
        {
            Debug.Assert(points != null);

            int count = points.Count;
            PrepareToAddPoints(count, isStroked, isSmoothJoin, segmentType);

            for (int i = 0; i < count; ++i)
            {
                _currentSegmentPoints.Add(points[i]);
            }
        }
        private void GenericPolyToHelper(bool isStroked, bool isSmoothJoin, bool hasCurves, MIL_SEGMENT_TYPE segmentType)
        {
            // Do we need to finish the old segment?
            // Yes, if there is an old segment and if its type or flags are different from 
            // the new segment.
            if ((_currentPolySegmentDataOffset != -1) &&
                 (
                   (_currentPolySegmentData.Type != segmentType) ||
                   (((_currentPolySegmentData.Flags & MILCoreSegFlags.SegIsAGap) == 0) != isStroked) ||
                   (((_currentPolySegmentData.Flags & MILCoreSegFlags.SegSmoothJoin) != 0) != isSmoothJoin)
                 )
               )
            {
                FinishSegment();
            }

            // Do we need to start a new segment?
            if (_currentPolySegmentDataOffset == -1)
            {
                MIL_SEGMENT_POLY tempSegment;
                int oldOffset = _currOffset;

                unsafe
                {
                    AppendData((byte*)&tempSegment, sizeof(MIL_SEGMENT_POLY));
                }

                _currentPolySegmentDataOffset = oldOffset;
                _currentPolySegmentData.Type = segmentType;
                _currentPolySegmentData.Flags |= isStroked ? 0 : MILCoreSegFlags.SegIsAGap;
                _currentPolySegmentData.Flags |= hasCurves ? MILCoreSegFlags.SegIsCurved : 0;
                _currentPolySegmentData.Flags |= isSmoothJoin ? MILCoreSegFlags.SegSmoothJoin : 0;
                _currentPolySegmentData.BackSize = _lastSegmentSize;
            }

            // Assert that everything is ready to go
            Debug.Assert((_currentPolySegmentDataOffset != -1) &&
                         (_currentPolySegmentData.Type == segmentType) &&
                         (((_currentPolySegmentData.Flags & MILCoreSegFlags.SegIsAGap) == 0) == isStroked) &&
                         (((_currentPolySegmentData.Flags & MILCoreSegFlags.SegSmoothJoin) != 0) == isSmoothJoin));

        }
        unsafe private void GenericPolyTo(Point* points,
                                   int count,
                                   bool isStroked,
                                   bool isSmoothJoin,
                                   bool hasCurves,
                                   MIL_SEGMENT_TYPE segmentType)
        {
            Debug.Assert(points != null);
            Debug.Assert(count > 0);

            if (_currentPathFigureDataOffset == -1)
            {
                throw new InvalidOperationException(SR.Get(SRID.StreamGeometry_NeedBeginFigure));
            }

            GenericPolyToHelper(isStroked, isSmoothJoin, hasCurves, segmentType);

            AppendData((byte*)points, sizeof(Point) * count);
            _currentPolySegmentData.Count += (uint)count;
        }
        private void GenericPolyTo(IList<Point> points,
                                   bool isStroked, 
                                   bool isSmoothJoin,
                                   bool hasCurves,
                                   int pointCountMultiple,
                                   MIL_SEGMENT_TYPE segmentType)
        {
            if (_currentPathFigureDataOffset == -1)
            {
                throw new InvalidOperationException(SR.Get(SRID.StreamGeometry_NeedBeginFigure));
            }

            if (points == null)
            {
                return;
            }

            int count = points.Count;
            count -= count % pointCountMultiple;

            if (count <= 0)
            {
                return;
            }

            GenericPolyToHelper(isStroked, isSmoothJoin, hasCurves, segmentType);

            for (int i = 0; i < count; i++)
            {
                Point p = points[i];

                unsafe
                {
                    AppendData((byte*)&p, sizeof(Point));
                }

                _currentPolySegmentData.Count++;
            }
        }