private void IntersectScanSegments()
 {
     var si = new SegmentIntersector();
     this.VisibilityGraph = si.Generate(HorizontalScanSegments.Segments, VerticalScanSegments.Segments);
     si.RemoveSegmentsWithNoVisibility(HorizontalScanSegments, VerticalScanSegments);
     HorizontalScanSegments.DevTraceVerifyVisibility();
     VerticalScanSegments.DevTraceVerifyVisibility();
 }
Exemplo n.º 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mc"></param>
 /// <param name="si"></param>
 public void ComputeIntersections(MonotoneChain mc, SegmentIntersector si)
 {
     this.mce.ComputeIntersectsForChain(chainIndex, mc.mce, mc.chainIndex, si);
 }
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mc"></param>
 /// <param name="si"></param>
 public virtual void ComputeIntersections(MonotoneChain mc, SegmentIntersector si)
 {
     _mce.ComputeIntersectsForChain(_chainIndex, mc._mce, mc._chainIndex, si);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IntersectionMatrix ComputeIM()
        {
            IntersectionMatrix im = new IntersectionMatrix();
            // since Geometries are finite and embedded in a 2-D space, the EE element must always be 2
            im.Set(Locations.Exterior, Locations.Exterior, Dimensions.Surface);

            // if the Geometries don't overlap there is nothing to do
            if (!arg[0].Geometry.EnvelopeInternal.Intersects(arg[1].Geometry.EnvelopeInternal))
            {
                ComputeDisjointIM(im);
                return im;
            }
            arg[0].ComputeSelfNodes(li, false);
            arg[1].ComputeSelfNodes(li, false);

            // compute intersections between edges of the two input geometries
            SegmentIntersector intersector = arg[0].ComputeEdgeIntersections(arg[1], li, false);           
            ComputeIntersectionNodes(0);
            ComputeIntersectionNodes(1);

            /*
             * Copy the labelling for the nodes in the parent Geometries.  These override
             * any labels determined by intersections between the geometries.
             */
            CopyNodesAndLabels(0);
            CopyNodesAndLabels(1);

            // complete the labelling for any nodes which only have a label for a single point
            LabelIsolatedNodes();

            // If a proper intersection was found, we can set a lower bound on the IM.
            ComputeProperIntersectionIM(intersector, im);

            /*
             * Now process improper intersections
             * (eg where one or other of the geometries has a vertex at the intersection point)
             * We need to compute the edge graph at all nodes to determine the IM.
             */

            // build EdgeEnds for all intersections
            EdgeEndBuilder eeBuilder = new EdgeEndBuilder();
            IList ee0 = eeBuilder.ComputeEdgeEnds(arg[0].GetEdgeEnumerator());
            InsertEdgeEnds(ee0);
            IList ee1 = eeBuilder.ComputeEdgeEnds(arg[1].GetEdgeEnumerator());
            InsertEdgeEnds(ee1);

            LabelNodeEdges();

            /*
             * Compute the labeling for isolated components
             * <br>
             * Isolated components are components that do not touch any other components in the graph.
             * They can be identified by the fact that they will
             * contain labels containing ONLY a single element, the one for their parent point.
             * We only need to check components contained in the input graphs, since
             * isolated components will not have been replaced by new components formed by intersections.
             */           
            LabelIsolatedEdges(0, 1);            
            LabelIsolatedEdges(1, 0);

            // update the IM from all components
            UpdateIM(im);
            return im;
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="intersector"></param>
        /// <param name="im"></param>
        private void ComputeProperIntersectionIM(SegmentIntersector intersector, IntersectionMatrix im)
        {
            // If a proper intersection is found, we can set a lower bound on the IM.
            Dimensions dimA              = arg[0].Geometry.Dimension;
            Dimensions dimB              = arg[1].Geometry.Dimension;
            bool       hasProper         = intersector.HasProperIntersection;
            bool       hasProperInterior = intersector.HasProperInteriorIntersection;

            // For Geometry's of dim 0 there can never be proper intersections.

            /*
             * If edge segments of Areas properly intersect, the areas must properly overlap.
             */
            if (dimA == Dimensions.Surface && dimB == Dimensions.Surface)
            {
                if (hasProper)
                {
                    im.SetAtLeast("212101212");
                }
            }

            /*
             * If an Line segment properly intersects an edge segment of an Area,
             * it follows that the Interior of the Line intersects the Boundary of the Area.
             * If the intersection is a proper <i>interior</i> intersection, then
             * there is an Interior-Interior intersection too.
             * Note that it does not follow that the Interior of the Line intersects the Exterior
             * of the Area, since there may be another Area component which contains the rest of the Line.
             */
            else if (dimA == Dimensions.Surface && dimB == Dimensions.Curve)
            {
                if (hasProper)
                {
                    im.SetAtLeast("FFF0FFFF2");
                }
                if (hasProperInterior)
                {
                    im.SetAtLeast("1FFFFF1FF");
                }
            }

            else if (dimA == Dimensions.Curve && dimB == Dimensions.Surface)
            {
                if (hasProper)
                {
                    im.SetAtLeast("F0FFFFFF2");
                }
                if (hasProperInterior)
                {
                    im.SetAtLeast("1F1FFFFFF");
                }
            }

            /* If edges of LineStrings properly intersect *in an interior point*, all
             * we can deduce is that
             * the interiors intersect.  (We can NOT deduce that the exteriors intersect,
             * since some other segments in the geometries might cover the points in the
             * neighbourhood of the intersection.)
             * It is important that the point be known to be an interior point of
             * both Geometries, since it is possible in a self-intersecting point to
             * have a proper intersection on one segment that is also a boundary point of another segment.
             */
            else if (dimA == Dimensions.Curve && dimB == Dimensions.Curve)
            {
                if (hasProperInterior)
                {
                    im.SetAtLeast("0FFFFFFFF");
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mc"></param>
 /// <param name="si"></param>
 public void ComputeIntersections(MonotoneChain mc, SegmentIntersector si)
 {
     this.mce.ComputeIntersectsForChain(chainIndex, mc.mce, mc.chainIndex, si);
 }
Exemplo n.º 7
0
        public IntersectionMatrix ComputeIM()
        {
            IntersectionMatrix im = new IntersectionMatrix();

            // since Geometries are finite and embedded in a 2-D space, the EE element must always be 2
            im.SetValue(LocationType.Exterior, LocationType.Exterior, 2);

            // if the Geometries don't overlap there is nothing to do
            if (!arg[0].Geometry.Bounds.Intersects(arg[1].Geometry.Bounds))
            {
                ComputeDisjointIM(im);
                return(im);
            }
            arg[0].ComputeSelfNodes(li, false);
            arg[1].ComputeSelfNodes(li, false);

            // compute intersections between edges of the two input geometries
            SegmentIntersector intersector = arg[0].ComputeEdgeIntersections(arg[1], li, false);

            //System.out.println("computeIM: # segment intersection tests: " + intersector.numTests);
            ComputeIntersectionNodes(0);
            ComputeIntersectionNodes(1);
            // Copy the labelling for the nodes in the parent Geometries.  These override
            // any labels determined by intersections between the geometries.
            CopyNodesAndLabels(0);
            CopyNodesAndLabels(1);

            // complete the labelling for any nodes which only have a label for a single geometry
            LabelIsolatedNodes();

            // If a proper intersection was found, we can set a lower bound on the IM.
            ComputeProperIntersectionIM(intersector, im);

            // Now process improper intersections
            // (eg where one or other of the geometries has a vertex at the intersection point)
            // We need to compute the edge graph at all nodes to determine the IM.

            // build EdgeEnds for all intersections
            EdgeEndBuilder eeBuilder = new EdgeEndBuilder();
            ArrayList      ee0       = eeBuilder.ComputeEdgeEnds(arg[0].EdgeIterator);

            InsertEdgeEnds(ee0);
            ArrayList ee1 = eeBuilder.ComputeEdgeEnds(arg[1].EdgeIterator);

            InsertEdgeEnds(ee1);

            LabelNodeEdges();

            // Compute the labeling for isolated components
            // Isolated components are components that do not touch any
            // other components in the graph.
            // They can be identified by the fact that they will
            // contain labels containing ONLY a single element, the one
            // for their parent geometry.
            // We only need to check components contained in the input graphs, since
            // isolated components will not have been replaced by new components
            // formed by intersections.
            LabelIsolatedEdges(0, 1);

            LabelIsolatedEdges(1, 0);

            // update the IM from all components
            UpdateIM(im);
            return(im);
        }
Exemplo n.º 8
0
        private void ComputeProperIntersectionIM(SegmentIntersector intersector,
                                                 IntersectionMatrix im)
        {
            // If a proper intersection is found, we can set a lower bound on the IM.
            int  dimA              = (int)arg[0].Geometry.Dimension;
            int  dimB              = (int)arg[1].Geometry.Dimension;
            bool hasProper         = intersector.HasProperIntersection();
            bool hasProperInterior = intersector.HasProperInteriorIntersection();

            // For Geometry's of dim 0 there can never be proper intersections.

            //If edge segments of Areas properly intersect, the areas
            // must properly overlap.
            if (dimA == 2 && dimB == 2)
            {
                if (hasProper)
                {
                    im.SetAtLeast("212101212");
                }
            }
            // If an line segment properly intersects an edge segment of an area,
            // it follows that the interior of the line intersects the Boundary of the area.
            // If the intersection is a proper interior intersection, then
            // there is an Interior-Interior intersection too.
            // Note that it does not follow that the Interior of the line
            // Intersects the exterior of the area, since there may be another
            // area component which Contains the rest of the line.
            else if (dimA == 2 && dimB == 1)
            {
                if (hasProper)
                {
                    im.SetAtLeast("FFF0FFFF2");
                }
                if (hasProperInterior)
                {
                    im.SetAtLeast("1FFFFF1FF");
                }
            }
            else if (dimA == 1 && dimB == 2)
            {
                if (hasProper)
                {
                    im.SetAtLeast("F0FFFFFF2");
                }
                if (hasProperInterior)
                {
                    im.SetAtLeast("1F1FFFFFF");
                }
            }
            // If edges of LineStrings properly intersect *in an interior point*, all
            // we can deduce is that
            // the interiors intersect.  (We can NOT deduce that the exteriors intersect,
            // since some other segments in the geometries might cover the points in the
            // neighbourhood of the intersection.)
            // It is important that the point be known to be an interior point of
            // both Geometries, since it is possible in a self-intersecting geometry to
            // have a proper intersection on one segment that is also a boundary
            // point of another segment.
            else if (dimA == 1 && dimB == 1)
            {
                if (hasProperInterior)
                {
                    im.SetAtLeast("0FFFFFFFF");
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mc"></param>
 /// <param name="si"></param>
 public virtual void ComputeIntersections(MonotoneChain mc, SegmentIntersector si)
 {
     _mce.ComputeIntersectsForChain(_chainIndex, mc._mce, mc._chainIndex, si);
 }
Exemplo n.º 10
0
        }         // public bool HasDuplicateRings()

        /// <summary>
        /// Computes the Intersection matrix for the geometries.
        /// </summary>
        /// <returns></returns>
        public IntersectionMatrix ComputeIM()
        {
            IntersectionMatrix im = new IntersectionMatrix();

            // since Geometries are finite and embedded in a 2-D space, the EE element must always be 2
            im.Set(Location.Exterior, Location.Exterior, 2);

            // if the Geometries don't overlap there is nothing to do
            if (!_arg[0].Geometry.GetEnvelopeInternal().Intersects(
                    _arg[1].Geometry.GetEnvelopeInternal()))
            {
                ComputeDisjointIM(im);
                return(im);
            }

            _arg[0].ComputeSelfNodes(_li);
            _arg[1].ComputeSelfNodes(_li);

            // compute intersections between edges of the two input geometries
            SegmentIntersector intersector = _arg[0].ComputeEdgeIntersections(_arg[1], _li, false);

            ComputeIntersectionNodes(0);
            ComputeIntersectionNodes(1);

            // Copy the labelling for the nodes in the parent Geometries.  These override
            // any labels determined by intersections between the geometries.
            CopyNodesAndLabels(0);
            CopyNodesAndLabels(1);

            // complete the labelling for any nodes which only have a label for a single geometry
            LabelIsolatedNodes();

            // If a proper intersection was found, we can set a lower bound on the IM.
            ComputeProperIntersectionIM(intersector, im);

            // Now process improper intersections
            // (eg where one or other of the geometrys has a vertex at the intersection point)
            // We need to compute the edge graph at all nodes to determine the IM.

            // build EdgeEnds for all intersections
            EdgeEndBuilder eeBuilder = new EdgeEndBuilder();
            ArrayList      ee0       = eeBuilder.ComputeEdgeEnds(_arg[0].Edges);

            InsertEdgeEnds(ee0);
            ArrayList ee1 = eeBuilder.ComputeEdgeEnds(_arg[1].Edges);

            InsertEdgeEnds(ee1);

            //Trace.WriteLine("==== NodeList ===");
            //Trace.WriteLine( _nodes.ToString() );

            LabelNodeEdges();

            // Compute the labeling for isolated components
            // <br>
            // Isolated components are components that do not touch any other components in the graph.
            // They can be identified by the fact that they will
            // contain labels containing ONLY a single element, the one for their parent geometry.
            // We only need to check components contained in the input graphs, since
            // isolated components will not have been replaced by new components formed by intersections.
            //Trace.WriteLine("Graph A isolated edges - ");
            LabelIsolatedEdges(0, 1);
            //Trace.WriteLine("Graph B isolated edges - ");
            LabelIsolatedEdges(1, 0);

            // update the IM from all components
            UpdateIM(im);
            return(im);
        }         // public IntersectionMatrix ComputeIM()