public override IList <Polygon2D> GetClipBoundary(GraphicsConfig graphicsConfig) { WW.Cad.Drawing.Polyline2DE polyline2De = (WW.Cad.Drawing.Polyline2DE)null; switch (this.splineType_0) { case SplineType.None: if (!graphicsConfig.ShowSplineApproximationPoints) { polyline2De = this.method_19(); break; } break; case SplineType.QuadraticBSpline: polyline2De = this.method_28(2, (int)graphicsConfig.NoOfSplineLineSegments); break; case SplineType.CubicBSpline: polyline2De = this.method_28(3, (int)graphicsConfig.NoOfSplineLineSegments); break; } if (polyline2De == null) { return((IList <Polygon2D>) new Polygon2D[0]); } Polygon2D polygon2D = new Polygon2D(polyline2De.Count); foreach (Point2DE point2De in (List <Point2DE>)polyline2De) { polygon2D.Add(point2De.Position); } return((IList <Polygon2D>) new Polygon2D[1] { polygon2D }); }
public void ChangeOutlineColor() { var polygon = new Polygon2D(Rectangle.One, Color.Red); polygon.Add(new OutlineColor(Color.Blue)); Assert.AreEqual(Color.Blue, polygon.Get <OutlineColor>().Value); }
public IList <Polygon2D> GetClipBoundary(GraphicsConfig graphicsConfig) { if (this.list_0.Count < 3) { return((IList <Polygon2D>) new Polygon2D[0]); } Polygon2D polygon2D = new Polygon2D(this.list_0.Count); for (int index = 0; index < this.list_0.Count - 1; ++index) { polygon2D.Add((WW.Math.Point2D) this.list_0[index]); } if (this.list_0.Count > 2 && this.list_0[this.list_0.Count - 1] != this.list_0[0]) { polygon2D.Add((WW.Math.Point2D) this.list_0[this.list_0.Count - 1]); } return((IList <Polygon2D>) new Polygon2D[1] { polygon2D }); }
public static Polygon2D GetProjection2D( IList <Point3D> polygon, Matrix4D projectionTransform) { Polygon2D polygon2D = new Polygon2D(polygon.Count); foreach (Point3D point in (IEnumerable <Point3D>)polygon) { polygon2D.Add(projectionTransform.TransformTo2D(point)); } return(polygon2D); }
public override IList <Polygon2D> GetClipBoundary(GraphicsConfig graphicsConfig) { WW.Math.Geometry.Polyline3D polyline3D = this.method_13(); Polygon2D polygon2D = new Polygon2D(polyline3D.Count); foreach (WW.Math.Point3D point3D in (List <WW.Math.Point3D>)polyline3D) { polygon2D.Add((WW.Math.Point2D)point3D); } return((IList <Polygon2D>) new Polygon2D[1] { polygon2D }); }
public override IList <Polygon2D> GetClipBoundary(GraphicsConfig graphicsConfig) { WW.Cad.Drawing.Polyline2DE polyline2De = Class639.Class640.smethod_0((IVertex2DCollection)this.dxfVertex2DCollection_0, graphicsConfig, this.Closed); Polygon2D polygon2D = new Polygon2D(polyline2De.Count); foreach (Point2DE point2De in (List <Point2DE>)polyline2De) { polygon2D.Add(point2De.Position); } return((IList <Polygon2D>) new Polygon2D[1] { polygon2D }); }
public IList <Polygon2D> GetClipBoundary(GraphicsConfig graphicsConfig) { if (this.double_1 == 0.0) { return((IList <Polygon2D>) new Polygon2D[0]); } WW.Math.Geometry.Polyline3D polyline3D = this.method_14(graphicsConfig, 0.0, 2.0 * System.Math.PI); Polygon2D polygon2D = new Polygon2D(polyline3D.Count); foreach (WW.Math.Point3D point3D in (List <WW.Math.Point3D>)polyline3D) { polygon2D.Add((WW.Math.Point2D)point3D); } return((IList <Polygon2D>) new Polygon2D[1] { polygon2D }); }
public void ReadFromTextFile(StreamReader r) { int num = int.Parse(r.ReadLine()); for (int index1 = 0; index1 < num; ++index1) { int capacity1 = int.Parse(r.ReadLine()); Polygon2DCollection polygon2Dcollection = new Polygon2DCollection(capacity1); this.Add(polygon2Dcollection); for (int index2 = 0; index2 < capacity1; ++index2) { int capacity2 = int.Parse(r.ReadLine()); Polygon2D polygon2D = new Polygon2D(capacity2); polygon2Dcollection.Add(polygon2D); for (int index3 = 0; index3 < capacity2; ++index3) { Point2D point2D = Point2D.Parse(r.ReadLine()); polygon2D.Add(point2D); } } } }
private static Polygon2D[] smethod_10( Polygon2D[] polies, bool right, bool outer, Interface28 xInterval, Interface28 yInterval, double epsilon) { bool isPeriodic1 = xInterval.IsPeriodic; bool isPeriodic2 = yInterval.IsPeriodic; if (!isPeriodic1 && !isPeriodic2) { return(polies); } List <Polygon2D> polygon2DList = new List <Polygon2D>(); double periodicLength1 = xInterval.PeriodicLength; double periodicLength2 = yInterval.PeriodicLength; Polygon2D polygon2D1 = new Polygon2D(); foreach (Polygon2D poly in polies) { int count = poly.Count; if (count > 0) { Point2D p1 = Class794.smethod_8(xInterval, yInterval, poly[0]); for (int index = 1; index <= count; ++index) { Point2D p2 = Class794.smethod_8(xInterval, yInterval, poly[index % count]); bool flag1 = isPeriodic1 && 2.0 * System.Math.Abs(p2.X - p1.X) > periodicLength1; bool flag2 = isPeriodic2 && 2.0 * System.Math.Abs(p2.Y - p1.Y) > periodicLength2; if (flag1 || flag2) { if (flag1 && flag2) { throw new NotSupportedException("Double interval crossing not yet supported!"); } Class794.Struct7 struct7 = flag1 ? Class794.smethod_11(xInterval, p1.X, p2.X) : Class794.smethod_11(yInterval, p1.Y, p2.Y); Point2D point2D = Class794.smethod_12(p1, p2, struct7.double_0); if (flag1) { point2D = new Point2D(struct7.bool_0 ? xInterval.End : xInterval.Start, point2D.Y); p2 = new Point2D(struct7.bool_0 ? xInterval.Start : xInterval.End, point2D.Y); } else { point2D = new Point2D(point2D.X, struct7.bool_0 ? yInterval.End : yInterval.Start); p2 = new Point2D(point2D.X, struct7.bool_0 ? yInterval.Start : yInterval.End); } polygon2D1.Add(point2D); polygon2DList.Add(polygon2D1); polygon2D1 = new Polygon2D(); } polygon2D1.Add(p2); p1 = p2; } } } if (polygon2D1.Count > 0) { if (polygon2DList.Count == 0) { polygon2DList.Add(polygon2D1); } else { polygon2DList.Add(polygon2D1); } } foreach (Polygon2D polygon2D2 in polygon2DList) { ; } return(polygon2DList.ToArray()); }
public override IList <Polyline4D> Clip(Polyline4D polyline, bool filled) { int count = polyline.Count; switch (count) { case 0: return(AbstractClipperBase4D.PolylinesClippedAway); case 1: if (!Class455.Contains(this.class461_0, this.matrix4D_1.TransformToPoint2D(polyline[0]))) { return(AbstractClipperBase4D.PolylinesClippedAway); } return((IList <Polyline4D>) new Polyline4D[1] { polyline }); default: Polyline3D polyline1 = new Polyline3D(polyline.Count, polyline.Closed); foreach (Vector4D vector in (List <Vector4D>)polyline) { polyline1.Add(this.matrix4D_1.TransformToPoint3D(vector)); } Class455.Class462 polylineInfo = new Class455.Class462(polyline1); List <Class455.Class456> class456List = this.class461_0.method_0((Class455.Class460)polylineInfo); if (class456List.Count == 0) { if (polyline1.Count == 0) { return (IList <Polyline4D>) new Polyline4D[1] { polyline } } ; foreach (Point3D point3D in (List <Point3D>)polyline1) { if (Class455.Contains(this.class461_0, (Point2D)point3D)) { return (IList <Polyline4D>) new Polyline4D[1] { polyline } } ; } if (!filled || polyline.Count < 3) { return(AbstractClipperBase4D.PolylinesClippedAway); } Polygon2D polygon2D = new Polygon2D(polyline1.Count); foreach (Point3D point3D in (List <Point3D>)polyline1) { polygon2D.Add((Point2D)point3D); } bool flag = false; foreach (Point2D p in (List <Point2D>) this.class461_0.polygon2D_0) { if (polygon2D.IsInside(p)) { flag = true; break; } } if (filled && flag) { Plane3D?plane = Polygon3D.GetPlane((IList <Point3D>)polyline1); if (plane.HasValue) { Plane3D plane3D = plane.Value; Polyline4D polyline4D = new Polyline4D(this.class461_0.polygon2D_0.Count, true); foreach (Point2D point2D in (List <Point2D>) this.class461_0.polygon2D_0) { Point3D?intersection = plane3D.GetIntersection(new Ray3D(point2D.X, point2D.Y, 0.0, 0.0, 0.0, 1.0)); if (intersection.HasValue) { polyline4D.Add(this.matrix4D_0.TransformTo4D(intersection.Value)); } else { intersection = plane3D.GetIntersection(new Ray3D(point2D.X, point2D.Y, 0.0, 0.0, 0.0, -1.0)); if (intersection.HasValue) { polyline4D.Add(this.matrix4D_0.TransformTo4D(intersection.Value)); } } } return((IList <Polyline4D>) new Polyline4D[1] { polyline4D }); } } return(AbstractClipperBase4D.PolylinesClippedAway); } bool flag1 = polylineInfo.double_0 * this.class461_0.double_0 >= 0.0; List <Polyline4D> polyline4DList = new List <Polyline4D>(); int index1; if (!Class455.Contains(this.class461_0, (Point2D)polyline1[0])) { index1 = 0; } else if (polyline.Closed) { index1 = class456List.Count - 1; } else { Polyline4D result = new Polyline4D(filled); this.method_0(result, 0.0, class456List[0].double_1, polylineInfo); polyline4DList.Add(result); class456List.RemoveAt(0); index1 = 0; if (class456List.Count == 0) { return((IList <Polyline4D>)polyline4DList); } } if (filled) { while (class456List.Count > 0) { if (polylineInfo.bool_0) { class456List.Sort(new Comparison <Class455.Class456>(Class455.Class456.smethod_2)); } else { class456List.Sort(new Comparison <Class455.Class456>(Class455.Class456.smethod_0)); if (!flag1) { class456List.Reverse(); } } for (int index2 = 0; index2 < class456List.Count; ++index2) { Class455.Class456 class456_1 = class456List[index2]; Class455.Class456 class456_2 = class456List[(index2 + 1) % class456List.Count]; class456_1.class456_0 = class456_2; class456_2.class456_1 = class456_1; } class456List.Sort(new Comparison <Class455.Class456>(Class455.Class456.smethod_1)); for (int index2 = 0; index2 < class456List.Count; ++index2) { Class455.Class456 class456_1 = class456List[index2]; Class455.Class456 class456_2 = class456List[(index2 + 1) % class456List.Count]; class456_1.class456_2 = class456_2; class456_2.class456_3 = class456_1; } Polyline4D result = new Polyline4D(true); polyline4DList.Add(result); Class455.Class456 class456 = class456List[index1]; class456List.RemoveAt(index1); bool flag2 = index1 > 0; index1 = 0; Class455.Class456 start = class456; do { Class455.Class456 end = start.class456_2; bool flag3; if (flag2 || end.double_1 >= start.double_1) { double parameter = 0.5 * (start.double_1 + end.double_1); if (flag2) { parameter += 0.5 * (double)count; flag2 = false; } flag3 = Class455.Contains(this.class461_0, (Point2D)Class455.smethod_1(polylineInfo.polyline3D_0, parameter)); } else { goto label_72; } label_65: if (flag3) { this.method_0(result, start.double_1, end.double_1, polylineInfo); } else { end = start.class456_0; if (polylineInfo.bool_0) { result.Add(this.matrix4D_0.TransformTo4D(Class455.smethod_1(polylineInfo.polyline3D_0, start.double_1))); } else { this.method_1(result, start, end, !flag1, polylineInfo); } } class456List.Remove(end); if (end.class456_2 != end.class456_3) { end.class456_1.class456_0 = end.class456_0; end.class456_0.class456_1 = end.class456_1; end.class456_3.class456_2 = end.class456_2; end.class456_2.class456_3 = end.class456_3; start = end; continue; } break; label_72: flag3 = false; goto label_65; }while (!object.ReferenceEquals((object)start, (object)class456)); if (result.Count < 3) { result.Closed = false; } } } else { bool flag2 = Class455.Contains(this.class461_0, (Point2D)polyline1[polyline1.Count - 1]); class456List.Sort(new Comparison <Class455.Class456>(Class455.Class456.smethod_1)); Class455.Class456 class456_1 = class456List[index1]; class456List.RemoveAt(index1); while (class456List.Count > 0) { Class455.Class456 class456_2 = class456List[0]; class456List.RemoveAt(0); double parameter = 0.5 * (class456_1.double_1 + class456_2.double_1); if (class456_2.double_1 < class456_1.double_1) { parameter += 0.5 * (double)count; } if (Class455.Contains(this.class461_0, (Point2D)Class455.smethod_1(polylineInfo.polyline3D_0, parameter))) { Polyline4D result = new Polyline4D(); this.method_0(result, class456_1.double_1, class456_2.double_1, polylineInfo); polyline4DList.Add(result); } class456_1 = class456_2; } if (!polyline.Closed && flag2) { Polyline4D result = new Polyline4D(); this.method_0(result, class456_1.double_1, (double)(polyline.Count - 1), polylineInfo); polyline4DList.Add(result); } } return((IList <Polyline4D>)polyline4DList); } }
public void ChangeOutlineColor() { var polygon = new Polygon2D(Rectangle.One, Color.Red); polygon.Add(new OutlineColor(Color.Blue)); Assert.AreEqual(Color.Blue, polygon.Get<OutlineColor>().Value); }
public virtual void vmethod_2(Class95 firstLoop, Class608 wires) { Interface26 pointParamMapper = this.PointParamMapper; if (pointParamMapper != null) { List <Polygon2D> polygon2DList1 = new List <Polygon2D>(); List <Polygon2D> polygon2DList2 = new List <Polygon2D>(); foreach (Class95 loop in (IEnumerable <Class95>)Class80.smethod_0 <Class95>(firstLoop)) { Class917 approximation = new Class917(); Polygon2D polygon2D1 = new Polygon2D(); foreach (ns9.Class107 coedge in (IEnumerable <ns9.Class107>)loop.Coedges) { ns9.Class88 curve = (ns9.Class88)coedge.Edge.Curve; if (curve != null) { curve.CurvePrimitive.imethod_3(loop, curve, coedge, approximation, wires.Accuracy); } else { Polyline2D polyline2D = this.vmethod_1(coedge); polygon2D1.AddRange((IEnumerable <Point2D>)polyline2D); } } if (polygon2D1.Count > 0) { if (pointParamMapper.IsRightHandedParametric) { if (polygon2D1.GetArea() >= 0.0) { polygon2DList1.Add(polygon2D1); } else { polygon2DList2.Add(polygon2D1); } } else if (polygon2D1.GetArea() < 0.0) { polygon2DList1.Add(polygon2D1); } else { polygon2DList2.Add(polygon2D1); } } Point3D[] points = approximation.Points; if (points.Length > 0) { Polygon2D polygon2D2 = new Polygon2D(points.Length); foreach (Point3D point in points) { polygon2D2.Add(pointParamMapper.imethod_0(point)); } if (pointParamMapper.IsRightHandedParametric) { if (polygon2D2.GetArea() >= 0.0) { polygon2DList1.Add(polygon2D2); } else { polygon2DList2.Add(polygon2D2); } } else if (polygon2D2.GetArea() < 0.0) { polygon2DList1.Add(polygon2D2); } else { polygon2DList2.Add(polygon2D2); } } } if (polygon2DList1.Count == 0 && polygon2DList2.Count != 0) { foreach (List <Point2D> point2DList in polygon2DList2) { point2DList.Reverse(); } polygon2DList1.AddRange((IEnumerable <Polygon2D>)polygon2DList2); polygon2DList2.Clear(); } Polygon2D[] paramShape = Class794.smethod_9(this.ExtendedIntervalU, this.ExtendedIntervalV, polygon2DList1.ToArray(), polygon2DList2.ToArray(), pointParamMapper.IsRightHandedParametric, wires.Accuracy.Epsilon); if (paramShape == null) { return; } foreach (Polygon2D polygon2D in paramShape) { Polygon3D polygon3D = new Polygon3D(polygon2D.Count); foreach (Point2D point2D in (List <Point2D>)polygon2D) { polygon3D.Add(pointParamMapper.imethod_1(point2D.X, point2D.Y)); } wires.method_9((ICollection <Point3D>)polygon3D, true); } this.vmethod_0(wires, paramShape, pointParamMapper); } else { Class80.smethod_2((Class80)firstLoop, wires); } }