public override ShapeBase ReadShape(IO.TextReader TReader)
        {
            var Reader = new IO.TextReaderWE(TReader);
            var Shapes = new ShapeCollection() { Name = "Parts" };

            var Lines = new List<Line>();

            while (!Reader.IsFinished)
            {
                Line L;
                PointF P1, P2;

                if (Reader.ReadLine().Trim() != "zone")
                {
                    throw new Exception("Invalid output");
                }

                var t = new String[] { " " };
                var PS = Reader.ReadLine().Split(t, StringSplitOptions.RemoveEmptyEntries);
                P1 = new PointF(Single.Parse(PS[0]), Single.Parse(PS[1]));
                PS = Reader.ReadLine().Split(t, StringSplitOptions.RemoveEmptyEntries);
                P2 = new PointF(Single.Parse(PS[0]), Single.Parse(PS[1]));
                L = new Line(P1, P2);
                Lines.Add(L);
            }

            Shapes.Shapes.Add(new LinesShape(Lines) { Name = "Part 1" });

            return Shapes;
        }
示例#2
0
 public Project()
 {
     this._InputFileName = "input.txt";
     this._OutputFileName = "output.txt";
     this._ProjectFilePath = null;
     this._Shape = new ShapeCollection() { Name = "Shapes" };
     this._ShapesForInput = new ShapeHierarchyList(this._Shape);
 }
示例#3
0
 protected Project(SerializationInfo Info, StreamingContext Context)
 {
     Utils.Deserializing();
     this._InputFileName = Info.GetString("InputFileName");
     this._InputFileTypeKey = Info.GetString("InputFileTypeKey");
     this._OutputFileName = Info.GetString("OutputFileName");
     this._OutputFileTypeKey = Info.GetString("OutputFileTypeKey");
     //this._ProjectFilePath = Info.GetString("ProjectFilePath");
     this._Shape = (ShapeCollection)Info.GetValue("Shape", typeof(ShapeCollection));
     this._ShapesForInput = (ShapeHierarchyList)Info.GetValue("ShapesToOutput", typeof(ShapeHierarchyList));
 }
        public override ShapeBase ReadShape(IO.TextReader Reader)
        {
            int n = int.Parse(Reader.ReadLine().Trim());
            var ar = new int[n];
            for (int i = 0; i < n; i++)
            {
                ar[i] = int.Parse(Reader.ReadLine().Trim());
            }
            int m = int.Parse(Reader.ReadLine().Trim());

            var Points = new PointF[m];

            for (int i = 0; i < m; i++)
            {
                var L = Reader.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                Points[i] = new PointF(Single.Parse(L[0]), Single.Parse(L[1]));
            }

            var Collection = new ShapeCollection() { Name = "Parts" };

            var MyColors = new Color[] { Color.Red, Color.Blue, Color.Magenta, Color.Green, Color.Teal };

            for (int i = 0; i < n; i++)
            {
                m = ar[i];
                var S = new List<Line>();

                for (int j = 0; j < m; j++)
                {
                    var L = Reader.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    S.Add(new Line(Points[int.Parse(L[0]) - 1], Points[int.Parse(L[1]) - 1]));
                }

                Collection.Shapes.Add(new LinesShape(S) { Color = MyColors[i], Name = "Part " + (i + 1).ToString() });
            }

            return Collection;
        }