Represents an object for labeling segment in the monotone chain.
Exemplo n.º 1
0
        /// <summary>
        /// Adds a segment to the chain.
        /// </summary>
        /// <param name="segment">The segment to add</param>
        /// <param name="label">The label of the segment</param>
        /// <returns>true, if the segment was added, false otherwise</returns>
        public bool InsertSegment(Segment segment, SegmentLabel label)
        {
            if (checkSegment(segment))
            {
                internalInsertSegment(segment, label);
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Replaces the label associated with segment having specified index in the chain.
 /// </summary>
 /// <param name="index">The index of segment in the chain</param>
 /// <param name="newValue">Instance of label</param>
 public void ReplaceLabel(int index, SegmentLabel newValue)
 {
     if (index > 0 || index < _labels.Count)
     {
         _labels[index] = newValue;
     }
     else
     {
         throw new ArgumentOutOfRangeException("The index should not be negative and smaller than the size of the collection", "index");
     }
 }
Exemplo n.º 3
0
        private void internalInsertSegment(Segment segment, SegmentLabel tag)
        {
            segment = (Segment)segment.Clone();

            _boundingRectangle.Join(segment.V1);
            _boundingRectangle.Join(segment.V2);

            if (_segments.Count > 0)
            {
                if (segment.V2.ExactEquals(_segments[0].V1))
                {
                    _segments.Insert(0, segment);
                    _labels.Insert(0, tag);
                    return;
                }
            }
            _segments.Add(segment);
            _labels.Add(tag);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of <see cref="MonotoneChain"/>.
 /// </summary>
 /// <param name="segment">An initial segment</param>
 /// <param name="tag">A label of initial segment</param>
 public MonotoneChain(Segment segment, SegmentLabel tag)
 {
     _orientation = GetSegmentOrientation(segment);
     internalInsertSegment(segment, tag);
 }
Exemplo n.º 5
0
        private void internalInsertSegment(Segment segment, SegmentLabel tag)
        {
            segment = (Segment)segment.Clone();

            _boundingRectangle.Join(segment.V1);
            _boundingRectangle.Join(segment.V2);

            if (_segments.Count > 0)
            {
                if (segment.V2.ExactEquals(_segments[0].V1))
                {
                    _segments.Insert(0, segment);
                    _labels.Insert(0, tag);
                    return;
                }
            }
            _segments.Add(segment);
            _labels.Add(tag);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of <see cref="MonotoneChain"/>.
 /// </summary>
 /// <param name="segment">An initial segment</param>
 /// <param name="tag">A label of initial segment</param>
 public MonotoneChain(Segment segment, SegmentLabel tag)
 {
     _orientation = GetSegmentOrientation(segment);
     internalInsertSegment(segment, tag);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Replaces the label associated with segment having specified index in the chain.
 /// </summary>
 /// <param name="index">The index of segment in the chain</param>
 /// <param name="newValue">Instance of label</param>
 public void ReplaceLabel(int index, SegmentLabel newValue)
 {
     if (index > 0 || index < _labels.Count)
         _labels[index] = newValue;
     else
         throw new ArgumentOutOfRangeException("The index should not be negative and smaller than the size of the collection", "index");
 }
Exemplo n.º 8
0
        /// <summary>
        /// Adds a segment to the chain.
        /// </summary>
        /// <param name="segment">The segment to add</param>
        /// <param name="label">The label of the segment</param>
        /// <returns>true, if the segment was added, false otherwise</returns>
        public bool InsertSegment(Segment segment, SegmentLabel label)
        {
            if (checkSegment(segment))
            {
                internalInsertSegment(segment, label);
                return true;
            }

            return false;
        }