/// <summary> /// 使用ICD文件初始化平面线形. /// </summary> /// <param name="icdfile">icd文件</param> public PM(string icdfile) { // 初始化节点 ICDList = new List <ICD>(); string[] altext = File.ReadAllLines(icdfile); for (int i = 0; i < altext.Count(); i++) { string line = altext[i]; if (i == 0) { StartPK = double.Parse(line); } else if (i == 1) { var xx = Regex.Split(line, ","); StartX = double.Parse(xx[0]); StartY = double.Parse(xx[1]); StartAngInDeg = double.Parse(xx[2]); } else { var xx = Regex.Split(line, ","); if (line.StartsWith("//")) { // 注释 continue; } else if (xx.Count() == 3 && int.Parse(xx[2]) == 0) { // 结束 break; } else { ICD aa = new ICD(line); ICDList.Add(aa); } } } }
private static void AddICD(ref Alignment myAg, ref SRBA.PM bill, ref Editor ed) { double curAngInDeg = bill.StartAngInDeg; Point3d St = new Point3d(bill.StartY, bill.StartX, 0); Point3d Ed, TmpPt; //AlignmentLine RefStartLine; //AlignmentArc curArc; AlignmentSpiral curSpiral; for (int i = 0; i < bill.ICDList.Count; i++) { SRBA.ICD item = bill.ICDList[i]; switch (item.TypeID) { case 1: Ed = new Point3d(St.X + Math.Sin(curAngInDeg) * item.Length, St.Y + Math.Cos(curAngInDeg) * item.Length, 0); AlignmentLine l = myAg.Entities.AddFixedLine(St, Ed); St = Ed; curAngInDeg = l.Direction; break; case 2: if (myAg.Entities.LastEntity != 0) { AlignmentArc a = myAg.Entities.AddFloatingCurve(myAg.Entities.LastEntity, item.R, item.Length, CurveParamType.CurveLength, item.isClookWise); Ed = new Point3d(a.EndPoint.X, a.EndPoint.Y, 0); myAg.Entities.Remove(a); AlignmentArc b = myAg.Entities.AddFixedCurve(St, Ed, item.R, item.isClookWise); St = Ed; curAngInDeg = b.EndDirection; } else { Ed = new Point3d(St.X - Math.Sin(curAngInDeg) * 10, St.Y - Math.Cos(curAngInDeg) * 10, 0); AlignmentLine ll = myAg.Entities.AddFixedLine(Ed, St); AlignmentArc a = myAg.Entities.AddFloatingCurve(myAg.Entities.LastEntity, item.R, item.Length, CurveParamType.CurveLength, item.isClookWise); Ed = new Point3d(a.EndPoint.X, a.EndPoint.Y, 0); myAg.Entities.Remove(a); AlignmentArc b = myAg.Entities.AddFixedCurve(St, Ed, item.R, item.isClookWise); St = Ed; curAngInDeg = b.EndDirection; myAg.Entities.Remove(ll); } break; case 3: if (myAg.Entities.LastEntity != 0) { AlignmentLine tp = myAg.Entities.AddFloatingLine(myAg.Entities.LastEntity, 10.0); Point3d spii = new Point3d(tp.EndPoint.X, tp.EndPoint.Y, 0); myAg.Entities.Remove(tp); AlignmentSpiral s = myAg.Entities.AddFixedSpiral(myAg.Entities.LastEntity, St, spii, item.EndR, item.Length, SpiralCurveType.InCurve, item.isClookWise, SpiralType.Clothoid); Ed = new Point3d(s.EndPoint.X, s.EndPoint.Y, 0); St = Ed; curAngInDeg = s.EndDirection; } else { TmpPt = new Point3d(St.X + Math.Sin(curAngInDeg) * 10, St.Y + Math.Cos(curAngInDeg) * 10, 0); curSpiral = myAg.Entities.AddFixedSpiral(-1, St, TmpPt, item.EndR, item.Length, SpiralCurveType.InCurve, item.isClookWise, SpiralType.Clothoid); Ed = new Point3d(curSpiral.EndPoint.X, curSpiral.EndPoint.Y, 0); St = Ed; curAngInDeg = curSpiral.EndDirection; } break; case 4: if (myAg.Entities.LastEntity != 0) { AlignmentLine tmp = myAg.Entities.AddFloatingLine(myAg.Entities.LastEntity, 10.0); Point3d SPI = new Point3d(tmp.EndPoint.X, tmp.EndPoint.Y, 0); myAg.Entities.Remove(tmp); AlignmentSpiral sp = myAg.Entities.AddFixedSpiral(myAg.Entities.LastEntity, St, SPI, item.StartR, item.Length, SpiralCurveType.OutCurve, item.isClookWise, Autodesk.Civil.SpiralType.Clothoid); Ed = new Point3d(sp.EndPoint.X, sp.EndPoint.Y, 0); St = Ed; curAngInDeg = sp.EndDirection; } else { TmpPt = new Point3d(St.X + Math.Sin(curAngInDeg) * 10, St.Y + Math.Cos(curAngInDeg) * 10, 0); curSpiral = myAg.Entities.AddFixedSpiral(-1, St, TmpPt, item.StartR, item.Length, SpiralCurveType.OutCurve, item.isClookWise, SpiralType.Clothoid); Ed = new Point3d(curSpiral.EndPoint.X, curSpiral.EndPoint.Y, 0); St = Ed; curAngInDeg = curSpiral.EndDirection; } break; case 5: AlignmentLine tt5 = myAg.Entities.AddFloatingLine(myAg.Entities.LastEntity, 10.0); Point3d Sip5 = new Point3d(tt5.EndPoint.X, tt5.EndPoint.Y, 0); myAg.Entities.Remove(tt5); AlignmentSpiral ss5 = myAg.Entities.AddFixedSpiral(myAg.Entities.LastEntity, St, Sip5, item.StartR, item.EndR, item.Length, item.isClookWise, Autodesk.Civil.SpiralType.Clothoid); Ed = new Point3d(ss5.EndPoint.X, ss5.EndPoint.Y, 0); St = Ed; curAngInDeg = ss5.EndDirection; break; case 6: //R小-R大 if (myAg.Entities.LastEntity != 0) { AlignmentLine tt = myAg.Entities.AddFloatingLine(myAg.Entities.LastEntity, 10.0); Point3d Sip = new Point3d(tt.EndPoint.X, tt.EndPoint.Y, 0); myAg.Entities.Remove(tt); AlignmentSpiral ss = myAg.Entities.AddFixedSpiral(myAg.Entities.LastEntity, St, Sip, item.StartR, item.EndR, item.Length, item.isClookWise, Autodesk.Civil.SpiralType.Clothoid); Ed = new Point3d(ss.EndPoint.X, ss.EndPoint.Y, 0); St = Ed; curAngInDeg = ss.EndDirection; } else { TmpPt = new Point3d(St.X + Math.Sin(curAngInDeg) * 10, St.Y + Math.Cos(curAngInDeg) * 10, 0); curSpiral = myAg.Entities.AddFixedSpiral(-1, St, TmpPt, item.StartR, item.EndR, item.Length, item.isClookWise, Autodesk.Civil.SpiralType.Clothoid); Ed = new Point3d(curSpiral.EndPoint.X, curSpiral.EndPoint.Y, 0); St = Ed; curAngInDeg = curSpiral.EndDirection; } break; default: break; } } }