Exemplo n.º 1
0
        /// <summary>
        /// Insert nodes for all intersections on the edges of a Geometry.
        /// Label the created nodes the same as the edge label if they do not already
        /// have a label.
        /// This allows nodes created by either self-intersections or
        /// mutual intersections to be labelled.
        /// Endpoint nodes will already be labelled from when they were inserted.
        /// <para>
        /// Precondition: edge intersections have been computed.
        /// </para>
        /// </summary>
        public void ComputeIntersectionNodes(GeometryGraph geomGraph, int argIndex)
        {
            for (IEdgeEnumerator edgeIt = geomGraph.EdgeIterator; edgeIt.MoveNext();)
            {
                Edge e    = edgeIt.Current;
                int  eLoc = e.Label.GetLocation(argIndex);

                for (IEnumerator eiIt = e.EdgeIntersectionList.Iterator(); eiIt.MoveNext();)
                {
                    EdgeIntersection ei = (EdgeIntersection)eiIt.Current;
                    RelateNode       n  = (RelateNode)nodes.AddNode(ei.coord);
                    if (eLoc == LocationType.Boundary)
                    {
                        n.SetLabelBoundary(argIndex);
                    }
                    else
                    {
                        if (n.Label.IsNull(argIndex))
                        {
                            n.SetLabel(argIndex, LocationType.Interior);
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Construct an enumerator over the out-edges
 /// </summary>
 /// <param name="vertexOutEdges">Out edge dictionary to iterate</param>
 /// <exception cref="ArgumentNullException">vertexOutEdges is null</exception>
 public VertexEdgesEnumerator(VertexEdgesDictionary vertexOutEdges)
 {
     if (vertexOutEdges == null)
         throw new ArgumentNullException("vertexOutEdges");
     VertexOutEdgeEnumerator = vertexOutEdges.GetEnumerator();
     OutEdgeEnumerator = null;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Test that no edge intersection is the endpoint of a closed line.
        /// To check this we compute the degree of each endpoint.
        /// The degree of endpoints of closed lines must be exactly 2.
        /// </summary>
        private bool HasClosedEndpointIntersection(GeometryGraph graph)
        {
            IDictionary endPoints = new SortedList();

            for (IEdgeEnumerator i = graph.EdgeIterator; i.MoveNext();)
            {
                Edge e = i.Current;
//				int maxSegmentIndex = e.MaximumSegmentIndex;
                bool       isClosed = e.IsClosed;
                Coordinate p0       = e.GetCoordinate(0);
                AddEndpoint(endPoints, p0, isClosed);
                Coordinate p1 = e.GetCoordinate(e.NumPoints - 1);
                AddEndpoint(endPoints, p1, isClosed);
            }

            for (IEnumerator i = endPoints.Values.GetEnumerator(); i.MoveNext();)
            {
                EndpointInfo eiInfo = (EndpointInfo)i.Current;
                if (eiInfo.isClosed && eiInfo.degree != 2)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 4
0
 public void AddAll(EdgeCollection edgeColl)
 {
     for (IEdgeEnumerator i = edgeColl.GetEnumerator(); i.MoveNext();)
     {
         Add(i.Current);
     }
 }
Exemplo n.º 5
0
 public void ComputeSplitEdges(EdgeCollection edgelist)
 {
     for (IEdgeEnumerator i = edges.GetEnumerator(); i.MoveNext();)
     {
         Edge e = i.Current;
         e.eiList.AddSplitEdges(edgelist);
     }
 }
Exemplo n.º 6
0
 public ReversedEdgeEnumerator(IEdgeEnumerator enumerator)
 {
     if (enumerator == null)
     {
         throw new ArgumentNullException("enumerator");
     }
     this.wrapped = enumerator;
 }
Exemplo n.º 7
0
		private void InsertUniqueEdges(EdgeCollection edges)
		{
			for (IEdgeEnumerator i = edges.GetEnumerator(); i.MoveNext(); )
			{
				Edge e = i.Current;
				InsertUniqueEdge(e);
			}
		}
Exemplo n.º 8
0
 public TargetVertexEnumerator(IEdgeEnumerable edges)
 {
     if (edges == null)
     {
         throw new ArgumentNullException("edges");
     }
     this.enumerator = edges.GetEnumerator();
 }
Exemplo n.º 9
0
 private void Add(EdgeCollection edges, object edgeSet)
 {
     for (IEdgeEnumerator i = edges.GetEnumerator(); i.MoveNext();)
     {
         Edge edge = i.Current;
         Add(edge, edgeSet);
     }
 }
Exemplo n.º 10
0
 private void Add(EdgeCollection edges)
 {
     for (IEdgeEnumerator i = edges.GetEnumerator(); i.MoveNext();)
     {
         Edge edge = i.Current;
         // edge is its own group
         Add(edge, edge);
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Construct an enumerator over the out-edges
 /// </summary>
 /// <param name="vertexOutEdges">Out edge dictionary to iterate</param>
 /// <exception cref="ArgumentNullException">vertexOutEdges is null</exception>
 public VertexEdgesEnumerator(VertexEdgesDictionary vertexOutEdges)
 {
     if (vertexOutEdges == null)
     {
         throw new ArgumentNullException("vertexOutEdges");
     }
     VertexOutEdgeEnumerator = vertexOutEdges.GetEnumerator();
     OutEdgeEnumerator       = null;
 }
Exemplo n.º 12
0
        /// <summary>
        /// Returns the number of in-edges (for directed graphs) or the number
        /// of incident edges (for undirected graphs) of vertex v in graph g.
        /// </summary>
        /// <param name="v">vertex to test</param>
        /// <returns>out-degree</returns>
        public int InDegree(IVertex v)
        {
            IEdgeEnumerator en = InEdges(v).GetEnumerator();
            int             n  = 0;

            while (en.MoveNext())
            {
                ++n;
            }
            return(n);
        }
Exemplo n.º 13
0
        public ArrayList ComputeEdgeEnds(IEdgeEnumerator edges)
        {
            ArrayList l = new ArrayList();

            for (IEdgeEnumerator i = edges; i.MoveNext();)
            {
                Edge e = i.Current;
                ComputeEdgeEnds(e, l);
            }
            return(l);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Check that there is no ring which self-intersects (except of course at its endpoints).
 /// This is required by OGC topology rules (but not by other models
 /// such as ESRI SDE, which allow inverted shells and exverted holes).
 ///
 /// </summary>
 /// <param name="graph">the topology graph of the geometry
 /// </param>
 private void CheckNoSelfIntersectingRings(GeometryGraph graph)
 {
     for (IEdgeEnumerator i = graph.EdgeIterator; i.MoveNext();)
     {
         Edge e = i.Current;
         CheckNoSelfIntersectingRing(e.EdgeIntersectionList);
         if (validErr != null)
         {
             return;
         }
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// Processes isolated edges by computing their labelling and adding them
 /// to the isolated edges list.
 /// Isolated edges are guaranteed not to touch the boundary of the target
 /// (since if they did, they would have caused an intersection to be
 /// computed and hence would not be isolated)
 /// </summary>
 private void  LabelIsolatedEdges(int thisIndex, int targetIndex)
 {
     for (IEdgeEnumerator ei = arg[thisIndex].EdgeIterator; ei.MoveNext();)
     {
         Edge e = ei.Current;
         if (e.Isolated)
         {
             LabelIsolatedEdge(e, targetIndex, arg[targetIndex].Geometry);
             isolatedEdges.Add(e);
         }
     }
 }
Exemplo n.º 16
0
        /// <summary>
        /// Move the vertex iterator to the next vertex.
        /// </summary>
        /// <returns></returns>
        public bool MoveNextVertex()
        {
            // check if empty vertex set
            if (!VertexOutEdgeEnumerator.MoveNext())
            {
                OutEdgeEnumerator = null;
                return(false);
            }

            // getting enumerator
            OutEdgeEnumerator = ((EdgeCollection)((DictionaryEntry)VertexOutEdgeEnumerator.Current).Value).GetEnumerator();
            return(true);
        }
Exemplo n.º 17
0
        public override void ComputeIntersections(EdgeCollection edges0,
                                                  EdgeCollection edges1, SegmentIntersector si)
        {
            for (IEdgeEnumerator i0 = edges0.GetEnumerator(); i0.MoveNext();)
            {
                Edge edge0 = i0.Current;

                for (IEdgeEnumerator i1 = edges1.GetEnumerator(); i1.MoveNext();)
                {
                    Edge edge1 = i1.Current;
                    ComputeIntersects(edge0, edge1, si);
                }
            }
        }
Exemplo n.º 18
0
        private void AddSelfIntersectionNodes(int argIndex)
        {
            for (IEdgeEnumerator i = edges.GetEnumerator(); i.MoveNext();)
            {
                Edge e    = i.Current;
                int  eLoc = e.Label.GetLocation(argIndex);

                for (IEnumerator eiIt = e.eiList.Iterator(); eiIt.MoveNext();)
                {
                    EdgeIntersection ei = (EdgeIntersection)eiIt.Current;
                    AddSelfIntersectionNode(argIndex, ei.coord, eLoc);
                }
            }
        }
Exemplo n.º 19
0
        private IEdge SelectSingleOutEdgeNotInCircuit(IVertex v)
        {
            IEdgeEnumerable en  = this.SelectOutEdgesNotInCircuit(v);
            IEdgeEnumerator eor = en.GetEnumerator();

            if (!eor.MoveNext())
            {
                return(null);
            }
            else
            {
                return(eor.Current);
            }
        }
Exemplo n.º 20
0
 public override void ComputeIntersections(EdgeCollection edges, SegmentIntersector si, bool testAllSegments)
 {
     for (IEdgeEnumerator i0 = edges.GetEnumerator(); i0.MoveNext();)
     {
         Edge edge0 = i0.Current;
         for (IEdgeEnumerator i1 = edges.GetEnumerator(); i1.MoveNext();)
         {
             Edge edge1 = i1.Current;
             if (testAllSegments || edge0 != edge1)
             {
                 ComputeIntersects(edge0, edge1, si);
             }
         }
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// Update the IM with the sum of the IMs for each component.
        /// </summary>
        private void  UpdateIM(IntersectionMatrix im)
        {
            for (IEdgeEnumerator ei = isolatedEdges.GetEnumerator(); ei.MoveNext();)
            {
                Edge e = ei.Current;
                e.UpdateIM(im);
            }

            for (IEnumerator ni = nodes.Iterator(); ni.MoveNext();)
            {
                RelateNode node = (RelateNode)ni.Current;
                node.UpdateIM(im);

                node.updateIMFromEdges(im);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Returns the last edge of the edge collection
        /// </summary>
        /// <param name="edges">edge collection</param>
        /// <returns>last edge if any, otherwise a null reference</returns>
        public static IEdge LastEdge(IEdgeEnumerable edges)
        {
            if (edges == null)
            {
                throw new ArgumentNullException("edges");
            }
            IEdgeEnumerator en      = edges.GetEnumerator();
            IEdge           current = null;

            while (en.MoveNext())
            {
                current = en.Current;
            }

            return(current);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Returns the first edge of the graph
        /// </summary>
        /// <param name="edges">graph</param>
        /// <returns>first edge if any, otherwise a null reference</returns>
        public static IEdge FirstEdge(IEdgeEnumerable edges)
        {
            if (edges == null)
            {
                throw new ArgumentNullException("edges");
            }
            IEdgeEnumerator en = edges.GetEnumerator();

            if (!en.MoveNext())
            {
                return(null);
            }
            else
            {
                return(en.Current);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// For all edges, check if there are any intersections which are NOT at an endpoint.
        /// The Geometry is not simple if there are intersections not at endpoints.
        /// </summary>
        private bool HasNonEndpointIntersection(GeometryGraph graph)
        {
            for (IEdgeEnumerator i = graph.EdgeIterator; i.MoveNext();)
            {
                Edge e = i.Current;
                int  maxSegmentIndex = e.MaximumSegmentIndex;

                for (IEnumerator eiIt = e.EdgeIntersectionList.Iterator(); eiIt.MoveNext();)
                {
                    EdgeIntersection ei = (EdgeIntersection)eiIt.Current;
                    if (!ei.IsEndPoint(maxSegmentIndex))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Add a set of edges to the graph.  For each edge two DirectedEdges
        /// will be created.  DirectedEdges are NOT linked by this method.
        /// </summary>
        public void AddEdges(EdgeCollection edgesToAdd)
        {
            // create all the nodes for the edges
            for (IEdgeEnumerator it = edgesToAdd.GetEnumerator();
                 it.MoveNext();)
            {
                Edge e = it.Current;

                edges.Add(e);

                DirectedEdge de1 = new DirectedEdge(e, true);
                DirectedEdge de2 = new DirectedEdge(e, false);
                de1.Sym = de2;
                de2.Sym = de1;

                Add(de1);
                Add(de2);
            }
        }
Exemplo n.º 26
0
		/// <summary> 
		/// If edges which have undergone dimensional collapse are found,
		/// replace them with a new edge which is a L edge
		/// </summary>
		private void ReplaceCollapsedEdges()
		{
            EdgeCollection replacableEdges = new EdgeCollection();

			for (IEdgeEnumerator it = edgeList.Iterator(); it.MoveNext();)
			{
				Edge e = it.Current;
				if (e.IsCollapsed)
				{
                    replacableEdges.Add(e);
				}
			}

            int nCount = replacableEdges.Count;
            for (int i = 0; i < nCount; i++)
            {
                Edge e = replacableEdges[i];
                edgeList.Replace(e, e.CollapsedEdge);
            }
		}
Exemplo n.º 27
0
		/// <summary> 
		/// Update the labels for edges according to their depths.
		/// For each edge, the depths are first normalized.
		/// Then, if the depths for the edge are equal,
		/// this edge must have collapsed into a line edge.
		/// If the depths are not equal, update the label
		/// with the locations corresponding to the depths
		/// (i.e. a depth of 0 corresponds to a Location of EXTERIOR,
		/// a depth of 1 corresponds to INTERIOR)
		/// </summary>
		private void ComputeLabelsFromDepths()
		{
			for (IEdgeEnumerator it = edgeList.Iterator(); it.MoveNext(); )
			{
				Edge e    = it.Current;
				Label lbl = e.Label;
				Depth depth = e.Depth;
				// Only check edges for which there were duplicates,
				// since these are the only ones which might
				// be the result of dimensional collapses.
				if (!depth.IsNull())
				{
					depth.Normalize();
					for (int i = 0; i < 2; i++)
					{
						if (!lbl.IsNull(i) && lbl.IsArea() && !depth.IsNull(i))
						{
							// if the depths are equal, this edge is the result of
							// the dimensional collapse of two or more edges.
							// It has the same location on both sides of the edge,
							// so it has collapsed to a line.
							if (depth.GetDelta(i) == 0)
							{
								lbl.ToLine(i);
							}
							else
							{
								// This edge may be the result of a dimensional collapse,
								// but it still has different locations on both sides.  The
								// label of the edge must be updated to reflect the resultant
								// side locations indicated by the depth values.
								Debug.Assert(!depth.IsNull(i, Position.Left), "depth of LEFT side has not been initialized");
								lbl.SetLocation(i, Position.Left, depth.GetLocation(i, Position.Left));
								Debug.Assert(!depth.IsNull(i, Position.Right), "depth of RIGHT side has not been initialized");
								lbl.SetLocation(i, Position.Right, depth.GetLocation(i, Position.Right));
							}
						}
					}
				}
			}
		}
Exemplo n.º 28
0
        private ArrayList TopoSortAdjVertices(IVertex v, IIncidenceGraph g, VertexIntDictionary topo_ordering)
        //	return adjacent vertices to "v" sorted in topological order
        {
            IEdgeEnumerator it    = g.OutEdges(v).GetEnumerator();
            bool            valid = false;
            ArrayList       adj   = new ArrayList();

            while (it.MoveNext())
            {
                valid = true;
                adj.Add(it.Current.Target);
            }
            if (!valid)                         // no outgoing edges
            {
                return(adj);
            }
            CompareTopo ctopo = new CompareTopo(topo_ordering);
            SwapTopo    stopo = new SwapTopo();
            QuickSorter qs    = new QuickSorter(ctopo, stopo);

            qs.Sort(adj);
            return(adj);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Sets the enumerator to its initial position,
 /// which is before the first element in the collection.
 /// </summary>
 public void Reset()
 {
     VertexOutEdgeEnumerator.Reset();
     OutEdgeEnumerator = null;
 }
 /// <summary>
 /// Sets the enumerator to its initial position, 
 /// which is before the first element in the collection.
 /// </summary>
 public void Reset()
 {
     VertexOutEdgeEnumerator.Reset();
     OutEdgeEnumerator=null;
 }
        /// <summary>
        /// Move the vertex iterator to the next vertex.
        /// </summary>
        /// <returns></returns>
        public bool MoveNextVertex()
        {
            // check if empty vertex set
            if (!VertexOutEdgeEnumerator.MoveNext())
            {
                OutEdgeEnumerator=null;
                return false;
            }

            // getting enumerator
            OutEdgeEnumerator = ((EdgeCollection)((DictionaryEntry)VertexOutEdgeEnumerator.Current).Value).GetEnumerator();
            return true;
        }
Exemplo n.º 32
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 /// <param name="p"></param>
 public Enumerator(IEdgeEnumerator e, IEdgePredicate p)
 {
     m_Enumerator = e;
     m_Predicate  = p;
 }
 public ReversedEdgeEnumerator(IEdgeEnumerator enumerator)
 {
     if (enumerator == null)
         throw new ArgumentNullException("enumerator");
     this.wrapped = enumerator;
 }
Exemplo n.º 34
0
			/// <summary>
			/// 
			/// </summary>
			/// <param name="e"></param>
			/// <param name="p"></param>
			public Enumerator(IEdgeEnumerator e, IEdgePredicate p)
			{
				m_Enumerator = e;
				m_Predicate = p;
			}
Exemplo n.º 35
0
 public DataTableVertexDataRelationEdgeCollectionEdgeEnumerator(IEnumerable en)
 {
     Debug.Assert(en!=null);
     this.edges = en.GetEnumerator();
     this.edge = null;
 }
Exemplo n.º 36
0
 public void Reset()
 {
     this.edges.Reset();
     this.edge=null;
 }
Exemplo n.º 37
0
                    private bool moveNextVertex()
                    {
                        // check if empty vertex set
                        if (!this.edges.MoveNext())
                        {
                            this.edges=null;
                            return false;
                        }

                        // getting enumerator
                        this.edge = ((DataRelationEdgeCollection)this.edges.Current).GetEnumerator();
                        return true;
                    }
 public TargetVertexEnumerator(IEdgeEnumerable edges)
 {
     if (edges==null)
         throw new ArgumentNullException("edges");
     this.enumerator = edges.GetEnumerator();
 }
Exemplo n.º 39
0
 public Face()
 {
     m_Points         = new List <Vector3>(10);
     m_PointIndicies  = new List <int>(10);
     m_LoopEnumerator = new EdgeLoopEnumerator();
 }