private void method_0( Polyline4D result, double startParam, double endParam, Class455.Class462 polylineInfo) { Polyline3D polyline3D0 = polylineInfo.polyline3D_0; int count = polyline3D0.Count; int num1 = (int)System.Math.Floor(startParam); double parameter1 = startParam - (double)num1; int num2 = (int)System.Math.Floor(endParam); double parameter2 = endParam - (double)num2; if (startParam > endParam) { num2 += count; } result.Add(this.matrix4D_0.TransformTo4D(Class455.smethod_0(polyline3D0[num1 % count], polyline3D0[(num1 + 1) % count], parameter1))); for (int index = num1 + 1; index <= num2; ++index) { result.Add(this.matrix4D_0.TransformTo4D(polyline3D0[index % count])); } if (parameter2 <= 0.0) { return; } result.Add(this.matrix4D_0.TransformTo4D(Class455.smethod_0(polyline3D0[num2 % count], polyline3D0[(num2 + 1) % count], parameter2))); }
private void method_1( Polyline4D result, Class455.Class456 start, Class455.Class456 end, bool backward, Class455.Class462 polylineInfo) { Polyline3D polyline3D0 = polylineInfo.polyline3D_0; Polygon2D polygon2D0 = this.class461_0.polygon2D_0; int count = polygon2D0.Count; double double0_1 = start.double_0; double double0_2 = end.double_0; double double1_1 = start.double_1; double double1_2 = end.double_1; int num1 = (int)System.Math.Floor(double0_1) % count; int num2 = (int)System.Math.Floor(double0_2) % count; result.Add(this.matrix4D_0.TransformTo4D(Class455.smethod_1(polyline3D0, double1_1))); if (backward) { for (int index = num1; index != num2; index = (index + count - 1) % count) { Point2D p = polygon2D0[index]; Point3D point = new Point3D(p.X, p.Y, polylineInfo.method_3(p)); result.Add(this.matrix4D_0.TransformTo4D(point)); } } else { for (int index = num1; index != num2; index = (index + 1) % count) { Point2D p = polygon2D0[index]; Point3D point = new Point3D(p.X, p.Y, polylineInfo.method_3(p)); result.Add(this.matrix4D_0.TransformTo4D(point)); } } if (double0_2 == System.Math.Floor(double0_2)) { return; } result.Add(this.matrix4D_0.TransformTo4D(Class455.smethod_1(polyline3D0, double1_2))); }
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); } }