Ejemplo n.º 1
0
        /// <summary>
        /// Al construir un LineElement se necesita un prototipo de Propiedades, que define el tipo de elemento que
        /// se forma. De esta manera, después de construir el elemento no se le puede cambiar el tipo, además de que
        /// se pueden crear varios elementos con las mismas propiedades. La constructora clona al prototipo, de manera
        /// que un objeto externo puede crear varios elementos con el mismo objeto de propiedades.
        /// </summary>
        /// <param name="prototype">El prototipo de propiedades.</param>
        public LineElement(LineProps prototype)
        {
            props  = (LineProps)prototype.Clone();
            joints = new Joint[2];
            angle  = 0;
            dofI   = new JointDOF(true);
            dofJ   = new JointDOF(true);

            Joint j = Model.Instance.JointList[1];
            int   i = 1;

            while (j == null && i < Model.Instance.JointList.Count)
            {
                j = Model.Instance.JointList[i++];
            }
            if (j != null)
            {
                I = j;
                J = j;
            }
            else
            {
                throw new NullReferenceException(Culture.Get("EM0020"));
            }
        }
Ejemplo n.º 2
0
        public JointDOF Clone()
        {
            JointDOF ret = new JointDOF();

            ret.restraints   = restraints;
            ret.springs      = springs;
            ret.springValues = (springValues == null) ? null : (float[])springValues.Clone();
            return(ret);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructora de copia que inicializa el LineElement como un clon de otro.
 /// </summary>
 /// <param name="src">El LineElement a copiar</param>
 internal LineElement(LineElement src, Joint i, Joint j) : base(src)
 {
     props         = (LineProps)src.Properties.Clone();
     joints        = new Joint[2];
     angle         = src.Angle;
     cardinalPoint = src.CardinalPoint;
     offsets       = src.EndOffsets;
     dofI          = src.DoFI;
     dofJ          = src.DoFJ;
     joints[0]     = i;
     joints[1]     = j;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructora que inicializa el LineElement con un clon de las propiedades indicadas y los nodos indicados.
        /// Si los nodos no están en la lista correspondiente, en la posición adecuada, se lanza una NullReferenceException
        /// Se recomienda usar esta constructora para minimizar el consumo de memoria en Model.Undo
        /// </summary>
        /// <param name="prototype"></param>
        /// <param name="i"></param>
        /// <param name="j"></param>
        public LineElement(LineProps prototype, Joint i, Joint j)
        {
            props = (LineProps)prototype.Clone();
            joints = new Joint[2];
            angle = 0;
            dofI = new JointDOF(true);
            dofJ = new JointDOF(true);

            if (i == null || j == null || 
                Model.Instance.JointList[i.Id] != i || Model.Instance.JointList[j.Id] != j)
                throw new NullReferenceException(Culture.Get("EM0021"));
            I = i;
            J = j;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructora que inicializa el LineElement con un clon de las propiedades indicadas y los nodos indicados.
        /// Si los nodos no están en la lista correspondiente, en la posición adecuada, se lanza una NullReferenceException
        /// Se recomienda usar esta constructora para minimizar el consumo de memoria en Model.Undo
        /// </summary>
        /// <param name="prototype"></param>
        /// <param name="i"></param>
        /// <param name="j"></param>
        public LineElement(LineProps prototype, Joint i, Joint j)
        {
            props  = (LineProps)prototype.Clone();
            joints = new Joint[2];
            angle  = 0;
            dofI   = new JointDOF(true);
            dofJ   = new JointDOF(true);

            if (i == null || j == null ||
                Model.Instance.JointList[i.Id] != i || Model.Instance.JointList[j.Id] != j)
            {
                throw new NullReferenceException(Culture.Get("EM0021"));
            }
            I = i;
            J = j;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Al construir un LineElement se necesita un prototipo de Propiedades, que define el tipo de elemento que
        /// se forma. De esta manera, después de construir el elemento no se le puede cambiar el tipo, además de que
        /// se pueden crear varios elementos con las mismas propiedades. La constructora clona al prototipo, de manera
        /// que un objeto externo puede crear varios elementos con el mismo objeto de propiedades.
        /// </summary>
        /// <param name="prototype">El prototipo de propiedades.</param>
        public LineElement(LineProps prototype)
        {
            props = (LineProps)prototype.Clone();
            joints = new Joint[2];
            angle = 0;
            dofI = new JointDOF(true);
            dofJ = new JointDOF(true);

            Joint j = Model.Instance.JointList[1];
            int i = 1;
            while (j == null && i < Model.Instance.JointList.Count)
                j = Model.Instance.JointList[i++];
            if (j != null)
            {
                I = j;
                J = j;
            }
            else
                throw new NullReferenceException(Culture.Get("EM0020"));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a cylinder and adds it to the model.
        /// </summary>
        /// <param name="model">The Model object</param>
        /// <param name="C">The Center of the base</param>
        /// <param name="radius">The radius</param>
        /// <param name="cols">Number of columns</param>
        /// <param name="height">Height of each story</param>
        /// <param name="stories">Number of stories</param>
        /// <param name="props">Frame properties to use in all elements</param>
        protected void createCylinder(Canguro.Model.Model model, Vector3 C, float radius, int cols, float height, int stories, StraightFrameProps props)
        {
            float[,] columns = new float[cols, 3];
            int i, f, c;
            Queue<Joint> jQueue = new Queue<Joint>();
            Joint joint, first, prev;
            joint = prev = first = null;
            LineElement line;

            double angle, delta = 2 * Math.PI / (double)cols;
            float[] angles = new float[cols];

            for (i = 0, angle = 0; i < cols; angle += delta, i++)
            {
                columns[i, 0] = (float)(C.X + Math.Cos(angle) * radius);
                columns[i, 1] = (float)(C.Y + Math.Sin(angle) * radius);
                columns[i, 2] = (float)C.Z;
                angles[i] = (float)(angle * 180.0 / Math.PI);
            }

            JointDOF baseDoF = new JointDOF();
            baseDoF.T1 = baseDoF.T2 = baseDoF.T3 = JointDOF.DofType.Restrained;
            for (f = 0; f < stories; f++)
            {
                for (c = 0; c < cols; c++)
                {
                    joint = new Joint(columns[c, 0], columns[c, 1], columns[c, 2] + height * f);
                    if (c == 0) first = joint;
                    if (f == 0) joint.DoF = baseDoF;
                    model.JointList.Add(joint);
                    jQueue.Enqueue(joint);
                    if (f > 0)
                    {
                        model.LineList.Add(line = new LineElement(props));
                        line.I = jQueue.Dequeue();
                        line.J = joint;
                        line.Angle = angles[c];
                        if (c > 0)
                        {
                            model.LineList.Add(line = new LineElement(props));
                            line.I = prev;
                            line.J = joint;
                            if (c == cols - 1)
                            {
                                model.LineList.Add(line = new LineElement(props));
                                line.I = joint;
                                line.J = first;
                            }
                        }
                        prev = joint;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private void store(OleDbConnection cn, uint joint, JointDOF obj)
        {
            if (obj.IsRestrained)
            {
                string u1 = (obj.T1 == JointDOF.DofType.Restrained) ? "Yes" : "No";
                string u2 = (obj.T2 == JointDOF.DofType.Restrained) ? "Yes" : "No";
                string u3 = (obj.T3 == JointDOF.DofType.Restrained) ? "Yes" : "No";
                string r1 = (obj.R1 == JointDOF.DofType.Restrained) ? "Yes" : "No";
                string r2 = (obj.R2 == JointDOF.DofType.Restrained) ? "Yes" : "No";
                string r3 = (obj.R3 == JointDOF.DofType.Restrained) ? "Yes" : "No";
                string sql = "INSERT INTO [Joint Restraint Assignments](Joint, U1, U2, U3, R1, R2, R3) " +
                    "VALUES (" + joint + ", \"" + u1 + "\", \"" + u2 + "\", \"" + u3 + "\", \"" + r1 + "\", \"" + r2 + "\", \"" + r3 + "\");";
                new OleDbCommand(sql, cn).ExecuteNonQuery();
            }

            if (obj.IsSpring)
            {
                float[] sp = obj.SpringValues;
                string sql = "INSERT INTO [Joint Spring Assignments 1 - Uncoupled](Joint, CoordSys, U1, U2, U3, R1, R2, R3) " +
                    "VALUES (" + joint + ", \"GLOBAL\", " + sp[0] + ", " + sp[1] + ", " + sp[2] + ", " + sp[3] + ", " + sp[4] + ", " + sp[5] + ");";
                new OleDbCommand(sql, cn).ExecuteNonQuery();
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 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.
        /// </summary>
        /// <param name="model">The Model object to add the Grid to.</param>
        /// <param name="x0">X Component of the Origin point</param>
        /// <param name="y0">Y Component of the Origin point</param>
        /// <param name="z0">Z Component of the Origin point</param>
        /// <param name="ux">X Component of the U directional vector</param>
        /// <param name="uy">Y Component of the U directional vector</param>
        /// <param name="uz">Z Component of the U directional vector</param>
        /// <param name="vx">X Component of the V directional vector</param>
        /// <param name="vy">Y Component of the V directional vector</param>
        /// <param name="vz">Z Component of the V directional vector</param>
        /// <param name="wx">X Component of the W directional vector</param>
        /// <param name="wy">Y Component of the W directional vector</param>
        /// <param name="wz">Z Component of the W directional vector</param>
        /// <param name="nu">Number of bays in the U direction</param>
        /// <param name="nv">Number of bays in the V direction</param>
        /// <param name="nw">Number of bays in the W direction</param>
        /// <param name="doLines">If set to false, only the Joints are created</param>
        /// <param name="props">Frame properties to use in all the Line Elements created</param>
        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();
                        }
            }
        }
Ejemplo n.º 10
0
 public JointDOF Clone()
 {
     JointDOF ret = new JointDOF();
     ret.restraints = restraints;
     ret.springs = springs;
     ret.springValues = (springValues == null) ? null : (float[])springValues.Clone();
     return ret;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Constructora de copia que inicializa el LineElement como un clon de otro.
 /// </summary>
 /// <param name="src">El LineElement a copiar</param>
 internal LineElement(LineElement src, Joint i, Joint j) : base(src)
 {
     props = (LineProps)src.Properties.Clone();
     joints = new Joint[2];
     angle = src.Angle;
     cardinalPoint = src.CardinalPoint;
     offsets = src.EndOffsets;
     dofI = src.DoFI;
     dofJ = src.DoFJ;
     joints[0] = i;
     joints[1] = j;
 }