Exemple #1
0
        /// <summary>
        ///     TODO
        /// </summary>
        /// <param name="nat"></param>
        /// <param name="axis"></param>
        /// <returns></returns>
        private Vector3d GetTangent(Curve3d nat, Axis axis)
        {
            var vec = new Vector3d();

            try
            {
                if (nat is LinearEntity3d || nat.IsClosed())
                {
                    vec = axis.ToVector();
                }
                else if (nat.StartPoint == axis.Start || nat.EndPoint == axis.Start)
                {
                    using (var curved = nat.GetClosestPointTo(axis.Start))
                    {
                        vec = curved.GetDerivative(1).GetNormal() * axis.Length;
                    }

                    using (var curved2 = nat.GetClosestPointTo(axis.Start + vec))
                    {
                        if (curved2.Point.IsEqualTo(axis.Start))
                        {
                            vec = vec.Negate();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                MailAgent.Report(e.Message);
            }

            return(vec);
        }
        public ICurve CurveToSpeckle(Curve3d curve)
        {
            if (curve.IsPlanar(out AC.Plane pln))
            {
                if (curve.IsPeriodic(out double period) && curve.IsClosed())
                {
                }

                if (curve.IsLinear(out Line3d line)) // defaults to polyline
                {
                    if (null != line)
                    {
                        return(LineToSpeckle(line));
                    }
                }
            }

            return(NurbsToSpeckle(curve as NurbCurve3d));
        }