public static LPResult ProjectTunnel_LS(EngineeringMap targetEMap, DGObject obj, ISpatialReference sp, DrawTunnelsSettings lsSettings) { IPolyline projLine = targetEMap.profileLine; if (projLine == null) return null; Tunnel tunnel = obj as Tunnel; if (tunnel.LineNo == null) return null; int lineNo = tunnel.LineNo.Value; double mapScale = targetEMap.Scale; Domain domain = Globals.project.getDomain(DomainType.Structure); DGObjectsCollection allAxes = domain.getObjects("TunnelAxis"); TunnelAxis axis = allAxes[tunnel.id] as TunnelAxis; if (axis == null) return null; double distance = 0; IMapPoint pt = Runtime.geometryEngine.newMapPoint(0, 0, sp); IMapPoint prjPt = Runtime.geometryEngine.newMapPoint(0, 0,sp); List<IMapPoint> upperPnts = new List<IMapPoint>(); List<IMapPoint> lowerPnts = new List<IMapPoint>(); int num = axis.AxisPoints.Count; double height = 0.0; if (tunnel.Height != null) height = tunnel.Height.Value; TunnelAxis profileAxis = new TunnelAxis(); List<TunnelAxisPoint> pts = new List<TunnelAxisPoint>(); profileAxis.AxisPoints = pts; profileAxis.LineNo = lineNo; for (int i = 0; i < num; ++i) { TunnelAxisPoint axisPt = axis.AxisPoints[i]; pt = Runtime.geometryEngine.newMapPoint(axisPt.X, axisPt.Y, sp); GeomUtil.ProjectPointToPolyline(pt, projLine.GetPoints(), ref distance, ref prjPt); distance /= mapScale; distance += lsSettings.xOffset; double X = distance; double Y = (axisPt.Z + height / 2.0) * lsSettings.zScale; IMapPoint upperPnt = Runtime.geometryEngine.newMapPoint(X, Y, sp); upperPnts.Add(upperPnt); X = distance; Y = (axisPt.Z - height / 2.0) * lsSettings.zScale; IMapPoint lowerPnt = Runtime.geometryEngine.newMapPoint(X, Y, sp); lowerPnts.Add(lowerPnt); TunnelAxisPoint newPt = new TunnelAxisPoint(); newPt.X = distance; newPt.Z = axisPt.Z * lsSettings.zScale; newPt.Mileage = axisPt.Mileage; profileAxis.AxisPoints.Add(newPt); } lowerPnts.Reverse(); upperPnts.AddRange(lowerPnts); upperPnts.Add(upperPnts[0]); IPointCollection tunnelPnts = Runtime.geometryEngine.newPointCollection(); foreach (IMapPoint mp in upperPnts) tunnelPnts.Add(mp); IGraphic g = Runtime.graphicEngine.newPolygon(tunnelPnts); ISimpleLineSymbol linesymbol = Runtime.graphicEngine.newSimpleLineSymbol( Colors.Black, Core.Graphics.SimpleLineStyle.Solid, 0.5); ISymbol symbol = Runtime.graphicEngine.newSimpleFillSymbol( Colors.Red, SimpleFillStyle.Solid, linesymbol); g.Symbol = symbol; LPResult result = new LPResult(); result.id = obj.id; result.name = obj.id.ToString() + targetEMap.MapID; result.Obj = obj; result.Graphic = g; result.PlanAxis = axis; result.ProfileAxis = profileAxis; result.Setting = lsSettings; return result; }
public DrawTunnelsWindow() { InitializeComponent(); //Initialize ISimpleLineSymbol linesymbol = Runtime.graphicEngine.newSimpleLineSymbol( Colors.Red, Core.Graphics.SimpleLineStyle.Solid, 1.0); _symbol = Runtime.graphicEngine.newSimpleFillSymbol( Colors.Blue, SimpleFillStyle.Solid, linesymbol); _tunnelsGraphics = new Dictionary<int, IGraphicCollection>(); _selectedTunnelsDict = new Dictionary<string, IEnumerable<DGObject>>(); _lpResults = new List<DGObject>(); _settings = new DrawTunnelsSettings(); SettingsHolder.DataContext = _settings; Loaded += DrawTunnelsWindow_Loaded; Unloaded += DrawTunnelsWindow_Unloaded; _mainFrame = Globals.mainframe; _prj = Globals.project; if (_mainFrame == null || _prj == null) { _initFailed = true; return; } _structureDomain = _prj.getDomain(DomainType.Structure); if (_structureDomain == null) { _initFailed = true; return; } _allTunnels = _structureDomain.getObjects("Tunnel"); _tunnelLayerIDs = new HashSet<string>(); foreach (DGObjects objs in _allTunnels) _tunnelLayerIDs.Add(objs.definition.GISLayerName); _allAxes = _structureDomain.getObjects("TunnelAxis"); if (_allAxes == null) { _initFailed = true; return; } }
// Project tunnels to longitudinal section // public static List<LPResult> ProjectTunnels_LS(EngineeringMap targetEMap, IList objList, ISpatialReference sp, DrawTunnelsSettings lsSettings) { List<LPResult> results = new List<LPResult>(); foreach (DGObject obj in objList) { LPResult result = ProjectTunnel_LS(targetEMap, obj, sp, lsSettings); if (result != null) { results.Add(result); } } return results; }