/***************************************************/ /**** Miscellanea ****/ /***************************************************/ public static List <object> ToRhino(this BHG.CompositeGeometry geometries) { if (geometries == null) { return(new List <object>()); } return(geometries.Elements.Select(x => x.IToRhino()).ToList()); }
/***************************************************/ public static void RenderMeshes(BHG.CompositeGeometry composite, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { if (composite.Elements.Count == 0) { return; } foreach (BHG.IGeometry geom in composite.Elements) { try { RenderMeshes(geom as dynamic, pipeline, material); } catch (Exception) { } } }
/***************************************************/ public static void RenderWires(BHG.CompositeGeometry composite, Rhino.Display.DisplayPipeline pipeline, Color bhColour) { if (composite.Elements.Count == 0) { return; } foreach (BHG.IGeometry geom in composite.Elements) { try { RenderWires(geom as dynamic, pipeline, bhColour); } catch (Exception) { } } }
public static global::Topologic.Topology TopologyByGeometry(BH.oM.Geometry.IGeometry geometry, double tolerance = 0.0001) { BH.oM.Geometry.Point bhomPoint = geometry as BH.oM.Geometry.Point; if (bhomPoint != null) { return(Create.VertexByPoint(bhomPoint)); } // Handle polyline and polycurve first BH.oM.Geometry.Polyline bhomPolyline = geometry as BH.oM.Geometry.Polyline; if (bhomPolyline != null) { if (bhomPolyline.ControlPoints.Count < 2) { throw new Exception("An invalid polyline with fewer than 2 control points is given."); } else if (bhomPolyline.ControlPoints.Count == 2) { BH.oM.Geometry.Line bhomLine = BH.Engine.Geometry.Create.Line(bhomPolyline.ControlPoints[0], bhomPolyline.ControlPoints[1]); return(Create.EdgeByLine(bhomLine)); } else { return(Create.WireByPolyLine(bhomPolyline)); } } BH.oM.Geometry.PolyCurve bhomPolyCurve = geometry as BH.oM.Geometry.PolyCurve; if (bhomPolyCurve != null) { if (bhomPolyCurve.Curves.Count == 0) { throw new Exception("An invalid polycurve with no curve is given."); } else if (bhomPolyCurve.Curves.Count == 1) { BH.oM.Geometry.ICurve bhomACurve = bhomPolyCurve.Curves[0]; return(Create.EdgeByCurve(bhomACurve)); } else { return(Create.WireByPolyCurve(bhomPolyCurve)); } } // Then curve BH.oM.Geometry.ICurve bhomCurve = geometry as BH.oM.Geometry.ICurve; if (bhomCurve != null) { return(Create.EdgeByCurve(bhomCurve)); } // Do polysurface first. BH.oM.Geometry.PolySurface bhomPolySurface = geometry as BH.oM.Geometry.PolySurface; if (bhomPolySurface != null) { return(Create.ShellByPolySurface(bhomPolySurface, tolerance)); } // Then surface BH.oM.Geometry.ISurface bhomSurface = geometry as BH.oM.Geometry.ISurface; if (bhomSurface != null) { return(Create.FaceBySurface(bhomSurface)); } BH.oM.Geometry.ISolid bhomSolid = geometry as BH.oM.Geometry.ISolid; if (bhomSolid != null) { return(Create.CellBySolid(bhomSolid, tolerance)); } BH.oM.Geometry.BoundingBox bhomBoundingBox = geometry as BH.oM.Geometry.BoundingBox; if (bhomBoundingBox != null) { return(Create.CellByBoundingBox(bhomBoundingBox)); } BH.oM.Geometry.CompositeGeometry bhomCompositeGeometry = geometry as BH.oM.Geometry.CompositeGeometry; if (bhomCompositeGeometry != null) { return(Create.ClusterByCompositeGeometry(bhomCompositeGeometry, tolerance)); } BH.oM.Geometry.Mesh bhomMesh = geometry as BH.oM.Geometry.Mesh; if (bhomMesh != null) { return(Create.TopologyByMesh(bhomMesh)); } throw new NotImplementedException("This BHoM geometry is not yet supported."); }