Esempio n. 1
0
        public DoubleCurvedGlulam(Curve centreline, Plane[] planes) : base()
        {
            Centreline = centreline;
            //Centreline.Domain.MakeIncreasing();


            if (planes != null)
            {
                List <Vector3d> vectors    = new List <Vector3d>();
                List <double>   parameters = new List <double>();
                double          t;

                for (int i = 0; i < planes.Length; ++i)
                {
                    Centreline.ClosestPoint(planes[i].Origin, out t);
                    parameters.Add(t);
                    vectors.Add(planes[i].YAxis);
                }

                Orientation = new VectorListOrientation(Centreline, parameters, vectors);
            }
            else
            {
                Orientation = new KCurveOrientation();
            }
        }
Esempio n. 2
0
        public SingleCurvedGlulam(Curve centreline, Plane[] planes, bool with_twist = false) : base()
        {
            if (planes == null)
            {
                Plane p;
                if (centreline.TryGetPlane(out p))
                {
                    double midT = centreline.Domain.Mid;
                    planes = new Plane[] {
                        new Plane(centreline.PointAtStart,
                                  p.ZAxis,
                                  Vector3d.CrossProduct(centreline.TangentAtStart, p.ZAxis)),
                        new Plane(centreline.PointAt(midT),
                                  p.ZAxis,
                                  Vector3d.CrossProduct(centreline.TangentAt(midT), p.ZAxis)
                                  ),
                        new Plane(centreline.PointAtEnd,
                                  p.ZAxis,
                                  Vector3d.CrossProduct(centreline.TangentAtEnd, p.ZAxis)
                                  )
                    };
                }
                else
                {
                    planes = new Plane[] { centreline.GetAlignedPlane(20, out double mag) };
                }
            }

            Centreline = centreline;
            //Centreline.Domain.MakeIncreasing();

            //Frames = new List<Tuple<double, Plane>>();
            double t;

            List <Vector3d> vectors    = new List <Vector3d>();
            List <double>   parameters = new List <double>();

            for (int i = 0; i < planes.Length; ++i)
            {
                Centreline.ClosestPoint(planes[i].Origin, out t);

                parameters.Add(t);
                vectors.Add(planes[i].YAxis);
                //Frames.Add(new Tuple<double, Plane>(t, planes[i]));
            }

            Orientation = new VectorListOrientation(centreline, parameters, vectors);

            //SortFrames();
            //RecalculateFrames();
        }
        public override CrossSectionOrientation Join(CrossSectionOrientation orientation)
        {
            if (orientation is VectorListOrientation)
            {
                VectorListOrientation vlo  = orientation as VectorListOrientation;
                VectorParameter[]     temp = new VectorParameter[m_guides.Length + vlo.m_guides.Length];
                Array.Copy(m_guides, temp, m_guides.Length);
                Array.Copy(vlo.m_guides, 0, temp, m_guides.Length, vlo.m_guides.Length);
                Array.Sort(temp, (a, b) => a.Parameter.CompareTo(b.Parameter));

                m_guides = temp;
            }

            return(this.Duplicate());
        }
Esempio n. 4
0
        public StraightGlulam(Curve curve, Plane[] planes, bool with_twist = false) : base()
        {
            Centreline = curve;
            //Centreline.Domain.MakeIncreasing();

            if (planes == null || planes.Length < 1)
            {
                Plane plane;
                Centreline.PerpendicularFrameAt(Centreline.Domain.Min, out plane);
                planes = new Plane[] { plane };
            }

            if (!Centreline.IsLinear(Tolerance))
            {
                throw new Exception("StraightGlulam only works with a linear centreline!");
            }

            List <Vector3d> vectors    = new List <Vector3d>();
            List <double>   parameters = new List <double>();

            if (with_twist)
            {
                double t;
                foreach (var plane in planes)
                {
                    Centreline.ClosestPoint(plane.Origin, out t);

                    parameters.Add(t);
                    vectors.Add(plane.YAxis);
                }
                Orientation = new VectorListOrientation(Centreline, parameters, vectors);
            }
            else
            {
                var origin = Centreline.PointAtStart;
                var x_axis = Vector3d.CrossProduct(planes[0].YAxis, Centreline.TangentAtStart);
                var y_axis = Vector3d.CrossProduct(Centreline.TangentAtStart, x_axis);

                Orientation = new VectorOrientation(y_axis);
            }
        }
        public override CrossSectionOrientation[] Split(IList <double> t)
        {
            CrossSectionOrientation[] new_orientations = new CrossSectionOrientation[t.Count + 1];

            if (t.Count < 1)
            {
                new_orientations[0] = this.Duplicate();
                return(new_orientations);
            }

            int    prev       = 0;
            double prev_param = 0.0;
            bool   flag       = false;

            VectorParameter[] new_guides;

            int index = 0;

            foreach (double param in t)
            {
                int res = Array.BinarySearch(m_guides, param);

                if (res < 0)
                {
                    res = ~res;

                    new_guides = new VectorParameter[res - prev + 1];
                    Array.Copy(m_guides, prev, new_guides, 0, res - prev);

                    new_guides[new_guides.Length - 1] = new VectorParameter {
                        Parameter = param, Direction = GetOrientation(m_curve, param)
                    };
                    new_guides[new_guides.Length - 1].CalculateAngularOffset(m_curve);

                    if (prev > 0 || flag)
                    {
                        VectorParameter[] temp = new VectorParameter[new_guides.Length + 1];
                        temp[0] = new VectorParameter {
                            Parameter = prev_param, Direction = GetOrientation(m_curve, prev_param)
                        };
                        temp[0].CalculateAngularOffset(m_curve);

                        Array.Copy(new_guides, 0, temp, 1, new_guides.Length);
                        new_guides = temp;
                    }

                    new_orientations[index] = new VectorListOrientation(
                        m_curve,
                        new_guides);

                    prev_param = param;
                    prev       = res;
                    flag       = true;
                }
                else
                {
                    new_guides = new VectorParameter[res - prev + 1];
                    Array.Copy(m_guides, prev, new_guides, 0, res - prev + 1);

                    new_orientations[index] = new VectorListOrientation(
                        m_curve,
                        new_guides);

                    prev = res;
                }

                index++;
            }

            new_guides = new VectorParameter[m_guides.Length - prev + 1];
            Array.Copy(m_guides, prev, new_guides, 1, m_guides.Length - prev);

            new_guides[0] = new VectorParameter {
                Parameter = t.Last(), Direction = GetOrientation(m_curve, t.Last())
            };
            new_guides[0].CalculateAngularOffset(m_curve);

            new_orientations[index] = new VectorListOrientation(
                m_curve,
                new_guides);

            return(new_orientations);
        }