Beispiel #1
0
        public static void CreateGlulamNodesAndElements(this Glulam g, out List <Node> nodes, out List <Element> elements, int Nx = 4, int Ny = 4, int Nz = 50)
        {
            double hWidth  = g.Width / 2;
            double hHeight = g.Height / 2;

            double stepX = g.Width / Nx;
            double stepY = g.Height / Ny;

            List <Point3d> xPts = new List <Point3d>();

            for (int y = 0; y <= Ny; ++y)
            {
                for (int x = 0; x <= Nx; ++x)
                {
                    Point3d pt = new Point3d(
                        -hWidth + x * stepX,
                        -hHeight + y * stepY,
                        0);
                    xPts.Add(pt);
                }
            }

            Plane[]  xplanes;
            double[] xt;

            int N = Nz + 1;

            g.GenerateCrossSectionPlanes(N, out xplanes, out xt, GlulamData.Interpolation.LINEAR);

            nodes = new List <Node>();

            int i = 0;

            for (int z = 0; z < N; ++z)
            {
                Transform xform = Transform.PlaneToPlane(Plane.WorldXY, xplanes[z]);
                for (int j = 0; j < xPts.Count; ++j)
                {
                    Point3d pt = new Point3d(xPts[j]);
                    pt.Transform(xform);
                    nodes.Add(new Node(pt.X, pt.Y, pt.Z, i + 1));
                    i++;
                }
            }

            elements = new List <Element>();

            int sz = (Nx + 1) * (Ny + 1);
            int sy = (Nx + 1);

            i = 0;
            for (int z = 0; z < Nz; ++z)
            {
                int cz = z * sz;
                for (int y = 0; y < Ny; ++y)
                {
                    int cy = y * sy;
                    for (int x = 0; x < Nx; ++x)
                    {
                        int[] indices = new int[] {
                            cz + cy + x,
                            cz + cy + x + 1,
                            cz + cy + x + sy + 1,
                            cz + cy + x + sy,
                            cz + sz + cy + x,
                            cz + sz + cy + x + 1,
                            cz + sz + cy + x + sy + 1,
                            cz + sz + cy + x + sy
                        };

                        for (int ii = 0; ii < 8; ++ii)
                        {
                            indices[ii] = nodes[indices[ii]].Id;
                        }

                        Element ele = new C3D8 {
                            Data = indices, Id = i + 1
                        };

                        elements.Add(ele);
                        ++i;
                    }
                }
            }
        }
Beispiel #2
0
        void GetRibbonEdges(Glulam g, double Offset, List <Line> lines, List <double> lengths, bool FlipXY = false)
        {
            double[] DivParams;
            Plane[]  xPlanes;

            g.GenerateCrossSectionPlanes(g.Data.Samples, 0, out xPlanes, out DivParams, g.Data.InterpolationType);
            Plane pplane, prevplane;

            double w;

            if (FlipXY)
            {
                w = g.Data.LamHeight * g.Data.NumHeight;
            }
            else
            {
                w = g.Data.LamWidth * g.Data.NumWidth;
            }

            double hw = w / 2;
            double l;

            Point3d p0, p1;
            Point3d p2, p3;

            // First section
            pplane = xPlanes.First();

            if (FlipXY)
            {
                p0 = pplane.Origin + pplane.YAxis * hw + pplane.XAxis * Offset;
                p1 = pplane.Origin + pplane.YAxis * -hw + pplane.XAxis * Offset;
            }
            else
            {
                p0 = pplane.Origin + pplane.XAxis * hw + pplane.YAxis * Offset;
                p1 = pplane.Origin + pplane.XAxis * -hw + pplane.YAxis * Offset;
            }

            p2        = p0;
            p3        = p1;
            prevplane = pplane;

            for (int i = 1; i < g.Data.Samples; ++i)
            {
                pplane = xPlanes[i];

                if (FlipXY)
                {
                    p0 = pplane.Origin + pplane.YAxis * hw + pplane.XAxis * Offset;
                    p1 = pplane.Origin + pplane.YAxis * -hw + pplane.XAxis * Offset;
                }
                else
                {
                    p0 = pplane.Origin + pplane.XAxis * hw + pplane.YAxis * Offset;
                    p1 = pplane.Origin + pplane.XAxis * -hw + pplane.YAxis * Offset;
                }

                if (FlipXY)
                {
                    l = (pplane.Origin + pplane.XAxis * Offset).DistanceTo(prevplane.Origin + prevplane.XAxis * Offset);
                }
                else
                {
                    l = (pplane.Origin + pplane.YAxis * Offset).DistanceTo(prevplane.Origin + prevplane.YAxis * Offset);
                }

                lines.Add(new Line(p0, p2));
                lines.Add(new Line(p1, p3));

                lengths.Add((p0.DistanceTo(p2) / l - 1.0) / m_radius_factor);
                lengths.Add((p1.DistanceTo(p3) / l - 1.0) / m_radius_factor);

                p2        = p0;
                p3        = p1;
                prevplane = pplane;
            }
        }