Beispiel #1
0
 public SingleCurvedGlulam(Curve curve, CrossSectionOrientation orientation, GlulamData data) : base()
 {
     Data        = data.Duplicate();
     Orientation = orientation.Duplicate();
     Centreline  = curve.DuplicateCurve();
     //Centreline.Domain.MakeIncreasing();
 }
Beispiel #2
0
        public GlulamData Duplicate()
        {
            GlulamData data = new GlulamData();

            data.LamHeight         = LamHeight;
            data.LamWidth          = LamWidth;
            data.Samples           = Samples;
            data.SectionAlignment  = SectionAlignment;
            data.InterpolationType = InterpolationType;
            data.Lamellae          = new Stick[NumWidth, NumHeight];
            Array.Copy(Lamellae, data.Lamellae, Lamellae.Length);

            return(data);
        }
Beispiel #3
0
        public Glulam Trim(Interval domain, double overlap)
        {
            double l1 = Centreline.GetLength(new Interval(Centreline.Domain.Min, domain.Min));
            double l2 = Centreline.GetLength(new Interval(Centreline.Domain.Min, domain.Max));
            double t1, t2;

            if (!Centreline.LengthParameter(l1 - overlap, out t1))
            {
                t1 = domain.Min;
            }
            if (!Centreline.LengthParameter(l2 + overlap, out t2))
            {
                t2 = domain.Max;
            }

            domain = new Interval(
                Math.Max(t1, Centreline.Domain.Min),
                Math.Min(t2, Centreline.Domain.Max));

            double length = Centreline.GetLength(domain);

            if (domain.IsDecreasing || length < overlap || length < Glulam.OverlapTolerance)
            {
                return(null);
            }

            double percentage = length / Centreline.GetLength();

            GlulamData data = Data.Duplicate();

            data.Samples = Math.Max(6, (int)(data.Samples * percentage));


            Curve trimmed_curve = Centreline.Trim(domain);

            CrossSectionOrientation trimmed_orientation = Orientation.Trim(domain);

            trimmed_orientation.Remap(Centreline, trimmed_curve);

            Glulam glulam = CreateGlulam(trimmed_curve, trimmed_orientation, data);

            return(glulam);
        }
Beispiel #4
0
        public static GlulamData FromByteArray(byte[] b)
        {
            if (b.Length != 28)
            {
                throw new Exception("Byte array is wrong size for GlulamData!");
            }

            GlulamData data       = new GlulamData();
            int        num_height = BitConverter.ToInt32(b, 0);
            int        num_width  = BitConverter.ToInt32(b, 4);

            data.LamHeight         = BitConverter.ToDouble(b, 8);
            data.LamWidth          = BitConverter.ToDouble(b, 16);
            data.Samples           = BitConverter.ToInt32(b, 24);
            data.SectionAlignment  = (GlulamData.CrossSectionPosition)BitConverter.ToInt32(b, 32);
            data.InterpolationType = (GlulamData.Interpolation)BitConverter.ToInt32(b, 40);
            data.Lamellae          = new Stick[num_width, num_height];

            return(data);
        }
Beispiel #5
0
        /// <summary>
        /// Split glulam into two at parameter t.
        /// </summary>
        /// <param name="t">Curve parameter to split glulam at.</param>
        /// <returns>List of new glulams.</returns>
        public List <Glulam> Split(double t)
        {
            if (!Centreline.Domain.IncludesParameter(t))
            {
                return(null);
            }

            double percentage = (t - Centreline.Domain.Min) / (Centreline.Domain.Max - Centreline.Domain.Min);

            Plane split_plane = GetPlane(t);

            Curve[] split_curves = Centreline.Split(t);
            if (split_curves == null || split_curves.Length != 2)
            {
                return(null);
            }

            GlulamData Data1 = Data.Duplicate();

            Data1.Samples = (int)(Data.Samples * percentage);

            CrossSectionOrientation[] SplitOrientations = Orientation.Split(new double[] { t });

            Glulam Blank1 = CreateGlulam(split_curves[0], SplitOrientations[0], Data1);

            GlulamData Data2 = Data.Duplicate();

            Data2.Samples = (int)(Data.Samples * (1 - percentage));

            Glulam Blank2 = CreateGlulam(split_curves[1], SplitOrientations[1], Data2);

            List <Glulam> blanks = new List <Glulam>()
            {
                Blank1, Blank2
            };

            return(blanks);
        }
Beispiel #6
0
        static public Glulam CreateGlulam(Curve curve, CrossSectionOrientation orientation, GlulamData data)
        {
            Glulam glulam;

            if (curve.IsLinear(Tolerance))
            {
                glulam = new StraightGlulam {
                    Centreline = curve.DuplicateCurve(), Orientation = orientation, Data = data.Duplicate()
                };
            }
            else if (curve.IsPlanar(Tolerance))
            {
                /*
                 * if (data.NumHeight < 2)
                 * {
                 *  data.Lamellae.ResizeArray(data.NumWidth, 2);
                 *  data.LamHeight /= 2;
                 * }
                 */
                glulam = new SingleCurvedGlulam {
                    Centreline = curve.DuplicateCurve(), Orientation = orientation, Data = data.Duplicate()
                };
            }
            else
            {
                /*
                 * if (data.NumHeight < 2)
                 * {
                 *  data.Lamellae.ResizeArray(data.NumWidth, 2);
                 *  data.LamHeight /= 2;
                 * }
                 *
                 * if (data.NumWidth < 2)
                 * {
                 *  data.Lamellae.ResizeArray(2, data.NumHeight);
                 *  data.LamWidth /= 2;
                 * }
                 */

                //glulam = new DoubleCurvedGlulam(curve, orientation, data);
                glulam = new DoubleCurvedGlulam {
                    Centreline = curve.DuplicateCurve(), Orientation = orientation, Data = data.Duplicate()
                };
            }

            return(glulam);
        }