uBIMEarthTools/地质建模/GeologyCompute.cs
2018-10-22 19:28:56 +08:00

220 lines
11 KiB
C#

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
{
/// <summary>
/// 三个钻孔的五种相等情况
/// </summary>
/// <param name="boreholeList"></param>
/// <param name="geologyBlockList"></param>
public static void CreateGeologyBlock(List<Borehole> boreholeList,List<GeologyBlock> 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;
}
}
}
/// <summary>
/// 三个钻孔的地质均相等
/// </summary>
/// <image url="$(ProjectDir)/Comments/均等.png" />
/// <remarks>
/// 钻孔一为F面左边,钻孔二为F面右边,E面左右距离为1
/// 地质块材质为三个钻孔当前地层材质
/// </remarks>
/// <param name="b1"></param>
/// <param name="b2"></param>
/// <param name="b3"></param>
/// <param name="geologyBlockList"></param>
private static void AllEqual(Borehole b1, Borehole b2, Borehole b3, List<GeologyBlock> 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++;
}
/// <summary>
/// 三个钻孔中的两个的地质相等,把这两个放在前两位
/// </summary>
/// <image url="$(ProjectDir)/Comments/部分相等.png" />
/// <remarks>
/// 钻孔一为F面左边,钻孔二为F面右边,E面左右、上下距离为1
/// 地质块1材质为前两个钻孔当前地层材质,地质块2、3材质为下个地层材质
/// </remarks>
/// <param name="b1"></param>
/// <param name="b2"></param>
/// <param name="b3"></param>
/// <param name="geologyBlockList"></param>
private static void PartEqual(Borehole b1, Borehole b2, Borehole b3, List<GeologyBlock> 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++;
}
/// <summary>
/// 三个钻孔的地质均不等时
/// </summary>
/// <image url="$(ProjectDir)/Comments/均不等.png" />
/// <remarks>
/// 钻孔一为F面,F面左右距离为1,钻孔二为E面左边,钻孔三为E面右边,E面上下距离为1
/// 地质块1材质为钻孔一当前地层材质,地质块2、3材质为下个地层材质
/// </remarks>
/// <param name="b1"></param>
/// <param name="b2"></param>
/// <param name="b3"></param>
/// <param name="geologyBlockList"></param>
private static void UnEqual(Borehole b1, Borehole b2, Borehole b3, List<GeologyBlock> 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++;
}
}
}