Example #1
0
        public V3DataOnGrid(string id, DateTime w, Grid1D grid_x, Grid1D grid_y) : base(id, w)

        {
            Dt = w;

            info = id;

            array = new double[grid_x.count, grid_y.count];
        }
Example #2
0
 public V3DataOnGridEnumerator(double[,] values_, Grid1D grid_x, Grid1D grid_y)
 {
     values = new DataItem[grid_x.count, grid_y.count];
     for (int i = 0; i < grid_x.count; i++)
     {
         for (int j = 0; j < grid_y.count; j++)
         {
             values[i, j] = new DataItem(new Vector2(i * grid_x.step, j * grid_y.step), values_[i, j]);
         }
     }
 }
Example #3
0
        public V3DataOnGrid(string filename) : base("", new DateTime())
        {
            // .: FORMAT :.
            // {string   info}\n
            // {DateTime Dt}\n
            // {float StepX}\n
            // {int countX}\n
            // {float StepY}\n
            // {int countY}\n
            // {double array[0, 0]}\n
            // {double array[0, 1]}\n
            // ...
            // {double array[0, countY]}\n
            // {double array[1, 0]}\n
            // ...
            // {double array[countX, countY]}\n

            FileStream fs = null;

            try
            {
                fs = new FileStream(filename, FileMode.Open);
                StreamReader sr = new StreamReader(fs);
                // base class
                info = sr.ReadLine();
                Dt   = Convert.ToDateTime(sr.ReadLine());

                float Step;
                int   count;
                // grid_x
                Step   = (float)Convert.ToDouble(sr.ReadLine());
                count  = Convert.ToInt32(sr.ReadLine());
                grid_x = new Grid1D(Step, count);
                // grid_y
                Step   = (float)Convert.ToDouble(sr.ReadLine());
                count  = Convert.ToInt32(sr.ReadLine());
                grid_y = new Grid1D(Step, count);

                // array[,]
                array = new double[grid_x.count, grid_y.count];
                for (int i = 0; i < grid_x.count; ++i)
                {
                    for (int j = 0; j < grid_y.count; ++j)
                    {
                        array[i, j] = Convert.ToDouble(sr.ReadLine());
                    }
                }

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