private bool MergeModels(IFeatureClass fc, string geometryField, int[] oidList, IResourceManager resMgr, ref IModelPoint desModelPoint) { bool flag = true; bool result; try { if (fc == null || oidList == null) { result = false; return(result); } Gvitech.CityMaker.Resource.IModel model = resMgr.GetModel(desModelPoint.ModelName); IMatrix matrix = desModelPoint.AsMatrix().Clone(); matrix.Inverse(); int position = fc.GetFields().IndexOf(geometryField); IFdeCursor rows = fc.GetRows(oidList, false); IVector3 src = new Vector3Class(); IVector3 vector = new Vector3Class(); System.Collections.Generic.Dictionary <IMatrix, string> dictionary = new System.Collections.Generic.Dictionary <IMatrix, string>(); IRowBuffer rowBuffer; while ((rowBuffer = rows.NextRow()) != null) { IModelPoint modelPoint = rowBuffer.GetValue(position) as IModelPoint; if (modelPoint != null) { dictionary[modelPoint.AsMatrix().Clone()] = modelPoint.ModelName; System.Runtime.InteropServices.Marshal.ReleaseComObject(modelPoint); } } foreach (IMatrix current in dictionary.Keys) { string name = dictionary[current]; Gvitech.CityMaker.Resource.IModel model2 = resMgr.GetModel(name); for (int i = 0; i < model2.GroupCount; i++) { Gvitech.CityMaker.Resource.IDrawGroup drawGroup = new DrawGroupClass(); Gvitech.CityMaker.Resource.IDrawGroup group = model2.GetGroup(i); for (int j = 0; j < group.PrimitiveCount; j++) { Gvitech.CityMaker.Resource.IDrawPrimitive primitive = group.GetPrimitive(j); if (primitive.PrimitiveType == Gvitech.CityMaker.Resource.gviPrimitiveType.gviPrimitiveBillboardZ) { flag = false; result = flag; return(result); } Gvitech.CityMaker.Resource.IDrawPrimitive drawPrimitive = new DrawPrimitiveClass(); IFloatArray vertexArray = primitive.VertexArray; IFloatArray floatArray = new FloatArrayClass(); int num = 0; while ((long)num < (long)((ulong)vertexArray.Length)) { vector.X = (double)vertexArray.Get(num); vector.Y = (double)vertexArray.Get(num + 1); vector.Z = (double)vertexArray.Get(num + 2); current.MultiplyVector(vector, ref src); matrix.MultiplyVector(src, ref vector); floatArray.Append((float)vector.X); floatArray.Append((float)vector.Y); floatArray.Append((float)vector.Z); num += 3; } drawPrimitive.VertexArray = floatArray; drawPrimitive.BakedTexcoordArray = primitive.BakedTexcoordArray; drawPrimitive.ColorArray = primitive.ColorArray; drawPrimitive.IndexArray = primitive.IndexArray; drawPrimitive.Material = primitive.Material; drawPrimitive.NormalArray = primitive.NormalArray; drawPrimitive.PrimitiveMode = primitive.PrimitiveMode; drawPrimitive.PrimitiveType = primitive.PrimitiveType; drawPrimitive.TexcoordArray = primitive.TexcoordArray; drawGroup.AddPrimitive(drawPrimitive); } drawGroup.CompleteMapFactor = group.CompleteMapFactor; drawGroup.CompleteMapTextureName = group.CompleteMapTextureName; drawGroup.LightMapTextureName = group.LightMapTextureName; model.AddGroup(drawGroup); } System.Runtime.InteropServices.Marshal.ReleaseComObject(model2); } System.Runtime.InteropServices.Marshal.ReleaseComObject(rows); desModelPoint.ModelEnvelope = model.Envelope.Clone(); resMgr.UpdateModel(desModelPoint.ModelName, model); resMgr.RebuildSimplifiedModel(desModelPoint.ModelName); System.Runtime.InteropServices.Marshal.ReleaseComObject(matrix); System.Runtime.InteropServices.Marshal.ReleaseComObject(model); } catch (System.Runtime.InteropServices.COMException ex) { flag = false; XtraMessageBox.Show(ex.Message); } catch (System.Exception e) { flag = false; LoggingService.Error(e); } result = flag; return(result); }
public List <PipeLineFac> GetTopoPipeLine() { if (this._tc == null) { return(null); } if (DF3DPipeCreateApp.App.PipeLib == null) { return(null); } IQueryFilter filter = null; IFdeCursor o = null; IRowBuffer r = null; Dictionary <string, List <int> > dictionary = null; Dictionary <string, FacClassReg> dictReg = null; Dictionary <int, int> dictionary2 = null; List <PipeLineFac> list = null; try { IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IFeatureClass class2 = fds.OpenFeatureClass(this._tc.TopoTable); if (class2 == null) { return(null); } filter = new QueryFilterClass { WhereClause = string.Format("(P_FacClass = '{0}' and PNode = {1}) or (E_FacClass = '{0}' and ENode = {1})", this._facClassReg.FeatureClassId, base._oid), SubFields = "oid,A_FacClass,Edge,PNode,ENode" }; int count = class2.GetCount(filter); if (count == 0) { return(null); } dictionary = new Dictionary <string, List <int> >(); dictionary2 = new Dictionary <int, int>(); dictReg = new Dictionary <string, FacClassReg>(); o = class2.Search(filter, true); while ((r = o.NextRow()) != null) { if (!r.IsNull(1) && !r.IsNull(2)) { FacClassReg reg = GetFacClassReg(r.GetValue(1).ToString()); if (!dictionary.ContainsKey(reg.FacClassCode)) { dictionary.Add(reg.FacClassCode, new List <int>()); dictReg.Add(reg.FacClassCode, reg); } dictionary[reg.FacClassCode].Add(Fac.GetInt(r, 2)); if (Fac.GetInt(r, 3) == this._oid) { dictionary2.Add(Fac.GetInt(r, 2), 0); } else { dictionary2.Add(Fac.GetInt(r, 2), 1); } } } if (dictionary.Count == 0) { return(null); } list = new List <PipeLineFac>(); foreach (KeyValuePair <string, List <int> > pair in dictionary) { FacClassReg reg = dictReg[pair.Key]; if (reg.FacilityType.Name == "PipeLine") { IFeatureClass class3 = reg.GetFeatureClass(); o = class3.GetRows(pair.Value.ToArray(), false); while ((r = o.NextRow()) != null) { int index = r.FieldIndex("StyleId"); if (index == -1) { continue; } FacStyleClass style = GetFacStyleByID(r.GetValue(index).ToString()); if (style != null) { PipeLineFac line = new PipeLineFac(reg, style, r, this._tc); line.Tag = dictionary2[line.FeatureId]; list.Add(line); } } } } return(list); } catch (Exception ex) { return(null); } finally { if (o != null) { Marshal.ReleaseComObject(o); o = null; } if (r != null) { Marshal.ReleaseComObject(r); r = null; } } }