using Autodesk.Revit.DB; using System.Collections.Generic; using System.Linq; namespace uBIM_EarthTools { /// /// 地质块 /// /// class GeologyBlock { /// /// F面左端上坐标 /// public XYZ FLeftUp { get; set; } /// /// F面左端下坐标 /// public XYZ FLeftBottom { get; set; } /// /// F面右端上坐标 /// public XYZ FRightUp { get; set; } /// /// F面右端下坐标 /// public XYZ FRightBottom { get; set; } /// /// 棱面左端上坐标 /// public XYZ ELeftUp { get; set; } /// /// 棱面左端下坐标 /// public XYZ ELeftBottom { get; set; } /// /// 棱面右端上坐标 /// public XYZ ERightUp { get; set; } /// /// 棱面右端下坐标 /// public XYZ ERightBottom { get; set; } /// /// 地质块地质层 /// public string Type { get; set; } /// /// 钻孔一编号 /// public string Num1 { get; } /// /// 钻孔二编号 /// public string Num2 { get; } /// /// 钻孔三编号 /// public string Num3 { get; } /// /// 构造函数 /// /// 钻孔一 /// 钻孔二 /// 钻孔三 public GeologyBlock(Borehole borehole1, Borehole borehole2, Borehole borehole3) { Num1 = borehole1.Name; Num2 = borehole2.Name; Num3 = borehole3.Name; } public GeologyParams GetGeologyParams(double Elevation) { GeologyParams geologyParams = new GeologyParams(); XYZ tmpPoint0 = new XYZ(this.FLeftUp.X, this.FLeftUp.Y, 0); XYZ tmpPoint1 = new XYZ(this.FRightUp.X, this.FRightUp.Y, 0); XYZ tmpPoint2 = new XYZ(this.ELeftUp.X, this.ELeftUp.Y, 0); XYZ tmpPoint3 = new XYZ(this.ERightUp.X, this.ERightUp.Y, 0); if ((tmpPoint1 - tmpPoint0).CrossProduct(tmpPoint3 - tmpPoint1).Z < 0) { this.Flip(); } List bottoms = new List() { this.FLeftBottom.Z, this.FRightBottom.Z, this.ELeftBottom.Z, this.ERightBottom.Z }; geologyParams.FLeftBottom = this.FLeftBottom.Z - bottoms.Min(); geologyParams.FRightBottom = this.FRightBottom.Z - bottoms.Min(); geologyParams.ELeftBottom = this.ELeftBottom.Z - bottoms.Min(); geologyParams.ERightBottom = this.ERightBottom.Z - bottoms.Min(); geologyParams.ElevationOffset = bottoms.Min() - Elevation; tmpPoint0 = new XYZ(this.FLeftUp.X, this.FLeftUp.Y, bottoms.Min()); tmpPoint1 = new XYZ(this.FRightUp.X, this.FRightUp.Y, bottoms.Min()); tmpPoint2 = new XYZ(this.ELeftUp.X, this.ELeftUp.Y, bottoms.Min()); tmpPoint3 = new XYZ(this.ERightUp.X, this.ERightUp.Y, bottoms.Min()); geologyParams.FLeftHeight = this.FLeftUp.DistanceTo(this.FLeftBottom); geologyParams.FRightHeight = this.FRightUp.DistanceTo(this.FRightBottom); geologyParams.FWidth = this.FLeftUp.DistanceTo(new XYZ(this.FRightUp.X, this.FRightUp.Y, this.FLeftUp.Z)); geologyParams.ELeftHeight = this.ELeftUp.DistanceTo(this.ELeftBottom); geologyParams.ERightHeight = this.ERightUp.DistanceTo(this.ERightBottom); geologyParams.EWidth = this.ELeftUp.DistanceTo(new XYZ(this.ERightUp.X, this.ERightUp.Y, this.ELeftUp.Z)); Line fLine = Line.CreateBound(tmpPoint0, tmpPoint1); double start = fLine.GetEndParameter(0); double end = fLine.GetEndParameter(1); fLine.MakeUnbound(); IntersectionResult intersectionResult = fLine.Project(tmpPoint2); geologyParams.FEOffset = intersectionResult.Distance; fLine.MakeBound(start, end); //bool inside = fLine.IsInside(intersectionResult.Parameter); bool near = intersectionResult.Parameter > fLine.GetEndParameter(0); geologyParams.Location = near ? tmpPoint0 : intersectionResult.XYZPoint; geologyParams.FDistance = near ? 0 : intersectionResult.XYZPoint.DistanceTo(tmpPoint0); geologyParams.EDistance = near ? intersectionResult.XYZPoint.DistanceTo(tmpPoint0) : 0; geologyParams.Angle = Common.AngleOfThreePoint(this.FRightUp, this.FLeftUp, this.FLeftUp + new XYZ(1, 0, 0)); return geologyParams; } private void Flip() { XYZ temp; temp = this.FRightUp; this.FRightUp = this.FLeftUp; this.FLeftUp = temp; temp = this.FRightBottom; this.FRightBottom = this.FLeftBottom; this.FLeftBottom = temp; temp = this.ERightUp; this.ERightUp = this.ELeftUp; this.ELeftUp = temp; temp = this.ERightBottom; this.ERightBottom = this.ELeftBottom; this.ELeftBottom = temp; } } //class GeologyBlocks //{ // /// // /// 钻孔一上坐标 // /// // public XYZ P1 { get; set; } // /// // /// 钻孔二上坐标 // /// // public XYZ P2 { get; set; } // /// // /// 钻孔三上坐标 // /// // public XYZ P3 { get; set; } // /// // /// 钻孔一下坐标 // /// // public XYZ P4 { get; set; } // /// // /// 钻孔二下坐标 // /// // public XYZ P5 { get; set; } // /// // /// 钻孔三下坐标 // /// // public XYZ P6 { get; set; } // /// // /// 地质块地质层 // /// // public string Type { get; set; } // /// // /// 钻孔一编号 // /// // public string Num1 { get; } // /// // /// 钻孔二编号 // /// // public string Num2 { get; } // /// // /// 钻孔三编号 // /// // public string Num3 { get; } // /// // /// 构造函数 // /// // /// 钻孔一 // /// 钻孔二 // /// 钻孔三 // public GeologyBlocks(Borehole borehole1, Borehole borehole2, Borehole borehole3) // { // Num1 = borehole1.Name; // Num2 = borehole2.Name; // Num3 = borehole3.Name; // } //} }