private static bool IsSurfaceInPlane(Surface surface, Plane plane, double tolerance) { if (!surface.IsPlanar(tolerance)) return false; var bbox = surface.GetBoundingBox(true); return bbox.GetCorners().All(c => System.Math.Abs(plane.DistanceTo(c)) <= tolerance); }
/***************************************************/ public static BHG.ISurface FromRhino(this RHG.Surface surface) { if (surface == null) { return(null); } if (surface.IsPlanar(BHG.Tolerance.Distance)) { BHG.ICurve externalEdge = RHG.Curve.JoinCurves(surface.ToBrep().DuplicateNakedEdgeCurves(true, false)).FirstOrDefault().FromRhino(); return(new BHG.PlanarSurface(externalEdge, new List <oM.Geometry.ICurve>())); } return(surface.ToNurbsSurface().FromRhino()); }