Canguro.Commands.Model.AddGridCmd.beamGrid3D C# (CSharp) Method

beamGrid3D() private static method

Creates a Grid with frames given an origin, 3 vectors and number of bays in the 3 directions. Joints at the base are not connected and have restricted translation.
private static beamGrid3D ( Canguro model, float x0, float y0, float z0, float ux, float uy, float uz, float vx, float vy, float vz, float wx, float wy, float wz, int nu, int nv, int nw, bool doLines, StraightFrameProps props ) : void
model Canguro The Model object to add the Grid to.
x0 float X Component of the Origin point
y0 float Y Component of the Origin point
z0 float Z Component of the Origin point
ux float X Component of the U directional vector
uy float Y Component of the U directional vector
uz float Z Component of the U directional vector
vx float X Component of the V directional vector
vy float Y Component of the V directional vector
vz float Z Component of the V directional vector
wx float X Component of the W directional vector
wy float Y Component of the W directional vector
wz float Z Component of the W directional vector
nu int Number of bays in the U direction
nv int Number of bays in the V direction
nw int Number of bays in the W direction
doLines bool If set to false, only the Joints are created
props Canguro.Model.StraightFrameProps Frame properties to use in all the Line Elements created
return void
        private static void beamGrid3D(Canguro.Model.Model model, float x0, float y0, float z0, float ux, float uy, float uz,
            float vx, float vy, float vz, float wx, float wy, float wz, int nu, int nv, int nw, bool doLines, StraightFrameProps props)
        {
            Joint joint;
            Joint[] joints = new Joint[nu * nv * nw];
            Stack<Joint> jStack = new Stack<Joint>();
            JointDOF baseDoF = new JointDOF();
            baseDoF.T1 = baseDoF.T2 = baseDoF.T3 = JointDOF.DofType.Restrained;

            for (int i = 0; i < nw; i++)
                for (int j = 0; j < nv; j++)
                    for (int k = 0; k < nu; k++)
                    {
                        model.JointList.Add(joints[i * nu * nv + j * nu + k] =
                            joint = new Joint(x0 + k * ux + j * vx + i * wx,
                                                    y0 + j * uy + j * vy + i * wy,
                                                    z0 + i * uz + i * vz + i * wz));
                        if (i == 0)
                            joints[i * nu * nv + j * nu + k].DoF = baseDoF;
                    }

            if (doLines)
            {
                LineElement beam;
                for (int i = 0; i < nw; i++)
                    for (int j = 0; j < nv; j++)
                        for (int k = 0; k < nu; k++)
                        {
                            jStack.Push(joints[i * nu * nv + j * nu + k]);
                            if (i > 0)
                            {
                                jStack.Push(joints[(i - 1) * nu * nv + j * nu + k]);
                                model.LineList.Add(beam = new LineElement(props));
                                beam.I = jStack.Pop();
                                beam.J = jStack.Peek();
                                if (j > 0)
                                {
                                    jStack.Push(joints[i * nu * nv + (j - 1) * nu + k]);
                                    model.LineList.Add(beam = new LineElement(props));
                                    beam.I = jStack.Pop();
                                    beam.J = jStack.Peek();
                                }
                                if (k > 0)
                                {
                                    jStack.Push(joints[i * nu * nv + j * nu + k - 1]);
                                    model.LineList.Add(beam = new Canguro.Model.LineElement(props));
                                    beam.I = jStack.Pop();
                                    beam.J = jStack.Peek();
                                }
                            }
                            jStack.Pop();
                        }
            }
        }