/// <summary> /// Initializes a new instance of the BufferOp class. /// </summary> /// <param name="g0"></param> public BufferOp(Geometry g0) : base(g0) { _graph = new PlanarGraph(new OverlayNodeFactory()); _geomFact = new GeometryFactory( g0.PrecisionModel, g0.GetSRID() ); }
} // public PolygonBuilder( GeometryFactory geometryFactory, CGAlgorithms cga ) #endregion #region Properties #endregion #region Methods /// <summary> /// Add a complete graph. /// The graph is assumed to contain one or more polygons, /// possibly with holes. /// </summary> /// <param name="graph"></param> public void Add( PlanarGraph graph ) { ArrayList nodes = new ArrayList(); foreach( DictionaryEntry entry in graph.Nodes.NodeList ) { Node node = (Node) entry.Value; nodes.Add( node ); } Add( graph.EdgeEnds, nodes ); } // public void Add( PlanarGraph graph )
public OverlayOp( Geometry g0, Geometry g1 ) : base( g0, g1 ) { _graph = new PlanarGraph( new OverlayNodeFactory() ); _geomFact = new GeometryFactory( g0.PrecisionModel, g0.GetSRID() ); } // public OverlayOp( Geometry g0, Geometry g1 ) : base( g0, g1 )
public bool IsInteriorsConnected() { // node the edges, in case holes touch the shell ArrayList splitEdges = new ArrayList(); _geomGraph.ComputeSplitEdges(splitEdges); // polygonize the edges PlanarGraph graph = new PlanarGraph(new OverlayNodeFactory()); graph.AddEdges(splitEdges); SetAllEdgesInResult(graph); graph.LinkAllDirectedEdges(); ArrayList edgeRings = buildEdgeRings(graph.EdgeEnds); /** * Mark all the edges for the edgeRings corresponding to the shells * of the input polygons. Note only ONE ring gets marked for each shell. */ VisitShellInteriors(_geomGraph.Geometry, graph); /** * If there are any unvisited shell edges * (i.e. a ring which is not a hole and which has the interior * of the parent area on the RHS) * this means that one or more holes must have split the interior of the * polygon into at least two pieces. The polygon is thus invalid. */ return ! HasUnvisitedShellEdge(edgeRings); }
private void VisitInteriorRing(ILineString iring, PlanarGraph graph) { LineString ring = (LineString)iring; Coordinates pts = ring.GetCoordinates(); Edge e = graph.FindEdgeInSameDirection(pts[0], pts[1]); DirectedEdge de = (DirectedEdge) graph.FindEdgeEnd(e); DirectedEdge intDe = null; if (de.Label.GetLocation(0, Position.Right) == Location.Interior) { intDe = de; } else if (de.Sym.Label.GetLocation(0, Position.Right) == Location.Interior) { intDe = de.Sym; } //Assert.isTrue(intDe != null, "unable to find dirEdge with Interior on RHS"); VisitLinkedDirectedEdges(intDe); }
/// <summary> /// Mark all the edges for the edgeRings corresponding to the shells /// of the input polygons. Note only ONE ring gets marked for each shell. /// </summary> /// <param name="g"></param> /// <param name="graph"></param> private void VisitShellInteriors(Geometry g, PlanarGraph graph) { if (g is Polygon) { Polygon p = (Polygon) g; this.VisitInteriorRing(p.GetExteriorRing(), graph); } if (g is MultiPolygon) { MultiPolygon mp = (MultiPolygon) g; for (int i = 0; i < mp.GetNumGeometries(); i++) { Polygon p = (Polygon) mp.GetGeometryN(i); this.VisitInteriorRing(p.GetExteriorRing(), graph); } } }
private void SetAllEdgesInResult(PlanarGraph graph) { foreach( object obj in graph.EdgeEnds) { DirectedEdge de = (DirectedEdge) obj; de.InResult=true; } }