internal Polyline2D2WN method_0( IVertex2DCollection vertices, GraphicsConfig config, bool closed) { int count = vertices.Count; if (count == 0) { return(new Polyline2D2WN(0)); } IVertex2D vertex = vertices.GetIVertex2D(0); Polyline2D2WN polyline = new Polyline2D2WN(count, closed); for (int index = 1; index < count; ++index) { IVertex2D ivertex2D = vertices.GetIVertex2D(index); this.method_1(config, polyline, vertex, ivertex2D); vertex = ivertex2D; } if (closed) { this.method_1(config, polyline, vertex, vertices.GetIVertex2D(0)); } else { double startWidth = vertex.StartWidth == 0.0 ? this.double_0 : vertex.StartWidth; double endWidth = vertex.EndWidth == 0.0 ? this.double_1 : vertex.EndWidth; Point2D2WN point2D2Wn = new Point2D2WN(vertex.Position, startWidth, endWidth); polyline.Add(point2D2Wn); } return(polyline); }
private void method_2(Polyline2D2WN polyline, IVertex2D vertex, IVertex2D nextVertex) { double startWidth = vertex.StartWidth == 0.0 ? this.double_0 : vertex.StartWidth; double endWidth = vertex.EndWidth == 0.0 ? this.double_1 : vertex.EndWidth; Vector2D vector2D = nextVertex.Position - vertex.Position; Point2D2WN point2D2Wn = new Point2D2WN(vertex.Position, startWidth, endWidth) { StartNormal = new Vector2D(-vector2D.Y, vector2D.X).GetUnit() }; point2D2Wn.EndNormal = point2D2Wn.StartNormal; polyline.Add(point2D2Wn); }
public void RecalculateApproximationPoints(int noOfSplineLineParts) { WW.Cad.Drawing.Polyline2D2WN polyline2D2Wn = this.method_31(this.method_15(), noOfSplineLineParts); this.dxfVertex2DCollection_1.Clear(); for (int index = 0; index < polyline2D2Wn.Count; ++index) { Point2D2WN point2D2Wn = polyline2D2Wn[index]; this.dxfVertex2DCollection_1.Add(new DxfVertex2D(point2D2Wn.Position) { Bulge = 0.0, StartWidth = point2D2Wn.StartWidth, EndWidth = point2D2Wn.EndWidth }); } }
public static double GetLength(Polyline2D2WN polyline, ILineTypeScaler lineTypeScaler) { double num = 0.0; if (polyline.Count > 1) { Point2D2WN point2D2Wn1 = polyline[0]; for (int index = 1; index < polyline.Count; ++index) { Point2D2WN point2D2Wn2 = polyline[index]; num += lineTypeScaler.GetScaledLength(point2D2Wn2.Position - point2D2Wn1.Position); point2D2Wn1 = point2D2Wn2; } if (polyline.Closed) { num += lineTypeScaler.GetScaledLength(polyline[0].Position - point2D2Wn1.Position); } } return(num); }
private WW.Cad.Drawing.Polyline2D2WN method_31(int power, int noOfSplineLineParts) { WW.Cad.Drawing.Polyline2D2WN polyline2D2Wn = new WW.Cad.Drawing.Polyline2D2WN(); int count = this.dxfVertex2DCollection_0.Count; if (count <= power) { return(this.method_23()); } BSplineD bsplineD = new BSplineD(power, count, this.Closed); double[] result = new double[power + 1]; double maxU = bsplineD.MaxU; int num1 = noOfSplineLineParts + 1; double num2 = maxU / (double)(num1 - 1); double num3 = 0.0; double num4 = 0.0; int num5 = -1; double[,] derivatives = new double[2, power + 1]; Point2D2WN point2D2Wn1 = (Point2D2WN)null; int num6 = 0; double u = 0.0; while (num6 < num1) { double d = (double)(count - 1) * u / maxU; int num7 = (int)System.Math.Floor(d); if (num5 != num7) { DxfVertex2D dxfVertex2D = this.dxfVertex2DCollection_0[num7 % count]; num3 = dxfVertex2D.StartWidth == 0.0 ? this.DefaultStartWidth : dxfVertex2D.StartWidth; num4 = (dxfVertex2D.EndWidth == 0.0 ? this.DefaultEndWidth : dxfVertex2D.EndWidth) - num3; } double num8 = d - (double)num7; num5 = num7; int knotSpanIndex = bsplineD.GetKnotSpanIndex(u); bsplineD.EvaluateBasisFunctions(knotSpanIndex, u, result); WW.Math.Point2D zero1 = WW.Math.Point2D.Zero; for (int index = 0; index <= power; ++index) { DxfVertex2D dxfVertex2D = this.dxfVertex2DCollection_0[(knotSpanIndex - power + index) % count]; zero1 += result[index] * new Vector2D(dxfVertex2D.Position); } bsplineD.GetDerivativesBasisFunctions(knotSpanIndex, u, 1, derivatives); Vector2D zero2 = Vector2D.Zero; for (int index = 0; index <= power; ++index) { zero2 += (Vector2D)this.dxfVertex2DCollection_0[(knotSpanIndex - power + index) % count].Position * derivatives[1, index]; } Vector2D unit = new Vector2D(-zero2.Y, zero2.X).GetUnit(); Point2D2WN point2D2Wn2 = new Point2D2WN(zero1, num3 + num8 * num4, num3 + (num8 + num2) * num4) { IsInterpolatedPoint = true }; point2D2Wn2.StartNormal = unit; if (point2D2Wn1 != null) { point2D2Wn1.EndNormal = unit; } polyline2D2Wn.Add(point2D2Wn2); point2D2Wn1 = point2D2Wn2; ++num6; u += num2; } if (this.Closed) { polyline2D2Wn[num1 - 1].EndNormal = polyline2D2Wn[0].StartNormal; } return(polyline2D2Wn); }
private void method_3( GraphicsConfig config, Polyline2D2WN polyline, IVertex2D vertex, IVertex2D nextVertex) { double num1 = vertex.StartWidth == 0.0 ? this.double_0 : vertex.StartWidth; double val1 = vertex.EndWidth == 0.0 ? this.double_1 : vertex.EndWidth; Vector2D vector2D1 = nextVertex.Position - vertex.Position; double length = vector2D1.GetLength(); double num2 = 4.0 * System.Math.Atan(vertex.Bulge); double num3 = length / (2.0 * System.Math.Abs(System.Math.Sin(num2 * 0.5))); Vector2D vector2D2 = vector2D1; vector2D2.Normalize(); double num4 = (double)System.Math.Sign(vertex.Bulge); Vector2D vector2D3 = new Vector2D(-vector2D2.Y, vector2D2.X) * num4; Point2D point2D = (Point2D)(((Vector2D)nextVertex.Position + (Vector2D)vertex.Position) * 0.5) + vector2D3 * System.Math.Cos(num2 * 0.5) * num3; Vector2D vector2D4 = vertex.Position - point2D; double num5 = System.Math.Atan2(vector2D4.Y, vector2D4.X); Vector2D vector2D5 = nextVertex.Position - point2D; double num6 = System.Math.Atan2(vector2D5.Y, vector2D5.X); double num7 = num5; double num8 = num4 * (2.0 * System.Math.PI) / (double)config.NoOfArcLineSegments; while (num6 < num5) { num6 += 2.0 * System.Math.PI; } double num9 = vertex.Bulge >= 0.0 ? num6 - num5 : 2.0 * System.Math.PI - (num6 - num5); double a = System.Math.Abs(num9 / num8); if (a < (double)config.NoOfArcLineSegmentsMinimum) { a = (double)config.NoOfArcLineSegmentsMinimum; num8 = num4 * System.Math.Abs(num9 / (double)config.NoOfArcLineSegmentsMinimum); } if (a < 2.0) { this.method_2(polyline, vertex, nextVertex); } else { double startWidth1 = num1; double num10 = (val1 - num1) / a; int num11 = (int)System.Math.Ceiling(a); double endWidth1 = System.Math.Min(val1, startWidth1 + num10); double x1 = System.Math.Cos(num7); double y1 = System.Math.Sin(num7); Point2D2WN point2D2Wn1 = new Point2D2WN(point2D + new Vector2D(x1 * num3, y1 * num3), startWidth1, endWidth1); point2D2Wn1.StartNormal = -num4 * new Vector2D(x1, y1); polyline.Add(point2D2Wn1); double startWidth2 = endWidth1; double num12 = num7 + num8; for (int index = 1; index < num11; ++index) { double x2 = System.Math.Cos(num12); double y2 = System.Math.Sin(num12); Vector2D vector2D6 = -num4 * new Vector2D(x2, y2); point2D2Wn1.EndNormal = vector2D6; Point2D position = point2D + new Vector2D(x2 * num3, y2 * num3); double endWidth2 = System.Math.Min(val1, startWidth2 + num10); Point2D2WN point2D2Wn2 = new Point2D2WN(position, startWidth2, endWidth2); point2D2Wn2.IsInterpolatedPoint = true; point2D2Wn2.StartNormal = vector2D6; polyline.Add(point2D2Wn2); startWidth2 = endWidth2; num12 += num8; point2D2Wn1 = point2D2Wn2; } point2D2Wn1.EndNormal = -num4 * new Vector2D(System.Math.Cos(num6), System.Math.Sin(num6)); } }