コード例 #1
0
ファイル: SpecGrid.cs プロジェクト: oilman007/PEXEL
 bool ReadFromCMG(string file)
 {
     try
     {
         using (StreamReader sr = new StreamReader(file))
         {
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 string[] split = CMGReader.ClearLine(line).Split();
                 if (split.Count() != 0 && split[0] == cmg_kw_specgrid)
                 {
                     NX        = int.Parse(split[2]);
                     NY        = int.Parse(split[3]);
                     NZ        = int.Parse(split[4]);
                     NumRes    = 1;
                     CoordType = CartesianCoordType;
                     return(true);
                 }
             }
         }
     }
     catch (Exception)
     {
         Init();
         return(false);
     }
     return(false);
 }
コード例 #2
0
ファイル: Coord.cs プロジェクト: oilman007/PEXEL
 bool ReadFromCMG(SpecGrid specGrid, string file)
 {
     try
     {
         using (StreamReader sr = new StreamReader(file))
         {
             Pillars = new Pillar[specGrid.NX + 1, specGrid.NY + 1];
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 if (CMGReader.ClearLine(line) == cmg_kw_coord)
                 {
                     break;
                 }
             }
             List <string> values       = new List <string>();
             int           valuesNeeded = 6 * (specGrid.NX + 1);
             int           n            = 0;
             for (int j = 0; j < specGrid.NY + 1; ++j)
             {
                 while (values.Count < valuesNeeded && (line = sr.ReadLine()) != null)// add
                 {
                     line = CMGReader.ClearLine(line);
                     if (line != string.Empty)
                     {
                         foreach (string word in line.Split())
                         {
                             values.Add(word);
                         }
                     }
                 }
                 for (int i = 0; i < specGrid.NX + 1; ++i)
                 {
                     double xt = double.Parse(values[n++]);
                     double yt = double.Parse(values[n++]);
                     double zt = double.Parse(values[n++]);
                     double xb = double.Parse(values[n++]);
                     double yb = double.Parse(values[n++]);
                     double zb = double.Parse(values[n++]);
                     Pillars[i, j] = new Pillar(xt, yt, zt, xb, yb, zb);
                 }
                 values.RemoveRange(0, valuesNeeded); // remove
                 n = 0;
             }
             return(true);
         }
     }
     catch (Exception)
     {
         Init();
         return(false);
     }
 }
コード例 #3
0
ファイル: Actnum.cs プロジェクト: oilman007/PEXEL
 bool ReadFromCMG(SpecGrid specGrid, string file)
 {
     try
     {
         using (StreamReader sr = new StreamReader(file))
         {
             Values = new bool[specGrid.NX, specGrid.NY, specGrid.NZ];
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 if (CMGReader.ClearLine(line) == cmg_kw_actnum)
                 {
                     break;
                 }
             }
             List <string> values       = new List <string>();
             int           valuesNeeded = specGrid.NX;
             int           n            = 0;
             for (int k = 0; k < specGrid.NZ; ++k)
             {
                 for (int j = 0; j < specGrid.NY; ++j)
                 {
                     while (values.Count < valuesNeeded && (line = sr.ReadLine()) != null)
                     {
                         line = CMGReader.ClearLine(line);
                         if (line != string.Empty)
                         {
                             foreach (string word in line.Split())
                             {
                                 values.Add(word);
                             }
                         }
                     }
                     for (int i = 0; i < specGrid.NX; ++i)
                     {
                         int value = int.Parse(values[n++]);
                         Values[i, j, k] = (value == 0) ? false : true;
                     }
                     values.RemoveRange(0, valuesNeeded);
                     n = 0;
                 }
             }
             return(true);
         }
     }
     catch (Exception)
     {
         Init();
         return(false);
     }
 }
コード例 #4
0
ファイル: Prop.cs プロジェクト: oilman007/PEXEL
 bool ReadCMG(int nx, int ny, int nz, string kw, string file)
 {
     try
     {
         using (StreamReader sr = new StreamReader(file))
         {
             Title  = kw;
             Values = new double[nx, ny, nz];
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 if (CMGReader.ClearLine(line) == kw)
                 {
                     break;
                 }
             }
             List <string> values       = new List <string>();
             int           valuesNeeded = nx;
             int           n            = 0;
             for (int k = 0; k < nz; ++k)
             {
                 for (int j = 0; j < ny; ++j)
                 {
                     while (values.Count < valuesNeeded && (line = sr.ReadLine()) != null)
                     {
                         line = CMGReader.ClearLine(line);
                         if (line != string.Empty)
                         {
                             foreach (string word in line.Split())
                             {
                                 values.Add(word);
                             }
                         }
                     }
                     for (int i = 0; i < nx; ++i)
                     {
                         Values[i, j, k] = double.Parse(values[n++]);
                     }
                     values.RemoveRange(0, valuesNeeded);
                     n = 0;
                 }
             }
             return(true);
         }
     }
     catch (Exception)
     {
         Clear();
         return(false);
     }
 }
コード例 #5
0
ファイル: Zcorn.cs プロジェクト: oilman007/PEXEL
 bool ReadFromCMG(SpecGrid specGrid, string file)
 {
     try
     {
         using (StreamReader sr = new StreamReader(file))
         {
             Items = new ZcornItem[specGrid.NX, specGrid.NY, specGrid.NZ];
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 if (CMGReader.ClearLine(line) == cmg_kw_zcorn)
                 {
                     break;
                 }
             }
             List <string> values       = new List <string>();
             int           valuesNeeded = 2 * specGrid.NX;
             int           n            = 0;
             int           c_last       = 2;
             int           jloop        = 1;
             int           kloop        = 1;
             for (int k = 0; k < specGrid.NZ; ++k)
             {
                 for (int j = 0; j < specGrid.NY; ++j)
                 {
                     while (values.Count < valuesNeeded && (line = sr.ReadLine()) != null) // add
                     {
                         line = CMGReader.ClearLine(line);
                         if (line != string.Empty)
                         {
                             foreach (string word in line.Split())
                             {
                                 values.Add(word);
                             }
                         }
                     }
                     for (int i = 0; i < specGrid.NX; ++i)
                     {
                         for (int c = c_last - 2; c < c_last; ++c)
                         {
                             Items[i, j, k].Corners[c] = double.Parse(values[n++]);
                         }
                     }
                     values.RemoveRange(0, valuesNeeded); // remove
                     n = 0;
                     if (jloop == 1)
                     {
                         jloop   = 2;
                         c_last += 2;
                         --j;
                     }
                     else
                     {
                         jloop   = 1;
                         c_last -= 2;
                     }
                 }
                 if (kloop == 1)
                 {
                     kloop   = 2;
                     c_last += 4;
                     --k;
                 }
                 else
                 {
                     kloop   = 1;
                     c_last -= 4;
                 }
             }
             return(true);
         }
     }
     catch (Exception)
     {
         Init();
         return(false);
     }
 }