/// <summary> Add an EdgeIntersection for intersection intIndex. /// An intersection that falls exactly on a vertex of the edge is normalized /// to use the higher of the two possible segmentIndexes /// </summary> public void AddIntersection(LineIntersector li, int segmentIndex, int geomIndex, int intIndex) { Coordinate intPt = new Coordinate(li.GetIntersection(intIndex)); int normalizedSegmentIndex = segmentIndex; double dist = li.GetEdgeDistance(geomIndex, intIndex); // Normalize the intersection point location int nextSegIndex = normalizedSegmentIndex + 1; if (nextSegIndex < pts.Count) { Coordinate nextPt = pts[nextSegIndex]; // Normalize segment index if intPt falls on vertex // The check for point equality is 2D only - Z values are ignored if (intPt.Equals(nextPt)) { normalizedSegmentIndex = nextSegIndex; dist = 0.0; } } // Add the intersection point to edge intersection list. // EdgeIntersection ei = eiList.Add(intPt, normalizedSegmentIndex, dist); eiList.Add(intPt, normalizedSegmentIndex, dist); }
/// <summary> /// Adds EdgeIntersections for one or both /// intersections found for a segment of an edge to the edge intersection list. /// </summary> /// <param name="li"></param> /// <param name="segmentIndex"></param> /// <param name="geomIndex"></param> public void AddIntersections(LineIntersector li, int segmentIndex, int geomIndex) { for (int i = 0; i < li.IntersectionNum; i++) { AddIntersection(li, segmentIndex, geomIndex, i); } }
/// <summary> /// Creates a new tester for consistent areas. /// </summary> /// <param name="geomGraph"> /// The topology graph of the area geometry /// </param> public ConsistentAreaTester(GeometryGraph geomGraph) { li = new RobustLineIntersector(); nodeGraph = new RelateNodeGraph(); this.geomGraph = geomGraph; }
internal GeometryGraph[] arg; // the arg(s) of the operation #endregion #region Constructors and Destructor protected GraphGeometryOp(Geometry g0, Geometry g1) { if (g0 == null) { throw new ArgumentNullException("g0"); } if (g1 == null) { throw new ArgumentNullException("g1"); } li = new RobustLineIntersector(); // use the most precise model for the result if (g0.PrecisionModel.CompareTo(g1.PrecisionModel) >= 0) { ComputationPrecision = g0.PrecisionModel; } else { ComputationPrecision = g1.PrecisionModel; } arg = new GeometryGraph[2]; arg[0] = new GeometryGraph(0, g0); arg[1] = new GeometryGraph(1, g1); }
/// <summary> /// /// </summary> /// <param name="segStrings"></param> /// <param name="li"></param> private void SnapRound(IList segStrings, LineIntersector li) { IList intersections = FindInteriorIntersections(segStrings, li); ComputeSnaps(segStrings, intersections); ComputeVertexSnaps(segStrings); }
/// <summary> /// Initializes a new instance of the <see cref="SimpleSnapRounder"/> class. /// </summary> /// <param name="pm">The <see cref="PrecisionModel" /> to use.</param> public SimpleSnapRounder(PrecisionModel pm) { _li = new RobustLineIntersector { PrecisionModel = pm }; _scaleFactor = pm.Scale; }
public BufferEdgeBuilder(CGAlgorithms cga, LineIntersector li, double distance, bool makePrecise, int quadrantSegments) { this._cga = cga; this._distance = distance; //lineBuilder = new BufferMultiLineBuilder(cga, li); _lineBuilder = new BufferLineBuilder(_cga, li, makePrecise, quadrantSegments); }
///<summary> /// Creates an intersection finder which finds all interior intersections. /// The intersections are recorded for later inspection. ///</summary> /// <param name="li">A line intersector.</param> /// <returns>a intersection finder which finds all interior intersections.</returns> public static InteriorIntersectionFinder CreateAllIntersectionsFinder(LineIntersector li) { InteriorIntersectionFinder finder = new InteriorIntersectionFinder(li); finder.FindAllIntersections = true; return(finder); }
/// <summary> /// /// </summary> /// <param name="segStrings"></param> /// <param name="li"></param> private void SnapRound(IList <ISegmentString> segStrings, LineIntersector li) { IList <Coordinate> intersections = FindInteriorIntersections(segStrings, li); ComputeSnaps(segStrings, intersections); ComputeVertexSnaps(segStrings); }
/// <summary> /// Creates an intersection finder which finds all interior intersections. /// The intersections are recorded for later inspection. /// </summary> /// <param name="li">A line intersector.</param> /// <returns>a intersection finder which finds all interior intersections.</returns> public static NodingIntersectionFinder CreateAllIntersectionsFinder(LineIntersector li) { var finder = new NodingIntersectionFinder(li); finder.FindAllIntersections = true; return(finder); }
/// <summary> Add an SegmentNode for intersection intIndex. /// An intersection that falls exactly on a vertex /// of the SegmentString is normalized /// to use the higher of the two possible segmentIndexes /// </summary> public void AddIntersection(LineIntersector li, int segmentIndex, int geomIndex, int intIndex) { Coordinate intPt = new Coordinate(li.GetIntersection(intIndex)); AddIntersection(intPt, segmentIndex); }
public MCIndexSnapRounder(PrecisionModel pm) { this.pm = pm; this.scaleFactor = pm.Scale; li = new RobustLineIntersector(); li.PrecisionModel = pm; }
///<summary> /// Creates an intersection finder which counts all interior intersections. /// The intersections are note recorded to reduce memory usage. ///</summary> /// <param name="li">A line intersector.</param> /// <returns>a intersection finder which counts all interior intersections.</returns> public static InteriorIntersectionFinder CreateIntersectionCounter(LineIntersector li) { var finder = new InteriorIntersectionFinder(li); finder.FindAllIntersections = true; finder.KeepIntersections = false; return(finder); }
/// <summary> /// Computes all interior intersections in the collection of <see cref="SegmentString" />s, /// and returns their <see cref="Coordinate" />s. /// Does NOT node the segStrings. /// </summary> /// <param name="segStrings"></param> /// <param name="li"></param> /// <returns>A list of <see cref="Coordinate" />s for the intersections.</returns> private IList FindInteriorIntersections(IList segStrings, LineIntersector li) { IntersectionFinderAdder intFinderAdder = new IntersectionFinderAdder(li); SinglePassNoder noder = new MCIndexNoder(intFinderAdder); noder.ComputeNodes(segStrings); return(intFinderAdder.InteriorIntersections); }
/// <summary> /// Computes all interior intersections in the collection of <see cref="SegmentString" />s, /// and returns their <see cref="Coordinate" />s. /// /// Does NOT node the segStrings. /// </summary> /// <param name="segStrings"></param> /// <param name="li"></param> /// <returns>A list of Coordinates for the intersections.</returns> private IList FindInteriorIntersections(IList segStrings, LineIntersector li) { IntersectionFinderAdder intFinderAdder = new IntersectionFinderAdder(li); _noder.SegmentIntersector = intFinderAdder; _noder.ComputeNodes(segStrings); return(intFinderAdder.InteriorIntersections); }
public RelateComputer(GeometryGraph[] arg) { li = new RobustLineIntersector(); ptLocator = new PointLocator(); nodes = new NodeMap(new RelateNodeFactory()); isolatedEdges = new EdgeCollection(); this.arg = arg; }
/// <summary> /// /// </summary> /// <param name="g"></param> /// <param name="li"></param> /// <param name="includeProper"></param> /// <returns></returns> public SegmentIntersector ComputeEdgeIntersections(GeometryGraph g, LineIntersector li, bool includeProper) { SegmentIntersector si = new SegmentIntersector(li, includeProper, true); si.SetBoundaryNodes(BoundaryNodes, g.BoundaryNodes); EdgeSetIntersector esi = CreateEdgeSetIntersector(); esi.ComputeIntersections(Edges, g.Edges, si); return si; }
} // public void AddPoint(Coordinate pt) /// <summary> /// /// </summary> /// <param name="li"></param> /// <returns></returns> public SegmentIntersector ComputeSelfNodes(LineIntersector li) { SegmentIntersector si = new SegmentIntersector(li, true, false); //EdgeSetIntersector esi = new MCQuadIntersector(); _edgeSetIntersector.ComputeIntersections(_edges, si); //Trace.WriteLine( "SegmentIntersector # tests = " + si._numTests ); AddSelfIntersectionNodes(_argIndex); return(si); } // public SegmentIntersector computeSelfNodes(LineIntersector li)
public BufferLineBuilder(CGAlgorithms _cga, LineIntersector li, bool makePrecise, int quadrantSegments) { this._cga = _cga; this._li = li; this._makePrecise = makePrecise; _angleInc = Math.PI / 2.0 / quadrantSegments; _lineList = new ArrayList(); // ensure array has exactly one element _lineList.Add(arrayTypeCoordinate); }
/// <summary> /// /// </summary> /// <param name="precisionModel"></param> /// <param name="quadrantSegments"></param> public OffsetCurveBuilder(PrecisionModel precisionModel, int quadrantSegments) { this.precisionModel = precisionModel; // compute intersections in full precision, to provide accuracy // the points are rounded as they are inserted into the curve line li = new RobustLineIntersector(); int limitedQuadSegs = quadrantSegments < 1 ? 1 : quadrantSegments; filletAngleQuantum = Math.PI / 2.0 / limitedQuadSegs; }
/// <summary> /// /// </summary> /// <param name="li"></param> /// <param name="bdyNodes"></param> /// <returns></returns> private static bool IsBoundaryPoint(LineIntersector li, IEnumerable <Node> bdyNodes) { foreach (Node node in bdyNodes) { Coordinate pt = node.Coordinate; if (li.IsIntersection(pt)) { return(true); } } return(false); }
/// <summary> /// Compute self-nodes, taking advantage of the Geometry type to /// minimize the number of intersection tests. (E.g. rings are /// not tested for self-intersection, since they are assumed to be valid). /// </summary> /// <param name="li">The <c>LineIntersector</c> to use.</param> /// <param name="computeRingSelfNodes">If <c>false</c>, intersection checks are optimized to not test rings for self-intersection.</param> /// <returns>The SegmentIntersector used, containing information about the intersections found.</returns> public SegmentIntersector ComputeSelfNodes(LineIntersector li, bool computeRingSelfNodes) { SegmentIntersector si = new SegmentIntersector(li, true, false); EdgeSetIntersector esi = CreateEdgeSetIntersector(); // optimized test for Polygons and Rings if (!computeRingSelfNodes && (_parentGeom is ILinearRing || _parentGeom is IPolygon || _parentGeom is IMultiPolygon)) esi.ComputeIntersections(Edges, si, false); else esi.ComputeIntersections(Edges, si, true); AddSelfIntersectionNodes(_argIndex); return si; }
/// <returns> true if there is an intersection point which is not an endpoint of the segment p0-p1 /// </returns> private bool HasInteriorIntersection(LineIntersector li, Coordinate p0, Coordinate p1) { for (int i = 0; i < li.IntersectionNum; i++) { Coordinate intPt = li.GetIntersection(i); if (!(intPt.Equals(p0) || intPt.Equals(p1))) { return(true); } } return(false); }
private void Exercise(LineIntersector lineIntersector) { Console.WriteLine(lineIntersector.GetType().Name); var sw = new Stopwatch(); sw.Start(); for (int i = 0; i < 1000000; i++) { ExerciseOnce(lineIntersector); } sw.Stop(); Console.WriteLine($"Milliseconds elapsed: {sw.ElapsedMilliseconds}"); }
private bool IsBoundaryPoint(LineIntersector li, NodeCollection bdyNodes) { for (INodeEnumerator i = bdyNodes.GetEnumerator(); i.MoveNext();) { Node node = i.Current; Coordinate pt = node.Coordinate; if (li.IsIntersection(pt)) { return(true); } } return(false); }
/// <summary> /// /// </summary> /// <param name="li"></param> /// <param name="bdyNodes"></param> /// <returns></returns> private static bool IsBoundaryPoint(LineIntersector li, IEnumerable bdyNodes) { for (IEnumerator i = bdyNodes.GetEnumerator(); i.MoveNext();) { Node node = (Node)i.Current; Coordinate pt = node.Coordinate; if (li.IsIntersection(pt)) { return(true); } } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="HotPixel"/> class. /// </summary> /// <param name="pt"></param> /// <param name="scaleFactor"></param> /// <param name="li"></param> public HotPixel(ICoordinate pt, double scaleFactor, LineIntersector li) { originalPt = pt; this.pt = pt; this.scaleFactor = scaleFactor; this.li = li; if (scaleFactor != 1.0) { this.pt = new Coordinate(Scale(pt.X), Scale(pt.Y)); p0Scaled = new Coordinate(); p1Scaled = new Coordinate(); } InitCorners(this.pt); }
/// <summary> /// Initializes a new instance of the <see cref="HotPixel"/> class. /// </summary> /// <param name="pt"></param> /// <param name="scaleFactor"></param> /// <param name="li"></param> public HotPixel(Coordinate pt, double scaleFactor, LineIntersector li) { _originalPt = pt; _pt = pt; _scaleFactor = scaleFactor; _li = li; if (scaleFactor != 1.0) { _pt = new Coordinate(Scale(pt.X), Scale(pt.Y)); _p0Scaled = new Coordinate(); _p1Scaled = new Coordinate(); } InitCorners(_pt); }
protected GraphGeometryOp(Geometry g0) { if (g0 == null) { throw new ArgumentNullException("g0"); } li = new RobustLineIntersector(); ComputationPrecision = g0.PrecisionModel; arg = new GeometryGraph[1]; arg[0] = new GeometryGraph(0, g0);; }
} // private bool IsBoundaryPoint(LineIntersector lineIntersector, ArrayList[] bdyNodes) private bool IsBoundaryPoint(LineIntersector lineIntersector, ArrayList bdyNodes) { //int i = lineIntersector.GetHashCode(); //int j = _lineIntersector.GetHashCode(); foreach (object objectNode in bdyNodes) { Node node = (Node)objectNode; Coordinate pt = node.Coordinate; if (lineIntersector.IsIntersection(pt)) { return(true); } } return(false); } // private bool IsBoundaryPoint(LineIntersector lineIntersector, ArrayList bdyNodes)