public static IList <PlanarFace> ListNearestFace(PlanarFace face, IList <PlanarFace> listFaces) { IList <PlanarFace> list = new List <PlanarFace>(); PlanarFace face2 = Facelibry.NearestFace(face, listFaces); XYZ point = Facelibry.CenterPoint(face2); double num = Facelibry.PointToFace(point, face); XYZ faceNormal = face.FaceNormal; XYZ right = Facelibry.CenterPoint(face); foreach (PlanarFace planarFace in listFaces) { XYZ xyz = Facelibry.CenterPoint(planarFace); XYZ xyz2 = xyz - right; bool flag = xyz2.IsAlmostEqualTo(new XYZ()); if (!flag) { double num2 = Facelibry.PointToFace(xyz, face); bool flag2 = num2 <1.02 * num && num2> 0.98 * num; if (flag2) { list.Add(planarFace); } } } return(list); }
public static CurveElement NearestLinesToFace(PlanarFace face, IList <CurveElement> listLines) { CurveElement curveElement = null; double num = 0.0; foreach (CurveElement curveElement2 in listLines) { DetailLine detailLine = curveElement2 as DetailLine; bool flag = detailLine == null; if (!flag) { XYZ endPoint = detailLine.GeometryCurve.GetEndPoint(0); double num2 = Facelibry.PointToFace(endPoint, face); bool flag2 = curveElement == null; if (flag2) { num = num2; curveElement = curveElement2; } else { bool flag3 = num2 < num; if (flag3) { num = num2; curveElement = curveElement2; } } } } return(curveElement); }
public static PlanarFace NearestFace(PlanarFace face, IList <PlanarFace> listFaces) { PlanarFace planarFace = null; double num = 0.0; XYZ faceNormal = face.FaceNormal; XYZ right = Facelibry.CenterPoint(face); foreach (PlanarFace planarFace2 in listFaces) { XYZ faceNormal2 = planarFace2.FaceNormal; XYZ xyz = faceNormal.CrossProduct(faceNormal2) / (faceNormal.GetLength() * faceNormal2.GetLength()); bool flag = !xyz.IsAlmostEqualTo(XYZ.Zero); if (!flag) { XYZ xyz2 = Facelibry.CenterPoint(planarFace2); XYZ xyz3 = xyz2 - right; bool flag2 = xyz3.IsAlmostEqualTo(new XYZ()); if (!flag2) { double num2 = Facelibry.PointToFace(xyz2, face); bool flag3 = null == planarFace && num2 > 1E-06; if (flag3) { planarFace = planarFace2; num = num2; } else { bool flag4 = num2 <num && num2> 1E-07; if (flag4) { planarFace = planarFace2; num = num2; } } } } } return(planarFace); }
public static PlanarFace GetTopFace(IList <PlanarFace> faces, XYZ direction, Transform transform) { PlanarFace result = null; double num = double.MinValue; XYZ point = new XYZ(); double num2 = double.MinValue; foreach (PlanarFace planarFace in faces) { foreach (object obj in planarFace.EdgeLoops) { EdgeArray edgeArray = (EdgeArray)obj; foreach (object obj2 in edgeArray) { Edge edge = (Edge)obj2; Curve curve = edge.AsCurve(); bool flag = curve == null; if (!flag) { XYZ xyz = transform.OfPoint(curve.GetEndPoint(0)); XYZ xyz2 = transform.OfPoint(curve.GetEndPoint(1)); double num3 = xyz.DotProduct(direction); double num4 = xyz2.DotProduct(direction); bool flag2 = num3 > num2; if (flag2) { point = xyz; num2 = num3; } bool flag3 = num4 > num2; if (flag3) { point = xyz2; num2 = num4; } } } } } List <PlanarFace> list = new List <PlanarFace>(); foreach (PlanarFace planarFace2 in faces) { double num5 = Facelibry.PointToFace(point, planarFace2, transform); bool flag4 = num5 < 0.001; if (flag4) { list.Add(planarFace2); } } foreach (PlanarFace planarFace3 in list) { XYZ xyz3 = transform.OfVector(planarFace3.FaceNormal); double num6 = xyz3.DotProduct(direction); bool flag5 = num6 > num; if (flag5) { result = planarFace3; num = num6; } } return(result); }