/// <summary>
 /// SpeckleEllipse to DS Ellipse
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 public DS.Curve EllipseToNative(Ellipse e)
 {
     if (e.trimDomain != null)
     {
         // Curve is an ellipse arc
         var ellipseArc = DS.EllipseArc.ByPlaneRadiiAngles(
             PlaneToNative(e.plane),
             ScaleToNative(e.firstRadius.Value, e.units),
             ScaleToNative(e.secondRadius.Value, e.units),
             e.trimDomain.start.Value * 360 / (2 * Math.PI),
             (double)(e.trimDomain.end - e.trimDomain.start) * 360 / (2 * Math.PI));
         return(ellipseArc);
     }
     else
     {
         // Curve is an ellipse
         var ellipse = DS.Ellipse.ByPlaneRadii(
             PlaneToNative(e.plane),
             ScaleToNative(e.firstRadius.Value, e.units),
             ScaleToNative(e.secondRadius.Value, e.units)
             );
         ellipse.SetDynamoProperties <DS.Ellipse>(GetDynamicMembersFromBase(e));
         return(ellipse);
     }
 }
        //Ellipse
        public Ellipse EllipseToSpeckle(RH.Ellipse e)
        {
            var el = new Ellipse(PlaneToSpeckle(e.Plane), e.Radius1, e.Radius2, ModelUnits);

            el.domain = new Interval(0, 1);
            return(el);
        }
        //Ellipse
        // TODO: handle conversions that define Radius1/Radius2 as major/minor instead of xaxis/yaxis
        public Ellipse EllipseToSpeckle(RH.Ellipse e, string units = null)
        {
            var u  = units ?? ModelUnits;
            var el = new Ellipse(PlaneToSpeckle(e.Plane, u), e.Radius1, e.Radius2, u);

            el.domain = new Interval(0, 1);
            el.length = e.ToNurbsCurve().GetLength();
            el.bbox   = BoxToSpeckle(new RH.Box(e.ToNurbsCurve().GetBoundingBox(true)), u);
            el.area   = Math.PI * e.Radius1 * e.Radius2; // Manual area computing, could not find the Rhino way...
            return(el);
        }
Esempio n. 4
0
        /// <summary>
        /// DS EllipseArc to Speckle Ellipse
        /// </summary>
        /// <param name="arc"></param>
        /// <returns></returns>
        public Ellipse EllipseToSpeckle(EllipseArc arc)
        {
            var ellipArc = new Ellipse(
                PlaneToSpeckle(arc.Plane),
                arc.MajorAxis.Length,
                arc.MinorAxis.Length,
                new Interval(0, 2 * Math.PI),
                new Interval(arc.StartAngle, arc.StartAngle + arc.SweepAngle),
                ModelUnits);

            CopyProperties(ellipArc, arc);
            return(ellipArc);
        }
Esempio n. 5
0
        /// <summary>
        /// DS Ellipse to SpeckleEllipse
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public Ellipse EllipseToSpeckle(DS.Ellipse e)
        {
            using (DS.Plane basePlane = DS.Plane.ByOriginNormalXAxis(e.CenterPoint, e.Normal, e.MajorAxis))
            {
                var ellipse = new Ellipse(
                    PlaneToSpeckle(basePlane),
                    e.MajorAxis.Length,
                    e.MinorAxis.Length,
                    new Interval(e.StartParameter(), e.EndParameter()),
                    null,
                    ModelUnits);

                CopyProperties(ellipse, e);
                return(ellipse);
            }
        }
        public RH.Curve EllipseToNative(Ellipse e)
        {
            RH.Ellipse elp    = new RH.Ellipse(PlaneToNative(e.plane), ScaleToNative((double)e.firstRadius, e.units), ScaleToNative((double)e.secondRadius, e.units));
            var        myEllp = elp.ToNurbsCurve();

            if (e.domain != null)
            {
                myEllp.Domain = IntervalToNative(e.domain);
            }

            if (e.trimDomain != null)
            {
                myEllp = myEllp.Trim(IntervalToNative(e.trimDomain)).ToNurbsCurve();
            }

            return(myEllp);
        }
        /// <summary>
        /// DS EllipseArc to Speckle Ellipse
        /// </summary>
        /// <param name="arc"></param>
        /// <returns></returns>
        public Ellipse EllipseToSpeckle(EllipseArc arc, string units = null)
        {
            var u        = units ?? ModelUnits;
            var ellipArc = new Ellipse(
                PlaneToSpeckle(arc.Plane, u),
                arc.MajorAxis.Length,
                arc.MinorAxis.Length,
                new Interval(0, 2 * Math.PI),
                new Interval(arc.StartAngle, arc.StartAngle + arc.SweepAngle),
                u);

            CopyProperties(ellipArc, arc);

            ellipArc.length = arc.Length;
            ellipArc.bbox   = BoxToSpeckle(arc.BoundingBox.ToCuboid(), u);

            return(ellipArc);
        }
Esempio n. 8
0
        public DB.Ellipse EllipseToNative(Ellipse ellipse)
        {
            //TODO: support ellipse arcs
            using (DB.Plane basePlane = PlaneToNative(ellipse.plane))
            {
                var e = DB.Ellipse.CreateCurve(
                    PointToNative(ellipse.plane.origin),
                    ScaleToNative((double)ellipse.firstRadius, ellipse.units),
                    ScaleToNative((double)ellipse.secondRadius, ellipse.units),
                    basePlane.XVec.Normalize(),
                    basePlane.YVec.Normalize(),
                    ellipse.domain.start ?? 0,
                    ellipse.domain.end ?? 2 * Math.PI
                    ) as DB.Ellipse;

                e.MakeBound(ellipse.trimDomain?.start ?? 0, ellipse.trimDomain?.end ?? 2 * Math.PI);
                return(e);
            }
        }
Esempio n. 9
0
        public Ellipse EllipseToSpeckle(DB.Ellipse ellipse, string units = null)
        {
            var u = units ?? ModelUnits;

            using (DB.Plane basePlane = DB.Plane.CreateByOriginAndBasis(ellipse.Center, ellipse.XDirection, ellipse.YDirection))
            {
                var trim = ellipse.IsBound ? new Interval(ellipse.GetEndParameter(0), ellipse.GetEndParameter(1)) : null;

                var ellipseToSpeckle = new Ellipse(
                    PlaneToSpeckle(basePlane, u),
                    u == Units.None ? ellipse.RadiusX : ScaleToSpeckle(ellipse.RadiusX),
                    u == Units.None ? ellipse.RadiusY : ScaleToSpeckle(ellipse.RadiusY),
                    new Interval(0, 2 * Math.PI),
                    trim,
                    u);
                ellipseToSpeckle.length = ellipse.Length;
                return(ellipseToSpeckle);
            }
        }
        /// <summary>
        /// DS Ellipse to SpeckleEllipse
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public Ellipse EllipseToSpeckle(DS.Ellipse e, string units = null)
        {
            var u = units ?? ModelUnits;

            using (DS.Plane basePlane = DS.Plane.ByOriginNormalXAxis(e.CenterPoint, e.Normal, e.MajorAxis))
            {
                var ellipse = new Ellipse(
                    PlaneToSpeckle(basePlane, u),
                    e.MajorAxis.Length,
                    e.MinorAxis.Length,
                    new Interval(e.StartParameter(), e.EndParameter()),
                    null,
                    u);

                CopyProperties(ellipse, e);

                ellipse.length = e.Length;
                ellipse.bbox   = BoxToSpeckle(e.BoundingBox.ToCuboid(), u);

                return(ellipse);
            }
        }