Exemplo n.º 1
0
        private void MakeArc(Canguro.Model.Model model, Vector3 C, Vector3 N, Joint from, Joint until, Joint passing, int segments)
        {
            Vector3 p0 = from.Position;
            Vector3 p1 = until.Position;
            Vector3 p2 = passing.Position;
            Vector3 a  = Vector3.Normalize(C - p0);
            Vector3 b  = Vector3.Normalize(C - p1);
            Vector3 c  = Vector3.Normalize(C - p2);

            N.Normalize();
            float ang   = (float)Math.Acos(Vector3.Dot(a, b));
            float p2Ang = (float)Math.Acos(Vector3.Dot(a, c));

            ang   = (Vector3.Dot(Vector3.Cross(a, N), b) > 0) ? 2f * (float)Math.PI - ang : ang;
            p2Ang = (Vector3.Dot(Vector3.Cross(a, N), c) > 0) ? 2f * (float)Math.PI - p2Ang : p2Ang;


            List <Joint> joints = new List <Joint>();

            joints.Add(from);
            float angle = 0;

            ang /= segments;

            for (int i = 0; i < segments - 1; i++)
            {
                angle += ang;

                Matrix trans1 = new Matrix();
                trans1.Translate(-C);
                Matrix rot = new Matrix();
                rot.RotateAxis(N, angle);
                Matrix trans2 = new Matrix();
                trans2.Translate(C);
                rot = trans1 * rot * trans2;
                Vector3 pos = from.Position;
                pos.TransformCoordinate(rot);
                if (Math.Abs(angle) > Math.Abs(p2Ang) && Math.Abs(angle) < Math.Abs(p2Ang + ang))
                {
                    joints.Add(passing);
                }
                Joint joint = new Joint(pos.X, pos.Y, pos.Z);
                joints.Add(joint);
                model.JointList.Add(joint);
            }
            joints.Add(until);
            StraightFrameProps props = new StraightFrameProps();

            for (int i = 1; i < joints.Count; i++)
            {
                model.LineList.Add(new LineElement(props, joints[i - 1], joints[i]));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds a Line Element to the given Model
 /// </summary>
 /// <param name="model">The Model object</param>
 /// <param name="ji">The initial Joint</param>
 /// <param name="jj">The final Joint</param>
 /// <param name="props">Frame properties for the Line Element</param>
 /// <param name="newJoints">List of new Joints to use in Join</param>
 /// <param name="newLines">List of new Line Elements to use in Join</param>
 private static void AddLine(Canguro.Model.Model model, Joint ji, Joint jj, StraightFrameProps props, List <Joint> newJoints, List <LineElement> newLines)
 {
     if (ji != null && jj != null)
     {
         model.JointList.Add(ji);
         model.JointList.Add(jj);
         LineElement elem = new LineElement(props, ji, jj);
         newJoints.Add(ji);
         newJoints.Add(jj);
         newLines.Add(elem);
         model.LineList.Add(elem);
     }
 }
Exemplo n.º 3
0
        private void addLoadDeflection(AbstractCase ac, LineElement line, float lineLength, float[,] controlPoints, DeformationAxis component, float scale, float EI)
        {
            if (ac == null)
            {
                return;
            }

            if (ac is LoadCombination)
            {
                foreach (AbstractCaseFactor acf in ((LoadCombination)ac).Cases)
                {
                    addLoadDeflection(acf.Case, line, lineLength, controlPoints, component, acf.Factor, EI);
                }
            }
            else if (ac is AnalysisCase)
            {
                if (((AnalysisCase)ac).Properties is StaticCaseProps)
                {
                    foreach (StaticCaseFactor staticCase in ((StaticCaseProps)((AnalysisCase)ac).Properties).Loads)
                    {
                        if (staticCase.AppliedLoad is LoadCase)
                        {
                            LoadCase lc = staticCase.AppliedLoad as LoadCase;
                            if (line.Loads[lc] != null)
                            {
                                foreach (Load load in line.Loads[lc])
                                {
                                    //addUniformLoadDeflection(line, lineLength, load as LineLoad, controlPoints, component, scale, EI);
                                    //addTriangularLoadDeflection(line, lineLength, load as LineLoad, controlPoints, component, scale, EI);
                                    if (load is DirectionalLineLoad)
                                    {
                                        addLoadDeflection(line, lineLength, load as DirectionalLineLoad, controlPoints, component, scale, EI);
                                    }
                                }
                            }
                            if (lc.SelfWeight > 0f)
                            {
                                if (line.Properties is StraightFrameProps)
                                {
                                    StraightFrameProps frameProps = line.Properties as StraightFrameProps;
                                    selfWeight.La = selfWeight.Lb = frameProps.Section.Area * frameProps.Section.Material.UnitWeight;
                                    //addUniformLoadDeflection(line, lineLength, selfWeight, controlPoints, component, lc.SelfWeight * scale, EI);
                                    addLoadDeflection(line, lineLength, selfWeight, controlPoints, component, lc.SelfWeight * scale, EI);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void addToShearMomentDiagram(AbstractCase ac, LineElement line, float[,] controlPoints, LineForceComponent component, float scale)
        {
            if (ac == null)
            {
                return;
            }

            if (ac is LoadCombination)
            {
                foreach (AbstractCaseFactor acf in ((LoadCombination)ac).Cases)
                {
                    addToShearMomentDiagram(acf.Case, line, controlPoints, component, acf.Factor);
                }
            }
            else if (ac is AnalysisCase)
            {
                if (((AnalysisCase)ac).Properties is StaticCaseProps)
                {
                    foreach (StaticCaseFactor staticCase in ((StaticCaseProps)((AnalysisCase)ac).Properties).Loads)
                    {
                        if (staticCase.AppliedLoad is LoadCase)
                        {
                            LoadCase lc = staticCase.AppliedLoad as LoadCase;
                            if (line.Loads[lc] != null)
                            {
                                foreach (Load load in line.Loads[lc])
                                {
                                    if (load is DirectionalLineLoad)
                                    {
                                        addToShearMomentDiagram(line, load as DirectionalLineLoad, controlPoints, component, scale);
                                    }
                                }
                            }

                            if (lc.SelfWeight > 0f)
                            {
                                if (line.Properties is StraightFrameProps)
                                {
                                    StraightFrameProps frameProps = line.Properties as StraightFrameProps;
                                    selfWeight.La = selfWeight.Lb = frameProps.Section.Area * frameProps.Section.Material.UnitWeight;
                                    addToShearMomentDiagram(line, selfWeight, controlPoints, component, lc.SelfWeight * scale);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Executes the command.
        /// Gets the parameters and calls beamGrid3D() to make the grid.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            if (section == null)
            {
                section = Canguro.Model.Section.SectionManager.Instance.DefaultFrameSection as Canguro.Model.Section.FrameSection;
            }
            services.GetProperties(Culture.Get("gridCmdTitle"), this);

            Controller.Snap.Magnet m = services.GetPoint(Culture.Get("selectGridOrigin"));
            if (m == null)
            {
                return;
            }
            Microsoft.DirectX.Vector3 o = m.SnapPosition;

            StraightFrameProps props = new StraightFrameProps();

            props.Section = section;
            beamGrid3D(services.Model, o.X, o.Y, o.Z, dx, 0, 0, 0, dy, 0, 0, 0, dz, nx + 1, ny + 1, nz + 1, true, props);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Executes the command.
        /// Gets the parameters and calls createCylinder to add a Cylinder to the model
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            if (section == null)
            {
                section = Canguro.Model.Section.SectionManager.Instance.DefaultFrameSection as Canguro.Model.Section.FrameSection;
            }
            services.GetProperties(Culture.Get("cylinderCmdTitle"), this);

            Controller.Snap.Magnet m = services.GetPoint(Culture.Get("selectCylinderCenter"));
            if (m == null)
            {
                return;
            }
            Microsoft.DirectX.Vector3 o = m.SnapPosition;

            StraightFrameProps props = new StraightFrameProps();

            props.Section = section;
            createCylinder(services.Model, o, r, c, h, s + 1, props);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Executes the command.
        /// Adds a set of Line Elements. Opens a properties window and asks the user for two points or Joints for each one.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            LineElement        line;
            Joint              joint1, joint2;
            LineProps          props    = new StraightFrameProps();
            List <LineElement> newLines = new List <LineElement>();
            List <AreaElement> newAreas = new List <AreaElement>();

            services.GetProperties(Culture.Get("addLineProps"), props);


            try
            {
                while ((joint1 = services.GetJoint(newLines)) != null)
                {
                    services.TrackingService = LineTrackingService.Instance;
                    services.TrackingService.SetPoint(joint1.Position);

                    while ((joint2 = services.GetJoint(newLines)) == joint1)
                    {
                        ;
                    }

                    if (joint2 == null)
                    {
                        services.Model.JointList.Remove(joint1);
                        break;
                    }
                    services.TrackingService = null;

                    services.Model.LineList.Add(line = new LineElement(props, joint1, joint2));
                    newLines.Add(line);

                    // Para que se refleje el cambio inmediatamente
                    services.Model.ChangeModel();
                }
            }
            catch (Canguro.Controller.CancelCommandException) { }
            JoinCmd.Join(services.Model, new List <Joint>(), newLines, newAreas);
        }
Exemplo n.º 8
0
        public void Repair(Model model)
        {
            ItemList <Joint>                   jList  = model.JointList;
            ItemList <LineElement>             lList  = model.LineList;
            ItemList <AreaElement>             aList  = model.AreaList;
            Dictionary <string, Load.LoadCase> lCases = model.LoadCases;

            // Repair Joints
            foreach (Joint val in jList)
            {
                if (val != null)
                {
                    val.Loads.Repair();
                    if (val.Layer != model.Layers[val.Layer.Id])
                    {
                        val.Layer = model.Layers[val.Layer.Id];
                    }
                }
            }

            // Repair Lines
            foreach (LineElement val in lList)
            {
                if (val != null && val.Id > 0)
                {
                    if (val.I != jList[val.I.Id])
                    {
                        if (jList[val.I.Id] != null)
                        {
                            val.I = jList[val.I.Id];
                        }
                        else
                        {
                            ((IList <Joint>)jList)[(int)val.I.Id] = val.I;
                        }
                    }
                    if (val.J != jList[val.J.Id] && jList[val.J.Id] != null)
                    {
                        if (jList[val.I.Id] != null)
                        {
                            val.J = jList[val.J.Id];
                        }
                        else
                        {
                            ((IList <Joint>)jList)[(int)val.J.Id] = val.J;
                        }
                    }
                    if (val.Loads != null)
                    {
                        val.Loads.Repair();
                    }
                    if (val.Properties is StraightFrameProps)
                    {
                        StraightFrameProps prop = (StraightFrameProps)val.Properties;
                        if (model.Sections[prop.Section.Name] == null)
                        {
                            model.Sections[prop.Section.Name] = prop.Section;
                        }
                        else if (prop.Section != model.Sections[prop.Section.Name])
                        {
                            prop.Section = (Section.FrameSection)model.Sections[prop.Section.Name];
                        }
                    }

                    //// Fix Releases
                    //JointDOF dofI = val.DoFI;
                    //JointDOF dofJ = val.DoFJ;
                    //dofJ.T1 = (dofI.T1 == JointDOF.DofType.Free) ? JointDOF.DofType.Restrained : dofJ.T1;
                    //dofJ.T2 = (dofI.T2 == JointDOF.DofType.Free) ? JointDOF.DofType.Restrained : dofJ.T2;
                    //dofJ.T3 = (dofI.T3 == JointDOF.DofType.Free) ? JointDOF.DofType.Restrained : dofJ.T3;
                    //dofJ.R1 = (dofI.R1 == JointDOF.DofType.Free) ? JointDOF.DofType.Restrained : dofJ.R1;
                    //dofJ.T2 = (dofI.R3 == JointDOF.DofType.Free && dofJ.R3 == JointDOF.DofType.Free) ? JointDOF.DofType.Restrained : dofJ.T2;
                    //dofJ.T3 = (dofI.R2 == JointDOF.DofType.Free && dofJ.R2 == JointDOF.DofType.Free) ? JointDOF.DofType.Restrained : dofJ.T3;
                    //val.DoFJ = dofJ;
                }
            }

            Repair(Material.MaterialManager.Instance.Materials, model.Sections);

            // Repair AbstractCases
            foreach (Load.AbstractCase aCase in model.AbstractCases)
            {
                if (aCase is Load.AnalysisCase)
                {
                    Repair(model, (Load.AnalysisCase)aCase);
                }
                else if (aCase is Load.LoadCombination)
                {
                    Repair(model, (Load.LoadCombination)aCase);
                }
            }

            foreach (Design.DesignOptions opt in model.DesignOptions)
            {
                Repair(opt);
            }
        }
Exemplo 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();
                        }
                    }
                }
            }
        }
Exemplo n.º 10
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;
                    }
                }
            }
        } // End of createCylinder
Exemplo n.º 11
0
        /// <summary>
        /// Reads a DXF file and adds all the lines defined in it to the given Model
        /// </summary>
        /// <param name="path">The path to the DXF file</param>
        /// <param name="model">The current Model object</param>
        public static void Import(string path, Canguro.Model.Model model)
        {
            if (path.Length > 0)
            {
                string[]           file      = File.ReadAllLines(path);
                List <string>      search    = new List <string>(new string[] { "LINE", "10", "20", "30", "11", "21", "31", "LWPOLYLINE" });
                int                state     = 0;
                Joint              ji        = null;
                Joint              jj        = null;
                StraightFrameProps props     = new StraightFrameProps();
                List <LineElement> newLines  = new List <LineElement>();
                List <AreaElement> newAreas  = new List <AreaElement>();
                List <Joint>       newJoints = new List <Joint>();

                bool addLine  = false;
                bool polyline = false;
                for (int i = 0; i < file.Length; i++)
                {
                    string line = file[i].Trim().ToUpper();
                    while (!search.Contains(line) && i < file.Length - 1)
                    {
                        line = file[++i].Trim().ToUpper();
                    }
                    state = search.IndexOf(line);
                    if (state == 0 || state > 6)
                    {
                        addLine = true;
                        jj      = null;
                        ji      = null;
                    }
                    if (state == 7)
                    {
                        polyline = true;
                    }

                    if (!addLine)
                    {
                        continue;
                    }
                    if (i == file.Length - 1)
                    {
                        break;
                    }
                    line = file[++i].Trim();
                    switch (state)
                    {
                    case 1:
                        jj = (polyline) ? ji : jj;
                        ji = new Joint(Convert.ToSingle(line), 0, 0);
                        if (polyline && jj != null)
                        {
                            AddLine(model, ji, jj, props, newJoints, newLines);
                        }
                        break;

                    case 2:
                        if (ji != null)
                        {
                            ji.Y = Convert.ToSingle(line);
                        }
                        break;

                    case 3:
                        if (ji != null)
                        {
                            ji.Z = Convert.ToSingle(line);
                        }
                        break;

                    case 4:
                        jj = new Joint(Convert.ToSingle(line), 0, 0);
                        break;

                    case 5:
                        if (addLine && jj != null)
                        {
                            jj.Y = Convert.ToSingle(line);
                        }
                        AddLine(model, ji, jj, props, newJoints, newLines);
                        polyline = false;
                        break;

                    case 6:
                        if (jj != null)
                        {
                            jj.Z = Convert.ToSingle(line);
                        }
                        break;
                    }
                }
                JoinCmd.Join(model, newJoints, newLines, newAreas);
            }
        }