コード例 #1
0
        public SetFixityDialog( SlopeCanvas canvas , LineConstraint lc )
        {
            InitializeComponent();

            this.canvas = canvas;

            this.lc = lc;
            isFixedX.IsChecked = lc.IsFixedX;
            isFixedY.IsChecked = lc.IsFixedY;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
ファイル: CanvasData.cs プロジェクト: karcheba/SlopeFEA
        public bool ApplyFixity( DrawingPoint p1 , DrawingPoint p2 )
        {
            bool added = false;

            // find point indices in list
            int index1 = BoundaryPoints.FindIndex( delegate( DrawingPoint p ) { return p == p1; } );
            int index2 = BoundaryPoints.FindIndex( delegate( DrawingPoint p ) { return p == p2; } );

            // if points were not successfully found
            if ( index1 == -1 || index2 == -1 )
            {
                MessageBox.Show( "Points not found on block." , "Fix X error" );
                return added;
            }

            // ensure max and min as appropriate
            if ( ((index1 > index2) && !(index2 == 0 && index1 == BoundaryPoints.Count - 1))
                || (index1 == 0 && index2 == BoundaryPoints.Count - 1) )
            {
                int tmp = index1;
                index1 = index2;
                index2 = tmp;

                DrawingPoint tmpPt = p1;
                p1 = p2;
                p2 = tmpPt;
            }

            // if points are the same, fix/unfix the point ...
            if ( index1 == index2 )
            {
                bool prevFixedX = p1.IsFixedX , prevFixedY = p1.IsFixedY;

                SetFixityDialog dlg = new SetFixityDialog( canvas , p1 );
                dlg.ShowDialog();

                if ( dlg.DialogResult == true )
                {
                    bool newFixedX = p1.IsFixedX;
                    if ( newFixedX != prevFixedX )
                    {
                        for ( int i = 0 ; i < p1.PhaseFixActiveX.Count ; i++ )
                        {
                            p1.PhaseFixActiveX[i] = newFixedX;
                        }
                    }

                    bool newFixedY = p1.IsFixedY;
                    if ( newFixedY != prevFixedY )
                    {
                        for ( int i = 0 ; i < p1.PhaseFixActiveY.Count ; i++ )
                        {
                            p1.PhaseFixActiveY[i] = newFixedY;
                        }
                    }

                    canvas.IsSaved = false;
                    canvas.IsVerified = false;
                }
                added = true;
            }

            // ... or if the points are adjacent, create a line constraint ...
            else if ( ((index2 - index1) == 1) || (index2 == 0 && index1 == BoundaryPoints.Count - 1) )
            {
                LineConstraint existingLC = LineConstraints.Find( delegate( LineConstraint lc ) { return lc.Nodes.Contains( p1 ) && lc.Nodes.Contains( p2 ); } );

                if ( existingLC != null )
                {
                    bool prevFixX = existingLC.IsFixedX;
                    bool prevFixY = existingLC.IsFixedY;

                    SetFixityDialog dlg = new SetFixityDialog( canvas , existingLC );
                    dlg.ShowDialog();

                    if ( dlg.DialogResult == true )
                    {
                        bool newFixX = existingLC.IsFixedX;
                        if ( newFixX != prevFixX )
                        {
                            for ( int i = 0 ; i < existingLC.PhaseFixedX.Count ; i++ )
                                existingLC.PhaseFixedX[i] = newFixX;

                            for ( int i = 0 ; i < existingLC.Nodes.Count ; i++ )
                            {
                                for ( int j = 0 ; j < existingLC.Nodes[i].PhaseFixActiveX.Count ; j++ )
                                    existingLC.Nodes[i].PhaseFixActiveX[j] =
                                        existingLC.Nodes[i].PhaseFixActiveX[j] || existingLC.PhaseFixedX[j];
                            }
                        }
                        bool newFixY = existingLC.IsFixedY;
                        if ( newFixY != prevFixY )
                        {
                            for ( int i = 0 ; i < existingLC.PhaseFixedY.Count ; i++ )
                                existingLC.PhaseFixedY[i] = newFixY;

                            for ( int i = 0 ; i < existingLC.Nodes.Count ; i++ )
                            {
                                for ( int j = 0 ; j < existingLC.Nodes.Count ; j++ )
                                    existingLC.Nodes[i].PhaseFixActiveY[j] =
                                        existingLC.Nodes[i].PhaseFixActiveY[j] || existingLC.PhaseFixedY[j];
                            }
                        }

                        canvas.IsSaved = false;
                        canvas.IsVerified = false;
                    }
                    added = true;
                }
                else
                {
                    LineConstraint newLC = new LineConstraint( canvas , p1 , p2 , false , false );
                    SetFixityDialog dlg = new SetFixityDialog( canvas , newLC );
                    dlg.ShowDialog();

                    if ( dlg.DialogResult == true )
                    {
                        bool newFixX = newLC.IsFixedX , newFixY = newLC.IsFixedY;
                        for ( int i = 0 ; i < newLC.PhaseFixedX.Count ; i++ )
                        {
                            newLC.PhaseFixedX[i] = newFixX;
                            newLC.PhaseFixedY[i] = newFixY;
                        }
                        for ( int i = 0 ; i < newLC.Nodes.Count ; i++ )
                        {
                            for ( int j = 0 ; j < newLC.Nodes[i].PhaseFixActiveX.Count ; j++ )
                            {
                                newLC.Nodes[i].PhaseFixActiveX[j] =
                                    newLC.Nodes[i].PhaseFixActiveX[j] || newLC.PhaseFixedX[j];

                                newLC.Nodes[i].PhaseFixActiveY[j] =
                                    newLC.Nodes[i].PhaseFixActiveY[j] || newLC.PhaseFixedY[j];
                            }
                        }

                        //canvas.MaterialBlocks.ForEach(
                        //    delegate( MaterialBlock mb )
                        //    {
                        //        if ( mb.BoundaryPoints.Contains( p1 ) && mb.BoundaryPoints.Contains( p2 ) )
                        //            mb.LineConstraints.Add( newLC );
                        //    } );

                        canvas.IsSaved = false;
                        canvas.IsVerified = false;
                    }

                    added = true;
                }
            }

            // ... otherwise, indicate that a constraint cannot be applied in this manner
            else
            {
                MessageBox.Show( "Points must be either the same or directly adjacent." , "Error" );
                return added;
            }

            // remove any line constraints that are both unfixed
            canvas.MaterialBlocks.ForEach(
                delegate( MaterialBlock mb )
                {
                    mb.LineConstraints.RemoveAll( delegate( LineConstraint lc ) { return (!lc.IsFixedX && !lc.IsFixedY); } );
                } );

            return added;
        }
コード例 #4
0
ファイル: CanvasData.cs プロジェクト: karcheba/SlopeFEA
        public DrawingPoint AddPoint( DrawingPoint p1 , DrawingPoint p2, DrawingPoint pNew )
        {
            // find point indices in list
            int index1 = BoundaryPoints.FindIndex( delegate( DrawingPoint p ) { return p == p1; } );
            int index2 = BoundaryPoints.FindIndex( delegate( DrawingPoint p ) { return p == p2; } );

            // if points were not successfully found
            if ( index1 == -1 || index2 == -1 )
            {
                MessageBox.Show( "Points not found on block." , "Error" );
                return null;
            }

            // ensure max and min as appropriate
            if ( ((index1 > index2) && !(index2 == 0 && index1 == BoundaryPoints.Count - 1))
                || (index1 == 0 && index2 == BoundaryPoints.Count - 1) )
            {
                int tmp = index1;
                index1 = index2;
                index2 = tmp;

                DrawingPoint tmpPt = p1;
                p1 = p2;
                p2 = tmpPt;
            }

            DrawingPoint newNode;
            Point newPoint;
            if ( (index2 - index1) == 1 )
            {
                if ( pNew == null )
                {
                    newPoint = new Point( 0.5 * (p1.Point.X + p2.Point.X) , 0.5 * (p1.Point.Y + p2.Point.Y) );
                    newNode = new DrawingPoint( canvas , this , newPoint );
                }
                else
                {
                    newNode = pNew;
                    newNode.ParentBlocks.Add( this );
                    newPoint = pNew.Point;
                }
                BoundaryPoints.Insert( index2 , newNode );
                Boundary.Points.Insert( index2 , newPoint );
            }
            else if ( index2 == 0 && index1 == BoundaryPoints.Count - 1 )
            {
                if ( pNew == null )
                {
                    newPoint = new Point( 0.5 * (p1.Point.X + p2.Point.X) , 0.5 * (p1.Point.Y + p2.Point.Y) );
                    newNode = new DrawingPoint( canvas , this , newPoint );
                }
                else
                {
                    newNode = pNew;
                    newNode.ParentBlocks.Add( this );
                    newPoint = pNew.Point;
                }
                BoundaryPoints.Add( newNode );
                Boundary.Points.Add( newPoint );
            }
            else
            {
                MessageBox.Show( "Points must be different and adjacent." , "Error" );
                return null;
            }

            // if a line constraint exists between these two points, remove it and create two in its place
            List<LineConstraint> existingLCs = new List<LineConstraint>();
            List<MaterialBlock> existingParents = new List<MaterialBlock>();
            canvas.MaterialBlocks.ForEach(
                delegate( MaterialBlock mb )
                {
                    existingLCs.AddRange( mb.LineConstraints.FindAll(
                        delegate( LineConstraint lc )
                        {
                            if ( lc.Nodes.Contains( p1 ) && lc.Nodes.Contains( p2 ) )
                            {
                                existingParents.Add( mb );
                                return true;
                            }
                            else return false;
                        } ) );
                } );
            // create the two new line constraints
            LineConstraint newLC1 = new LineConstraint( canvas , p1 , newNode , false , false );
            LineConstraint newLC2 = new LineConstraint( canvas , newNode , p2 , false , false );
            existingLCs.ForEach(
                delegate( LineConstraint lc )
                {
                    // match the new node fixity to the line constraint
                    newNode.IsFixedX = newNode.IsFixedX || lc.IsFixedX;
                    newNode.IsFixedY = newNode.IsFixedY || lc.IsFixedY;
                    newLC1.IsFixedX = newLC1.IsFixedX || lc.IsFixedX;
                    newLC1.IsFixedY = newLC1.IsFixedY || lc.IsFixedY;
                    newLC2.IsFixedX = newLC2.IsFixedX || lc.IsFixedX;
                    newLC2.IsFixedY = newLC2.IsFixedY || lc.IsFixedY;

                    // clear the existing plotting lines, remove the existing constraint, and add the new constraints
                    existingParents.ForEach( delegate( MaterialBlock mb ) { mb.LineConstraints.Remove( lc ); } );
                    lc.Delete();
                } );
            existingParents.ForEach( delegate( MaterialBlock mb ) { mb.LineConstraints.Add( newLC1 ); mb.LineConstraints.Add( newLC2 ); } );
            existingLCs.Clear(); existingParents.Clear();

            // if a line load exists between these two points, remove it and create two in its place
            List<LineLoad> existingLLs = new List<LineLoad>();
            canvas.MaterialBlocks.ForEach(
                delegate( MaterialBlock mb )
                {
                    existingLLs.AddRange( mb.LineLoads.FindAll(
                        delegate( LineLoad ll )
                        {
                            if ( ll.Nodes.Contains( p1 ) && ll.Nodes.Contains( p2 ) )
                            {
                                existingParents.Add( mb );
                                return true;
                            }
                            else return false;
                        } ) );
                } );
            LineLoad newLL1 = new LineLoad( canvas , p1 , newNode , false , 0 , 0 , false , 0 , 0 );
            LineLoad newLL2 = new LineLoad( canvas , newNode , p2 , false , 0 , 0 , false , 0 , 0 );
            existingLLs.ForEach(
                delegate( LineLoad ll )
                {
                    newLL1.IsLoadedN = newLL1.IsLoadedN || ll.IsLoadedN;
                    if ( newLL1.IsLoadedN )
                    {
                        newLL1.NLoad1 += ll.NLoad1;
                        newLL1.NLoad2 += 0.5 * (ll.NLoad1 + ll.NLoad2);
                    }
                    newLL1.IsLoadedT = newLL1.IsLoadedT || ll.IsLoadedT;
                    if ( newLL1.IsLoadedT )
                    {
                        newLL1.TLoad1 += ll.TLoad1;
                        newLL1.TLoad2 += 0.5 * (ll.TLoad1 + ll.TLoad2);
                    }

                    newLL2.IsLoadedN = newLL2.IsLoadedN || ll.IsLoadedN;
                    if ( newLL2.IsLoadedN )
                    {
                        newLL2.NLoad1 += 0.5 * (ll.NLoad1 + ll.NLoad2);
                        newLL2.NLoad2 += ll.NLoad2;
                    }
                    newLL2.IsLoadedT = newLL2.IsLoadedT || ll.IsLoadedT;
                    if ( newLL2.IsLoadedT )
                    {
                        newLL2.TLoad1 += 0.5 * (ll.TLoad1 + ll.TLoad2);
                        newLL2.TLoad2 += ll.TLoad2;
                    }

                    // clear the existing plotting lines, remove the existing line load, and add the new line loads
                    existingParents.ForEach( delegate( MaterialBlock mb ) { mb.LineLoads.Remove( ll ); } );
                    ll.Delete();
                } );
            LineLoads.Add( newLL1 ); LineLoads.Add( newLL2 );
            existingLLs.Clear(); existingParents.Clear();

            foreach ( MaterialBlock mb in canvas.MaterialBlocks )
            {
                for ( int i = mb.LineLoads.Count - 1 ; i >= 0 ; i-- )
                {
                    if ( !mb.LineLoads[i].IsLoadedN && !mb.LineLoads[i].IsLoadedT )
                    {
                        mb.LineLoads[i].Delete();
                        mb.LineLoads.RemoveAt( i );
                    }
                }

                for ( int i = mb.LineConstraints.Count - 1 ; i >= 0 ; i-- )
                {
                    if ( !mb.LineConstraints[i].IsFixedX && !mb.LineConstraints[i].IsFixedY )
                    {
                        mb.LineConstraints[i].Delete();
                        mb.LineConstraints.RemoveAt( i );
                    }
                }
            }

            canvas.IsSaved = false;
            canvas.IsVerified = false;

            return newNode;
        }