public void Initialize(IArgument[] properties)
        {
            MsheOrg.Initialize(properties);

            string mshefilename = System.IO.Path.Combine(properties.First(a => a.Key == "SetupPath").Value, properties.First(a => a.Key == "SetupFileName").Value);

            Model mshe = new Model(mshefilename);

            List <double> InnerXValues = new List <double>();
            List <double> InnerYValues = new List <double>();

            int k = 0;

            for (int j = 0; j < mshe.GridInfo.NumberOfColumns; j++)
            {
                for (int i = 0; i < mshe.GridInfo.NumberOfRows; i++)
                {
                    if (mshe.GridInfo.ModelDomainAndGrid.Data[i, j] == 1)
                    {
                        InnerXValues.Add(mshe.GridInfo.GetXCenter(j));
                        InnerYValues.Add(mshe.GridInfo.GetYCenter(i));
                        InnerIdeces.Add(k);
                        k++;
                    }
                    else if (mshe.GridInfo.ModelDomainAndGrid.Data[i, j] == 2)
                    {
                        k++;
                    }
                }
            }


            DHI.OpenMI.MikeShe.BaseGridElementSet NewBaseGrid = new DHI.OpenMI.MikeShe.BaseGridElementSet(new DHI.MikeShe.Engine.BaseGrid(InnerXValues.Count, InnerXValues.ToArray(), InnerYValues.ToArray(), mshe.GridInfo.GridSize, 0));

            mshe.Dispose();
            for (int i = 0; i < MsheOrg.OutputExchangeItemCount; i++)
            {
                var org = MsheOrg.GetOutputExchangeItem(i);

                if (org.ElementSet.ID == "BaseGrid")
                {
                    OutputExchangeItem onew = new OutputExchangeItem();
                    onew.Quantity   = org.Quantity;
                    onew.ElementSet = NewBaseGrid;
                    for (int j = 0; j < org.DataOperationCount; j++)
                    {
                        onew.AddDataOperation(org.GetDataOperation(j));
                    }
                    OutputExchangeItems.Add(onew);
                }
                else
                {
                    OutputExchangeItems.Add(org);
                }
            }
        }
     public void Initialize(IArgument[] properties)
    {
      MsheOrg.Initialize(properties);

      string mshefilename = System.IO.Path.Combine(properties.First(a => a.Key == "SetupPath").Value, properties.First(a => a.Key == "SetupFileName").Value);

      Model mshe = new Model(mshefilename);

      List<double> InnerXValues= new List<double>();
      List<double> InnerYValues = new List<double>();

      int k=0;
        for(int j=0;j<mshe.GridInfo.NumberOfColumns;j++)
          for (int i = 0; i < mshe.GridInfo.NumberOfRows; i++)
          {
          if (mshe.GridInfo.ModelDomainAndGrid.Data[i, j] == 1)
          {
            InnerXValues.Add(mshe.GridInfo.GetXCenter(j));
            InnerYValues.Add(mshe.GridInfo.GetYCenter(i));
            InnerIdeces.Add(k);
            k++;
          }
          else if (mshe.GridInfo.ModelDomainAndGrid.Data[i, j] == 2)
            k++;
        }


        DHI.OpenMI.MikeShe.BaseGridElementSet NewBaseGrid = new DHI.OpenMI.MikeShe.BaseGridElementSet(new DHI.MikeShe.Engine.BaseGrid(InnerXValues.Count, InnerXValues.ToArray(), InnerYValues.ToArray(), mshe.GridInfo.GridSize,0));

      mshe.Dispose();
      for (int i = 0; i < MsheOrg.OutputExchangeItemCount; i++)
      {
        var org = MsheOrg.GetOutputExchangeItem(i);

        if (org.ElementSet.ID == "BaseGrid")
        {
          OutputExchangeItem onew = new OutputExchangeItem();
          onew.Quantity = org.Quantity;
          onew.ElementSet = NewBaseGrid;
          for (int j = 0; j < org.DataOperationCount; j++)
          {
            onew.AddDataOperation(org.GetDataOperation(j));
          }
          OutputExchangeItems.Add(onew);
        }
        else
        {
          OutputExchangeItems.Add(org);
        }
      }
    }
Пример #3
0
        private OutputExchangeItem addDataOperations(OutputExchangeItem outputexchangeitem)
        {
            //Add dataoperations to outputexchangeitems
            ElementMapper elementMapper  = new ElementMapper();
            ArrayList     dataOperations = new ArrayList();

            dataOperations = elementMapper.GetAvailableDataOperations(outputexchangeitem.ElementSet.ElementType);
            bool spatialDataOperationExists;
            bool linearConversionDataOperationExists;
            bool smartBufferDataOperationExists;

            foreach (IDataOperation dataOperation in dataOperations)
            {
                spatialDataOperationExists = false;
                foreach (IDataOperation existingDataOperation in outputexchangeitem.DataOperations)
                {
                    if (dataOperation.ID == existingDataOperation.ID)
                    {
                        spatialDataOperationExists = true;
                    }
                }

                if (!spatialDataOperationExists)
                {
                    outputexchangeitem.AddDataOperation(dataOperation);
                }
            }

            IDataOperation linearConversionDataOperation = new LinearConversionDataOperation();

            linearConversionDataOperationExists = false;
            foreach (IDataOperation existingDataOperation in outputexchangeitem.DataOperations)
            {
                if (linearConversionDataOperation.ID == existingDataOperation.ID)
                {
                    linearConversionDataOperationExists = true;
                }
            }

            if (!linearConversionDataOperationExists)
            {
                outputexchangeitem.AddDataOperation(new LinearConversionDataOperation());
            }

            IDataOperation smartBufferDataOperaion = new SmartBufferDataOperation();

            smartBufferDataOperationExists = false;
            foreach (IDataOperation existingDataOperation in outputexchangeitem.DataOperations)
            {
                if (smartBufferDataOperaion.ID == existingDataOperation.ID)
                {
                    smartBufferDataOperationExists = true;
                }
            }

            if (!smartBufferDataOperationExists)
            {
                outputexchangeitem.AddDataOperation(new SmartBufferDataOperation());
            }

            return(outputexchangeitem);
        }
Пример #4
0
        /// <summary>
        /// get a output exchange item
        /// </summary>
        /// <param name="index">index number of the requested output exchange item</param>
        /// <returns>The requested exchange item</returns>
        public override IOutputExchangeItem GetOutputExchangeItem(int index)
        {
            OutputExchangeItem outputExchangeItem = ((IEngine)_engineApiAccess).GetOutputExchangeItem(index);

            //Add dataoperations to outputExchangeItems
            ElementMapper elementMapper  = new ElementMapper();
            ArrayList     dataOperations = new ArrayList();

            dataOperations = elementMapper.GetAvailableDataOperations(outputExchangeItem.ElementSet.ElementType);
            bool spatialDataOperationExists;
            bool linearConversionDataOperationExists;
            bool smartBufferDataOperationExists;

            foreach (IDataOperation dataOperation in dataOperations)
            {
                spatialDataOperationExists = false;
                foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
                {
                    if (dataOperation.ID == existingDataOperation.ID)
                    {
                        spatialDataOperationExists = true;
                    }
                }

                if (!spatialDataOperationExists)
                {
                    outputExchangeItem.AddDataOperation(dataOperation);
                }
            }

            IDataOperation linearConversionDataOperation = new LinearConversionDataOperation();

            linearConversionDataOperationExists = false;
            foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
            {
                if (linearConversionDataOperation.ID == existingDataOperation.ID)
                {
                    linearConversionDataOperationExists = true;
                }
            }

            if (!linearConversionDataOperationExists)
            {
                outputExchangeItem.AddDataOperation(new LinearConversionDataOperation());
            }

            IDataOperation smartBufferDataOperaion = new SmartBufferDataOperation();

            smartBufferDataOperationExists = false;
            foreach (IDataOperation existingDataOperation in outputExchangeItem.DataOperations)
            {
                if (smartBufferDataOperaion.ID == existingDataOperation.ID)
                {
                    smartBufferDataOperationExists = true;
                }
            }

            if (!smartBufferDataOperationExists)
            {
                outputExchangeItem.AddDataOperation(new SmartBufferDataOperation());
            }

            return((IOutputExchangeItem)outputExchangeItem);
        }
Пример #5
0
 public void Init()
 {
     exchangeItem = new OutputExchangeItem();
     exchangeItem.AddDataOperation(new DataOperation("DataOperation"));
 }