Пример #1
0
        /// <summary>
        /// This method is called by clients of the EdgeIntersector class to test for and add
        /// intersections for two segments of the edges being intersected.
        /// Note that clients (such as MonotoneChainEdges) may choose not to intersect
        /// certain pairs of segments for efficiency reasons.
        /// </summary>
        /// <param name="e0"></param>
        /// <param name="segIndex0"></param>
        /// <param name="e1"></param>
        /// <param name="segIndex1"></param>
        public void AddIntersections(Edge e0, int segIndex0, Edge e1, int segIndex1)
        {
            // if (e0 == e1 && segIndex0 == segIndex1)
            if (ReferenceEquals(e0, e1) && segIndex0 == segIndex1)
            {
                return;             // Diego Guidi say's: Avoid overload equality, i use references equality, otherwise TOPOLOGY ERROR!
            }
            NumTests++;
            Coordinate p00 = e0.Coordinates[segIndex0];
            Coordinate p01 = e0.Coordinates[segIndex0 + 1];
            Coordinate p10 = e1.Coordinates[segIndex1];
            Coordinate p11 = e1.Coordinates[segIndex1 + 1];

            _li.ComputeIntersection(p00, p01, p10, p11);

            /*
             *  Always record any non-proper intersections.
             *  If includeProper is true, record any proper intersections as well.
             */
            if (_li.HasIntersection)
            {
                if (_recordIsolated)
                {
                    e0.Isolated = false;
                    e1.Isolated = false;
                }
                _numIntersections++;
                // if the segments are adjacent they have at least one trivial intersection,
                // the shared endpoint.  Don't bother adding it if it is the
                // only intersection.
                if (!IsTrivialIntersection(e0, segIndex0, e1, segIndex1))
                {
                    _hasIntersection = true;
                    if (_includeProper || !_li.IsProper)
                    {
                        e0.AddIntersections(_li, segIndex0, 0);
                        e1.AddIntersections(_li, segIndex1, 1);
                    }
                    if (_li.IsProper)
                    {
                        _properIntersectionPoint = (Coordinate)_li.GetIntersection(0).Copy();
                        _hasProper = true;
                        if (_isDoneWhenProperInt)
                        {
                            _isDone = true;
                        }
                        if (!IsBoundaryPoint(_li, _bdyNodes))
                        {
                            _hasProperInterior = true;
                        }
                    }
                }
            }
        }
Пример #2
0
        /// <summary> This method is called by clients of the EdgeIntersector class to test for and Add
        /// intersections for two segments of the edges being intersected.
        /// Note that clients (such as MonotoneChainEdges) may choose not to intersect
        /// certain pairs of segments for efficiency reasons.
        /// </summary>
        public void AddIntersections(Edge e0, int segIndex0, Edge e1, int segIndex1)
        {
            if (e0 == e1 && segIndex0 == segIndex1)
            {
                return;
            }

            numTests++;
            Coordinate p00 = e0.Coordinates[segIndex0];
            Coordinate p01 = e0.Coordinates[segIndex0 + 1];
            Coordinate p10 = e1.Coordinates[segIndex1];
            Coordinate p11 = e1.Coordinates[segIndex1 + 1];

            li.ComputeIntersection(p00, p01, p10, p11);
            //if (li.HasIntersection() && li.isProper()) Debug.println(li);
            // Always record any non-proper intersections.
            // If includeProper is true, record any proper intersections as well.
            if (li.HasIntersection)
            {
                if (recordIsolated)
                {
                    e0.Isolated = false;
                    e1.Isolated = false;
                }

                //intersectionFound = true;
                numIntersections++;
                // if the segments are adjacent they have at least one trivial intersection,
                // the shared endpoint.  Don't bother adding it if it is the
                // only intersection.
                if (!IsTrivialIntersection(e0, segIndex0, e1, segIndex1))
                {
                    hasIntersection = true;
                    if (includeProper || !li.Proper)
                    {
                        e0.AddIntersections(li, segIndex0, 0);
                        e1.AddIntersections(li, segIndex1, 1);
                    }

                    if (li.Proper)
                    {
                        properIntersectionPoint = (Coordinate)li.GetIntersection(0).Clone();
                        hasProper = true;
                        if (!IsBoundaryPoint(li, bdyNodes))
                        {
                            hasProperInterior = true;
                        }
                    }
                }
            }
        }
Пример #3
0
        }         // private bool IsTrivialIntersection(Edge e0, int segIndex0, Edge e1, int segIndex1)

        /// <summary>
        /// This method is called by clients of the EdgeIntersector class to test for and add
        /// intersections for two segments of the edges being intersected.
        /// Note that clients (such as MonotoneChainEdges) may choose not to intersect
        /// certain pairs of segments for efficiency reasons.
        /// </summary>
        /// <param name="e0"></param>
        /// <param name="segIndex0"></param>
        /// <param name="e1"></param>
        /// <param name="segIndex1"></param>
        public void AddIntersections(Edge e0, int segIndex0, Edge e1, int segIndex1)
        {
            if (e0 == e1 && segIndex0 == segIndex1)
            {
                return;
            }
            _numTests++;
            Coordinate p00 = e0.Coordinates[segIndex0];
            Coordinate p01 = e0.Coordinates[segIndex0 + 1];
            Coordinate p10 = e1.Coordinates[segIndex1];
            Coordinate p11 = e1.Coordinates[segIndex1 + 1];

            _lineIntersector.ComputeIntersection(p00, p01, p10, p11);

            if (_lineIntersector.HasIntersection())
            {
                if (_recordIsolated)
                {
                    e0.SetIsIsolated(false);
                    e1.SetIsIsolated(false);
                }
                //intersectionFound = true;
                _numIntersections++;
                // if the segments are adjacent they have at least one trivial intersection,
                // the shared endpoint.  Don't bother adding it if it is the
                // only intersection.
                if (!IsTrivialIntersection(e0, segIndex0, e1, segIndex1))
                {
                    _hasIntersection = true;
                    if (_includeProper || !_lineIntersector.IsProper())
                    {
                        //Debug.println(_lineIntersector);
                        e0.AddIntersections(_lineIntersector, segIndex0, 0);
                        e1.AddIntersections(_lineIntersector, segIndex1, 1);
                    }
                    if (_lineIntersector.IsProper())
                    {
                        _properIntersectionPoint = (Coordinate)_lineIntersector.GetIntersection(0).Clone();
                        _hasProper = true;
                        if (!IsBoundaryPoint(_lineIntersector, _bdyNodes))
                        {
                            _hasProperInterior = true;
                        }
                    }
                } // if ( !IsTrivialIntersection( e0, segIndex0, e1, segIndex1) )
            }     // if ( _lineIntersector.HasIntersection() )
        }         // public void AddIntersections(Edge e0, int segIndex0, Edge e1, int segIndex1)