public override RingSet2 <double> ConstructRingSet(IList <Ring2 <double> > chains) { if (chains == null || chains.Count < 1) { return(null); } Ring2 <double>[] Chains = new Ring2 <double> [chains.Count]; for (int i = 0; i < Chains.Length; i++) { Chains[i] = chains[i]; } PlanarChainGraph <double> graph = new PlanarChainGraph <double>(); foreach (Ring2 <double> ch in Chains) { if (ch == null) { return(null); //can't have null chains } graph.Add(ch); } if (PlanarGraphUtils.AnyIntersections(graph)) //there must be overlap { return(null); } return(new RingSet2 <double>(Chains)); }
public override PolylineSet2 <double> ConstructPolylineSet(Polyline2 <double>[] chains) { if (chains == null || chains.Length < 1) { return(null); } Polyline2 <double>[] Chains = new Polyline2 <double> [chains.Length]; Polyline2 <double> ch; PlanarChainGraph <double> graph = new PlanarChainGraph <double>(); for (int i = 0; i < Chains.Length; i++) { ch = chains[i]; if (ch == null) { return(null); //can't have null chains } Chains[i] = ch; graph.Add(new LineChain2 <double>(ch.Points)); //TODO -- fix this, it's broken } if (PlanarGraphUtils.AnyIntersections(graph)) //there must be overlap { return(null); } return(new PolylineSet2 <double>(Chains)); }
public override Ring2 <double> ConstructRing(Point2 <double>[] points) { if (points == null || points.Length < 3) { return(null); } Point2 <double>[] pts = PointUtils.RemoveAdjacentDups <double>(points, true); if (pts.Length < 3) { return(null); } PlanarChainGraph <double> graph = new PlanarChainGraph <double>(); graph.Add(pts, true); if (PlanarGraphUtils.AnyIntersections(graph)) { return(null); } Orientation o = Orientation.Clockwise; if (PointUtilsDouble.IsCCW(pts)) { o = Orientation.Counterclockwise; } return(new Ring2 <double>(pts, false, o)); }
public override LineChainSet2 <double> ConstructLineSet(LineChain2 <double>[] chains) { if (chains == null || chains.Length < 1) { return(null); } LineChain2 <double>[] Chains = new LineChain2 <double> [chains.Length]; LineChain2 <double> ch; PlanarChainGraph <double> graph = new PlanarChainGraph <double>(); for (int i = 0; i < Chains.Length; i++) { ch = chains[i]; if (ch == null) { return(null); //can't have null chains } Chains[i] = ch; graph.Add(ch); } if (PlanarGraphUtils.AnyIntersections(graph)) //there must be overlap { return(null); } return(new LineChainSet2 <double>(Chains)); }
public override PolylineSet2 <double> ConstructPolylineSet(IList <Polyline2 <double> > chains) { if (chains == null || chains.Count < 1) { return(null); } Polyline2 <double>[] Chains = chains.ToArray(); PlanarChainGraph <double> graph = new PlanarChainGraph <double>(); foreach (Polyline2 <double> ch in Chains) { if (ch == null) { return(null); //can't have null chains } graph.Add(new LineChain2 <double>(ch.Points)); //TODO -- fix this, it's broken } if (PlanarGraphUtils.AnyIntersections(graph)) //there must be overlap { return(null); } return(new PolylineSet2 <double>(Chains)); }
public override LineChainSet2 <double> ConstructLineSet(IEnumerable <LineChain2 <double> > chains) { if (chains == null) { return(null); } LineChain2 <double>[] Chains = chains.ToArray(); PlanarChainGraph <double> graph = new PlanarChainGraph <double>(); foreach (LineChain2 <double> ch in Chains) { if (ch == null) { return(null); //can't have null chains } graph.Add(ch); } if (PlanarGraphUtils.AnyIntersections(graph)) //there must be overlap { return(null); } return(new LineChainSet2 <double>(Chains)); }
public override RingSet2 <double> ConstructRingSet(Ring2 <double>[] chains) { if (chains == null || chains.Length < 1) { return(null); } Ring2 <double>[] Chains = new Ring2 <double> [chains.Length]; Array.Copy(chains, Chains, Chains.Length); PlanarChainGraph <double> graph = new PlanarChainGraph <double>(); foreach (Ring2 <double> ch in Chains) { if (ch == null) { return(null); //can't have null chains } graph.Add(ch); } if (PlanarGraphUtils.AnyIntersections(graph)) //there must be overlap { return(null); } return(new RingSet2 <double>(Chains)); }
public override Polygon2 <double> ConstructPolygon(Ring2 <double> outerRing, RingSet2 <double> innerRings) { if (outerRing == null) { return(null); } if (innerRings == null) { return(new Polygon2 <double>(outerRing)); } if (PlanarGraphUtils.ValidPolygon(outerRing, innerRings)) { return(new Polygon2 <double>(outerRing, innerRings)); } return(null); }
public override Ring2 <double> CloseChain(LineChain2 <double> chain) { if (chain == null) { return(null); } if (chain.Points.Length < 3) { return(null); } PlanarChainGraph <double> graph = new PlanarChainGraph <double>(); graph.Add(chain.Points, true); if (PlanarGraphUtils.AnyIntersections(graph)) { return(null); } Orientation o = Orientation.Clockwise; if (chain.IsReversed) { if (PointUtilsDouble.IsCCW(chain.Points)) { o = Orientation.Clockwise; } else { o = Orientation.Counterclockwise; } } else { if (PointUtilsDouble.IsCCW(chain.Points)) { o = Orientation.Counterclockwise; } else { o = Orientation.Counterclockwise; } } return(new Ring2 <double>(chain.Points, chain.IsReversed, o)); }
public override LineChain2 <double> ConstructLineChain(IEnumerable <Point2 <double> > points) { if (points == null) { return(null); } PlanarChainGraph <double> graph = new PlanarChainGraph <double>(); Point2 <double>[] Coordinates = PointUtils.RemoveAdjacentDups <double>(points, false); if (Coordinates.Length < 2) { return(null); } graph.Add(Coordinates, false); if (PlanarGraphUtils.AnyIntersections(graph)) { return(null); } return(new LineChain2 <double>(Coordinates)); }
public override PolygonSet2 <double> ConstructPolygonSet(Polygon2 <double>[] parts) { if (parts == null) { return(null); } Ring2 <double>[] shells = new Ring2 <double> [parts.Length]; for (int i = 0; i < parts.Length; i++) { Polygon2 <double> curA = parts[i]; if (curA == null) { return(null); } shells[i] = curA.OuterRing; } if (PlanarGraphUtils.ValidRingSet(shells)) { return(new PolygonSet2 <double>(parts)); } return(null); }
public override RingSet2 <double> ConstructRingSet(IEnumerable <Ring2 <double> > chains) { if (chains == null) { return(null); } LeakyResizableArray <Ring2 <double> > chainSet = new LeakyResizableArray <Ring2 <double> >(); foreach (Ring2 <double> ch in chains) { if (ch == null) { return(null); } chainSet.Add(ch); } chainSet.TrimExcess(); Ring2 <double>[] Chains = chainSet.Data; PlanarChainGraph <double> graph = new PlanarChainGraph <double>(); foreach (Ring2 <double> ch in Chains) { if (ch == null) { return(null); //can't have null chains } graph.Add(ch); } if (PlanarGraphUtils.AnyIntersections(graph)) //there must be overlap { return(null); } return(new RingSet2 <double>(Chains)); }