Esempio n. 1
0
        public ResultControl UpdateMesh(Database DB, RenderInterface iRen, ResultControl ResControl)
        {
            // Catch increment
            int inc = ResControl.Step;

            // --- Scalar Bar ---------------------------------------------
            if (ResControl.Result != "None")
            {
                string title = ResControl.Result;
                if (ResControl.Result.Contains("Displacement"))  // Use shorter title
                {
                    title = ResControl.Result.Replace("Displacement", "Displ.");
                }
                if (ResControl.Result == "von Mises Stress")  // Use shorter title
                {
                    title = "Stress\nvon Mises";
                }
                if (ResControl.Result == "Effective Strain")  // Use shorter title
                {
                    title = "Effective\nStrain";
                }
                iRen.ChangeScalarName(title);
                iRen.ShowScalarBar();
            }
            else
            {
                iRen.HideScalarBar();
            }

            // --- Colormaps --------------------------------------------

            // Set range of results (manual or automatic, depends on variable "Manual_Range")
            if (ResControl.ManualRange == false)
            {
                //Set automatic result range
                List <double> MinVal = new List <double>();
                List <double> MaxVal = new List <double>();

                foreach (Part p in DB.PartLib.Values)
                {
                    double[] PartRange = p.Get_ScalarRange(inc, ResControl.Result, ResControl.ResultStyle);
                    MinVal.Add(PartRange[0]);
                    MaxVal.Add(PartRange[1]);
                }
                // Calculate total result range
                ResControl.ResultRange = new double[2] {
                    MinVal.Min(), MaxVal.Max()
                };
            }

            // Change Color LookupTable range
            iRen.ChangeColorRange(ResControl.ResultRange[0], ResControl.ResultRange[1]);

            // Update Parts
            foreach (Part p in DB.PartLib.Values)
            {
                p.UpdateNode(DB, inc);
                p.UpdateScalar(inc, ResControl.Result, ResControl.ResultStyle);
            }

            double[] N = iRen.Get_ClipPlane().GetNormal();
            if (N[0] < 0)
            {
                iRen.SetClipPlane("-X");
            }
            if (N[1] < 0)
            {
                iRen.SetClipPlane("-Y");
            }
            if (N[2] < 0)
            {
                iRen.SetClipPlane("-Z");
            }
            if (N[0] > 0)
            {
                iRen.SetClipPlane("X");
            }
            if (N[1] > 0)
            {
                iRen.SetClipPlane("Y");
            }
            if (N[2] > 0)
            {
                iRen.SetClipPlane("Z");
            }

            // Refresh Viewport
            iRen.Refresh();

            return(ResControl);
        }
Esempio n. 2
0
        private void Open_Click(object sender, RoutedEventArgs e)
        {
            bool DataOk = false;

            OpenFileDialog dialog = new OpenFileDialog
            {
                Filter           = "STAN Database (*.STdb)|*.STdb",
                FilterIndex      = 0,
                RestoreDirectory = true
            };

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Load Database from binary file (or try)
                Tuple <Database, bool> Data = Fun.OpenDatabase(dialog.FileName);
                DataOk = Data.Item2;
                if (Data.Item2 == true)
                {
                    DB = Data.Item1;
                }
            }

            if (DataOk == true)
            {
                // Add Parts to GUI
                foreach (Part p in DB.PartLib.Values)
                {
                    p.SetProperty(DB);
                    Fun.AddPart2GUI(p, iRen, PartBox, Tree);
                }

                // Add Boundary Conditions to GUI
                foreach (BoundaryCondition BC in DB.BCLib.Values)
                {
                    BC.Initialize();
                    Fun.AddBC2GUI(BC, iRen, Tree, false);
                    BC.Update_Arrows(DB.NodeLib, BC_Arrow_scale, ResControl.Step, ClipMode);   // Create BC arrows actors
                }

                // Add Materials to GUI
                foreach (Material Mat in DB.MatLib.Values)
                {
                    Fun.AddMat2GUI(Mat, Tree);
                }

                // Load result to Parts if exists
                if (DB.AnalysisLib.GetResultStepNo() > 0)
                {
                    foreach (Part p in DB.PartLib.Values)
                    {
                        p.Set_ColorTable(iRen.Get_ColorTable());
                        p.Load_Scalar(DB);
                    }
                    // Activate Result Tree item
                    TreeResult.IsEnabled = true;
                    TreeResult.Header    = "Results";
                }

                // Refresh Viewport and Set Model as loaded
                iRen.InitializeFaces();
                iRen.FitView();
                iRen.Refresh();
                ModelLoaded      = true;
                iRen.ModelLoaded = true;

                // Set size of Clip Plane
                iRen.SetClipPlaneScale(DB.GetBounds());
                iRen.SetClipPlane("X");  // Set initial section normal to X

                // Active/Deactive buttons
                OpenButton.IsEnabled   = false;
                ImportButton.IsEnabled = false;
                TopButtonBar.IsEnabled = true;

                // Active/Deactive Menuitems
                Open.IsEnabled   = false;
                Import.IsEnabled = false;
                Save.IsEnabled   = true;

                // Active TreeView
                Tree.IsEnabled = true;
            }
        }