示例#1
0
        /***************************************************/

        public static RHG.GeometryBase IToRhino(this BHG.ISurface surface)
        {
            return((surface == default(BHG.ISurface)) ? null : Convert.ToRhino(surface as dynamic));
        }
示例#2
0
        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.");
        }
示例#3
0
        public static BH.oM.Analytical.Elements.ISurface SetGeometry(this BH.oM.Analytical.Elements.ISurface anaSurface, BH.oM.Geometry.ISurface geoSurface)
        {
            if (anaSurface == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot set the geometry of a null surface.");
                return(null);
            }

            anaSurface.Extents = geoSurface;
            return(anaSurface);
        }