コード例 #1
0
        public V3DataOnGrid(string info, DateTime time, Grid1D xgrid, Grid1D ygrid) : base(info, time)
        {
            XGrid = xgrid;
            YGrid = ygrid;

            Value = new double[xgrid.NSteps, ygrid.NSteps];
        }
コード例 #2
0
        public V3DataOnGrid(string filename) : base("", new DateTime())
        {
            // .: FORMAT :.
            // {string   Info}\n
            // {DateTime Time}\n
            // {float StepX}\n
            // {int NStepsX}\n
            // {float StepY}\n
            // {int NStepsY}\n
            // {double Value[0, 0]}\n
            // {double Value[0, 1]}\n
            // ...
            // {double Value[0, NStepsY]}\n
            // {double Value[1, 0]}\n
            // ...
            // {double Value[NStepsX, NStepsY]}\n

            FileStream  fs          = null;
            CultureInfo cultureInfo = new CultureInfo("ru-RU");

            cultureInfo.NumberFormat.NumberDecimalSeparator = ",";
            try
            {
                fs = new FileStream(filename, FileMode.Open);
                StreamReader sr = new StreamReader(fs);
                // base class
                Info = sr.ReadLine();
                Time = Convert.ToDateTime(sr.ReadLine(), cultureInfo);

                float Step;
                int   NSteps;
                // XGrid
                Step   = (float)Convert.ToDouble(sr.ReadLine(), cultureInfo);
                NSteps = Convert.ToInt32(sr.ReadLine(), cultureInfo);
                XGrid  = new Grid1D(Step, NSteps);
                // YGrid
                Step   = (float)Convert.ToDouble(sr.ReadLine(), cultureInfo);
                NSteps = Convert.ToInt32(sr.ReadLine(), cultureInfo);
                YGrid  = new Grid1D(Step, NSteps);

                // Value[,]
                Value = new double[XGrid.NSteps, YGrid.NSteps];
                for (int i = 0; i < XGrid.NSteps; ++i)
                {
                    for (int j = 0; j < YGrid.NSteps; ++j)
                    {
                        Value[i, j] = Convert.ToDouble(sr.ReadLine(), cultureInfo);
                    }
                }

                sr.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }