コード例 #1
0
ファイル: ShapeTool.cs プロジェクト: 15831944/WW
        public static Bounds2D GetBounds(IShape2D shape, Matrix4D transformation)
        {
            Bounds2D bounds = new Bounds2D();

            ShapeTool.AddToBounds(bounds, shape.CreateIterator(), transformation);
            return(bounds);
        }
コード例 #2
0
ファイル: ShapeTool.cs プロジェクト: 15831944/WW
 public static bool AreEqual(IShape2D shape1, IShape2D shape2)
 {
     if (shape1 == shape2)
     {
         return(true);
     }
     return(ShapeTool.smethod_1(shape1.CreateIterator(), shape2.CreateIterator()));
 }
コード例 #3
0
ファイル: WoutWareFont.cs プロジェクト: 15831944/WW
        private static uint smethod_14(IShape2D shape)
        {
            uint num = 0;
            ISegment2DIterator iterator = shape.CreateIterator();

            while (iterator.MoveNext())
            {
                num = (uint)((byte)(13 * (int)num) + iterator.CurrentType);
            }
            return(num);
        }
コード例 #4
0
ファイル: WoutWareFont.cs プロジェクト: 15831944/WW
        private static void smethod_10(Stream stream, IShape2D shape)
        {
            Point2D[]          points   = new Point2D[3];
            ISegment2DIterator iterator = shape.CreateIterator();

            while (iterator.MoveNext())
            {
                switch (iterator.Current(points, 0))
                {
                case SegmentType.MoveTo:
                    stream.WriteByte((byte)77);
                    WoutWareFont.smethod_8(stream, points[0]);
                    continue;

                case SegmentType.LineTo:
                    stream.WriteByte((byte)76);
                    WoutWareFont.smethod_8(stream, points[0]);
                    continue;

                case SegmentType.QuadTo:
                    stream.WriteByte((byte)81);
                    WoutWareFont.smethod_8(stream, points[0]);
                    WoutWareFont.smethod_8(stream, points[1]);
                    continue;

                case SegmentType.CubicTo:
                    stream.WriteByte((byte)67);
                    WoutWareFont.smethod_8(stream, points[0]);
                    WoutWareFont.smethod_8(stream, points[1]);
                    WoutWareFont.smethod_8(stream, points[2]);
                    continue;

                case SegmentType.Close:
                    stream.WriteByte((byte)46);
                    continue;

                default:
                    continue;
                }
            }
            stream.WriteByte((byte)33);
        }
コード例 #5
0
ファイル: ShapeTool.cs プロジェクト: 15831944/WW
        internal static string smethod_2(IShape2D shape)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("GeneralShape2D path = new GeneralShape2D();\n");
            Point2D[]          points   = new Point2D[3];
            ISegment2DIterator iterator = shape.CreateIterator();

            while (iterator.MoveNext())
            {
                switch (iterator.Current(points, 0))
                {
                case SegmentType.MoveTo:
                    stringBuilder.Append("path.MoveTo(").Append(ShapeTool.smethod_3(points[0].X)).Append(",").Append(ShapeTool.smethod_3(points[0].Y)).Append(");\n");
                    continue;

                case SegmentType.LineTo:
                    stringBuilder.Append("path.LineTo(").Append(ShapeTool.smethod_3(points[0].X)).Append(",").Append(ShapeTool.smethod_3(points[0].Y)).Append(");\n");
                    continue;

                case SegmentType.QuadTo:
                    stringBuilder.Append("path.QuadTo(").Append(ShapeTool.smethod_3(points[0].X)).Append(",").Append(ShapeTool.smethod_3(points[0].Y)).Append(",").Append(ShapeTool.smethod_3(points[1].X)).Append(",").Append(ShapeTool.smethod_3(points[1].Y)).Append(");\n");
                    continue;

                case SegmentType.CubicTo:
                    stringBuilder.Append("path.CubicTo(").Append(ShapeTool.smethod_3(points[0].X)).Append(",").Append(ShapeTool.smethod_3(points[0].Y)).Append(",").Append(ShapeTool.smethod_3(points[1].X)).Append(",").Append(ShapeTool.smethod_3(points[1].Y)).Append(",").Append(ShapeTool.smethod_3(points[2].X)).Append(",").Append(ShapeTool.smethod_3(points[2].Y)).Append(");\n");
                    continue;

                case SegmentType.Close:
                    stringBuilder.Append("path.Close();\n");
                    continue;

                default:
                    continue;
                }
            }
            return(stringBuilder.ToString());
        }
コード例 #6
0
 public void Append(IShape2D shape, bool connect, Matrix4D transform)
 {
     this.Append(shape.CreateIterator(), connect, transform);
 }
コード例 #7
0
 public void Append(IShape2D shape, bool connect)
 {
     this.Append(shape.CreateIterator(), connect);
 }
コード例 #8
0
 public GeneralShape2D(IShape2D shape, Matrix4D transformation, bool fixate)
     : this(shape.CreateIterator(), transformation, fixate)
 {
     this.method_2(shape);
 }
コード例 #9
0
 public GeneralShape2D(IShape2D shape, Matrix3D transformation)
     : this(shape.CreateIterator(), transformation)
 {
     this.method_2(shape);
 }
コード例 #10
0
 public GeneralShape2D(IShape2D shape, bool fixate)
     : this(shape.CreateIterator(), fixate)
 {
     this.method_2(shape);
 }
コード例 #11
0
 public GeneralShape2D(IShape2D shape)
     : this(shape.CreateIterator())
 {
     this.method_2(shape);
 }
コード例 #12
0
ファイル: ShapeTool.cs プロジェクト: 15831944/WW
        public static List <Polyline4D> GetFlattened(
            ITransformer4D transformation,
            IShape2D shape,
            double epsilon)
        {
            if (epsilon == 0.0)
            {
                epsilon = -0.01;
            }
            List <Polyline4D> polyline4DList = new List <Polyline4D>();

            if (epsilon < 0.0)
            {
                Bounds2D bounds = ShapeTool.GetBounds(shape);
                if (!bounds.Initialized)
                {
                    return(polyline4DList);
                }
                epsilon *= -System.Math.Max(bounds.Delta.X, bounds.Delta.Y);
            }
            epsilon *= epsilon;
            ISegment2DIterator iterator = shape.CreateIterator();

            if (iterator.MoveNext())
            {
                Point2D[]  points   = new Point2D[3];
                Polyline4D polyline = (Polyline4D)null;
                Point2D    p0       = new Point2D();
                do
                {
                    switch (iterator.Current(points, 0))
                    {
                    case SegmentType.MoveTo:
                        polyline = new Polyline4D();
                        polyline4DList.Add(polyline);
                        polyline.Add(transformation.TransformTo4D(points[0]));
                        p0 = points[0];
                        break;

                    case SegmentType.LineTo:
                        polyline.Add(transformation.TransformTo4D(points[0]));
                        p0 = points[0];
                        break;

                    case SegmentType.QuadTo:
                        ShapeTool.smethod_8(polyline, transformation, p0, points[0], points[1], epsilon);
                        p0 = points[1];
                        break;

                    case SegmentType.CubicTo:
                        ShapeTool.smethod_12(polyline, transformation, p0, points[0], points[1], points[2], epsilon);
                        p0 = points[2];
                        break;

                    case SegmentType.Close:
                        polyline.Closed = true;
                        if (polyline.Count > 1 && polyline[polyline.Count - 1] == polyline[0])
                        {
                            polyline.RemoveAt(polyline.Count - 1);
                            break;
                        }
                        break;
                    }
                }while (iterator.MoveNext());
            }
            return(polyline4DList);
        }
コード例 #13
0
ファイル: ShapeTool.cs プロジェクト: 15831944/WW
        public static Polyline2DCollection GetFlattened(
            IShape2D shape,
            double epsilon)
        {
            if (epsilon == 0.0)
            {
                epsilon = -0.01;
            }
            Polyline2DCollection polyline2Dcollection = new Polyline2DCollection();

            if (epsilon < 0.0)
            {
                Bounds2D bounds = ShapeTool.GetBounds(shape);
                if (!bounds.Initialized)
                {
                    return(polyline2Dcollection);
                }
                epsilon *= -System.Math.Max(bounds.Delta.X, bounds.Delta.Y);
            }
            epsilon *= epsilon;
            ISegment2DIterator iterator = shape.CreateIterator();

            if (iterator.MoveNext())
            {
                Point2D[]  points   = new Point2D[3];
                Polyline2D polyline = (Polyline2D)null;
                do
                {
                    switch (iterator.Current(points, 0))
                    {
                    case SegmentType.MoveTo:
                        polyline = new Polyline2D();
                        polyline2Dcollection.Add(polyline);
                        polyline.Add(points[0]);
                        break;

                    case SegmentType.LineTo:
                        polyline.Add(points[0]);
                        break;

                    case SegmentType.QuadTo:
                        ShapeTool.smethod_7(polyline, polyline[polyline.Count - 1], points[0], points[1], epsilon);
                        break;

                    case SegmentType.CubicTo:
                        ShapeTool.smethod_11(polyline, polyline[polyline.Count - 1], points[0], points[1], points[2], epsilon);
                        break;

                    case SegmentType.Close:
                        polyline.Closed = true;
                        if (polyline.Count > 1 && polyline[polyline.Count - 1] == polyline[0])
                        {
                            polyline.RemoveAt(polyline.Count - 1);
                            break;
                        }
                        break;
                    }
                }while (iterator.MoveNext());
            }
            return(polyline2Dcollection);
        }
コード例 #14
0
ファイル: ShapeTool.cs プロジェクト: 15831944/WW
        public static Matrix3D?GetTransformation(
            IShape2D shape1,
            IShape2D shape2,
            double accuracy)
        {
            if (!shape1.HasSegments || !shape2.HasSegments)
            {
                return(new Matrix3D?());
            }
            ISegment2DIterator iterator1 = shape1.CreateIterator();
            ISegment2DIterator iterator2 = shape2.CreateIterator();

            if (iterator1.TotalPointCount != iterator2.TotalPointCount || iterator1.TotalSegmentCount != iterator2.TotalSegmentCount)
            {
                return(new Matrix3D?());
            }
            if (iterator1.MoveNext() && iterator2.MoveNext())
            {
                Point2D[] point2DArray1 = new Point2D[iterator1.TotalPointCount];
                Point2D[] point2DArray2 = new Point2D[iterator2.TotalPointCount];
                double    num1          = accuracy * accuracy;
                if (iterator1.Current(point2DArray1, 0) == iterator2.Current(point2DArray2, 0))
                {
                    Matrix3D?nullable = new Matrix3D?();
                    int      offset   = 1;
                    if (!iterator1.MoveNext() || !iterator2.MoveNext())
                    {
                        return(new Matrix3D?(Transformation3D.Translation(point2DArray2[0] - point2DArray1[0])));
                    }
                    do
                    {
                        int         num2         = offset;
                        SegmentType segmentType1 = iterator1.Current(point2DArray1, offset);
                        SegmentType segmentType2 = iterator2.Current(point2DArray2, offset);
                        if (segmentType1 == segmentType2)
                        {
                            offset += GeneralShape2D.int_1[(int)segmentType1];
                            if (!nullable.HasValue && offset >= 3)
                            {
                                nullable = ShapeTool.smethod_0(point2DArray1, point2DArray2);
                                num2     = 3;
                            }
                            if (nullable.HasValue)
                            {
                                int index = num2;
                                while (true)
                                {
                                    if (index < offset)
                                    {
                                        if ((nullable.Value.Transform(point2DArray1[index]) - point2DArray2[index]).GetLengthSquared() <= num1)
                                        {
                                            ++index;
                                        }
                                        else
                                        {
                                            goto label_15;
                                        }
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            goto label_14;
                        }
                    }while (iterator1.MoveNext() && iterator2.MoveNext());
                    goto label_16;
label_14:
                    return(new Matrix3D?());

label_15:
                    return(new Matrix3D?());

label_16:
                    return(nullable);
                }
            }
            return(new Matrix3D?());
        }