Пример #1
0
        static public Glulam CreateGlulam(Curve curve, GlulamOrientation orientation, GlulamData data)
        {
            Glulam glulam;

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

                glulam = new SingleCurvedGlulam(curve, orientation, data);
            }
            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);
            }

            return(glulam);
        }
Пример #2
0
        /// <summary>
        /// Glulam factory methods.
        /// </summary>
        /// <param name="curve">Input curve.</param>
        /// <param name="planes">Input orientation planes.</param>
        /// <param name="data">Input glulam data.</param>
        /// <returns>New glulam.</returns>
        static public Glulam CreateGlulam(Curve curve, Plane[] planes = null, GlulamData data = null)
        {
            if (data == null)
            {
                data = GlulamData.FromCurveLimits(curve);
            }


            Glulam glulam;

            if (planes == null || planes.Length < 1)
            // if there are no planes defined, create defaults
            {
                Plane p;
                if (curve.IsLinear(Tolerance))
                {
                    curve.PerpendicularFrameAt(curve.Domain.Min, out p);
                    glulam = new StraightGlulam(curve, new Plane[] { p });
                }
                else if (curve.IsPlanar(Tolerance))
                {
                    curve.TryGetPlane(out p, Tolerance);
                    glulam = new SingleCurvedGlulam(curve, new Plane[]
                    {
                        new Plane(
                            curve.PointAtStart,
                            p.ZAxis,
                            Vector3d.CrossProduct(
                                curve.TangentAtStart, p.ZAxis
                                )
                            ),
                        new Plane(
                            curve.PointAtEnd,
                            p.ZAxis,
                            Vector3d.CrossProduct(
                                curve.TangentAtEnd, p.ZAxis
                                )
                            )
                    });
                }
                else
                {
                    Plane start, end;
                    curve.PerpendicularFrameAt(curve.Domain.Min, out start);
                    curve.PerpendicularFrameAt(curve.Domain.Max, out end);
                    glulam = new DoubleCurvedGlulam(curve, new Plane[] { start, end });
                }
            }
            else // if there are planes defined
            {
                if (curve.IsLinear(Tolerance))
                {
                    if (planes.Length == 1)
                    {
                        glulam = new StraightGlulam(curve, planes);
                    }
                    else
                    {
                        glulam = new StraightGlulam(curve, planes, true);
                        // glulam = new StraightGlulamWithTwist(curve, planes);
                        Console.WriteLine("Not implemented...");
                    }
                }
                else if (curve.IsPlanar(Tolerance))
                {
                    Plane crv_plane;
                    curve.TryGetPlane(out crv_plane);

                    /*
                     * Are all the planes perpendicular to the curve normal?
                     *    Yes: basic SC Glulam
                     * Are all the planes consistently aligned from the curve normal?
                     *    Yes: SC Glulam with rotated cross-section
                     * SC Glulam with twisting
                     */

                    bool HasTwist = false;

                    foreach (Plane p in planes)
                    {
                        if (Math.Abs(p.XAxis * crv_plane.ZAxis) > Tolerance)
                        {
                            HasTwist = true;
                        }
                    }
                    if (HasTwist)
                    {
                        glulam = new DoubleCurvedGlulam(curve, planes);
                    }
                    else
                    {
                        Plane first = new Plane(curve.PointAtStart, crv_plane.ZAxis, Vector3d.CrossProduct(curve.TangentAtStart, crv_plane.ZAxis));
                        Plane last  = new Plane(curve.PointAtEnd, crv_plane.ZAxis, Vector3d.CrossProduct(curve.TangentAtEnd, crv_plane.ZAxis));
                        glulam = new SingleCurvedGlulam(curve, new Plane[] { first, last });
                    }
                }
                else
                {
                    Plane  temp;
                    double t;
                    bool   Twisted = false;
                    curve.PerpendicularFrameAt(curve.Domain.Min, out temp);

                    double Angle = Vector3d.VectorAngle(planes[0].YAxis, temp.YAxis);

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

                        if (Math.Abs(Vector3d.VectorAngle(planes[0].YAxis, temp.YAxis) - Angle) > AngleTolerance)
                        {
                            // Twisting Glulam
                            Twisted = true;
                            break;
                        }
                    }

                    /*
                     * Are all the planes consistently aligned from some plane?
                     *    Yes: DC Glulam with constant cross-section
                     * Are all the planes at a consistent angle from the perpendicular frame of the curve?
                     *    Yes: DC Glulam with minimal twisting
                     * DC Glulam with twisting
                     */

                    if (Twisted)
                    {
                        // TODO: differentiate between DC Glulam with minimal twist, and DC Glulam with twist
                        glulam = new DoubleCurvedGlulam(curve, planes);
                    }
                    else
                    {
                        glulam = new DoubleCurvedGlulam(curve, planes);
                    }
                }
            }

            //glulam.ValidateFrames();

            int nh = data.NumHeight;
            int nw = data.NumWidth;

            if (glulam is DoubleCurvedGlulam)
            {
                if (data.NumHeight < 2)
                {
                    nh              = 2;
                    data.LamHeight /= 2;
                }

                if (data.NumWidth < 2)
                {
                    nw             = 2;
                    data.LamWidth /= 2;
                }

                data.Lamellae.ResizeArray(nw, nh);
            }
            else if (glulam is SingleCurvedGlulam)
            {
                if (data.NumHeight < 2)
                {
                    nh              = 2;
                    data.LamHeight /= 2;
                }
                data.Lamellae.ResizeArray(nw, nh);
            }

            glulam.Data = data;

            return(glulam);
        }