using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.DB; using Autodesk.Revit.UI; namespace uBIM_EarthTools { class GeologyCompute { /// /// 三个钻孔的五种相等情况 /// /// /// public static void CreateGeologyBlock(List boreholeList,List geologyBlockList) { switch (Common.IsTypeEquals(boreholeList)) { case (int)TypeEquals.AllEqual: { GeologyCompute.AllEqual(boreholeList[0], boreholeList[1], boreholeList[2], geologyBlockList); break; } case (int)TypeEquals.OneTwo: { GeologyCompute.PartEqual(boreholeList[0], boreholeList[1], boreholeList[2], geologyBlockList); break; } case (int)TypeEquals.OneThree: { GeologyCompute.PartEqual(boreholeList[0], boreholeList[2], boreholeList[1], geologyBlockList); break; } case (int)TypeEquals.TwoThree: case (int)TypeEquals.UnEqual: { GeologyCompute.UnEqual(boreholeList[0], boreholeList[1], boreholeList[2], geologyBlockList); break; } } } /// /// 三个钻孔的地质均相等 /// /// /// /// 钻孔一为F面左边,钻孔二为F面右边,E面左右距离为1 /// 地质块材质为三个钻孔当前地层材质 /// /// /// /// /// private static void AllEqual(Borehole b1, Borehole b2, Borehole b3, List geologyBlockList) { GeologyBlock geologyBlock = new GeologyBlock(b1, b2, b3) { FLeftUp = b1.ValueList.ElementAt(b1.CurrentIndex).Point, FLeftBottom = b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point, FRightUp = b2.ValueList.ElementAt(b2.CurrentIndex).Point, FRightBottom = b2.ValueList.ElementAt(b2.CurrentIndex + 1).Point, ELeftUp = b3.ValueList.ElementAt(b3.CurrentIndex).Point, ELeftBottom = b3.ValueList.ElementAt(b3.CurrentIndex + 1).Point, Type = b1.CurrentType }; XYZ translate = geologyBlock.FRightUp - geologyBlock.FLeftUp; translate = (new XYZ(translate.X, translate.Y, 0)).Normalize()/ 304.8; geologyBlock.ERightUp = geologyBlock.ELeftUp + translate; geologyBlock.ERightBottom = geologyBlock.ELeftBottom + translate; geologyBlockList.Add(geologyBlock); b1.CurrentIndex++; b2.CurrentIndex++; b3.CurrentIndex++; } /// /// 三个钻孔中的两个的地质相等,把这两个放在前两位 /// /// /// /// 钻孔一为F面左边,钻孔二为F面右边,E面左右、上下距离为1 /// 地质块1材质为前两个钻孔当前地层材质,地质块2、3材质为下个地层材质 /// /// /// /// /// private static void PartEqual(Borehole b1, Borehole b2, Borehole b3, List geologyBlockList) { GeologyBlock geologyBlock = new GeologyBlock(b1, b2, b3) { FLeftUp = b1.ValueList.ElementAt(b1.CurrentIndex).Point, FLeftBottom = b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point, FRightUp = b2.ValueList.ElementAt(b2.CurrentIndex).Point, FRightBottom = b2.ValueList.ElementAt(b2.CurrentIndex + 1).Point, ELeftUp = (b1.ValueList.ElementAt(b1.CurrentIndex).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, ERightUp = (b2.ValueList.ElementAt(b2.CurrentIndex).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, Type = b1.CurrentType }; XYZ translate = (new XYZ(0, 0, -1)) / 304.8; geologyBlock.ELeftBottom = geologyBlock.ELeftUp + translate; geologyBlock.ERightBottom = geologyBlock.ERightUp + translate; geologyBlockList.Add(geologyBlock); geologyBlock = new GeologyBlock(b1, b2, b3) { FLeftUp = b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point, FRightUp = b2.ValueList.ElementAt(b2.CurrentIndex + 1).Point, ELeftUp = (b1.ValueList.ElementAt(b1.CurrentIndex).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, ELeftBottom = (b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, ERightUp = (b2.ValueList.ElementAt(b2.CurrentIndex).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, ERightBottom = (b2.ValueList.ElementAt(b2.CurrentIndex + 1).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, Type = string.Empty }; translate = (new XYZ(0, 0, -1)) / 304.8; geologyBlock.FLeftBottom = geologyBlock.FLeftUp + translate; geologyBlock.FRightBottom = geologyBlock.FRightUp + translate; geologyBlockList.Add(geologyBlock); geologyBlock = new GeologyBlock(b1, b2, b3) { FLeftUp = (b1.ValueList.ElementAt(b1.CurrentIndex).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, FLeftBottom = (b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, FRightUp = (b2.ValueList.ElementAt(b2.CurrentIndex).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, FRightBottom = (b2.ValueList.ElementAt(b2.CurrentIndex + 1).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, ELeftUp = b3.ValueList.ElementAt(b3.CurrentIndex).Point, Type = string.Empty }; translate = geologyBlock.FRightUp - geologyBlock.FLeftUp; translate = (new XYZ(translate.X, translate.Y, 0)).Normalize() / 304.8; geologyBlock.ERightUp = geologyBlock.ELeftUp + translate; translate = (new XYZ(0, 0, -1)) / 304.8; geologyBlock.ELeftBottom = geologyBlock.ELeftUp + translate; geologyBlock.ERightBottom = geologyBlock.ERightUp + translate; geologyBlockList.Add(geologyBlock); b1.CurrentIndex++; b2.CurrentIndex++; } /// /// 三个钻孔的地质均不等时 /// /// /// /// 钻孔一为F面,F面左右距离为1,钻孔二为E面左边,钻孔三为E面右边,E面上下距离为1 /// 地质块1材质为钻孔一当前地层材质,地质块2、3材质为下个地层材质 /// /// /// /// /// private static void UnEqual(Borehole b1, Borehole b2, Borehole b3, List geologyBlockList) { GeologyBlock geologyBlock = new GeologyBlock(b1, b2, b3) { FLeftUp = b1.ValueList.ElementAt(b1.CurrentIndex).Point, FLeftBottom = b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point, ELeftUp = (b1.ValueList.ElementAt(b1.CurrentIndex).Point + b2.ValueList.ElementAt(b2.CurrentIndex).Point) / 2, ERightUp = (b1.ValueList.ElementAt(b1.CurrentIndex).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, Type = b1.CurrentType }; XYZ translate = geologyBlock.ERightUp - geologyBlock.ELeftUp; translate = (new XYZ(translate.X, translate.Y, 0)).Normalize() / 304.8; geologyBlock.FRightUp = geologyBlock.FLeftUp + translate; geologyBlock.FRightBottom = geologyBlock.FLeftBottom + translate; translate = (new XYZ(0, 0, -1)) / 304.8; geologyBlock.ELeftBottom = geologyBlock.ELeftUp + translate; geologyBlock.ERightBottom = geologyBlock.ERightUp + translate; geologyBlockList.Add(geologyBlock); geologyBlock = new GeologyBlock(b1, b2, b3) { FLeftUp = b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point, ELeftUp = (b1.ValueList.ElementAt(b1.CurrentIndex).Point + b2.ValueList.ElementAt(b2.CurrentIndex).Point) / 2, ELeftBottom = (b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point + b2.ValueList.ElementAt(b2.CurrentIndex).Point) / 2, ERightUp = (b1.ValueList.ElementAt(b1.CurrentIndex).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, ERightBottom = (b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, Type = string.Empty }; translate = geologyBlock.ERightUp - geologyBlock.ELeftUp; translate = (new XYZ(translate.X, translate.Y, 0)).Normalize() / 304.8; geologyBlock.FRightUp = geologyBlock.FLeftUp + translate; translate = (new XYZ(0, 0, -1)) / 304.8; geologyBlock.FLeftBottom = geologyBlock.FLeftUp + translate; geologyBlock.FRightBottom = geologyBlock.FRightUp + translate; geologyBlockList.Add(geologyBlock); geologyBlock = new GeologyBlock(b1, b2, b3) { FLeftUp = (b1.ValueList.ElementAt(b1.CurrentIndex).Point + b2.ValueList.ElementAt(b2.CurrentIndex).Point) / 2, FLeftBottom = (b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point + b2.ValueList.ElementAt(b2.CurrentIndex).Point) / 2, FRightUp = (b1.ValueList.ElementAt(b1.CurrentIndex).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, FRightBottom = (b1.ValueList.ElementAt(b1.CurrentIndex + 1).Point + b3.ValueList.ElementAt(b3.CurrentIndex).Point) / 2, ELeftUp = b2.ValueList.ElementAt(b2.CurrentIndex).Point, ERightUp = b3.ValueList.ElementAt(b3.CurrentIndex).Point, Type = string.Empty }; translate = (new XYZ(0, 0, -1)) / 304.8; geologyBlock.ELeftBottom = geologyBlock.ELeftUp + translate; geologyBlock.ERightBottom = geologyBlock.ERightUp + translate; geologyBlockList.Add(geologyBlock); b1.CurrentIndex++; } } }