public PQXElement(EITypeID idd, Point2D stpoint, Angle stangle, LeftRightEnum lr) { TypeID = idd; StartPoint = stpoint; StartAngle = stangle; LeftRight = lr; }
double[] NomralVec(double[] V, LeftRightEnum dir) { if (dir == LeftRightEnum.Left) { return(new double[] { -V[1], V[0] }); } else { return(new double[] { V[1], -V[0] }); } }
/// <summary> /// 三要素交点 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="r"></param> /// <param name="l1"></param> /// <param name="l2"></param> public JD(double x, double y, double r, double l1, double l2, LeftRightEnum dir) { X = x; Y = y; R = r; L1 = l1; L2 = l2; R1 = 10000000000.0; R2 = 10000000000.0; Dir = dir; TypeID = EnumTypeID.JD3; ak1 = ((int)dir / R - 1 / R1) / L1; ak2 = ((int)dir / R - 1 / R2) / L2; A1 = 1 / Math.Sqrt(Math.Abs(ak1)); A2 = 1 / Math.Sqrt(Math.Abs(ak2)); beta1 = L1 / (2.0 * R); beta2 = L2 / (2.0 * R); }
public void ReadICDFile(string[] altext) { // 初始化节点 Point2D CurPoint = new Point2D(); Angle CurAngle = Angle.FromDegrees(0); ElemCollection = new List <PQXElement>(); for (int i = 0; i < altext.Count(); i++) { string line = altext[i]; if (line == "") { continue; } if (i == 0) { StartPK = double.Parse(line); } else if (i == 1) { var xx = Regex.Split(line, ","); double StartX = double.Parse(xx[0]); double StartY = double.Parse(xx[1]); double StartAngInRad = double.Parse(xx[2]); StartPoint = new Point2D(StartY, StartX); StartAngle = Angle.FromRadians(StartAngInRad); CurPoint = StartPoint; CurAngle = StartAngle; } else { var xx = Regex.Split(line, ","); if (line.StartsWith("//")) { // 注释 continue; } else if (xx.Count() == 3 && int.Parse(xx[2]) == 0) { // 结束 break; } else { // 读取元素点 int TypeID; double AngInDeg; PQXElement item = null; try { TypeID = int.Parse(xx[0]); } catch { throw new Exception(); } if (TypeID == 1) { // 直线,长度,方位角 double ll = double.Parse(xx[1]); if (xx.Count() == 3) { AngInDeg = double.Parse(xx[2]); } item = new Straight(ll, CurPoint, CurAngle); } else if (TypeID == 2) { double rr = double.Parse(xx[1]); double ll = double.Parse(xx[2]); LeftRightEnum sdir = int.Parse(xx[3]) == -1 ? LeftRightEnum.Left : LeftRightEnum.Right; item = new Arc(rr, ll, CurPoint, CurAngle, sdir); } else if (TypeID == 3) { EITypeID idd = (EITypeID)TypeID; double aa = double.Parse(xx[1]); double EndR = double.Parse(xx[2]); LeftRightEnum sdir = int.Parse(xx[3]) == -1 ? LeftRightEnum.Left : LeftRightEnum.Right; item = new Spiral(idd, aa, double.MaxValue, EndR, CurPoint, CurAngle, sdir); } else if (TypeID == 4) { EITypeID idd = (EITypeID)TypeID; double aa = double.Parse(xx[1]); double StartR = double.Parse(xx[2]); LeftRightEnum sdir = int.Parse(xx[3]) == -1 ? LeftRightEnum.Left : LeftRightEnum.Right; item = new Spiral(idd, aa, StartR, double.MaxValue, CurPoint, CurAngle, sdir); } else if (TypeID == 5 || TypeID == 6) { EITypeID idd = (EITypeID)TypeID; double aa = double.Parse(xx[1]); double StartR = double.Parse(xx[2]); double EndR = double.Parse(xx[3]); LeftRightEnum sdir = int.Parse(xx[4]) == -1 ? LeftRightEnum.Left : LeftRightEnum.Right; item = new Spiral(idd, aa, StartR, EndR, CurPoint, CurAngle, sdir); } else { throw new Exception("读取IDC文件错误!!"); } ElemCollection.Add(item); CurAngle = ElemCollection.Last().EndAngle; CurPoint = ElemCollection.Last().EndPoint; } } } }
public Arc(double r, double length, Point2D st, Angle sdir, LeftRightEnum dir, EITypeID idd = EITypeID.Arc) : base(idd, st, sdir, dir) { Radius = r; _length = length; }
/// <summary> /// 跟据IE参数构建缓和曲线原型 /// </summary> /// <param name="a"></param> /// <param name="sr"></param> /// <param name="er"></param> /// <param name="dir"></param> public Spiral(EITypeID idd, double a, double sr, double er, Point2D st, Angle sdir, LeftRightEnum dir) : base(idd, st, sdir, dir) { A = a; StartR = sr; EndR = er; }
public Straight(double length, Point2D st, Angle sdir, EITypeID idd = EITypeID.Line, LeftRightEnum dir = LeftRightEnum.None) : base(idd, st, sdir, dir) { _length = length; }