internal HDXElement ConvertABS() { HDXElement ret = new HDXElement(); if (Type != HDXMethod.TGF) { return(this); } else { List <HDXData> newLeftLine = new List <HDXData>(); for (int i = 0; i < LeftLine.Count; i++) { var range = LeftLine.GetRange(0, i + 1); newLeftLine.Add(new HDXData((from a in range select a.x).ToList().Sum(), (from a in range select a.h).ToList().Sum())); } ret.LeftLine = newLeftLine; List <HDXData> newRightLine = new List <HDXData>(); for (int i = 0; i < RightLine.Count; i++) { var range = RightLine.GetRange(0, i + 1); newRightLine.Add(new HDXData((from a in range select a.x).ToList().Sum(), (from a in range select a.h).ToList().Sum())); } ret.RightLine = newRightLine; ret.Type = HDXMethod.ABS; ret.PK = PK; return(ret); } }
internal double GetBG(double x) { HDXElement NewElem = this.ConvertABS(); HDXData t1, t2; double absx = Math.Abs(x); List <double> xlist = new List <double>(); List <HDXData> RcdList = new List <HDXData>(); if (x == 0) { return(0); } else if (x > 0) { xlist = (from a in NewElem.RightLine select a.x).ToList(); RcdList = NewElem.RightLine; } else { xlist = (from a in NewElem.LeftLine select a.x).ToList(); RcdList = NewElem.LeftLine; } if (xlist.Contains(absx)) { return(RcdList[xlist.IndexOf(absx)].h); } else { xlist.Add(absx); xlist.Sort(); int i0 = xlist.IndexOf(absx); if (i0 == 0) { if (this.Type == HDXMethod.ABS) { double dd = LeftLine[0].x + RightLine[0].x; double cl = RightLine[0].x / dd; double cr = LeftLine[0].x / dd; t1 = new HDXData(0, cl * LeftLine[0].h + cr * RightLine[0].h); } else { t1 = new HDXData(0, 0); } t2 = RcdList[i0]; } else if (i0 == RcdList.Count()) { t1 = RcdList[i0 - 1]; t2 = RcdList[i0 - 1]; } else { t1 = RcdList[i0 - 1]; t2 = RcdList[i0]; } double f1 = (t2.x - absx) / (t2.x - t1.x); double f2 = (absx - t1.x) / (t2.x - t1.x); return(t1.h * f1 + t2.h * f2); } }
public HDX(string[] hdxtext) { string[] altext = hdxtext; HDXDataList = new List <HDXElement>(); Method = 0; if (altext.Count() <= 1) { return; } int i = 0; int n = 0; HDXElement curData = new HDXElement(); foreach (string item in altext) { if (item.StartsWith("//") || item == "") { if (i != 0) { i++; continue; } if (item.Contains("ABS")) { Method = HDXMethod.ABS; curData.Type = HDXMethod.ABS; } else if (item.Contains("抬杆法")) { Method = HDXMethod.TGF; curData.Type = HDXMethod.TGF; } else { throw new Exception("地面线数据未说明类型"); } i++; continue; } string line = item.TrimEnd('\r'); line = line.TrimEnd('\t'); if (line == "ABS") { i++; continue; } var xx = (Regex.Split(line, @"\s+")).ToList(); xx.Remove(""); if (n == 0) { curData = new HDXElement(); curData.PK = double.Parse(xx[0]); curData.Type = Method; n = 1; } else if (n == 1) { var dataline = (from a in xx select double.Parse(a)).ToList(); HDXData dt = new HDXData(); for (int ii = 0; ii < dataline.Count; ii++) { if (ii % 2 == 0) { dt = new HDXData(); dt.x = dataline[ii]; } else { dt.h = dataline[ii]; curData.LeftLine.Add(dt); } } n = 2; } else if (n == 2) { var dataline = (from a in xx select double.Parse(a)).ToList(); HDXData dt = new HDXData(); for (int ii = 0; ii < dataline.Count; ii++) { if (ii % 2 == 0) { dt = new HDXData(); dt.x = dataline[ii]; } else { dt.h = dataline[ii]; curData.RightLine.Add(dt); } } ; HDXDataList.Add(curData); n = 0; } } ; }