예제 #1
0
 public ModifyApplyModel(string k, RegionParam r, string v, Func <double, double, double> f)
 {
     key    = k;
     region = r;
     value  = v;
     func   = f;
 }
예제 #2
0
            public ModifyApplyModel ToModel(Func <double, double, double> func, ModifyKey modify)
            {
                RegionParam region = null;

                if (
                    !string.IsNullOrEmpty(xf3) &&
                    !string.IsNullOrEmpty(xt4) &&
                    !string.IsNullOrEmpty(yf5) &&
                    !string.IsNullOrEmpty(yt6) &&
                    !string.IsNullOrEmpty(zf7) &&
                    !string.IsNullOrEmpty(zt8))
                {
                    region       = new RegionParam();
                    region.XFrom = xf3.ToInt();
                    region.XTo   = xt4.ToInt();
                    region.YFrom = yf5.ToInt();
                    region.YTo   = yt6.ToInt();
                    region.ZFrom = zf7.ToInt();
                    region.ZTo   = zt8.ToInt();

                    // Todo :将当前范围附加到临时关键字上
                    modify.DefautRegion = region;
                    //modify.BaseFile.TempRegion = region;
                }
                else
                {
                    region = modify.DefautRegion;
                    //region = modify.BaseFile.TempRegion;
                }

                ModifyApplyModel model = new ModifyApplyModel(this.p1, region, this.p2, func);

                return(model);
            }
예제 #3
0
            public ModifyCopyModel ToModel(COPY copy)
            {
                RegionParam region = null;

                if (
                    !string.IsNullOrEmpty(xf3) &&
                    !string.IsNullOrEmpty(xt4) &&
                    !string.IsNullOrEmpty(yf5) &&
                    !string.IsNullOrEmpty(yt6) &&
                    !string.IsNullOrEmpty(zf7) &&
                    !string.IsNullOrEmpty(zt8))
                {
                    region       = new RegionParam();
                    region.XFrom = xf3.ToInt();
                    region.XTo   = xt4.ToInt();
                    region.YFrom = yf5.ToInt();
                    region.YTo   = yt6.ToInt();
                    region.ZFrom = zf7.ToInt();
                    region.ZTo   = zt8.ToInt();

                    //copy.BaseFile.TempRegion = region;
                    copy.defautRegion = region;
                }
                else
                {
                    //region = copy.BaseFile.TempRegion;
                    region = copy.defautRegion;
                }

                ModifyCopyModel model = new ModifyCopyModel(this.p2, region, this.p1);

                return(model);
            }
예제 #4
0
        /// <summary> 深复制 </summary>
        public RegionParam Copy()
        {
            RegionParam r = new RegionParam();

            r.xFrom = this.xFrom;
            r.xTo   = this.xTo;
            r.yFrom = this.yFrom;
            r.yTo   = this.yTo;
            r.zFrom = this.zFrom;
            r.zTo   = this.zTo;
            return(r);
        }
예제 #5
0
        /// <summary> 修正关键字 对关键字的指定范围值执行Func操作 </summary>
        public void RunModify(Func <double, double> func)
        {
            RegionParam region = new RegionParam();

            region.XFrom = 1;
            region.XTo   = this.x;
            region.YFrom = 1;
            region.YTo   = this.y;
            region.ZFrom = 1;
            region.ZTo   = this.z;

            RunModify(func, region);
        }
예제 #6
0
 /// <summary> 检查修改分区是否合法 </summary>
 bool CheckRegion(RegionParam region)
 {
     if (region.ZTo > this.Z ||
         region.XTo > this.X ||
         region.YTo > this.Y
         )
     {
         throw new Exception("CheckRegion() err Dimens Count");
     }
     else
     {
         return(true);
     }
 }
예제 #7
0
        void CmdGetItems()
        {
            string str = string.Empty;

            for (int i = 0; i < Lines.Count; i++)
            {
                str = Lines[i];
                //  读到结束符不继续读取
                if (str.StartsWith("/") && str.EndsWith("/"))
                {
                    break;
                }

                //  不为空的行
                if (str.IsWorkLine())
                {
                    List <string> newStr = str.EclExtendToArray();

                    if (newStr.Count > 0)
                    {
                        ModifyItem pitem = new ModifyItem();
                        pitem.Build(newStr);
                        //  标记行的ID位置
                        //Lines[i] = pitem.ID;
                        if (pitem != null)
                        {
                            Items.Add(pitem);
                        }
                    }
                }
            }


            if (this.DefautRegion == null)
            {
                this.DefautRegion = this.BaseFile.TempRegion;
            }

            ConvertToModel();
        }
예제 #8
0
        /// <summary> 修正关键字 对关键字的指定范围值执行Func操作 </summary>
        public void RunModify(Func <double, double> func, RegionParam region)
        {
            if (CheckRegion(region))
            {
                double temp;

                //  遍历更改区域
                for (int x = region.XFrom; x < region.XTo; x++)
                {
                    for (int y = region.YFrom; y < region.YTo; y++)
                    {
                        for (int z = region.ZFrom; z < region.ZTo; z++)
                        {
                            ////  对值执行func操作
                            //this.Tables[z].Matrix.Mat[y, x] = func(this.Tables[z].Matrix.Mat[y, x].ToString().ToDouble());


                            //  对值执行func操作
                            this.Tables[z].Set(y, x, func(this.Tables[z].Get(y, x).ToString().ToDouble()));
                        }
                    }
                }
            }
        }
예제 #9
0
 public ModifyCopyModel(string k, RegionParam r, string v)
 {
     key    = k;
     region = r;
     value  = v;
 }
예제 #10
0
 public ModifyBoxModel(TableKey k, RegionParam r)
 {
     key    = k;
     region = r;
 }
        /// <summary> 对文件执行修改关键字修改 跟DataImportEcl对接方法 </summary>
        public static void RunModify_bak(this EclipseData ecl)
        {
            //  查找所有修改关键字
            List <ModifyKey> modify = ecl.Key.FindAll <ModifyKey>();

            DIMENS d = ecl.Key.Find <DIMENS>();

            if (d == null)
            {
                return;
            }

            //  构造全网格范围
            RegionParam tempRegion = new RegionParam();

            tempRegion.XFrom = 1;
            tempRegion.XTo   = d.X;
            tempRegion.YFrom = 1;
            tempRegion.YTo   = d.Y;
            tempRegion.ZFrom = 1;
            tempRegion.ZTo   = d.Z;

            foreach (ModifyKey m in modify)
            {
                ParentKey p = m.GetParentKey();

                if (p != null && p.Name == "EDIT")
                {
                    continue;
                }

                //  是空则用临时范围
                if (m.DefautRegion == null)
                {
                    m.DefautRegion = tempRegion;
                }
                else
                {
                    //  不是空赋值临时范围
                    tempRegion = m.DefautRegion;
                }

                foreach (IModifyModel md in m.ObsoverModel)
                {
                    //  是空则用临时范围
                    if (md.Region == null)
                    {
                        md.Region = tempRegion;
                    }
                    else
                    {
                        //  不是空赋值临时范围
                        tempRegion = md.Region;
                    }



                    if (md is ModifyApplyModel)
                    {
                        TableKey funKey = ecl.Key.Find <TableKey>(l => l.Name == md.KeyName);

                        if (funKey == null)
                        {
                            //  没有则创建关键字
                            funKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(md.KeyName) as TableKey;

                            m.ParentKey.Add(funKey);
                        }

                        funKey.Build(d.Z, d.X, d.Y);

                        ModifyApplyModel app = md as ModifyApplyModel;

                        app.RunModify(funKey);
                    }
                    else if (md is ModifyCopyModel)
                    {
                        ModifyCopyModel copy = md as ModifyCopyModel;

                        TableKey copyKey = ecl.Key.Find <TableKey>(l => l.Name == copy.Key);

                        if (copyKey == null)
                        {
                            //  没有则创建关键字
                            copyKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(copy.Key, ecl.SimKeyType) as TableKey;

                            m.ParentKey.Add(copyKey);
                        }

                        TableKey funKey = ecl.Key.Find <TableKey>(l => l.Name == copy.Value);

                        if (funKey == null)
                        {
                            //  没有则创建关键字
                            funKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(copy.Value) as TableKey;

                            m.ParentKey.Add(funKey);
                        }

                        funKey.Build(d.Z, d.X, d.Y);

                        copyKey.Build(d.Z, d.X, d.Y);

                        copy.RunModify(copyKey, funKey);
                    }
                    else if (md is ModifyBoxModel)
                    {
                        TableKey funKey = ecl.Key.Find <TableKey>(l => l.Name == md.KeyName);

                        if (funKey == null)
                        {
                            //  没有则创建关键字
                            funKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(md.KeyName) as TableKey;

                            m.ParentKey.Add(funKey);
                        }

                        funKey.Build(d.Z, d.X, d.Y);

                        ModifyBoxModel app = md as ModifyBoxModel;

                        app.RunModify(funKey);
                    }
                }
            }
        }
예제 #12
0
        /// <summary> 用修正参数获取临时数据 endPosition 碰到此修正参数退出 </summary>
        public void RefreshCacheTable(CARFIN carfin, List <ModifyKey> modifys, IModifyModel endPosition = null)
        {
            if (!IsModifyChanged)
            {
                return;
            }

            this.InitCacheTables();

            IsModifyChanged = false;


            //  构造全网格范围
            RegionParam tempRegion = new RegionParam();

            tempRegion.XFrom = 1;
            tempRegion.XTo   = carfin.X;
            tempRegion.YFrom = 1;
            tempRegion.YTo   = carfin.Y;
            tempRegion.ZFrom = 1;
            tempRegion.ZTo   = carfin.Z;

            foreach (ModifyKey m in modifys)
            {
                //  是空则用临时范围
                if (m.DefautRegion == null)
                {
                    m.DefautRegion = tempRegion;
                }
                else
                {
                    //  不是空赋值临时范围
                    tempRegion = m.DefautRegion;
                }

                List <IModifyModel> models = new List <IModifyModel>();
                //  加载本修改模型中关键字
                models.AddRange(m.ObsoverModel);

                //  加载子修改模型中关键字 如BOX
                List <ModifyKey> ms = m.FindAll <ModifyKey>();

                ms.Remove(m);

                ms.ForEach(l => models.AddRange(l.ObsoverModel));

                foreach (IModifyModel md in models)
                {
                    //  读取到结束标记处退出
                    if (endPosition != null && md == endPosition)
                    {
                        return;
                    }

                    //  是空则用临时范围
                    if (md.Region == null)
                    {
                        md.Region = tempRegion;
                    }
                    else
                    {
                        //  不是空赋值临时范围
                        tempRegion = md.Region;
                    }

                    if (md.KeyName != this.Name)
                    {
                        continue;
                    }

                    if (md is ModifyApplyModel)
                    {
                        ModifyApplyModel app = md as ModifyApplyModel;

                        app.RunModify(this.CacheTable);
                    }
                    else if (md is ModifyCopyModel)
                    {
                        ModifyCopyModel copy = md as ModifyCopyModel;

                        //  查找关键字模型
                        ModifyBoxModel boxModel = carfin.ObsoverModel.Find(l => l is ModifyBoxModel && l.KeyName == copy.Value) as ModifyBoxModel;

                        TableKey copyKey = null;

                        if (boxModel != null)
                        {
                            copyKey = boxModel.Key;
                        }

                        if (copyKey == null)
                        {
                            //  没有则创建关键字
                            copyKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(copy.Value, this.BaseFile.SimKeyType) as TableKey;

                            m.ParentKey.Add(copyKey);
                        }

                        copyKey.Build(this.Z, this.X, this.Y);

                        copyKey.RefreshCacheTable(carfin, modifys, copy);

                        copyKey.IsModifyChanged = true;

                        copy.RunModify(this.CacheTable, copyKey.CacheTable);

                        copyKey.IsModifyChanged = true;
                    }
                    else if (md is ModifyBoxModel)
                    {
                        ModifyBoxModel app = md as ModifyBoxModel;

                        app.RunModify(this.CacheTable);
                    }
                }
            }
        }
예제 #13
0
        /// <summary> 用修正参数获取临时数据 endPosition 碰到此修正参数退出 </summary>
        public void RefreshCacheTable(EclipseData _eclData, List <ModifyKey> modifys, IModifyModel endPosition = null)
        {
            if (!IsModifyChanged)
            {
                return;
            }

            this.InitCacheTables();

            //  查找所有修改关键字
            //List<ModifyKey> modifys = _eclData.Key.FindAll<ModifyKey>();

            ////  获取当前关键字关联的修改关键字
            //List<ModifyKey> thisModify = modifys.FindAll(l => l.ObsoverModel.Exists(k => k.KeyName == this.Name));

            DIMENS d = _eclData.Key.Find <DIMENS>();

            if (d == null)
            {
                return;
            }

            IsModifyChanged = false;

            //  构造全网格范围
            RegionParam tempRegion = new RegionParam();

            tempRegion.XFrom = 1;
            tempRegion.XTo   = d.X;
            tempRegion.YFrom = 1;
            tempRegion.YTo   = d.Y;
            tempRegion.ZFrom = 1;
            tempRegion.ZTo   = d.Z;

            foreach (ModifyKey m in modifys)
            {
                //  是空则用临时范围
                if (m.DefautRegion == null)
                {
                    m.DefautRegion = tempRegion;
                }
                else
                {
                    //  不是空赋值临时范围
                    tempRegion = m.DefautRegion;
                }



                foreach (IModifyModel md in m.ObsoverModel)
                {
                    //  读取到结束标记处退出
                    if (endPosition != null && md == endPosition)
                    {
                        return;
                    }

                    //  是空则用临时范围
                    if (md.Region == null)
                    {
                        md.Region = tempRegion;
                    }
                    else
                    {
                        //  不是空赋值临时范围
                        tempRegion = md.Region;
                    }

                    if (md.KeyName != this.Name)
                    {
                        continue;
                    }

                    if (md is ModifyApplyModel)
                    {
                        ModifyApplyModel app = md as ModifyApplyModel;

                        app.RunModify(this.CacheTable);
                    }
                    else if (md is ModifyCopyModel)
                    {
                        ModifyCopyModel copy = md as ModifyCopyModel;

                        TableKey copyKey = _eclData.Key.Find <TableKey>(l => l.Name == copy.Value);

                        ////  取到当前位置
                        //List<ModifyKey> modifysCopyPosition = modifys.TakeWhile(l => l == m).ToList();

                        ////  取当前model位置
                        //List<IModifyModel> modelCopyPosition = m.ObsoverModel.TakeWhile(l => l == md).ToList();

                        //modifysCopyPosition.rem

                        if (copyKey == null)
                        {
                            //  没有则创建关键字
                            copyKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(copy.Value, this.BaseFile.SimKeyType) as TableKey;

                            m.ParentKey.Add(copyKey);
                        }

                        copyKey.Build(this.Z, this.X, this.Y);

                        copyKey.RefreshCacheTable(_eclData, modifys, copy);

                        copyKey.IsModifyChanged = true;

                        copy.RunModify(this.CacheTable, copyKey.CacheTable);
                    }
                    else if (md is ModifyBoxModel)
                    {
                        ModifyBoxModel app = md as ModifyBoxModel;

                        app.RunModify(this.CacheTable);
                    }
                }
            }
        }