/// <summary> 深复制成指定名称的关键字 isDisposeOld 是否清楚原有镜像文件 </summary> public TableKey TransToTableKeyByName(string name, bool isDisposeOld = false) { TableKey tb = KeyConfigerFactroy.Instance.CreateKey <TableKey>(name, this.BaseFile.SimKeyType) as TableKey; //// 复制行数据 //this.Lines.ForEach(l => tb.Lines.Add(l)); //tb.Build(this.z, this.x, this.y, mmfPath); tb.BuildTableEntity(this.z, this.x, this.y, MmfPath); // Todo :复制数据 //tb.RunModify(); for (int ix = 0; ix < this.x; ix++) { for (int iy = 0; iy < this.y; iy++) { for (int iz = 0; iz < this.z; iz++) { // 对值执行func操作 tb.Tables[iz].Set(iy, ix, this.Tables[iz].Get(iy, ix).ToString().ToDouble()); } } } if (isDisposeOld) { this.Close(); this.Dispose(); } return(tb); }
/// <summary> 执行更改 </summary> public void RunModify(TableKey funcKey) { if (CheckRegion(funcKey)) { double temp; bool isDouble = double.TryParse(value, out temp); if (isDouble) { // 遍历更改区域 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操作 //funcKey.Tables[z].Matrix.Mat[y, x] = func(funcKey.Tables[z].Matrix.Mat[y, x].ToString().ToDouble(), temp); // 对值执行func操作 funcKey.Tables[z].Set(y, x, func(funcKey.Tables[z].Get(y, x).ToString().ToDouble(), temp)); } } } } else { } } }
//DxyMmfEntity<double> _matrix = null; ///// <summary> 硬盘内存镜像 </summary> //public DxyMmfEntity<double> Matrix //{ // get { return _matrix; } // set { _matrix = value; } //} public GridTable(TableKey parent, int indexNum) { _parent = parent; _indexNum = indexNum; //string dir = Path.GetDirectoryName(parent.BaseFile.FilePath); //string filepath = Path.Combine(dir, parent.Name + "-" + Guid.NewGuid().ToString() + ".mmf"); ; //_matrix = new DxyMmfEntity<double>(filepath, parent.X * parent.Y * parent.Z); }
/// <summary> 检查修改分区是否合法 </summary> public bool CheckRegion(TableKey funcKey) { if (region.ZTo > funcKey.Z || region.XTo > funcKey.X || region.YTo > funcKey.Y ) { throw new Exception("CheckRegion() err Dimens Count"); } else { return(true); } }
public TableKey Clone() { TableKey clone = new TableKey(this.Name); clone.X = this.x; clone.Y = this.y; clone.Z = this.z; foreach (GridTable t in this.Tables) { clone.Tables.Add(t.Clone()); } return(clone); }
/// <summary> 执行复值 p1=被复值参数 </summary> public void RunModify(TableKey toKey, TableKey fromKey) { if (CheckRegion(toKey)) { // 遍历更改区域 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操作 //toKey.Tables[z].Matrix.Mat[y, x] = fromKey.Tables[z].Matrix.Mat[y, x]; // 对值执行func操作 toKey.Tables[z].Set(y, x, fromKey.Tables[z].Get(y, x)); } } } } }
/// <summary> 执行复值 </summary> public void RunModify(TableKey funcKey) { if (CheckRegion(funcKey)) { // 遍历更改区域 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操作 //funcKey.Tables[z].Matrix.Mat[y, x] = key.Tables[z - region.ZFrom].Matrix.Mat[y - region.YFrom, x - region.XFrom]; // 对值执行func操作 funcKey.Tables[z].Set(y, x, key.Tables[z - region.ZFrom].Get(y - region.YFrom, x - region.XFrom)); } } } } }
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); } } } }
/// <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); } } } }
/// <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); } } } }