예제 #1
0
 private void method_14(
     DrawContext context,
     WW.Cad.Drawing.Surface.Geometry geometry,
     DxfPolyline2DSpline.Interface43 polylineProvider,
     bool allWidthsAreZero)
 {
     if (allWidthsAreZero)
     {
         if (this.Thickness == 0.0)
         {
             WW.Cad.Drawing.Polyline2DE wrappee = polylineProvider.imethod_0();
             geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Polyline2DE(wrappee, this.Transform));
         }
         else
         {
             WW.Cad.Drawing.Polyline2D2N wrappee1 = polylineProvider.imethod_1();
             if (wrappee1.Count > 0)
             {
                 geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Polyline2D2N(wrappee1, this.Transform));
             }
             else
             {
                 WW.Cad.Drawing.Polyline2DE wrappee2 = polylineProvider.imethod_0();
                 geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Polyline2DE(wrappee2, this.Transform));
             }
         }
     }
     else if (this.Thickness == 0.0)
     {
         WW.Cad.Drawing.Polyline2D2WN wrappee1 = polylineProvider.imethod_2();
         if (wrappee1.Count > 0)
         {
             geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Polyline2D2WN(wrappee1, context.Model.Header.FillMode, this.Transform));
         }
         else
         {
             WW.Cad.Drawing.Polyline2DE wrappee2 = polylineProvider.imethod_0();
             geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Polyline2DE(wrappee2, this.Transform));
         }
     }
     else
     {
         WW.Cad.Drawing.Polyline2D2WN wrappee1 = polylineProvider.imethod_2();
         if (wrappee1.Count > 0)
         {
             geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Polyline2D2WN(wrappee1, context.Model.Header.FillMode, this.Transform));
         }
         else
         {
             WW.Cad.Drawing.Polyline2DE wrappee2 = polylineProvider.imethod_0();
             geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Polyline2DE(wrappee2, this.Transform));
         }
     }
 }
예제 #2
0
 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
         });
     }
 }
예제 #3
0
        private WW.Cad.Drawing.Polyline2D2WN method_27(
            DxfVertex2DCollection points,
            bool isInterpolatedPoint)
        {
            bool closed = this.Closed;
            int  count  = points.Count;

            WW.Cad.Drawing.Polyline2D2WN polyline2D2Wn = new WW.Cad.Drawing.Polyline2D2WN(count, closed);
            if (count > 0)
            {
                DxfVertex2D dxfVertex2D = points[0];
                for (int index = 1; index < count; ++index)
                {
                    DxfVertex2D point = points[index];
                    if (!(dxfVertex2D.Position == point.Position))
                    {
                        Vector2D unit     = (point.Position - dxfVertex2D.Position).GetUnit();
                        Vector2D vector2D = new Vector2D(-unit.Y, unit.X);
                        polyline2D2Wn.Add(new Point2D2WN(dxfVertex2D.Position, dxfVertex2D.StartWidth, dxfVertex2D.EndWidth, vector2D, vector2D)
                        {
                            IsInterpolatedPoint = isInterpolatedPoint
                        });
                        dxfVertex2D = point;
                    }
                }
                if (closed)
                {
                    DxfVertex2D point = points[0];
                    if (dxfVertex2D.Position != point.Position)
                    {
                        Vector2D unit     = (point.Position - dxfVertex2D.Position).GetUnit();
                        Vector2D vector2D = new Vector2D(-unit.Y, unit.X);
                        polyline2D2Wn.Add(new Point2D2WN(dxfVertex2D.Position, dxfVertex2D.StartWidth, dxfVertex2D.EndWidth, vector2D, vector2D)
                        {
                            IsInterpolatedPoint = isInterpolatedPoint
                        });
                    }
                }
                else
                {
                    polyline2D2Wn.Add(new Point2D2WN(dxfVertex2D.Position)
                    {
                        IsInterpolatedPoint = isInterpolatedPoint
                    });
                }
            }
            return(polyline2D2Wn);
        }
예제 #4
0
        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);
        }
예제 #5
0
        internal override void GetPolylines(
            DrawContext context,
            ILineTypeScaler lineTypeScaler,
            out IList <IList <WW.Cad.Drawing.Polyline2D2N> > polylinesList1,
            out IList <IList <WW.Cad.Drawing.Polyline2D2N> > polylinesList2,
            out IList <FlatShape4D> shapes,
            out bool fill)
        {
            DxfHeader      header = context.Model.Header;
            GraphicsConfig config = context.Config;

            polylinesList1 = (IList <IList <WW.Cad.Drawing.Polyline2D2N> >) new List <IList <WW.Cad.Drawing.Polyline2D2N> >();
            polylinesList2 = (IList <IList <WW.Cad.Drawing.Polyline2D2N> >) new List <IList <WW.Cad.Drawing.Polyline2D2N> >();
            shapes         = (IList <FlatShape4D>)null;
            if (config.ShowSplineControlPoints)
            {
                polylinesList1.Add((IList <WW.Cad.Drawing.Polyline2D2N>) new WW.Cad.Drawing.Polyline2D2N[1]
                {
                    this.method_20()
                });
                polylinesList2.Add((IList <WW.Cad.Drawing.Polyline2D2N>)null);
            }
            if (config.ShowSplineApproximationPoints)
            {
                polylinesList1.Add((IList <WW.Cad.Drawing.Polyline2D2N>) new WW.Cad.Drawing.Polyline2D2N[1]
                {
                    this.method_21()
                });
                polylinesList2.Add((IList <WW.Cad.Drawing.Polyline2D2N>)null);
            }
            WW.Cad.Drawing.Polyline2D2WN polyline = (WW.Cad.Drawing.Polyline2D2WN)null;
            if (config.ShowSplineInterpolatedPoints)
            {
                switch (this.splineType_0)
                {
                case SplineType.None:
                    if (!config.ShowSplineApproximationPoints)
                    {
                        polyline = this.method_23();
                        break;
                    }
                    break;

                case SplineType.QuadraticBSpline:
                    polyline = this.method_31(2, (int)context.Config.NoOfSplineLineSegments);
                    break;

                case SplineType.CubicBSpline:
                    polyline = this.method_31(3, (int)context.Config.NoOfSplineLineSegments);
                    break;
                }
            }
            fill = false;
            IList <WW.Cad.Drawing.Polyline2D2N> resultPolylines1;
            IList <WW.Cad.Drawing.Polyline2D2N> resultPolylines2;

            if (polyline != null && DxfUtil.smethod_27(context.Config, polyline, context.Config.ApplyLineType ? this.GetLineType(context) : (DxfLineType)null, context.TotalLineTypeScale * this.LineTypeScale, lineTypeScaler, false, out resultPolylines1, out resultPolylines2, out shapes, out fill))
            {
                polylinesList1.Add(resultPolylines1);
                polylinesList2.Add(resultPolylines2);
                if (shapes != null && shapes.Count == 0)
                {
                    shapes = (IList <FlatShape4D>)null;
                }
            }
            fill &= context.Model.Header.FillMode;
        }
예제 #6
0
 public double GetLength()
 {
     return(Polyline2D2WN.GetLength((IList <Point2D2WN>) this, this.Closed));
 }