Compare commits

...

3 Commits

Author SHA1 Message Date
5aba199b66 增加拟合测试按钮 2024-09-04 18:25:34 +08:00
f0b589073f Merge branch 'monitor' 2024-09-04 17:44:33 +08:00
57afe56c77 yyf update 2024-09-04 17:44:01 +08:00
4 changed files with 132 additions and 67 deletions

View File

@ -86,9 +86,10 @@ namespace uBIMEarthTools.Commands
if (transGroup.Start() == TransactionStatus.Started)
{
Transaction transaction = new Transaction(doc, "uBIM");
transaction.Start();
int k = 0;
while (true)
while (k<1000)
{
#region
XYZ origin_k = pointFirstTable_L + new XYZ(k * (pointSecTable.X - pointFirstTable_L.X), 0, 0);//当前图框左上角坐标
@ -100,7 +101,7 @@ namespace uBIMEarthTools.Commands
#region textnote
foreach (TextNote tntmp in textnoteList)
{
{
if (tntmp.Coord.X > origin_k.X && tntmp.Coord.X < origin_k.X + (pointFirstTable_R.X - pointFirstTable_L.X) &&
tntmp.Coord.Y > origin_k.Y - (pointFirstTable_L.Y - pointFirstTable_R.Y) && tntmp.Coord.Y < origin_k.Y)
{
@ -120,15 +121,24 @@ namespace uBIMEarthTools.Commands
textnoteKList.Add(tntmp);
}
}
foreach (TextNote tntmp in textnoteKList)
{
tntmp.Text = tntmp.Text.Replace("X=", "").Replace("Y=", "").Replace("m", "").Trim();
}
if (textnoteKList.Count == 0) //获取不到时,跳出
{
break;
}
#endregion
#region ,,X,Y
TextNote zkbhTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointNum.X - pointFirstTable_L.X, pointNum.Y, pointNum.Z), textnoteKList, 4); //钻孔编号
TextNote kkbgTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointLevel.X - pointFirstTable_L.X, pointLevel.Y, pointLevel.Z), textnoteKList, 4); //孔口标高
TextNote xTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointX.X - pointFirstTable_L.X, pointX.Y, pointX.Z), textnoteKList, 4); //孔口X
TextNote yTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointY.X - pointFirstTable_L.X, pointY.Y, pointY.Z), textnoteKList, 4); //孔口Y
TextNote zkbhTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointNum.X - pointFirstTable_L.X, pointNum.Y, pointNum.Z), textnoteKList, 100); //钻孔编号
TextNote kkbgTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointLevel.X - pointFirstTable_L.X, pointLevel.Y, pointLevel.Z), textnoteKList, 100); //孔口标高
TextNote xTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointX.X - pointFirstTable_L.X, pointX.Y, pointX.Z), textnoteKList, 100); //孔口X
TextNote yTn = Common.Textnote_At_Point(new XYZ(origin_k.X + pointY.X - pointFirstTable_L.X, pointY.Y, pointY.Z), textnoteKList, 100); //孔口Y
//钻孔编号跟孔口标高不对应时,跳至下个图框
if (zkbhTn == null || kkbgTn == null)
@ -142,6 +152,8 @@ namespace uBIMEarthTools.Commands
#region 3-1(:X公差:4mm;Y公差:2mm;:null)
foreach (TextNote tntmp1 in textnoteKList)
{
tntmp1.Text = Common.NameByRule(tntmp1.Text);
if (tntmp1.Coord.X > origin_k.X + pointLayer_R.X - pointFirstTable_L.X)//排除超出范围的
continue;
if (delTextnoteList.Contains(tntmp1))//排除已剔除的
@ -150,6 +162,8 @@ namespace uBIMEarthTools.Commands
continue;
foreach (TextNote tntmp2 in textnoteKList)
{
tntmp2.Text = Common.NameByRule(tntmp2.Text);
if (delTextnoteList.Contains(tntmp2))//排除已剔除的
continue;
if (tntmp2.Coord.X > origin_k.X + pointLayer_R.X - pointFirstTable_L.X)//排除超出范围的
@ -163,18 +177,20 @@ namespace uBIMEarthTools.Commands
if (Math.Abs(tntmp1.Coord.X - tntmp2.Coord.X) < 4 / 304.8 &&
Math.Abs(tntmp1.Coord.Y - tntmp2.Coord.Y) < 2 / 304.8)// &&Math.Abs(tntmp1.Height - tntmp2.Height) > 0.00001 / 304.8)
{
transaction.Start();
//transaction.Start();
if (tntmp1.Coord.X < tntmp2.Coord.X)
{
tntmp1.Text = tntmp1.Text + "-" + tntmp2.Text;
string s = tntmp1.Text.Trim() + "-" + tntmp2.Text.Trim();
tntmp1.Text = Common.NameByRule(s);
delTextnoteList.Add(tntmp2);
}
else
{
tntmp2.Text = tntmp2.Text + "-" + tntmp1.Text;
string s = tntmp2.Text.Trim() + "-" + tntmp1.Text.Trim();
tntmp2.Text = Common.NameByRule(s);
delTextnoteList.Add(tntmp1);
}
transaction.Commit();
//transaction.Commit();
}
}
}
@ -199,7 +215,7 @@ namespace uBIMEarthTools.Commands
dcgcList = dcgcList.OrderByDescending(x => x.Coord.Y).ToList();
#endregion
#region ,
#region
Borehole bh;
if (boreholes.Count != 0 && boreholes.Select(x => x.Name).ToList().Contains(zkbhTn.Text))
{
@ -208,6 +224,22 @@ namespace uBIMEarthTools.Commands
else
{
bh = new Borehole { Name = zkbhTn.Text };
double xxx = 0;
double yyy = 0;
double zzz = 0;
try
{
xxx = Convert.ToDouble(xTn.Text);
yyy = Convert.ToDouble(yTn.Text);
zzz = Convert.ToDouble(kkbgTn.Text);
}
catch
{
k++;
MessageBox.Show(k+ "\n" +xTn.Text + "\n" + yTn.Text + "\n" + kkbgTn.Text, "向日葵", MessageBoxButtons.OK);
continue;
}
bh.ValueList.Add(new GeologyLayer(dcbhList.First().Text, new XYZ(Convert.ToDouble(xTn.Text), Convert.ToDouble(yTn.Text), Convert.ToDouble(kkbgTn.Text))));
boreholes.Add(bh);
}
@ -216,18 +248,31 @@ namespace uBIMEarthTools.Commands
#region
for (int i = 0; i < (dcbhList.Count < dcgcList.Count ? dcbhList.Count : dcgcList.Count); i++)
{
string dcbh_i = dcbhList[i].Text.Replace("\r", "").Replace("\n", "");
string dcmc_i = dcgcList[i].Text.Replace("\r", "").Replace("\n", "");
double x = Convert.ToDouble(xTn.Text);
double y = Convert.ToDouble(yTn.Text);
double z = Convert.ToDouble(dcmc_i);
GeologyLayer geologyLayer = new GeologyLayer(dcbh_i, new XYZ(x, y, z));
bh.ValueList.Add(geologyLayer);
string dcmc_i = "default";
string dcbh_i = "default";
//MessageBox.Show(xTn.Text + "\n" + yTn.Text + "\n" + dcbh_i + "\n" + dcmc_i, "向日葵", MessageBoxButtons.OK);
try
{
dcbh_i = dcbhList[i].Text.Trim();
dcmc_i = dcgcList[i].Text.Trim();
double x = Convert.ToDouble(xTn.Text);
double y = Convert.ToDouble(yTn.Text);
double z = Convert.ToDouble(dcmc_i);
GeologyLayer geologyLayer = new GeologyLayer(dcbh_i, new XYZ(x, y, z));
bh.ValueList.Add(geologyLayer);
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message, "向日葵", MessageBoxButtons.OK);
}
}
#endregion
k++;
}
transaction.Commit();
}
status = transGroup.RollBack();
#endregion
@ -241,7 +286,7 @@ namespace uBIMEarthTools.Commands
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
FileInfo fileInfo = new FileInfo(localFilePath);
using (ExcelPackage excelPackage = new ExcelPackage(fileInfo))
using (ExcelPackage excelPackage = new ExcelPackage())
{
//using (FileStream fs = new FileStream(localFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
//{
@ -281,7 +326,7 @@ namespace uBIMEarthTools.Commands
}
}
excelPackage.Save();
excelPackage.SaveAs(fileInfo);
//}
//File.WriteAllBytes(localFilePath, excelPackage.GetAsByteArray());
}

View File

@ -108,51 +108,51 @@ namespace uBIMEarthTools.Commands.Monitor
var boreholeKriging = new IDW<Point3D>(boreholeList.SelectMany(b => b.ValueList.Select(p => new Point3D() { X = p.Point.X, Y = p.Point.Y, Z = p.Point.Z, Value = typeValue[p.Type] })).ToList(), 2);
List<Borehole> boreholes1 = new List<Borehole>();
//tris.AsParallel().ForAll(item =>
//{
// Func<XYZ, Borehole> func = (p =>
// {
// var topZ = topKriging.Interpolate(new Point2D() { X = p.X, Y = p.Y });
// var bottomZ = bottomKriging.Interpolate(new Point2D() { X = p.X, Y = p.Y });
// var plus = (topZ - bottomZ) / 10;
// var geologyLayers = new List<GeologyLayer>();
// for (int i = 0; i < 10; i++)
// {
// var p3d = new Point3D() { X = p.X, Y = p.Y, Z = topZ - i * plus };
// var value = boreholeKriging.Interpolate2(p3d);
// geologyLayers.Add(new GeologyLayer(valueType[(int)Math.Round(value)], new Autodesk.Revit.DB.XYZ(p3d.X, p3d.Y, p3d.Z)));
// }
// return new Borehole("", geologyLayers);
// });
tris.AsParallel().ForAll(item =>
{
Func<XYZ, Borehole> func = (p =>
{
var topZ = topKriging.Interpolate(new Point2D() { X = p.X, Y = p.Y });
var bottomZ = bottomKriging.Interpolate(new Point2D() { X = p.X, Y = p.Y });
var plus = (topZ - bottomZ) / 10;
var geologyLayers = new List<GeologyLayer>();
for (int i = 0; i < 10; i++)
{
var p3d = new Point3D() { X = p.X, Y = p.Y, Z = topZ - i * plus };
var value = boreholeKriging.Interpolate2(p3d);
geologyLayers.Add(new GeologyLayer(valueType[(int)Math.Round(value)], new Autodesk.Revit.DB.XYZ(p3d.X, p3d.Y, p3d.Z)));
}
return new Borehole("", geologyLayers);
});
// var v1 = boreholeList.ElementAt(item[1]).ValueList[0].Point - boreholeList.ElementAt(item[0]).ValueList[0].Point;
// var v2 = boreholeList.ElementAt(item[2]).ValueList[0].Point - boreholeList.ElementAt(item[0]).ValueList[0].Point;
// var originP = boreholeList.ElementAt(item[0]).ValueList[0].Point;
// var triangle = new List<XYZ>() { boreholeList.ElementAt(item[0]).ValueList[0].Point,
// boreholeList.ElementAt(item[1]).ValueList[0].Point,
// boreholeList.ElementAt(item[2]).ValueList[0].Point };
// var seg = 10;
// v1 = v1 / seg;
// v2 = v2 / seg;
// for (int i = 0; i < seg; i++)
// {
// for (int j = 0; j < seg; j++)
// {
// if (i == j && i == 0) { continue; }
// var xyz = originP + v1 * i + v2 * j;
// if (IsInPolygon(xyz, triangle))
// {
// boreholes1.Add(func(xyz));
// }
// }
// }
//});
var v1 = boreholeList.ElementAt(item[1]).ValueList[0].Point - boreholeList.ElementAt(item[0]).ValueList[0].Point;
var v2 = boreholeList.ElementAt(item[2]).ValueList[0].Point - boreholeList.ElementAt(item[0]).ValueList[0].Point;
var originP = boreholeList.ElementAt(item[0]).ValueList[0].Point;
var triangle = new List<XYZ>() { boreholeList.ElementAt(item[0]).ValueList[0].Point,
boreholeList.ElementAt(item[1]).ValueList[0].Point,
boreholeList.ElementAt(item[2]).ValueList[0].Point };
var seg = 20;
v1 = v1 / seg;
v2 = v2 / seg;
for (int i = 0; i < seg; i++)
{
for (int j = 0; j < seg; j++)
{
if (i == j && i == 0) { continue; }
var xyz = originP + v1 * i + v2 * j;
if (IsInPolygon(xyz, triangle))
{
boreholes1.Add(func(xyz));
}
}
}
});
//foreach (int[] item in tris)
//{
//}
#endregion
boreholeList.AddRange(boreholes1);
boreholeList.AddRange(boreholes1);
#region
List<int[]> triIndexList = Common.Delaunay(boreholeList, 10000000 / 304.8);

View File

@ -53,6 +53,9 @@ namespace uBIMEarthTools
ReLoadLink_ButtonData.LargeImage = Icon(uBIMEarthTools.Properties.Resources.pyramid);
sPanel.AddItem(ReLoadLink_ButtonData);
ReLoadLink_ButtonData = new PushButtonData("Test", "Test", AddInPath, "uBIMEarthTools.Commands.Monitor.MonitorCommand");
sPanel.AddItem(ReLoadLink_ButtonData);
}
private BitmapSource Icon(System.Drawing.Bitmap bitmap)

View File

@ -251,13 +251,23 @@ namespace uBIMEarthTools.Utils
{
TextNote tn = null;
XYZ newXyz = new XYZ(p.X, p.Y, textnoteList[0].Coord.Z);
foreach (TextNote tntmp in textnoteList)
{
if (Math.Round(tntmp.Coord.DistanceTo(newXyz), 5) < (tolerance / 304.8))
{
tn = tntmp;
}
}
List<string> lines = new List<string>();
textnoteList = textnoteList.FindAll(m => m.Text != "X =" && m.Text != "Y =").ToList();
TextNote tntmp = textnoteList.OrderBy(m => m.Coord.DistanceTo(newXyz)).First();
if (Math.Round(tntmp.Coord.DistanceTo(newXyz), 5) < (tolerance / 304.8))
tn = tntmp;
//foreach (TextNote tntmp in textnoteList)
//{
// string text = tntmp.Text;
// if (text == "X=" || text == "Y=")
// continue;
// if (Math.Round(tntmp.Coord.DistanceTo(newXyz), 5) < (tolerance / 304.8))
// {
// tn = tntmp;
// }
//}
return tn;
}
public static void Swap<T>(ref T x, ref T y)
@ -266,5 +276,12 @@ namespace uBIMEarthTools.Utils
x = y;
y = temp;
}
public static string NameByRule(string s)
{
//①②③④⑤⑥⑦⑧⑨
string ss = s.Replace("--", "-").Replace("①","1").Replace("②", "2").Replace("③", "3").Replace("④", "4").Replace("⑤", "5").Replace("⑥", "6").Replace("⑦", "7").Replace("⑧", "8").Replace("⑨", "9");
return ss;
}
}
}