private void addPolygon(PlanarGraph graph, OverlayType operation, Polygon p1, Polygon p2, Collection<IGeometry> collection) { foreach (PlanarGraphEdge edge in graph.Edges) { edge.IsVisited = false; edge.Enabled = isAreaEdgeEnabled(edge, operation, p1, p2); } foreach (PlanarGraphNode node in graph.Nodes) node.Layout = PlanarGraphNode.NodeLayout.Unknown; Polygon polygon = graph.BuildPolygon(false, false); if (polygon.CoordinateCount > 0) collection.Add(polygon); }
private void addPoints(PlanarGraph graph, OverlayType operation, Polygon p1, Polygon p2, Collection<IGeometry> collection) { foreach (PlanarGraphNode node in graph.Nodes) node.Enabled = isNodeEnabled(node, operation, p1, p2); List<PointD> points = graph.BuildPoints(); foreach (PointD p in points) collection.Add(p); }
private void addPolyline(PlanarGraph graph, OverlayType operation, Polygon p1, Polygon p2, Collection<IGeometry> collection) { foreach (PlanarGraphEdge edge in graph.Edges) { edge.IsVisited = false; edge.Enabled = isLinearEdgeEnabled(edge, operation, p1, p2); } Polyline polyline = graph.BuildPolyline(false, false); if (polyline.CoordinateCount > 0) collection.Add(polyline); }
/// <summary> /// Builds a planar graph of two geometries. /// </summary> /// <param name="geometry1">First geometry</param> /// <param name="geometry2">Second geometry</param> /// <param name="gridOrigin">Snapping grid origin</param> /// <returns>Planar graph of two geometries</returns> public static PlanarGraph BuildWithSnap(IGeometry geometry1, IGeometry geometry2, ICoordinate gridOrigin) { PlanarGraph graph = new PlanarGraph(); graph._gridOrigin = gridOrigin; graph._performSnapping = true; graph.internalBuild(geometry1, geometry2); return graph; }
/// <summary> /// Builds a planar graph of two geometries. /// </summary> /// <param name="geometry1">First geometry</param> /// <param name="geometry2">Second geometry</param> /// <returns>Planar graph of two geometries</returns> public static PlanarGraph Build(IGeometry geometry1, IGeometry geometry2) { PlanarGraph graph = new PlanarGraph(); graph.internalBuild(geometry1, geometry2); return graph; }
private void buildGraph() { try { _graph = PlanarGraph.Build(_sourceGeometry1, _sourceGeometry2); } catch(Exception ex) { if (ex is TopologyException || ex is InvalidOperationException) { List<ICoordinate> points = new List<ICoordinate>(); foreach (ICoordinate p in _sourceGeometry1.ExtractCoordinates()) points.Add(p); foreach (ICoordinate p in _sourceGeometry2.ExtractCoordinates()) points.Add(p); ICoordinate center = PlanimetryAlgorithms.GetCentroid(points); _sourceGeometry1 = snapGeometryPoints(_sourceGeometry1, center); _sourceGeometry2 = snapGeometryPoints(_sourceGeometry2,center); _graph = PlanarGraph.BuildWithSnap(_sourceGeometry1, _sourceGeometry2, center); } else throw; } }
/// <summary> /// Calculates an intersection matrix for two geometries. /// </summary> /// <param name="geometry1">First geometry</param> /// <param name="geometry2">Second geometry</param> public void Calculate(IGeometry geometry1, IGeometry geometry2) { checkGeometry(geometry1); checkGeometry(geometry2); _graph = null; initSourceGeometries(geometry1, geometry2); getDimensionPair(); calculateValues(); }
/// <summary> /// Calculates a specified elements of intersection matrix /// for two geometries. /// </summary> /// <param name="geometry1">First geometry</param> /// <param name="geometry2">Second geometry</param> /// <param name="template">String template of intersection matrix /// Will be calculated all the elements that do not correspond to the symbol '*'.</param> public void CalculatePartial(IGeometry geometry1, IGeometry geometry2, string template) { checkGeometry(geometry1); checkGeometry(geometry2); if(template.Length != 9) throw new ArgumentException("Intersection matrix template should be 9-character string", "template"); _graph = null; initSourceGeometries(geometry1, geometry2); getDimensionPair(); calculateValuesPartial(template); }