Inheritance: IModel
Exemplo n.º 1
0
        public static List <LinkedList <LineElement> > GetLineGraph(Canguro.Model.Model model)
        {
            List <LinkedList <LineElement> > list = new List <LinkedList <LineElement> >(model.JointList.Count);

            for (int i = 0; i < model.JointList.Count; i++)
            {
                list.Add(null);
            }

            foreach (LineElement element in model.LineList)
            {
                if (element != null && element.I != null && element.J != null)
                {
                    int i = (int)element.I.Id;
                    int j = (int)element.J.Id;
                    if (list[i] == null)
                    {
                        list[i] = new LinkedList <LineElement>();
                    }
                    if (list[j] == null)
                    {
                        list[j] = new LinkedList <LineElement>();
                    }
                    list[i].AddLast(element);
                    list[j].AddLast(element);
                }
            }

            return(list);
        }
Exemplo n.º 2
0
 private void CopyLoads(Canguro.Model.Model model, Element from, Element to)
 {
     from.Loads.Repair();
     Canguro.Model.Load.LoadCase active = model.ActiveLoadCase;
     foreach (Canguro.Model.Load.LoadCase lCase in model.LoadCases.Values)
     {
         ItemList <Canguro.Model.Load.Load> copy = from.Loads[lCase];
         ItemList <Canguro.Model.Load.Load> list = to.Loads[lCase];
         if (list != null && list.Count > 0)
         {
             for (int i = list.Count; i > 0; i--)
             {
                 list.RemoveAt(i - 1);
             }
         }
         if (copy != null)
         {
             foreach (Canguro.Model.Load.Load l in copy)
             {
                 if (l != null)
                 {
                     Canguro.Model.Load.Load nl = (Canguro.Model.Load.Load)l.Clone();
                     nl.Id = 0;
                     to.Loads.Add(nl, lCase);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        public void Reset(Canguro.Model.Model model)
        {
            maxStress = 0f;
            minStress = 0f;
            largest   = 0f;

            if (recalculateMinMaxStressesOfSelection(model))
            {
                largest = Math.Max(Math.Abs(maxStress), Math.Abs(minStress));
            }
        }
Exemplo n.º 4
0
 private void store(OleDbConnection cn, AbstractCase obj, Canguro.Model.Model model)
 {
     if (obj is AnalysisCase && obj.IsActive)
     {
         store(cn, (AnalysisCase)obj);
     }
     else if (obj is LoadCombination && obj.IsActive)
     {
         store(cn, (LoadCombination)obj, model);
     }
 }
Exemplo n.º 5
0
        public static Joint Intersect(Canguro.Model.Model model, LineElement l1, LineElement l2)
        {
            if (l1 != null && l2 != null && l1 != l2 && l1.I != l2.I && l1.J != l2.J && l1.I != l2.J && l1.J != l2.I)
            {
                float   numer, denom;
                float   d1, d2, d3, d4, d5;
                Vector3 p13 = l1.I.Position - l2.I.Position;
                Vector3 p21 = l1.J.Position - l1.I.Position;
                Vector3 p43 = l2.J.Position - l2.I.Position;

                d1 = p13.X * p43.X + p13.Y * p43.Y + p13.Z * p43.Z;
                d2 = p43.X * p21.X + p43.Y * p21.Y + p43.Z * p21.Z;
                d3 = p13.X * p21.X + p13.Y * p21.Y + p13.Z * p21.Z;
                d4 = p43.X * p43.X + p43.Y * p43.Y + p43.Z * p43.Z;
                d5 = p21.X * p21.X + p21.Y * p21.Y + p21.Z * p21.Z;

                denom = d5 * d4 - d2 * d2;
                if (Math.Abs(denom) < 0.0001)
                {
                    return(null);
                }
                numer = d1 * d2 - d3 * d4;

                float r = numer / denom;
                float s = (d1 + d2 * r) / d4;

                float   scale = model.UnitSystem.FromInternational(1, Canguro.Model.UnitSystem.Units.Distance);
                Vector3 pa    = Vector3.Scale(l1.I.Position, scale) + Vector3.Scale(p21, r * scale);
                Vector3 pb    = Vector3.Scale(l2.I.Position, scale) + Vector3.Scale(p43, s * scale);

                if (r > (-0.001) && r < 1.001 && s > (-0.001) && s < 1.001 && (pa - pb).Length() < 0.001 &&
                    ((pa - l1.I.Position).LengthSq() > 0.000001f) && ((pa - l1.J.Position).LengthSq() > 0.000001f) &&
                    ((pa - l2.I.Position).LengthSq() > 0.000001f) && ((pa - l2.J.Position).LengthSq() > 0.000001f))
                {
                    Joint joint = new Joint(pa.X, pa.Y, pa.Z);
                    model.JointList.Add(joint);
                    return(joint);
                    //SplitCmd.Split(l1, joint, model);
                    //SplitCmd.Split(l2, joint, model);
                }
                //// Create magnet
                //PointMagnet intPtMagnet = new PointMagnet(l1.Position + Vector3.Scale(l1.Direction, r),
                //    PointMagnetType.Intersection);
                //if (intPtMagnet.Snap(activeView, e.Location) < SnapViewDistance)
                //{
                //    intPtMagnet.RelatedMagnets.Add(l1);
                //    intPtMagnet.RelatedMagnets.Add(l2);
                //    return intPtMagnet;
                //}
            }

            return(null);
        }
Exemplo n.º 6
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.º 7
0
        private void store(OleDbConnection cn, LoadCombination obj, Canguro.Model.Model model)
        {
            List <AbstractCaseFactor> list = obj.Cases;

            string sql       = "";
            string steel     = CodeYN(model.SteelDesignOptions.DesignCombinations.Contains(obj));
            string concrete  = CodeYN(model.ConcreteDesignOptions.DesignCombinations.Contains(obj));
            string alum      = CodeYN(model.AluminumDesignOptions.DesignCombinations.Contains(obj));
            string cold      = CodeYN(model.ColdFormedDesignOptions.DesignCombinations.Contains(obj));
            string comboType = GetComboType(obj.Type);

            foreach (AbstractCaseFactor f in list)
            {
                AbstractCase aCase = f.Case as AbstractCase;
                sql = "";
                if (aCase != null) // && aCase.IsActive)
                {
                    if (aCase is LoadCombination)
                    {
                        sql = "INSERT INTO [Combination Definitions] " +
                              "(ComboName,ComboType,CaseType,CaseName,ScaleFactor,SteelDesign,ConcDesign,AlumDesign,ColdDesign) VALUES " +
                              "(\"" + obj.Name + "\",\"\",\"Combo\",\"" + aCase.Name + "\"," + f.Factor + "," + steel + "," + concrete + "," + alum + "," + cold + ");";
                    }
                    else if (aCase is AnalysisCase)
                    {
                        AnalysisCaseProps props = ((AnalysisCase)aCase).Properties;
                        if (props is StaticCaseProps)
                        {
                            // StaticCaseProps sprops = (StaticCaseProps)props;
                            sql = "INSERT INTO [Combination Definitions] " +
                                  "(ComboName,ComboType,CaseType,CaseName,ScaleFactor,SteelDesign,ConcDesign,AlumDesign,ColdDesign) VALUES " +
                                  "(\"" + obj.Name + "\",\"" + comboType + "\",\"Linear Static\",\"" + aCase.Name + "\"," + f.Factor + "," + steel + "," + concrete + "," + alum + "," + cold + ");";
                        }
                        else if (props is ResponseSpectrumCaseProps)
                        {
                            sql = "INSERT INTO [Combination Definitions] " +
                                  "(ComboName,ComboType,CaseType,CaseName,ScaleFactor,SteelDesign,ConcDesign,AlumDesign,ColdDesign) VALUES " +
                                  "(\"" + obj.Name + "\",\"" + comboType + "\",\"Response Spectrum\",\"" + aCase.Name + "\"," + f.Factor + "," + steel + "," + concrete + "," + alum + "," + cold + ");";
                        }
                        //steel = concrete = alum = cold = "\"\"";
                    }
                    if (sql.Length > 0)
                    {
                        new OleDbCommand(sql, cn).ExecuteNonQuery();
                    }
                }
            }

            // Insert record in RESULTS Named Set
            sql = " INSERT INTO [Named Sets - Database Tables 2 - Selections] " +
                  "(DBNamedSet, SelectType, [Selection]) VALUES (\"RESULTS\", \"Combo\", \"" + obj.Name + "\");";
            new OleDbCommand(sql, cn).ExecuteNonQuery();
        }
Exemplo n.º 8
0
        private bool recalculateMinMaxStressesOfSelection(Canguro.Model.Model model)
        {
            if (!model.HasResults || model.Results.ActiveCase == null)
            {
                return(false);
            }

            Model.Load.AbstractCase ac = model.Results.ActiveCase.AbstractCase;
            int numPoints = Properties.Settings.Default.ElementForcesSegments;

            LineStressCalculator lsc = new LineStressCalculator();

            Model.Section.FrameSection section;
            StraightFrameProps         sfProps;

            Vector2[][] contour;
            float       stress;

            float[,] s1, m22, m33;

            foreach (LineElement line in model.LineList)
            {
                if (line != null && line.IsVisible)
                {
                    sfProps = line.Properties as StraightFrameProps;
                    if (sfProps != null)
                    {
                        s1  = lsc.GetForcesDiagram(ac, line, Canguro.Model.Load.LineForceComponent.Axial, numPoints);
                        m22 = lsc.GetForcesDiagram(ac, line, Canguro.Model.Load.LineForceComponent.Moment22, numPoints);
                        m33 = lsc.GetForcesDiagram(ac, line, Canguro.Model.Load.LineForceComponent.Moment33, numPoints);

                        section = sfProps.Section;
                        contour = section.Contour;
                        for (int j = 0; j < numPoints; j++)
                        {
                            for (int i = 0; i < contour[0].Length; i++)
                            {
                                stress = lsc.GetStressAtPoint(section, s1, m22, m33, j, contour[0][i].X, contour[0][i].Y);
                                if (stress > maxStress)
                                {
                                    maxStress = stress;
                                }
                                if (stress < minStress)
                                {
                                    minStress = stress;
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Executes the command.
        /// Gets the parameters and creates the analysis case.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            string name = Culture.Get("defaultAnalysisCaseName");

            Canguro.Model.Model model = services.Model;
            StaticCaseProps     props = new StaticCaseProps();
            AnalysisCase        aCase = new AnalysisCase(name, props);

            services.GetProperties(aCase.Name, aCase, false);

            model.AbstractCases.Add(aCase);
        }
Exemplo n.º 10
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.º 11
0
        /// <summary>
        /// Detects inconsistencies in the model and repairs them.
        /// If a line is connected to a joint outside the model,
        /// it's added (if ID is free) or changed (if a joint with same ID exists).
        /// </summary>
        /// <param name="model"></param>
        public static void RepairJoints(Canguro.Model.Model model)
        {
            foreach (LineElement line in model.LineList)
            {
                if (line != null && line.I != null && line.J != null)
                {
                    Joint j = line.I;
                    if (model.JointList[j.Id] == null)
                    {
                        model.JointList.Add(j);
                    }
                    else if (model.JointList[j.Id] != j)
                    {
                        line.I = model.JointList[j.Id];
                    }

                    j = line.J;
                    if (model.JointList[j.Id] == null)
                    {
                        model.JointList.Add(j);
                    }
                    else if (model.JointList[j.Id] != j)
                    {
                        line.J = model.JointList[j.Id];
                    }
                }
            }

            foreach (AreaElement area in model.AreaList)
            {
                if (area != null && area.J1 != null && area.J2 != null && area.J3 != null)
                {
                    for (int i = 0; i < ((area.J4 != null) ? 4 : 3); i++)
                    {
                        Joint j = area[i];
                        if (model.JointList[j.Id] == null)
                        {
                            model.JointList.Add(j);
                        }
                        else if (model.JointList[j.Id] != j)
                        {
                            area[i] = model.JointList[j.Id];
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        public static void Intersect(Canguro.Model.Model model, IList <Joint> joints, IList <LineElement> lines)
        {
            System.Windows.Forms.Cursor cursor = System.Windows.Forms.Cursor.Current;
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

            try
            {
                int nJoints = (joints == null) ? 0 : joints.Count;
                int nLines  = (lines == null) ? 0 : lines.Count;

                Joint joint;
                for (int i = 0; i < nLines; i++)
                {
                    System.Windows.Forms.Application.DoEvents();
                    for (int j = i + 1; j < nLines; j++)
                    {
                        if (lines[i] != null && lines[j] != null)
                        {
                            joint = Intersect(model, lines[i], lines[j]);
                            if (joint != null)
                            {
                                joints.Add(joint);
                            }
                        }
                    }
                }

                //for (int i = 0; i < nJoints; i++)
                //{
                //    Joint joint = joints[i];
                //    if (joint != null)
                foreach (LineElement line in lines)
                {
                    if (line != null)
                    {
                        SplitCmd.Split(line, joints, model);
                        System.Windows.Forms.Application.DoEvents();
                    }
                }
                //}
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = cursor;
            }
        }
Exemplo n.º 13
0
        public SectionsGUI(FrameSection section)
        {
            oneSection = (section != null);
            InitializeComponent();

            steelSections = new Dictionary<string, FrameSection>();
            concreteSections = new Dictionary<string, FrameSection>();
            allSections = new Dictionary<string, FrameSection>();
            concreteSectionProps = new List<ConcreteSectionProps>();
            shapeNames = new Dictionary<string, string>();

            shapeNames.Add("R", Culture.Get("RectangularSection"));
            shapeNames.Add("RN", Culture.Get("CircleSection"));
            //            shapeNames.Add("2L", Culture.Get("DoubleAngle"));
            shapeNames.Add("C", Culture.Get("Channel"));
            shapeNames.Add("I", Culture.Get("I_WideFlange"));
            shapeNames.Add("B", Culture.Get("Box_Tube"));
            shapeNames.Add("P", Culture.Get("Pipe"));
            shapeNames.Add("L", Culture.Get("Angle"));
            shapeNames.Add("T", Culture.Get("Tee"));
            shapeNames.Add("G", Culture.Get("General"));
            model = Canguro.Model.Model.Instance;

            coverTopLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            coverBottomLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            roTopLeftLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            roTopRightLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            roBottomLeftLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            roBottomRightLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            sqCoverLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            sqReinforcementsLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            areaLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.Area) + ")";
            JLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.AreaInertia) + ")";
            sa33Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.Area) + ")";
            sa22Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.Area) + ")";
            i33Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.AreaInertia) + ")";
            i22Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.AreaInertia) + ")";
            s33Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.ShearModulus) + ")";
            s22Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.ShearModulus) + ")";
            z33Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.ShearModulus) + ")";
            z22Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.ShearModulus) + ")";
            r33Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            r22Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
        }
Exemplo n.º 14
0
        public SectionsGUI(FrameSection section)
        {
            oneSection = (section != null);
            InitializeComponent();

            steelSections        = new Dictionary <string, FrameSection>();
            concreteSections     = new Dictionary <string, FrameSection>();
            allSections          = new Dictionary <string, FrameSection>();
            concreteSectionProps = new List <ConcreteSectionProps>();
            shapeNames           = new Dictionary <string, string>();

            shapeNames.Add("R", Culture.Get("RectangularSection"));
            shapeNames.Add("RN", Culture.Get("CircleSection"));
//            shapeNames.Add("2L", Culture.Get("DoubleAngle"));
            shapeNames.Add("C", Culture.Get("Channel"));
            shapeNames.Add("I", Culture.Get("I_WideFlange"));
            shapeNames.Add("B", Culture.Get("Box_Tube"));
            shapeNames.Add("P", Culture.Get("Pipe"));
            shapeNames.Add("L", Culture.Get("Angle"));
            shapeNames.Add("T", Culture.Get("Tee"));
            shapeNames.Add("G", Culture.Get("General"));
            model = Canguro.Model.Model.Instance;

            coverTopLabel.Text         += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            coverBottomLabel.Text      += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            roTopLeftLabel.Text        += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            roTopRightLabel.Text       += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            roBottomLeftLabel.Text     += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            roBottomRightLabel.Text    += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            sqCoverLabel.Text          += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            sqReinforcementsLabel.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            areaLabel.Text             += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.Area) + ")";
            JLabel.Text    += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.AreaInertia) + ")";
            sa33Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.Area) + ")";
            sa22Label.Text += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.Area) + ")";
            i33Label.Text  += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.AreaInertia) + ")";
            i22Label.Text  += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.AreaInertia) + ")";
            s33Label.Text  += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.ShearModulus) + ")";
            s22Label.Text  += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.ShearModulus) + ")";
            z33Label.Text  += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.ShearModulus) + ")";
            z22Label.Text  += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.ShearModulus) + ")";
            r33Label.Text  += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
            r22Label.Text  += " (" + model.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.SmallDistance) + ")";
        }
Exemplo n.º 15
0
        private void ConstraintFrom(Joint j, Canguro.Model.Model model, List <LinkedList <int> > graph)
        {
            ItemList <Joint> joints      = model.JointList;
            LinkedList <int> neighbors   = graph[(int)j.Id];
            List <int>       floorJoints = getNeighbors(j, graph, joints);

            if (floorJoints != null && floorJoints.Count > 1)
            {
                Constraint cons = new Constraint(floor + "_" + (int)j.Z);
                model.ConstraintList.Add(cons);
                j.Constraint = cons;
                foreach (int jid in floorJoints)
                {
                    if (joints[jid] != null && Equal(j.Z, joints[jid].Z))
                    {
                        joints[jid].Constraint = j.Constraint;
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void storeFrameDesignProcedures(OleDbConnection cn, Canguro.Model.Model model)
        {
            if (model.SteelDesignOptions is NoDesign &&
                model.ConcreteDesignOptions is NoDesign
                //&& model.AluminumDesignOptions is NoDesign
                //&& model.ColdFormedDesignOptions is NoDesign
                )
            {
                return;
            }

            foreach (LineElement e in model.LineList)
            {
                if (e != null)
                {
                    string sql = "INSERT INTO [Frame Design Procedures] (Frame, DesignProc) VALUES (\"" + e.Id + "\", \"From Material\");";
                    new OleDbCommand(sql, cn).ExecuteNonQuery();
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Splits a line element and it's loads with an intermediate joint.
        /// </summary>
        /// <param name="line">The line element to split</param>
        /// <param name="joint">The joint, which should be located inside the line element</param>
        /// <param name="model">The Model object</param>
        /// <returns>The new line element, added to the model</returns>
        internal static void Split(LineElement line, IList <Joint> joints, Canguro.Model.Model model)
        {
            //float intersect = getIntersection(line, joint);
            //Commands.View.Selection.

            List <Utility.DistancedItem.dItem> dJoints = new List <Canguro.Utility.DistancedItem.dItem>(joints.Count);

            foreach (Joint j in joints)
            {
                if (line.I != j && line.J != j)
                {
                    dJoints.Add(new Canguro.Utility.DistancedItem.dItem(getIntersection(line, j), j));
                }
            }

            dJoints.Sort(Utility.DistancedItem.ReverseComparer.Instance);

            foreach (Utility.DistancedItem.dItem dItem in dJoints)
            {
                Split(line, (Joint)dItem.item, dItem.distance, model);
            }
        }
Exemplo n.º 18
0
 private void writeNonLinearParameters(XmlWriter xml, Model model)
 {
     xml.WriteStartElement("Case_-_Static_4_-_NonLinear_Parameters");
     foreach (AbstractCase ac in model.AbstractCases)
         if (ac is AnalysisCase && ((AnalysisCase)ac).Properties is PDeltaCaseProps)
         {
             NonLinearParams nl = ((PDeltaCaseProps)((AnalysisCase)ac).Properties).NonLinearParams;
             xml.WriteStartElement("Case");
             xml.WriteAttributeString("Case", ac.Name);
             xml.WriteAttributeString("Unloading", nl.Unloading);
             xml.WriteAttributeString("GeoNonLin", nl.GeoNonLin);
             xml.WriteAttributeString("ResultsSave", nl.ResultsSave);
             xml.WriteAttributeString("MaxTotal", nl.MaxTotal.ToString());
             xml.WriteAttributeString("MaxNull", nl.MaxNull.ToString());
             xml.WriteAttributeString("MaxIterCS", nl.MaxIterCS.ToString());
             xml.WriteAttributeString("MaxIterNR", nl.MaxIterNR.ToString());
             xml.WriteAttributeString("ItConvTol", nl.ItConvTol.ToString());
             xml.WriteAttributeString("UseEvStep", CodeYN(nl.UseEvStep));
             xml.WriteAttributeString("EvLumpTol", nl.EvLumpTol.ToString());
             xml.WriteAttributeString("LSPerIter", nl.LSPerIter.ToString());
             xml.WriteAttributeString("LSTol", nl.LSTol.ToString());
             xml.WriteAttributeString("LSStepFact", nl.LSStepFact.ToString());
             xml.WriteAttributeString("FrameTC", CodeYN(nl.FrameTC));
             xml.WriteAttributeString("FrameHinge", CodeYN(nl.FrameHinge));
             xml.WriteAttributeString("CableTC", CodeYN(nl.CableTC));
             xml.WriteAttributeString("LinkTC", CodeYN(nl.LinkTC));
             xml.WriteAttributeString("LinkOther", CodeYN(nl.LinkOther));
             xml.WriteAttributeString("TFMaxIter", nl.TFMaxIter.ToString());
             xml.WriteAttributeString("TFTol", nl.TFTol.ToString());
             xml.WriteAttributeString("TFAccelFact", nl.TFAccelFact.ToString());
             xml.WriteAttributeString("TFNoStop", CodeYN(nl.TFNoStop));
             xml.WriteEndElement();
         }
     xml.WriteEndElement();
 }
Exemplo n.º 19
0
 private void writeNonLinearLoadApplication(XmlWriter xml, Model model)
 {
     xml.WriteStartElement("Case_-_Static_2_-_NonLinear_Load_Application");
     foreach (AbstractCase ac in model.AbstractCases)
         if (ac is AnalysisCase && ((AnalysisCase)ac).Properties is PDeltaCaseProps)
         {
             xml.WriteStartElement("Case");
             xml.WriteAttributeString("Case", ac.Name);
             xml.WriteAttributeString("LoadApp", "Full Load");
             xml.WriteAttributeString("MonitorDOF", "U1");
             xml.WriteEndElement();
         }
     xml.WriteEndElement();
 }
Exemplo n.º 20
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.º 21
0
        private Vector3 getHoverPos(Joint j, Model.Model model, View.Renderer.RenderOptions options)
        {
            if (options.ShowDeformed && model.HasResults && model.Results.ActiveCase != null)
            {
                float[,] deformations = model.Results.JointDisplacements;
                if (deformations != null)
                {
                    // Get joint defomations
                    Vector3 vI = new Vector3(deformations[j.Id, 0],
                                     deformations[j.Id, 1],
                                     deformations[j.Id, 2]);

                    vI = options.DeformationScale * model.Results.PaintScaleFactorTranslation * vI + j.Position;

                    return vI;
                }
            }
            return j.Position;
        }
Exemplo n.º 22
0
 public Deserializer(Model model)
 {
     this.model = model;
 }
 /// <summary>
 /// Gets the stress at the point specified by (pt22, pt33) in the Line's contour local axes, given the internal
 /// forces diagrams for Axial and Moments in 2 and 3.
 /// </summary>
 /// <param name="line">The line to calculate the stress to</param>
 /// <param name="s1">The axial internal forces diagram for the Line</param>
 /// <param name="m22">The Moment in 2 internal forces diagram for the Line</param>
 /// <param name="m33">The Moment in 3 internal forces diagram for the Line</param>
 /// <param name="pointIndex">The index of the diagram to use at the moment, 
 /// corresponds to the position in the Local-1 Axis</param>
 /// <param name="pt22">The point in the Local-2 Axis, corresponds to contour [.][1]</param>
 /// <param name="pt33">The point in the Local-2 Axis, corresponds to contour [.][0]</param>
 /// <returns>The stress at the specified point.</returns>
 public float GetStressAtPoint(Model.Section.FrameSection section, float[,] s1, float[,] m22, float[,] m33, int pointIndex, float pt22, float pt33)
 {
     return (s1[pointIndex, 1] / section.Area) + (m22[pointIndex, 1] * pt22 / section.I22) - (m33[pointIndex, 1] * pt33 / section.I33);
 }
Exemplo n.º 24
0
 public ConstraintsDialog(Canguro.Model.Model model)
 {
     this.model = model;
     InitializeComponent();
 }
Exemplo n.º 25
0
        /// <summary>
        /// Relocates all the LineLoads in the oldLine to keep the position in both, the old and new lines.
        /// </summary>
        /// <param name="oldLine">The line which used to be a whole</param>
        /// <param name="newLine">The line which forms part of the old line</param>
        /// <param name="x">The dividing point</param>
        /// <param name="model">The Model object</param>
        private static void RelocateLoads(LineElement oldLine, LineElement newLine, float x, Canguro.Model.Model model)
        {
            AssignedLineLoads loads = (AssignedLineLoads)oldLine.Loads;

            foreach (LoadCase lc in model.LoadCases.Values)
            {
                IList <Canguro.Model.Load.Load> list = loads[lc];
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        bool relocated             = false;
                        Canguro.Model.Load.Load ll = list[i];
                        if (ll is ConcentratedSpanLoad)
                        {
                            relocated = RelocateConcentratedLoads(newLine.Loads, lc, x, (ConcentratedSpanLoad)ll);
                        }
                        else if (ll is DistributedSpanLoad)
                        {
                            relocated = RelocateDistributedLoads(newLine.Loads, lc, x, (DistributedSpanLoad)ll);
                        }
                        if (relocated)
                        {
                            loads[lc].RemoveAt(i);
                        }
                    }
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Implemented method from abstract class ModelCommand
        /// </summary>
        /// <param name="services"></param>

        /// <summary>
        /// Executes the command.
        /// Calls the Export static method with the current Model and the file name "tmp"
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Canguro.Model.Model m = services.Model;
            Export(m, "tmp");
        }
Exemplo n.º 27
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.º 28
0
        /// <summary>
        /// Finds repeated Joints and Line Elements and deletes them. Deletes only Items in the
        /// parameters and keeps the Item with the smallest ID.
        /// </summary>
        /// <param name="model">The Model object</param>
        /// <param name="joints">List of Joints to check</param>
        /// <param name="lines">List of Line Elements to check</param>
        /// <param name="areas">List of Area Elements to check</param>
        public static void Join(Canguro.Model.Model model, IList <Joint> joints, IList <LineElement> lines, IList <AreaElement> areas)
        {
            System.Windows.Forms.Cursor cursor = System.Windows.Forms.Cursor.Current;
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            try
            {
                Dictionary <uint, uint> deleteJoints = new Dictionary <uint, uint>();
                ItemList <Joint>        jList        = model.JointList;
                ItemList <LineElement>  lList        = model.LineList;
                ItemList <AreaElement>  aList        = model.AreaList;
                bool[] usedJoints = new bool[jList.Count];

                // Find repeated joints
                for (uint ii = 0; ii < joints.Count; ii++)
                {
                    Joint j = joints[(int)ii];
                    if (j != null)
                    {
                        for (uint jj = 0; jj < j.Id; jj++)
                        {
                            Joint mj = jList[jj];
                            if (mj != null && equals(j, mj) &&
                                !deleteJoints.ContainsKey(j.Id))
                            {
                                deleteJoints.Add(j.Id, jj);
                                break;
                            }
                        }
                    }
                    System.Windows.Forms.Application.DoEvents();
                }

                // Move lines to current joints.
                foreach (LineElement l in lines)
                {
                    if (l != null && l.I != null && deleteJoints.ContainsKey(l.I.Id))
                    {
                        l.I = jList[deleteJoints[l.I.Id]];
                    }
                    if (l != null && l.J != null && deleteJoints.ContainsKey(l.J.Id))
                    {
                        l.J = jList[deleteJoints[l.J.Id]];
                    }
                }

                // Delete repeated and Zero-lenght lines.
                for (int i = 0; i < lines.Count; i++)
                {
                    LineElement l = lines[i];
                    if (l != null)
                    {
                        if (l.I.Id == l.J.Id || l.Length < 0.0001F)
                        {
                            lList.RemoveAt((int)l.Id);
                        }
                        else
                        {
                            for (int j = 0; j < (int)l.Id; j++)
                            {
                                LineElement ml = lList[j];
                                if (ml != null && (ml.Id < l.Id && equals(l, ml)))
                                {
                                    lList.RemoveAt((int)l.Id);
                                    ml.IsVisible = true;
                                    break;
                                }
                            }
                        }
                    }
                }

                // Move areas to current joints.
                foreach (AreaElement a in areas)
                {
                    if (a != null && a.J1 != null && deleteJoints.ContainsKey(a.J1.Id))
                    {
                        a.J1 = jList[deleteJoints[a.J1.Id]];
                    }
                    if (a != null && a.J2 != null && deleteJoints.ContainsKey(a.J2.Id))
                    {
                        a.J2 = jList[deleteJoints[a.J2.Id]];
                    }
                    if (a != null && a.J3 != null && deleteJoints.ContainsKey(a.J3.Id))
                    {
                        a.J3 = jList[deleteJoints[a.J3.Id]];
                    }
                    if (a != null && a.J4 != null && deleteJoints.ContainsKey(a.J4.Id))
                    {
                        a.J4 = jList[deleteJoints[a.J4.Id]];
                    }
                }

                // Delete repeated and Zero-area Areas.
                for (int i = 0; i < areas.Count; i++)
                {
                    AreaElement a = areas[i];
                    if (a != null)
                    {
                        if ((a.J4 != null && (a.J1.Id == a.J2.Id || a.J1.Id == a.J3.Id || a.J1.Id == a.J4.Id || a.J2.Id == a.J3.Id || a.J2.Id == a.J4.Id || a.J3.Id == a.J4.Id)) ||
                            (a.J1.Id == a.J2.Id || a.J1.Id == a.J3.Id || a.J2.Id == a.J3.Id) || a.Area < 0.0001F)
                        {
                            aList.RemoveAt((int)a.Id);
                        }
                        else
                        {
                            for (int j = 0; j < (int)a.Id; j++)
                            {
                                AreaElement ml = aList[j];
                                if (ml != null && (ml.Id < a.Id && equals(a, ml)))
                                {
                                    aList.RemoveAt((int)a.Id);
                                    ml.IsVisible = true;
                                    break;
                                }
                            }
                        }
                    }
                }

                // Delete repeated joints.
                foreach (int id in deleteJoints.Keys)
                {
                    jList.RemoveAt(id);
                }

                // Delete unused joints only if lines or areas are used.
                if (lines.Count > 0 || areas.Count > 0)
                {
                    foreach (LineElement l in lList)
                    {
                        if (l != null)
                        {
                            usedJoints[l.I.Id] = true;
                            usedJoints[l.J.Id] = true;
                        }
                    }
                    foreach (AreaElement a in aList)
                    {
                        if (a != null)
                        {
                            usedJoints[a.J1.Id] = true;
                            usedJoints[a.J2.Id] = true;
                            usedJoints[a.J3.Id] = true;
                            usedJoints[a.J4.Id] = true;
                        }
                    }
                    for (int i = 0; i < joints.Count; i++)
                    {
                        Joint j = joints[i];
                        if (j != null && !usedJoints[j.Id] && jList[j.Id] == j)
                        {
                            jList.RemoveAt((int)j.Id);
                        }
                    }
                }
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = cursor;
            }
        }
Exemplo n.º 29
0
        private Vector3 getHoverPos(LineElement line, GraphicView activeView, Point location, Model.Model model, View.Renderer.RenderOptions options)
        {
            Vector3 pos = Vector3.Empty;
            bool lastUndoEnabled = model.Undo.Enabled;
            bool lastUnitSystemEnabled = Model.UnitSystem.UnitSystemsManager.Instance.Enabled;

            if (!model.HasResults || model.Results.ActiveCase == null)
                return pos;

            try
            {
                if (model.IsLocked)
                    model.Undo.Enabled = false;

                Model.UnitSystem.UnitSystemsManager.Instance.Enabled = false;

                int numPoints = (int)options.LOD.GetLOD(line).LODSegments + 1;

                float[] xPos;
                Analysis.LineDeformationCalculator calc = new Analysis.LineDeformationCalculator();
                curve = calc.GetCurve(line, model.Results.ActiveCase.AbstractCase, numPoints, options.DeformationScale, model.Results.PaintScaleFactorTranslation, out xPos);

                int iCurve = 0, numLines = curve.Length - 1;
                Snap.LineMagnet minLine = null, lm;
                float minLineDist = float.MaxValue, lineDist;

                for (int i = 0; i < numLines; i++)
                {
                    lm = new Canguro.Controller.Snap.LineMagnet(curve[i], curve[i + 1] - curve[i], Canguro.Controller.Snap.LineMagnetType.FollowProjection);
                    if ((lineDist = lm.Snap(activeView, location)) < minLineDist)
                    {
                        if ((lm.SnapPositionInt - curve[i]).LengthSq() <= (curve[i + 1] - curve[i]).LengthSq())
                        {
                            minLineDist = lineDist;
                            minLine = lm;
                            iCurve = i;
                        }
                    }
                }

                if (minLine != null)
                {
                    pos = minLine.SnapPositionInt;
                    lm = new Canguro.Controller.Snap.LineMagnet(curve[iCurve], curve[iCurve + 1] - curve[iCurve], Canguro.Controller.Snap.LineMagnetType.FollowProjection);

                    Vector3 tmp = pos - curve[0];
                    Vector3 xPosUnit = curve[numLines] - curve[0];
                    xPosUnit = Vector3.Scale(xPosUnit, 1.0f / xPosUnit.LengthSq());
                    hoverXPos = Vector3.Dot(tmp, xPosUnit);
                }
                else
                    hoverItem = null;
            }
            finally
            {
                Model.UnitSystem.UnitSystemsManager.Instance.Enabled = lastUnitSystemEnabled;
                model.Undo.Enabled = lastUndoEnabled;
            }

            return pos;
        }
Exemplo n.º 30
0
        private void writeConstraints(XmlWriter xml, Model model)
        {
            xml.WriteStartElement("Constraint_Definitions_-_Diaphragm");
            foreach (Constraint cons in model.ConstraintList)
            {
                if (cons != null)
                {
                    xml.WriteStartElement("Constraint");
                    xml.WriteAttributeString("Name", cons.Name);
                    xml.WriteAttributeString("CoordSys", cons.CoordinateSystem);
                    xml.WriteAttributeString("Axis", cons.Axis.ToString());
                    xml.WriteAttributeString("MultiLevel", "No");
                    xml.WriteEndElement();
                }
            }
            xml.WriteEndElement();

            xml.WriteStartElement("Joint_Constraint_Assignments");
            foreach (Joint j in model.JointList)
            {
                if (j != null && j.Constraint != null)
                {
                    xml.WriteStartElement("Joint");
                    xml.WriteAttributeString("Joint", j.Id.ToString());
                    xml.WriteAttributeString("Constraint", j.Constraint.Name);
                    xml.WriteAttributeString("Type", j.Constraint.ConstraintType.ToString());
                    xml.WriteEndElement();
                }
            }
            xml.WriteEndElement();
        }
Exemplo n.º 31
0
        private void writeLayerAssignments(XmlWriter xml, Model model)
        {
            xml.WriteStartElement("T-Layers_2_-_Assignments");

            foreach (Item item in model.Layers)
                if (item != null && item.Layer != null)
                    writeLayerAssignments(xml, item, "Layer");

            foreach (Item item in model.JointList)
                if (item != null && item.Layer != null)
                    writeLayerAssignments(xml, item, "Joint");

            foreach (Item item in model.LineList)
                if (item != null && item.Layer != null)
                    writeLayerAssignments(xml, item, "Frame");

            xml.WriteEndElement();
        }
Exemplo n.º 32
0
        /// <summary>
        /// Create a temporary MDB file that will be send to SAP application
        /// </summary>
        /// <param name="m"></param>
        /// <param name="filePath"></param>
        internal void Export(Canguro.Model.Model m, string filePath)
        {
            OleDbConnection cn = null;

            Canguro.Model.UnitSystem.UnitSystem uSystem = m.UnitSystem;

            try
            {
                File.Copy(System.Windows.Forms.Application.StartupPath + "\\RuntimeData\\modelTransfer", filePath /*"tmp"*/, true);

                //Use a string variable to hold the ConnectionString.
                string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath;

                //Create an OleDbConnection object,
                //and then pass in the ConnectionString to the constructor.
                cn = new OleDbConnection(connectString);
                cn.Open();

                m.UnitSystem = Canguro.Model.UnitSystem.InternationalSystem.Instance;
                // Create store procedures for joint items
                store(cn, m.JointList);
                // Create store procedures for line itemes
                store(cn, m.LineList);
                // Create store procedures for materials
                foreach (Material mat in MaterialManager.Instance.Materials.AsReadOnly())
                {
                    if (mat != null)
                    {
                        store(cn, mat);
                    }
                }
                // Create store procedures for abstract case
                foreach (AbstractCase aCase in m.AbstractCases)
                {
                    if (aCase != null)
                    {
                        store(cn, aCase, m);
                    }
                }
                // Create store procedures for load cases
                foreach (LoadCase lCase in m.LoadCases.Values)
                {
                    if (lCase != null)
                    {
                        store(cn, lCase);
                    }
                }
                // Create store procedures for concrete material
                store(cn, m.ConcreteDesignOptions);
                // Create store procedures for steel materia
                store(cn, m.SteelDesignOptions);
                // Create store procedures for frame design
                storeFrameDesignProcedures(cn, m);
                // Create store procedures for spectrum analysis
                store(cn, m.ResponseSpectra, m.AbstractCases);
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show(Culture.Get("ErrorExporting"), Culture.Get("error"),
                                                     System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                throw;
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                }
                m.UnitSystem = uSystem;
            }
        }
Exemplo n.º 33
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);
            }
        }
Exemplo n.º 34
0
        /// <summary>
        /// Splits a line element and it's loads with an intermediate joint.
        /// </summary>
        /// <param name="line">The line element to split</param>
        /// <param name="joint">The joint, which should be located inside the line element</param>
        /// <param name="pos">The position of the intersection (between 0 - 1 means they intersect)</param>
        /// <param name="model">The Model object</param>
        /// <returns>The new line element, added to the model</returns>
        internal static LineElement Split(LineElement line, Joint joint, float intersectPos, Canguro.Model.Model model)
        {
            if (line == null || joint == null || model == null || intersectPos <= 0 || intersectPos >= 1)
            {
                return(null);
            }

            Layer layer = line.Layer;

            joint.Layer = layer;

            LineElement newLine = new LineElement(line.Properties, joint, line.J);

            newLine.Angle         = line.Angle;
            newLine.CardinalPoint = line.CardinalPoint;
            newLine.Layer         = layer;
            line.J = joint;

            LineEndOffsets off1 = line.EndOffsets;
            LineEndOffsets off2 = line.EndOffsets;

            off1.EndJ          = 0;
            off2.EndI          = 0;
            line.EndOffsets    = off1;
            newLine.EndOffsets = off2;

            JointDOF dofi = line.DoFI;
            JointDOF dofj = line.DoFJ;

            line.DoFJ    = new JointDOF(true);
            newLine.DoFJ = dofj;

            if (model.JointList[joint.Id] != joint)
            {
                model.JointList.Add(joint);
            }

            RelocateLoads(line, newLine, intersectPos, model);

            model.LineList.Add(newLine);
            return(newLine);
        }
Exemplo n.º 35
0
 public float getMinStress(Model.Model model)
 {
     return model.UnitSystem.FromInternational(minStress, Canguro.Model.UnitSystem.Units.Stress);
 }
Exemplo n.º 36
0
 /// <summary>
 /// Splits a line element and it's loads with an intermediate joint.
 /// </summary>
 /// <param name="line">The line element to split</param>
 /// <param name="joint">The joint, which should be located inside the line element</param>
 /// <param name="pos">The position of the intersection (between 0 - 1 means they intersect)</param>
 /// <param name="model">The Model object</param>
 /// <returns>The new line element, added to the model</returns>
 internal static LineElement Split(LineElement line, Joint joint, Canguro.Model.Model model)
 {
     return(Split(line, joint, getIntersection(line, joint), model));
 }
Exemplo n.º 37
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Windows Vista Virtualization Problem FIX
            if (fixVistaVirtualizationError())
            {
                return;
            }
            // End of Windows Vista FIX

            Utility.Updater updater = new Utility.Updater();
            if (updater.Update())
            {
                return;
            }

            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;

            Splash.Show(3000);
            Model.Model             model      = Model.Model.Instance;
            Controller.Controller   controller = Controller.Controller.Instance;
            View.GraphicViewManager view       = View.GraphicViewManager.Instance;
            model.Reset();
            //TestModel(model);

            using (MainFrm frm = new MainFrm())
            {
                frm.Show();

                try
                {
                    view.InitializeGraphics(frm.ScenePanel, frm);

                    controller.MainFrm = frm;

                    if (args.Length > 0)
                    {
                        controller.LoadModel(args[0]);
                    }

                    //////// TESTS /////////////
                    //TestView(view);
                    //model.AbstractCases.Add(new Canguro.Model.Load.AnalysisCase("aCase1"));
                    //Model.Load.AnalysisCase anc = model.AbstractCases[0] as Model.Load.AnalysisCase;
                    //if (anc != null)
                    //{
                    //    Model.Load.StaticCaseProps props = anc.Properties as Model.Load.StaticCaseProps;
                    //    if (props != null)
                    //    {
                    //        List<Model.Load.StaticCaseFactor> list = props.Loads;
                    //        list.Add(new Canguro.Model.Load.StaticCaseFactor(model.ActiveLoadCase));
                    //        props.Loads = list;
                    //    }
                    //}
                    ////////// END TESTS /////////////
                    Application.Run(frm);
                    //              Model.Model.Instance.Save();
                    controller.Execute("cancel");
                    updater.CancelDownload();
                    updater.InstallUpdate();
                }

#if DEBUG
                catch (View.NoDirectXSupportException ex)
                {
                    MessageBox.Show(Culture.Get("strDirectXFatalError") + "\n" + ex.ToString(), Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Microsoft.DirectX.DirectXException ex)
                {
                    MessageBox.Show(Culture.Get("strDirectXFatalError") + "\n" + ex.ToString(), Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (NotSupportedException ex)
                {
                    MessageBox.Show(ex.Message, Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
#else
                catch (View.NoDirectXSupportException ex)
                {
                    MessageBox.Show(Culture.Get("strDirectXFatalError"), Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Microsoft.DirectX.DirectXException ex)
                {
                    MessageBox.Show(Culture.Get("strDirectXFatalError"), Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (NotSupportedException ex)
                {
                    MessageBox.Show(ex.Message, Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
#endif
            }
        }
Exemplo n.º 38
0
 public ConstraintsDialog(Canguro.Model.Model model)
 {
     this.model = model;
     InitializeComponent();
 }