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 static List<DepthResult> DoAnalysis(LPResult result, string mapID, double startMilage, double endMilage) { double zScale = result.Setting.zScale; TunnelAxis axis = result.ProfileAxis; int num = axis.AxisPoints.Count; int iMax = -1, iMin = -1; double zMax = -1e10, zMin = 1e+10; for (int i = 0; i < num; ++i) { TunnelAxisPoint axisPt = axis.AxisPoints[i]; double m = axisPt.Mileage; if (m >= startMilage && m <= endMilage) { if (axisPt.Z > zMax) { zMax = axisPt.Z; iMax = i; } if (axisPt.Z < zMin) { zMin = axisPt.Z; iMin = i; } } } if (iMax == -1 || iMin == -1) return null; Tunnel tunnel = result.Obj as Tunnel; double h = 0.0; if (tunnel.Height != null) h = tunnel.Height.Value; DepthResult r1 = new DepthResult(); r1.Name = "Shallowest"; r1.Mileage = axis.AxisPoints[iMin].Mileage; r1.Depth = axis.AxisPoints[iMin].Z / zScale + h / 2; r1.Index = iMin; DepthResult r2 = new DepthResult(); r2.Name = "Deepest"; r2.Mileage = axis.AxisPoints[iMax].Mileage; r2.Depth = axis.AxisPoints[iMax].Z / zScale + h / 2; r2.Index = iMax; List<DepthResult> results = new List<DepthResult>(); results.Add(r1); results.Add(r2); return results; }