Ejemplo n.º 1
0
        public Res11(string Res11FileName)
        {
            AbsoluteFileName = System.IO.Path.GetFullPath(Res11FileName);
            df = DHI.Generic.MikeZero.DFS.DfsFileFactory.DfsGenericOpen(AbsoluteFileName);

            //For some reason the next line gives an error on one of GEUS' XP-machine. The NumberOfTimeSteps == 0
            TimeSteps = df.FileInfo.TimeAxis.GetDateTimes();

            for (int i = 0; i < df.FileInfo.TimeAxis.NumberOfTimeSteps; i++)
            {
                TimeSteps[i] = TimeSteps[0].AddSeconds(df.ReadItemTimeStep(1, i).TimeInSeconds(df.FileInfo.TimeAxis));
            }
            int offset = 4;
            int nitems = df.ItemInfo.Count() / 2;

            Points = new List <Res11Point>();
            for (int j = 0; j < nitems; j++)
            {
                string name = System.Text.Encoding.ASCII.GetString((byte[])StaticData[offset].Data).Replace("\0", "");
                string topo = System.Text.Encoding.ASCII.GetString((byte[])StaticData[offset + 1].Data).Replace("\0", "");

                PointType           pt = PointType.Discharge;
                int                 waterlevelcounter = 0;
                int                 dischargecounter  = 0;
                int                 itemcounter;
                IDfsDynamicItemInfo CurrentItem;
                for (int i = 0; i < StaticData[offset + 2].ElementCount; i++)
                {
                    if (pt == PointType.Discharge)
                    {
                        itemcounter = waterlevelcounter;
                        CurrentItem = df.ItemInfo[j];
                        waterlevelcounter++;
                        pt = PointType.WaterLevel;
                    }
                    else
                    {
                        itemcounter = dischargecounter;
                        CurrentItem = df.ItemInfo[j + nitems];
                        dischargecounter++;
                        pt = PointType.Discharge;
                    }

                    double chain = (double)(float)StaticData[offset + 2].Data.GetValue(i);
                    double x     = (double)(float)StaticData[offset + 3].Data.GetValue(i);
                    double y     = (double)(float)StaticData[offset + 4].Data.GetValue(i);
                    Points.Add(new Res11Point(this, CurrentItem, itemcounter, chain, name, topo, x, y, pt));
                }

                int ncross = ((int[])StaticData[offset + 13].Data).Count(var => var != 0);
                offset = offset + 23 + 4 * ncross;
            }

            StaticData.Clear();
        }