Compare commits

..

No commits in common. "master" and "monitor" have entirely different histories.

4 changed files with 67 additions and 132 deletions

View File

@ -86,10 +86,9 @@ namespace uBIMEarthTools.Commands
if (transGroup.Start() == TransactionStatus.Started)
{
Transaction transaction = new Transaction(doc, "uBIM");
transaction.Start();
int k = 0;
while (k<1000)
while (true)
{
#region
XYZ origin_k = pointFirstTable_L + new XYZ(k * (pointSecTable.X - pointFirstTable_L.X), 0, 0);//当前图框左上角坐标
@ -121,24 +120,15 @@ 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, 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
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
//钻孔编号跟孔口标高不对应时,跳至下个图框
if (zkbhTn == null || kkbgTn == null)
@ -152,8 +142,6 @@ 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))//排除已剔除的
@ -162,8 +150,6 @@ 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)//排除超出范围的
@ -177,20 +163,18 @@ 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)
{
string s = tntmp1.Text.Trim() + "-" + tntmp2.Text.Trim();
tntmp1.Text = Common.NameByRule(s);
tntmp1.Text = tntmp1.Text + "-" + tntmp2.Text;
delTextnoteList.Add(tntmp2);
}
else
{
string s = tntmp2.Text.Trim() + "-" + tntmp1.Text.Trim();
tntmp2.Text = Common.NameByRule(s);
tntmp2.Text = tntmp2.Text + "-" + tntmp1.Text;
delTextnoteList.Add(tntmp1);
}
//transaction.Commit();
transaction.Commit();
}
}
}
@ -215,7 +199,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))
{
@ -224,22 +208,6 @@ 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);
}
@ -248,31 +216,18 @@ namespace uBIMEarthTools.Commands
#region
for (int i = 0; i < (dcbhList.Count < dcgcList.Count ? dcbhList.Count : dcgcList.Count); i++)
{
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();
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);
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message, "向日葵", MessageBoxButtons.OK);
}
}
#endregion
k++;
}
transaction.Commit();
}
status = transGroup.RollBack();
#endregion
@ -286,7 +241,7 @@ namespace uBIMEarthTools.Commands
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
FileInfo fileInfo = new FileInfo(localFilePath);
using (ExcelPackage excelPackage = new ExcelPackage())
using (ExcelPackage excelPackage = new ExcelPackage(fileInfo))
{
//using (FileStream fs = new FileStream(localFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
//{
@ -326,7 +281,7 @@ namespace uBIMEarthTools.Commands
}
}
excelPackage.SaveAs(fileInfo);
excelPackage.Save();
//}
//File.WriteAllBytes(localFilePath, excelPackage.GetAsByteArray());
}

View File

@ -108,45 +108,45 @@ 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 = 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));
}
}
}
});
// 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));
// }
// }
// }
//});
//foreach (int[] item in tris)
//{

View File

@ -53,9 +53,6 @@ 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,23 +251,13 @@ namespace uBIMEarthTools.Utils
{
TextNote tn = null;
XYZ newXyz = new XYZ(p.X, p.Y, textnoteList[0].Coord.Z);
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();
foreach (TextNote tntmp in textnoteList)
{
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)
@ -276,12 +266,5 @@ 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;
}
}
}