Example #1
0
        public SetFixityDialog(SlopeCanvas canvas, LineConstraint lc)
        {
            InitializeComponent();

            this.canvas = canvas;

            this.lc            = lc;
            isFixedX.IsChecked = lc.IsFixedX;
            isFixedY.IsChecked = lc.IsFixedY;
        }
        public ActivateFixityDialog(SlopeDefineCanvas canvas, LineConstraint lc)
        {
            InitializeComponent();

            this.canvas = canvas;

            this.lc = lc;

            MaterialBlock parent = canvas.Substructs.Find(delegate(MaterialBlock mb) { return(mb.Material.Name != "NULL" && mb.LineConstraints.Contains(lc)); });

            isFixedX.IsEnabled = parent != null && lc.IsFixedX;
            isFixedY.IsEnabled = parent != null && lc.IsFixedY;
            isFixedX.IsChecked = parent != null && lc.IsActiveX;
            isFixedY.IsChecked = parent != null && lc.IsActiveY;
        }
Example #3
0
        /// <summary>
        /// Gets substruct (material block data) from file
        /// </summary>
        public void LoadSubstructData()
        {
            if (!File.Exists(FilePath))
            {
                MessageBox.Show("Could not find input data file.", "Error");
                return;
            }

            // get canvas dimensions/properties
            double originX = OriginOffsetX,
                   originY = OriginOffsetY,
                   scale   = Scale,
                   yHeight = ActualHeight;
            Units units    = Units;

            // get units dependent scaling factor
            double factor;

            switch (units)
            {
            case Units.Metres: factor = 0.0254; break;

            case Units.Millimetres: factor = 25.4; break;

            case Units.Feet: factor = 1.0 / 12.0; break;

            default: factor = 1.0; break;
            }

            // Load material blocks from source canvas
            substructs = new List <MaterialBlock>();
            using (TextReader tr = new StreamReader(FilePath))
            {
                // advance to material block data
                while (!tr.ReadLine().Contains("MATERIAL BLOCK DATA"))
                {
                    ;
                }

                tr.ReadLine();
                tr.ReadLine();

                int numMaterialBlocks = int.Parse(tr.ReadLine().Split('=')[1]);

                tr.ReadLine();

                if (numMaterialBlocks > 0)
                {
                    MaterialBlock  block;
                    MaterialType   mtl;
                    DrawingPoint   p1, p2;
                    LineConstraint newLC, existingLC;
                    LineLoad       newLL, existingLL;
                    PointLoad      newPL, existingPL;
                    Point[]        materialBoundPoints;
                    bool[]         isFixedX;
                    bool[]         isFixedY;
                    bool[]         isPrintPoint;
                    string         materialName;
                    int            numMaterialBoundPoints, numLineConstraints, numLineLoads, numPointLoads;
                    double         xCoord, yCoord;
                    string[]       coords, lineConstraint, lineLoad, pointLoad;

                    for (int i = 0; i < numMaterialBlocks; i++)
                    {
                        tr.ReadLine();

                        materialName = tr.ReadLine().Split(new char[] { '\"' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        mtl          = materialTypes.Find(delegate(MaterialType mt) { return(mt.Name == materialName); });

                        numMaterialBoundPoints = int.Parse(tr.ReadLine().Split('=')[1]);

                        materialBoundPoints = new Point[numMaterialBoundPoints];
                        isFixedX            = new bool[numMaterialBoundPoints];
                        isFixedY            = new bool[numMaterialBoundPoints];
                        isPrintPoint        = new bool[numMaterialBoundPoints];

                        for (int j = 0; j < numMaterialBoundPoints; j++)
                        {
                            coords = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            xCoord = double.Parse(coords[0]);
                            yCoord = double.Parse(coords[1]);
                            materialBoundPoints[j].X = xCoord / (factor * Scale) * dpiX + OriginOffsetX;
                            materialBoundPoints[j].Y = ActualHeight - (yCoord / (factor * Scale) * dpiY + OriginOffsetY);
                            isFixedX[j]     = coords[2] == bool.TrueString;
                            isFixedY[j]     = coords[3] == bool.TrueString;
                            isPrintPoint[j] = coords[4] == bool.TrueString;
                        }

                        block = new MaterialBlock(this, mtl, materialBoundPoints);
                        for (int j = 0; j < numMaterialBoundPoints; j++)
                        {
                            block.BoundaryPoints[j].IsFixedX     = isFixedX[j];
                            block.BoundaryPoints[j].IsFixedY     = isFixedY[j];
                            block.BoundaryPoints[j].IsPrintPoint = isPrintPoint[j];
                        }

                        substructs.Add(block);

                        numLineConstraints = int.Parse(tr.ReadLine().Split('=')[1]);
                        for (int j = 0; j < numLineConstraints; j++)
                        {
                            lineConstraint = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            p1 = block.BoundaryPoints[int.Parse(lineConstraint[0])];
                            p2 = block.BoundaryPoints[int.Parse(lineConstraint[1])];

                            existingLC = null;
                            foreach (MaterialBlock mb in substructs)
                            {
                                existingLC = mb.LineConstraints.Find(delegate(LineConstraint lc) { return(lc.Nodes.Contains(p1) && lc.Nodes.Contains(p2)); });
                                if (existingLC != null)
                                {
                                    break;
                                }
                            }

                            if (existingLC == null)
                            {
                                newLC = new LineConstraint(this, p1, p2,
                                                           //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                                                           //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                                                           lineConstraint[2] == bool.TrueString,
                                                           lineConstraint[3] == bool.TrueString);
                            }
                            else
                            {
                                block.LineConstraints.Add(existingLC);
                            }

                            //newLC = new LineConstraint( this ,
                            //    block.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                            //    block.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                            //    lineConstraint[2] == bool.TrueString ,
                            //    lineConstraint[3] == bool.TrueString );
                            //existingLC = null;
                            //foreach ( MaterialBlock mb in substructs )
                            //{
                            //    existingLC = mb.LineConstraints.Find(
                            //        delegate( LineConstraint lc )
                            //        {
                            //            return lc.Nodes.Contains( newLC.Nodes[0] ) && lc.Nodes.Contains( newLC.Nodes[1] );
                            //        } );
                            //    if ( existingLC != null ) break;
                            //}
                            //if ( existingLC != null )
                            //{
                            //    if ( !block.LineConstraints.Contains( existingLC ) )
                            //        block.LineConstraints.Add( existingLC );
                            //}
                            //else block.LineConstraints.Add( newLC );
                        }

                        numLineLoads = int.Parse(tr.ReadLine().Split('=')[1]);
                        for (int j = 0; j < numLineLoads; j++)
                        {
                            lineLoad = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            p1 = block.BoundaryPoints[int.Parse(lineLoad[0])];
                            p2 = block.BoundaryPoints[int.Parse(lineLoad[1])];

                            existingLL = null;
                            foreach (MaterialBlock mb in substructs)
                            {
                                existingLL = mb.LineLoads.Find(delegate(LineLoad ll) { return(ll.Nodes.Contains(p1) && ll.Nodes.Contains(p2)); });
                                if (existingLL != null)
                                {
                                    break;
                                }
                            }

                            if (existingLL == null)
                            {
                                newLL = new LineLoad(this, p1, p2,
                                                     //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                                                     //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                                                     lineLoad[2] == bool.TrueString, double.Parse(lineLoad[3]), double.Parse(lineLoad[4]),
                                                     lineLoad[5] == bool.TrueString, double.Parse(lineLoad[6]), double.Parse(lineLoad[7]));
                            }
                            else
                            {
                                block.LineLoads.Add(existingLL);
                            }

                            //block.LineLoads.Add( new LineLoad( this ,
                            //    block.BoundaryPoints[int.Parse( lineLoad[0] )] ,
                            //    block.BoundaryPoints[int.Parse( lineLoad[1] )] ,
                            //    lineLoad[2] == bool.TrueString , double.Parse( lineLoad[3] ) , double.Parse( lineLoad[4] ) ,
                            //    lineLoad[5] == bool.TrueString , double.Parse( lineLoad[6] ) , double.Parse( lineLoad[7] ) ) );
                        }

                        numPointLoads = int.Parse(tr.ReadLine().Split('=')[1]);
                        for (int j = 0; j < numPointLoads; j++)
                        {
                            pointLoad = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            p1 = block.BoundaryPoints[int.Parse(pointLoad[0])];

                            existingPL = null;
                            foreach (MaterialBlock mb in substructs)
                            {
                                existingPL = mb.PointLoads.Find(delegate(PointLoad pl) { return(pl.Node == p1); });
                                if (existingPL != null)
                                {
                                    break;
                                }
                            }

                            if (existingPL == null)
                            {
                                newPL = new PointLoad(this, p1,
                                                      //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                                                      //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                                                      pointLoad[1] == bool.TrueString, double.Parse(pointLoad[2]),
                                                      pointLoad[3] == bool.TrueString, double.Parse(pointLoad[4]));
                            }
                            else
                            {
                                block.PointLoads.Add(existingPL);
                            }

                            //block.PointLoads.Add( new PointLoad( this ,
                            //    block.BoundaryPoints[int.Parse( pointLoad[0] )] ,
                            //    pointLoad[1] == bool.TrueString , double.Parse( pointLoad[2] ) ,
                            //    pointLoad[3] == bool.TrueString , double.Parse( pointLoad[4] ) ) );
                        }



                        tr.ReadLine();
                    }
                }
            }

            // Set selected analysis phase to first (if present)
            if (source.AnalysisPhases.Count > 1)
            {
                ComboBox      phaseList = (ComboBox)((Grid)((GroupBox)((Grid)((ScrollViewer)((Grid)this.Parent).Children[2]).Content).Children[1]).Content).Children[1];
                AnalysisPhase initial   = source.AnalysisPhases[1];
                phaseList.SelectedItem = initial;
            }
        }
Example #4
0
 bool SolveLine(LineConstraint constraint)
 {
     throw new NotImplementedException();
 }