Exemplo n.º 1
0
        private void SetCurveType(Rg.Curve curve)
        {
            Rg.Circle   R = new Rg.Circle();
            Rg.Arc      A = new Rg.Arc();
            Rg.Ellipse  S = new Rg.Ellipse();
            Rg.Polyline P = new Rg.Polyline();

            if (curve.TryGetCircle(out R))
            {
                curveType = CurveTypes.Circle;
            }
            else if (curve.TryGetArc(out A))
            {
                curveType = CurveTypes.Arc;
            }
            else if (curve.TryGetEllipse(out S))
            {
                curveType = CurveTypes.Ellipse;
            }
            else if (curve.IsLinear())
            {
                curveType = CurveTypes.Line;
            }
            else if (curve.TryGetPolyline(out P))
            {
                curveType = CurveTypes.Polyline;
            }
            else
            {
                curveType = CurveTypes.Spline;
            }
        }
Exemplo n.º 2
0
        /***************************************************/

        public static BHG.ICurve FromRhino(this RHG.Curve rCurve)
        {
            if (rCurve == null)
            {
                return(null);
            }

            Type curveType = rCurve.GetType();

            if (rCurve.IsLinear() && rCurve.SpanCount < 2)
            {
                return(new BHG.Line {
                    Start = rCurve.PointAtStart.FromRhino(), End = rCurve.PointAtEnd.FromRhino(), Infinite = false
                });
            }
            if (rCurve.IsCircle())
            {
                RHG.Circle circle = new RHG.Circle();
                rCurve.TryGetCircle(out circle);
                return(circle.FromRhino());
            }
            else if (rCurve.IsArc() || typeof(RHG.ArcCurve).IsAssignableFrom(curveType))
            {
                RHG.Arc arc = new RHG.Arc();
                rCurve.TryGetArc(out arc);
                return(arc.FromRhino());
            }
            else if (rCurve.IsPolyline() || typeof(RHG.PolylineCurve).IsAssignableFrom(curveType))
            {
                RHG.Polyline polyline = new RHG.Polyline();
                rCurve.TryGetPolyline(out polyline);
                return(polyline.FromRhino());
            }
            else if (rCurve.IsClosed && rCurve.IsEllipse())
            {
                RHG.Ellipse ellipse = new RHG.Ellipse();
                rCurve.TryGetEllipse(out ellipse);
                return(ellipse.FromRhino());
            }
            else if (rCurve is RHG.NurbsCurve)
            {
                return(((RHG.NurbsCurve)rCurve).FromRhino());
            }
            else if (rCurve is RHG.PolyCurve)
            {
                return(((RHG.PolyCurve)rCurve).FromRhino());  //The test of IsPolyline above is very important to make sure we can cast to PolyCurve here
            }
            else
            {
                return((rCurve.ToNurbsCurve()).FromRhino());
            }
        }