Represents a monotone chain of segments. All segments in chain are placed in single quadrant Monotone chain segments are used to avoid a large number of segments intersection checks.
Inheritance: IIndexable
Beispiel #1
0
        /// <summary>
        /// Computes the 2D intersections of two chains.
        /// </summary>
        /// <param name="chain">Monotone chain</param>
        /// <returns>A list containing segments that represent 2D intersections of chain</returns>
        public List<Segment> GetCrossSegments(MonotoneChain chain)
        {
            List<Segment> result = new List<Segment>();

            if (BoundsIntersect(chain))
            {
                Segment crossSegment = new Segment();
                ICoordinate stub = null;

                foreach (Segment s1 in this._segments)
                    foreach (Segment s2 in chain._segments)
                    {
                        Dimension crossKind = PlanimetryAlgorithms.RobustSegmentsIntersection(s1, s2, out stub, out crossSegment);
                        if (crossKind == Dimension.One)
                            result.Add(crossSegment);
                    }
            }

            return result;
        }
Beispiel #2
0
        /// <summary>
        /// Determines whether the bounding rectangle of this chain 
        /// intersects the bounding rectangle of specified chain.
        /// </summary>
        /// <param name="chain">Monotone chain</param>
        /// <returns>true, if the bounding rectangle of this chain 
        /// intersects the bounding rectangle of specified chain, false otherwise</returns>
        public bool BoundsIntersect(MonotoneChain chain)
        {
            if (this._boundingRectangle.IsEmpty() || chain._boundingRectangle.IsEmpty())
                return false;

            if (this._boundingRectangle.Intersects(chain._boundingRectangle))
                return true;

            return false;
        }
Beispiel #3
0
        /// <summary>
        /// Determines whether this chain crosses with other.
        /// </summary>
        /// <param name="chain">Chain</param>
        /// <returns>true, if this chain crosses with the specified chain, false otherwise</returns>
        public bool CrossesWith(MonotoneChain chain)
        {
            if (BoundsIntersect(chain))
            {
                Segment stub = new Segment();
                ICoordinate crossPoint = null;

                foreach (Segment s1 in this._segments)
                    foreach (Segment s2 in chain._segments)
                    {
                        Dimension crossKind = PlanimetryAlgorithms.RobustSegmentsIntersection(s1, s2, out crossPoint, out stub);
                        if (crossKind == Dimension.Zero)
                            return true;
                    }
            }

            return false;
        }
Beispiel #4
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>A new object that is a copy of this instance</returns>
        public object Clone()
        {
            MonotoneChain clone = new MonotoneChain(this._orientation);
            foreach (Segment s in this._segments)
                clone._segments.Add(s);

            foreach (SegmentLabel label in this._labels)
                clone._labels.Add(label);

            clone._boundingRectangle = (BoundingRectangle)this._boundingRectangle.Clone();

            return clone;
        }