public static ICurve Top(this IEnvironmentObject environmentObject, double distanceTolerance = BH.oM.Geometry.Tolerance.Distance, double angleTolerance = BH.oM.Geometry.Tolerance.Angle, double numericTolerance = BH.oM.Geometry.Tolerance.Distance) { if (environmentObject == null) { return(null); } double tilt = environmentObject.Tilt(distanceTolerance, angleTolerance); if ((tilt >= 0 - numericTolerance && tilt <= 0 + numericTolerance) || (tilt >= 180 - numericTolerance && tilt <= 180 + numericTolerance)) { BH.Engine.Reflection.Compute.RecordWarning("Cannot find the top of a horizontal IEnvironemntObject"); return(null); } Polyline workingCurves = environmentObject.Polyline(); if (workingCurves == null) { return(null); } double aZ = double.MinValue; ICurve aResult = null; foreach (ICurve aCurve in workingCurves.SplitAtPoints(workingCurves.DiscontinuityPoints())) { Point aPoint_Start = aCurve.IStartPoint(); Point aPoint_End = aCurve.IEndPoint(); if (aPoint_End.Z >= aZ && aPoint_Start.Z >= aZ) { aZ = Math.Min(aPoint_End.Z, aPoint_Start.Z); aResult = aCurve; } } return(aResult); }
public static List <ICurve> Sides(this IEnvironmentObject environmentObject, double distanceTolerance = BH.oM.Geometry.Tolerance.Distance, double angleTolerance = BH.oM.Geometry.Tolerance.Angle, double numericTolerance = BH.oM.Geometry.Tolerance.Distance) { if (environmentObject == null) { return(null); } double tilt = environmentObject.Tilt(distanceTolerance, angleTolerance); if ((tilt >= 0 - numericTolerance && tilt <= 0 + numericTolerance) || (tilt >= 180 - numericTolerance && tilt <= 180 + numericTolerance)) { BH.Engine.Reflection.Compute.RecordWarning("Cannot find the sides of a horizontal IEnvironmentObject"); return(null); } Polyline workingCurves = environmentObject.Polyline(); if (workingCurves == null) { return(null); } double aZMax = workingCurves.ControlPoints().Select(z => z.Z).Max(); double aZMin = workingCurves.ControlPoints().Select(z => z.Z).Max(); List <ICurve> aResult = new List <ICurve>(); foreach (ICurve aCurve in workingCurves.SplitAtPoints(workingCurves.DiscontinuityPoints())) { if (aCurve.IControlPoints().Where(x => x.Z == aZMax).Count() == 1 && aCurve.IControlPoints().Where(x => x.Z == aZMin).Count() == 1) { aResult.Add(aCurve); } } return(aResult); }
public static double Tilt(this IEnvironmentObject environmentObject) { return(environmentObject.Tilt(BH.oM.Geometry.Tolerance.Distance, BH.oM.Geometry.Tolerance.Angle)); }