/// <summary> /// Initializes a new instance of the <see cref="SegmentIntersection"/> class. /// </summary> /// <param name="edgeA">The edge a.</param> /// <param name="edgeB">The edge b.</param> /// <param name="intersectionPoint">The intersection point.</param> /// <param name="relationship">The relationship.</param> internal SegmentIntersection(PolygonEdge edgeA, PolygonEdge edgeB, Vector2 intersectionPoint, SegmentRelationship relationship, WhereIsIntersection whereIsIntersection, CollinearityTypes collinearity) { this.EdgeA = edgeA; this.EdgeB = edgeB; this.IntersectCoordinates = intersectionPoint; this.Relationship = relationship; this.WhereIntersection = whereIsIntersection; this.CollinearityType = collinearity; VisitedA = false; VisitedB = false; }
private void MakeThisPolygonsEdges() { var numPoints = Vertices.Count; _edges = new PolygonEdge[numPoints]; for (int i = 0, j = numPoints - 1; i < numPoints; j = i++) // note this compact approach to setting i and j. { var fromNode = Vertices[j]; var toNode = Vertices[i]; var polySegment = new PolygonEdge(fromNode, toNode); fromNode.StartLine = polySegment; toNode.EndLine = polySegment; _edges[i] = polySegment; } }
/// <summary> /// Determines whether [is adjacent to] [the specified other]. That is, do they share an endpoint or not. /// </summary> /// <param name="other">The other.</param> /// <returns><c>true</c> if [is adjacent to] [the specified other]; otherwise, <c>false</c>.</returns> public bool IsAdjacentTo(PolygonEdge other) { return(FromPoint == other.ToPoint || ToPoint == other.FromPoint); }
protected override bool PolygonCompleted(SegmentIntersection currentIntersection, SegmentIntersection startingIntersection, PolygonEdge currentEdge, PolygonEdge startingEdge) { if (startingIntersection != currentIntersection) { return(false); } if (startingIntersection.Relationship == SegmentRelationship.DoubleOverlap && startingIntersection.CollinearityType == CollinearityTypes.None) { return(currentEdge == startingEdge); } return(true); }
protected override bool ValidStartingIntersection(SegmentIntersection intersectionData, out PolygonEdge currentEdge, out bool startAgain) { startAgain = false; if (intersectionData.Relationship == SegmentRelationship.DoubleOverlap) { if (intersectionData.CollinearityType == CollinearityTypes.ABeforeBAfter && !intersectionData.VisitedA && !intersectionData.VisitedB) { currentEdge = intersectionData.EdgeB; return(true); } if (intersectionData.CollinearityType == CollinearityTypes.AAfterBBefore && !intersectionData.VisitedA && !intersectionData.VisitedB) { currentEdge = intersectionData.EdgeA; return(true); } if (intersectionData.CollinearityType == CollinearityTypes.None) { startAgain = !(intersectionData.VisitedB || intersectionData.VisitedA); if (!intersectionData.VisitedA) { currentEdge = intersectionData.EdgeA; return(true); } if (!intersectionData.VisitedB) { currentEdge = intersectionData.EdgeB; return(true); } } } if (intersectionData.VisitedB || intersectionData.VisitedA) { currentEdge = null; return(false); } if (intersectionData.Relationship == SegmentRelationship.AEnclosesB && !intersectionData.VisitedB) { currentEdge = intersectionData.EdgeB; return(true); } if (intersectionData.Relationship == SegmentRelationship.BEnclosesA && !intersectionData.VisitedA) { currentEdge = intersectionData.EdgeA; return(true); } if (intersectionData.Relationship == SegmentRelationship.CrossOver_AOutsideAfter && !intersectionData.VisitedA) { currentEdge = intersectionData.EdgeA; return(true); } if (intersectionData.Relationship == SegmentRelationship.CrossOver_BOutsideAfter && !intersectionData.VisitedB) { currentEdge = intersectionData.EdgeB; return(true); } currentEdge = null; return(false); }