// Arc
        // Rh Capture can be a circle OR an arc
        public Base ArcToSpeckle(ArcCurve a, string units = null)
        {
            var u = units ?? ModelUnits;

            if (a.IsClosed)
            {
                RH.Circle preCircle;
                a.TryGetCircle(out preCircle);
                Circle myCircle = CircleToSpeckle(preCircle, u);
                myCircle.domain = IntervalToSpeckle(a.Domain);
                myCircle.length = a.GetLength();
                myCircle.bbox   = BoxToSpeckle(new RH.Box(a.GetBoundingBox(true)), u);
                return(myCircle);
            }
            else
            {
                RH.Arc preArc;
                a.TryGetArc(out preArc);
                Arc myArc = ArcToSpeckle(preArc, u);
                myArc.domain = IntervalToSpeckle(a.Domain);
                myArc.length = a.GetLength();
                myArc.bbox   = BoxToSpeckle(new RH.Box(a.GetBoundingBox(true)), u);
                return(myArc);
            }
        }
        // Circle
        // Gh Capture
        public Circle CircleToSpeckle(RH.Circle circ)
        {
            var circle = new Circle(PlaneToSpeckle(circ.Plane), circ.Radius, ModelUnits);

            circle.domain = new Interval(0, 1);
            return(circle);
        }
        // Circle
        // Gh Capture
        public Circle CircleToSpeckle(RH.Circle circ, string units = null)
        {
            var u      = units ?? ModelUnits;
            var circle = new Circle(PlaneToSpeckle(circ.Plane, u), circ.Radius, u);

            circle.domain = new Interval(0, 1);
            circle.length = 2 * Math.PI * circ.Radius;
            circle.area   = Math.PI * circ.Radius * circ.Radius;
            return(circle);
        }
Exemple #4
0
 /// <summary>
 /// DS Circle to SpeckleCircle.
 /// </summary>
 /// <param name="circ"></param>
 /// <returns></returns>
 public Circle CircleToSpeckle(DS.Circle circ)
 {
     using (DS.Vector xAxis = DS.Vector.ByTwoPoints(circ.CenterPoint, circ.StartPoint))
         using (DS.Plane plane = DS.Plane.ByOriginNormalXAxis(circ.CenterPoint, circ.Normal, xAxis))
         {
             var myCircle = new Circle(PlaneToSpeckle(plane), circ.Radius, ModelUnits);
             CopyProperties(myCircle, circ);
             return(myCircle);
         }
 }
        /// <summary>
        /// SpeckleCircle to DS Circle. Rotating the circle is due to a bug in ProtoGeometry
        /// that will be solved on Dynamo 2.1.
        /// </summary>
        /// <param name="circ"></param>
        /// <returns></returns>
        public DS.Circle CircleToNative(Circle circ)
        {
            using (DS.Plane basePlane = PlaneToNative(circ.plane))
                using (DS.Circle preCircle = DS.Circle.ByPlaneRadius(basePlane, ScaleToNative(circ.radius.Value, circ.units)))
                    using (DS.Vector preXvector = DS.Vector.ByTwoPoints(preCircle.CenterPoint, preCircle.StartPoint))
                    {
                        double angle  = preXvector.AngleAboutAxis(basePlane.XAxis, basePlane.Normal);
                        var    circle = (DS.Circle)preCircle.Rotate(basePlane, angle);

                        return(circle.SetDynamoProperties <DS.Circle>(GetDynamicMembersFromBase(circ)));
                    }
        }
        public ArcCurve CircleToNative(Circle circ)
        {
            RH.Circle circle = new RH.Circle(PlaneToNative(circ.plane), ScaleToNative((double)circ.radius, circ.units));

            var myCircle = new ArcCurve(circle);

            if (circ.domain != null)
            {
                myCircle.Domain = IntervalToNative(circ.domain);
            }

            return(myCircle);
        }
        /// <summary>
        /// DS Circle to SpeckleCircle.
        /// </summary>
        /// <param name="circ"></param>
        /// <returns></returns>
        public Circle CircleToSpeckle(DS.Circle circ, string units = null)
        {
            var u = units ?? ModelUnits;

            using (DS.Vector xAxis = DS.Vector.ByTwoPoints(circ.CenterPoint, circ.StartPoint))
                using (DS.Plane plane = DS.Plane.ByOriginNormalXAxis(circ.CenterPoint, circ.Normal, xAxis))
                {
                    var myCircle = new Circle(PlaneToSpeckle(plane, u), circ.Radius, u);
                    CopyProperties(myCircle, circ);
                    myCircle.length = circ.Length;
                    myCircle.bbox   = BoxToSpeckle(circ.BoundingBox.ToCuboid(), u);
                    return(myCircle);
                }
        }
        // Arc
        // Rh Capture can be a circle OR an arc
        public Base ArcToSpeckle(ArcCurve a)
        {
            if (a.IsClosed)
            {
                RH.Circle preCircle;
                a.TryGetCircle(out preCircle);
                Circle myCircle = CircleToSpeckle(preCircle);
                myCircle.domain = IntervalToSpeckle(a.Domain);

                return(myCircle);
            }
            else
            {
                RH.Arc preArc;
                a.TryGetArc(out preArc);
                Arc myArc = ArcToSpeckle(preArc);
                myArc.domain = IntervalToSpeckle(a.Domain);

                return(myArc);
            }
        }