/// <summary>
 ///
 /// </summary>
 /// <param name="precisionModel"></param>
 /// <param name="quadrantSegments"></param>
 public OffsetCurveBuilder(PrecisionModel precisionModel, int quadrantSegments)
 {
     _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;
 }
Example #2
0
 /// <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);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="segStrings"></param>
 /// <param name="li"></param>
 private void SnapRound(IList segStrings, LineIntersector li)
 {
     IList intersections = FindInteriorIntersections(segStrings, li);
     ComputeIntersectionSnaps(intersections);
     ComputeVertexSnaps(segStrings);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="McIndexSnapRounder"/> class.
 /// </summary>
 /// <param name="pm">The <see cref="PrecisionModel" /> to use.</param>
 public McIndexSnapRounder(PrecisionModel pm)
 {
     _li = new RobustLineIntersector();
     _li.PrecisionModel = pm;
     _scaleFactor = pm.Scale;
 }
 /// <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;
 }
 /// <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 static IList FindInteriorIntersections(IList segStrings, LineIntersector li)
 {
     IntersectionFinderAdder intFinderAdder = new IntersectionFinderAdder(li);
     SinglePassNoder noder = new McIndexNoder(intFinderAdder);
     noder.ComputeNodes(segStrings);
     return intFinderAdder.InteriorIntersections;
 }
Example #7
0
 /// <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 virtual 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;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="IntersectionAdder"/> class.
 /// </summary>
 /// <param name="li"></param>
 public IntersectionAdder(LineIntersector li)
 {
     _li = li;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="li"></param>
 /// <param name="bdyNodes"></param>
 /// <returns></returns>
 private static bool IsBoundaryPoint(LineIntersector li, ICollection[] bdyNodes)
 {
     if (bdyNodes == null)
         return false;
     if (IsBoundaryPoint(li, bdyNodes[0]))
         return true;
     if (IsBoundaryPoint(li, bdyNodes[1]))
         return true;
     return false;
 }
Example #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="li"></param>
 public EdgeSetNoder(LineIntersector li)
 {
     _li = li;
 }
Example #11
0
 /// <summary>
 /// Add an <see cref="SegmentNode" /> for intersection intIndex.
 /// An intersection that falls exactly on a vertex
 /// of the <see cref="SegmentString" /> is normalized
 /// to use the higher of the two possible segmentIndexes.
 /// </summary>
 /// <param name="li"></param>
 /// <param name="segmentIndex"></param>
 /// <param name="intIndex"></param>
 public void AddIntersection(LineIntersector li, int segmentIndex, int intIndex)
 {
     Coordinate intPt = new Coordinate(li.GetIntersection(intIndex));
     AddIntersection(intPt, segmentIndex);
 }
Example #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="li"></param>
 /// <param name="p0"></param>
 /// <param name="p1"></param>
 /// <returns><c>true</c> if there is an intersection point which is not an endpoint of the segment p0-p1.</returns>
 private static 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;
 }
Example #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="g"></param>
 /// <param name="li"></param>
 /// <param name="includeProper"></param>
 /// <returns></returns>
 public virtual 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;
 }
Example #14
0
 /// <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 virtual void AddIntersections(LineIntersector li, int segmentIndex, int geomIndex)
 {
     for (int i = 0; i < li.IntersectionNum; i++)
         AddIntersection(li, segmentIndex, geomIndex, i);
 }
 /// <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;
 }
Example #16
0
        /// <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>
        /// <param name="li"></param>
        /// <param name="segmentIndex"></param>
        /// <param name="geomIndex"></param>
        /// <param name="intIndex"></param>
        public virtual 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 < Points.Count)
            {
                Coordinate nextPt = Points[nextSegIndex];

                // Normalize segment index if intPt falls on vertex
                // The check for point equality is 2D only - Z values are ignored
                if (intPt.Equals2D(nextPt))
                {
                    normalizedSegmentIndex = nextSegIndex;
                    dist = 0.0;
                }
                // Add the intersection point to edge intersection list.
                EdgeIntersectionList.Add(intPt, normalizedSegmentIndex, dist);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="li"></param>
 /// <param name="includeProper"></param>
 /// <param name="recordIsolated"></param>
 public SegmentIntersector(LineIntersector li, bool includeProper, bool recordIsolated)
 {
     _li = li;
     _includeProper = includeProper;
     _recordIsolated = recordIsolated;
 }
Example #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IteratedNoder"/> class.
 /// </summary>
 /// <param name="pm"></param>
 public IteratedNoder(PrecisionModel pm)
 {
     _li = new RobustLineIntersector();
     _li.PrecisionModel = pm;
 }
 /// <summary>
 /// Creates an intersection finder which finds all proper intersections.
 /// </summary>
 /// <param name="li">The <see cref="LineIntersector" /> to use.</param>
 public IntersectionFinderAdder(LineIntersector li)
 {
     _li = li;
     _interiorIntersections = new ArrayList();
 }