Esempio n. 1
0
        /// <summary>
        /// Defines the shape of a Post Tensioned Cable.
        /// </summary>
        public PtcShapeType(PtcShapeStart start, PtcShapeEnd end, IEnumerable <PtcShapeInner> intermediates)
        {
            DenormalizePriorInflectionParameters(ref end, ref intermediates);

            StartPoint        = start;
            EndPoint          = end;
            IntermediatePoint = intermediates.ToArray();
        }
Esempio n. 2
0
        /// <summary>
        /// Change normalization on PriorInflectionPosition from normalized along parent element to be normalized between ptc shape base points.
        /// </summary>
        /// <param name="end"></param>
        /// <param name="intermediates"></param>
        private void DenormalizePriorInflectionParameters(ref PtcShapeEnd end, ref IEnumerable <PtcShapeInner> intermediates)
        {
            var sortedInner = intermediates.OrderBy(i => i.Position).ToList();
            List <PtcShapeInner> newIntermediates = new List <PtcShapeInner>();

            double Denormalize(double t, double x1, double x2)
            {
                if (t < x1 || t > x2)
                {
                    throw new ArgumentException($"PriorInflectionPosition must be a parameter between prior end next basepoint but got (position: {t}, prior: {x1}, next: {x2})");
                }
                return((t - x1) / (x2 - x1));
            }

            // Normalize inner
            for (int i = 0; i < sortedInner.Count; i++)
            {
                var next = sortedInner[i];
                if (next.PriorInflectionPosition.HasValue)
                {
                    double x1 = 0.0;
                    if (i > 0)
                    {
                        x1 = sortedInner[i - 1].Position;
                    }
                    double x2 = next.Position;
                    double t  = next.PriorInflectionPosition.Value;

                    newIntermediates.Add(new PtcShapeInner(next.Position, next.Z, next.Tangent, Denormalize(t, x1, x2)));
                }
                else
                {
                    newIntermediates.Add(next);
                }
            }
            intermediates = newIntermediates;

            // Normalize end
            if (sortedInner.Any() && end.PriorInflectionPosition.HasValue && end.NormalizedInflectionPosition)
            {
                double x1 = sortedInner.Last().Position;
                double x2 = 1.0;
                double t  = end.PriorInflectionPosition.Value;

                end = new PtcShapeEnd(end.Z, end.Tangent, Denormalize(t, x1, x2))
                {
                    NormalizedInflectionPosition = false
                };
            }
        }
Esempio n. 3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            double z = 0.0;

            if (!DA.GetData("z'", ref z))
            {
                return;
            }

            double tangent = 0.0;

            if (!DA.GetData("Tangent", ref tangent))
            {
                return;
            }

            double?priorInflectionParam = null;

            DA.GetData("PriorInflection x'", ref priorInflectionParam);

            PtcShapeEnd end = new PtcShapeEnd(z, tangent, priorInflectionParam);

            DA.SetData("End", end);
        }
Esempio n. 4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            PtcShapeStart start = null;

            if (!DA.GetData("Start", ref start) || start == null)
            {
                return;
            }

            List <PtcShapeInner> intermediates = new List <PtcShapeInner>();

            DA.GetDataList("Intermidiate", intermediates);

            PtcShapeEnd end = null;

            if (!DA.GetData("End", ref end) || end == null)
            {
                return;
            }

            PtcShapeType shape = new PtcShapeType(start, end, intermediates);

            DA.SetData("Shape", shape);
        }