/// <summary> /// Update the IM with the contribution for the EdgeStubs around the node. /// </summary> /// <param name="im"></param> public virtual void UpdateIM(IntersectionMatrix im) { for (IEnumerator it = GetEnumerator(); it.MoveNext(); ) { EdgeEndBundle esb = (EdgeEndBundle) it.Current; esb.UpdateIM(im); } }
private int _depthDelta; // the change in area depth from the R to Curve side of this edge /// <summary> /// Updates an IM from the label for an edge. /// Handles edges from both L and A geometries. /// </summary> /// <param name="im"></param> /// <param name="label"></param> public static void UpdateIM(Label label, IntersectionMatrix im) { im.SetAtLeastIfValid(label.GetLocation(0, Positions.On), label.GetLocation(1, Positions.On), Dimensions.Curve); if (label.IsArea()) { im.SetAtLeastIfValid(label.GetLocation(0, Positions.Left), label.GetLocation(1, Positions.Left), Dimensions.Surface); im.SetAtLeastIfValid(label.GetLocation(0, Positions.Right), label.GetLocation(1, Positions.Right), Dimensions.Surface); } }
/// <summary> /// Creates an <c>IntersectionMatrix</c> with the same elements as /// <c>other</c>. /// </summary> /// <param name="other">An <c>IntersectionMatrix</c> to copy.</param> public IntersectionMatrix(IntersectionMatrix other) : this() { matrix[(int)Locations.Interior,(int)Locations.Interior] = other.matrix[(int)Locations.Interior,(int)Locations.Interior]; matrix[(int)Locations.Interior,(int)Locations.Boundary] = other.matrix[(int)Locations.Interior,(int)Locations.Boundary]; matrix[(int)Locations.Interior,(int)Locations.Exterior] = other.matrix[(int)Locations.Interior,(int)Locations.Exterior]; matrix[(int)Locations.Boundary,(int)Locations.Interior] = other.matrix[(int)Locations.Boundary,(int)Locations.Interior]; matrix[(int)Locations.Boundary,(int)Locations.Boundary] = other.matrix[(int)Locations.Boundary,(int)Locations.Boundary]; matrix[(int)Locations.Boundary,(int)Locations.Exterior] = other.matrix[(int)Locations.Boundary,(int)Locations.Exterior]; matrix[(int)Locations.Exterior,(int)Locations.Interior] = other.matrix[(int)Locations.Exterior,(int)Locations.Interior]; matrix[(int)Locations.Exterior,(int)Locations.Boundary] = other.matrix[(int)Locations.Exterior,(int)Locations.Boundary]; matrix[(int)Locations.Exterior,(int)Locations.Exterior] = other.matrix[(int)Locations.Exterior,(int)Locations.Exterior]; }
/// <summary> /// Update the IM with the contribution for this component. /// A component only contributes if it has a labelling for both parent geometries. /// </summary> /// <param name="im"></param> public override void ComputeIM(IntersectionMatrix im) { UpdateIM(Label, im); }
/// <summary> /// Update the IM with the contribution for the EdgeEnds incident on this node. /// </summary> /// <param name="im"></param> public virtual void UpdateIMFromEdges(IntersectionMatrix im) { ((EdgeEndBundleStar) Edges).UpdateIM(im); }
/// <summary> /// Update the IM with the contribution for this component. /// A component only contributes if it has a labelling for both parent geometries. /// </summary> public override void ComputeIM(IntersectionMatrix im) { im.SetAtLeastIfValid(Label.GetLocation(0), Label.GetLocation(1), Dimensions.Point); }
/// <summary> /// /// </summary> /// <returns></returns> public virtual 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; }
/// <summary> /// Update the IM with the sum of the IMs for each component. /// </summary> /// <param name="im"></param> private void UpdateIM(IntersectionMatrix im) { for (IEnumerator ei = isolatedEdges.GetEnumerator(); ei.MoveNext(); ) { Edge e = (Edge)ei.Current; e.UpdateIM(im); } for (IEnumerator ni = nodes.GetEnumerator(); ni.MoveNext(); ) { RelateNode node = (RelateNode)ni.Current; node.UpdateIM(im); node.UpdateIMFromEdges(im); } }
/// <summary> /// If the Geometries are disjoint, we need to enter their dimension and /// boundary dimension in the Ext rows in the IM /// </summary> /// <param name="im"></param> private void ComputeDisjointIM(IntersectionMatrix im) { IGeometry ga = arg[0].Geometry; if (!ga.IsEmpty) { im.Set(Locations.Interior, Locations.Exterior, ga.Dimension); im.Set(Locations.Boundary, Locations.Exterior, ga.BoundaryDimension); } IGeometry gb = arg[1].Geometry; if (!gb.IsEmpty) { im.Set(Locations.Exterior, Locations.Interior, gb.Dimension); im.Set(Locations.Exterior, Locations.Boundary, gb.BoundaryDimension); } }
/// <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"); } }
/// <summary> /// Update the IM with the contribution for this component. /// A component only contributes if it has a labelling for both parent geometries. /// </summary> /// <param name="im"></param> public virtual void UpdateIM(IntersectionMatrix im) { Assert.IsTrue(Label.GeometryCount >= 2, "found partial label"); ComputeIM(im); }
/// <summary> /// Compute the contribution to an IM for this component. /// </summary> abstract public void ComputeIM(IntersectionMatrix im);
/// <summary> /// Update the IM with the contribution for the computed label for the EdgeStubs. /// </summary> /// <param name="im"></param> public virtual void UpdateIM(IntersectionMatrix im) { Edge.UpdateIM(Label, im); }
/// <summary> /// Returns true if each of the actual dimension symbols satisfies the /// corresponding required dimension symbol. /// </summary> /// <param name="actualDimensionSymbols"> /// Nine dimension symbols to validate. /// Possible values are <c>T, F, * , 0, 1, 2</c>. /// </param> /// <param name="requiredDimensionSymbols"> /// Nine dimension symbols to validate /// against. Possible values are <c>T, F, * , 0, 1, 2</c>. /// </param> /// <returns> /// True if each of the required dimension /// symbols encompass the corresponding actual dimension symbol. /// </returns> public static bool Matches(string actualDimensionSymbols, string requiredDimensionSymbols) { IntersectionMatrix m = new IntersectionMatrix(actualDimensionSymbols); return m.Matches(requiredDimensionSymbols); }
/// <summary> /// Basic nodes do not compute IMs. /// </summary> /// <param name="im"></param> public override void ComputeIM(IntersectionMatrix im) { }