private void btnConstructMultiPolyline_Click(object sender, EventArgs e) { if (gfactory == null) gfactory = new GeometryFactory(); multiPolyline = gfactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolyline, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolyline; if (multiPolyline == null) return; // 添加两条Polyline point = gfactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); polyline = gfactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline; int length = 100; for (int i = 0; i < length; i++) { point.SetCoords(i, 2 * i, 0, 0, i + 1); polyline.AppendPoint(point); } IPolyline polylineClone = polyline.Clone() as IPolyline; polylineClone.RemovePoints(50, 50); multiPolyline.AddPolyline(polyline); multiPolyline.AddPolyline(polylineClone); MultiCurve geo = new MultiCurve(); // Geometry属性 geo.Dimension = multiPolyline.Dimension; if (multiPolyline.Envelope != null) { geo.MaxX = multiPolyline.Envelope.MaxX; geo.MaxY = multiPolyline.Envelope.MaxY; geo.MaxZ = multiPolyline.Envelope.MaxZ; geo.MinX = multiPolyline.Envelope.MinX; geo.MinY = multiPolyline.Envelope.MinY; geo.MinZ = multiPolyline.Envelope.MinZ; } geo.GeometryType = multiPolyline.GeometryType; geo.IsEmpty = multiPolyline.IsEmpty; geo.IsValid = multiPolyline.IsValid; geo.VertexAttribute = multiPolyline.VertexAttribute; geo.HasId = multiPolyline.HasId(); geo.HasM = multiPolyline.HasM(); geo.HasZ = multiPolyline.HasZ(); // GeometryCollection属性 geo.GeometryCount = multiPolyline.GeometryCount; geo.IsOverlap = multiPolyline.IsOverlap; // MultiCurve属性 geo.Length = multiPolyline.Length; this.propertyGrid1.SelectedObject = geo; }
public bool ShowFlowDirection(int flowDir, out IRenderModelPoint rpt) { rpt = null; if (base._rowInfo == null) { return(false); } string str = Application.StartupPath + @"\..\Resource\Images\FlowDirection"; if (!Directory.Exists(str)) { return(false); } IImage _imgFlowImg = DrawGeometry.resFactory.CreateImageFromFile(str); _imgFlowImg.FrameInterval = 50; IPolyline path = null; IPipeSection pipeSection = null; string name = "FlowDirection"; IDrawDynamicFlow flow = null; IModelPoint mp = null; try { IModel model; IModel model2; IPoint pointValue = null; IPolyline polyline2 = null; polyline2 = base._geoGroup[1] as IPolyline; if ((polyline2 == null) || (polyline2.PointCount < 2)) { return(false); } path = polyline2.Clone() as IPolyline; for (int i = 0; i < path.PointCount; i++) { pointValue = path.GetPoint(i); if (pointValue != null) { pointValue.Z += this.OffsetZ; path.UpdatePoint(i, pointValue); } } pipeSection = new PipeSection(this._dia1, this._dia2, HorizontalPos.Center, VerticalPos.Center, 0.02, 0); flow = ParamModelFactory.Instance.CreateGeometryDraw(ModelType.DynamicFlow, Guid.NewGuid().ToString()) as IDrawDynamicFlow; flow.SetParameter(pipeSection, path, flowDir); flow.SetTextureRender(new string[] { name }); if (!flow.Draw(out mp, out model, out model2)) { return(false); } #region 需要runtime授权 IFeatureDataSet iFeatureDataSet = DF3DPipeCreateApp.App.TempLib.OpenFeatureDataset("FeatureDataSet"); IResourceManager manager = iFeatureDataSet as IResourceManager; if (!manager.ModelExist(mp.ModelName)) { manager.AddModel(mp.ModelName, model, null); } if (!manager.ImageExist(name)) { manager.AddImage(name, _imgFlowImg); } #endregion IModelPointSymbol symbol = new ModelPointSymbolClass(); symbol.SetResourceDataSet(iFeatureDataSet); symbol.Color = uint.MaxValue; symbol.EnableColor = true; mp.ModelEnvelope = model.Envelope; rpt = DrawGeometry.Ocx.ObjectManager.CreateRenderModelPoint(mp, symbol, DrawGeometry.Ocx.ProjectTree.RootID); return(true); } catch (Exception exception) { return(false); } }