public int BuildLisFileExecutor(FormParas paras)
        {
            LisFileExecutor = new Models.LISFileReader();


            return(LisFileExecutor.WrapperInstaller(paras.StageID, paras.ModelID, paras.SpecialID, paras.BuildModel));
        }
Ejemplo n.º 2
0
        private void RunModelButtonClick(object sender, RoutedEventArgs e)
        {
            Models.CraftsModeExecutor CfExe = new Models.CraftsModeExecutor();
            //Set the environment
            CfExe.CraftsModeEnvSetter((int)this.WinFormGrid.Width, (int)this.WinFormGrid.Height);
            //Get the Model
            int ModelIdx = ModelName.SelectedIndex - 1;

            List <Models.CraftsModePreDefinedModelType> pdList = CfExe.CraftsModeGetModelPreDefined();

            Models.CraftsModePreDefinedModelType pd = pdList[ModelIdx];

            CfExe.CraftsModeEnvModelSetter(pd.GetModelStageId(), pd.GetModelModelId(), pd.GetModelSpecialId());
            CfExe.CraftsModeEnvStartRunningSetter();

            TowerModel CraftsModeTowerModel = CfExe.CraftsModePreExecutor();

            FormParas      CraftsModeFormParas         = CfExe.CraftsModeFormParasGetter();
            WorkSpaceClass CraftsModeWorkSpaceInstance = CfExe.CraftsModeWorkSpaceInstance();

            VTKFormRender CraftsModeForm = new VTKFormRender(CraftsModeFormParas,
                                                             CraftsModeTowerModel,
                                                             CraftsModeWorkSpaceInstance);

            CraftsModeForm.TopLevel = false;
            CraftsModeWinForm.Child = CraftsModeForm;
        }
Ejemplo n.º 3
0
        public void VTKDrawEdgesModel(ref vtkPoints points,
                                      ref vtkCellArray strips,
                                      FormParas paras)
        {
            int cnt = 0;

            for (int i = 0; i < NodeListSize; i++)
            {
                points.InsertPoint(cnt,
                                   NodeList[i].Node_Coord[0],
                                   0,
                                   -NodeList[i].Node_Coord[1]);
                cnt++;
            }

            foreach (ListElemBase elem in ElemList)
            {
                for (int i = 0; i < 8; i++)
                {
                    strips.InsertNextCell(2);
                    if (i != 7)
                    {
                        strips.InsertCellPoint((int)NodeElemTable[elem.Elem_Nodes[i]] - 1);
                        strips.InsertCellPoint((int)NodeElemTable[elem.Elem_Nodes[i + 1]] - 1);
                    }
                    else
                    {
                        strips.InsertCellPoint((int)NodeElemTable[elem.Elem_Nodes[i]] - 1);
                        strips.InsertCellPoint((int)NodeElemTable[elem.Elem_Nodes[0]] - 1);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public VTKFormRender(FormParas paras, TowerModel tmpModel, WorkSpaceClass WorkSpaceInstance)
        {
            this.paras = new FormParas();
            this.paras = paras;
            this.TowerModelInstance = tmpModel;
            this.WorkSpaceInstance  = WorkSpaceInstance;

            InitializeComponent();
        }
Ejemplo n.º 5
0
        public CraftsMode()
        {
            this.InitializeComponent();

            // 在此点之下插入创建对象所需的代码。
            // 在此点之下插入创建对象所需的代码。
            //First: Chart -- Working Status
            Models.WorkStatusDataSeriesGenerator DataSeriesGenerator = new Models.WorkStatusDataSeriesGenerator();

            DataSeriesGenerator.CSVImporter();
            StatusChart.Series.Add(DataSeriesGenerator.GetTowerTopSeries());
            StatusChart.Series.Add(DataSeriesGenerator.GetTowerBottomSeries());
            StatusChart.Series[0].Name   = "塔顶";
            StatusChart.Series[1].Name   = "塔底";
            StatusChart.AnimationEnabled = false;

            //Second: VTK
            Models.CraftsModeExecutor CfExe = new Models.CraftsModeExecutor();
            //Set the environment
            CfExe.CraftsModeEnvSetter(450, 500);
            //MessageBox.Show(this.WinFormGrid.ActualWidth.ToString() + ' ' + this.WinFormGrid.ActualHeight.ToString());
            //Get the Model
            TowerModel CraftsModeTowerModel = CfExe.CraftsModePreExecutor();

            FormParas CraftsModeFormParas = CfExe.CraftsModeFormParasGetter();

            WorkSpaceClass CraftsModeWorkSpaceInstance = CfExe.CraftsModeWorkSpaceInstance();

            VTKFormRender CraftsModeForm = new VTKFormRender(CraftsModeFormParas,
                                                             CraftsModeTowerModel,
                                                             CraftsModeWorkSpaceInstance);

            CraftsModeForm.TopLevel = false;
            CraftsModeWinForm.Child = CraftsModeForm;

            // Third: Append Child of CheckBox
            foreach (Models.HeatDoubler hd in CraftsModeWorkSpaceInstance.HeatDoublerInstances.list)
            {
                CheckBox cb = new CheckBox();
                cb.Content = hd.Name;

                KeyPointsHolder.Children.Add(cb);
            }

            //Fourth: Append Child to the ComboBox
            foreach (Models.CraftsModePreDefinedModelType pd in CfExe.CraftsModeGetModelPreDefined())
            {
                ModelName.Items.Add(pd.GetModelNameString());
            }
        }
Ejemplo n.º 6
0
        private void Menu_Click_1(object sender, RoutedEventArgs e)
        {
            Models.CraftsModeExecutor CfExe = new Models.CraftsModeExecutor();
            //Set the environment
            CfExe.CraftsModeEnvSetter((int)this.WinFormGrid.Width, (int)this.WinFormGrid.Height);

            MenuItem mi = e.Source as MenuItem;

            if (mi.Header.ToString() != "System.Windows.Controls.TextBlock")
            {
                string   mi_header = (string)mi.Header;
                MenuItem mi_parent = (MenuItem)mi.Parent;

                string mi_p_header = (string)mi_parent.Header;

                int StageId = 0, ModelId = 0, SpecialId = 0;
                if (mi_header == "温度模型")
                {
                    StageId   = NameToStageId(mi_p_header);
                    ModelId   = 0;
                    SpecialId = 0;
                }
                else
                {
                    MenuItem mi_pparent   = (MenuItem)mi_parent.Parent;
                    string   mi_pp_header = (string)mi_pparent.Header;

                    StageId   = NameToStageId(mi_pp_header);
                    ModelId   = NameToModelId(mi_p_header);
                    SpecialId = int.Parse(mi_header.Split(' ')[0]);
                }


                CfExe.CraftsModeEnvModelSetter(StageId, ModelId, SpecialId);
                CfExe.CraftsModeEnvStartRunningSetter();

                TowerModel CraftsModeTowerModel = CfExe.CraftsModePreExecutor();

                FormParas      CraftsModeFormParas = CfExe.CraftsModeFormParasGetter();
                WorkSpaceClass CraftsModeWorkSpaceInstance = CfExe.CraftsModeWorkSpaceInstance();

                VTKFormRender CraftsModeForm = new VTKFormRender(CraftsModeFormParas,
                                                                 CraftsModeTowerModel,
                                                                 CraftsModeWorkSpaceInstance);
                CraftsModeForm.TopLevel = false;
                CraftsModeWinForm.Child = CraftsModeForm;
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            WorkSpaceInstance = new WorkSpaceClass();
            storeDB           = new Models.StoreDB();

            //WorkSpaceInfo.DataContext = WorkSpaceInstance;
            // Insert code required on object creation below this point.
            paras                    = new FormParas();
            paras.RotateAngle        = 180;
            paras.UsingEdges         = 1;
            paras.Using3DTower       = 0;
            paras.UsingVirtualHeater = 0;
            paras.Width              = winform.Width;
            paras.Height             = winform.Height;

            VTKFormRender form = new VTKFormRender(paras, null, MainWindow.WorkSpaceInstance);

            form.TopLevel = false;
            winform.Child = form;
        }
Ejemplo n.º 8
0
        public void VTKLabelGetter(ref vtkPoints pointsrc, ref vtkStringArray strArr, ref vtkCellArray cellArr, FormParas paras,
                                   WorkSpaceClass WorkSpaceInstance)
        {
            Models.HeatDoublers hdlist = WorkSpaceInstance.HeatDoublerInstances;

            //MessageBox.Show(hdlist.listSize.ToString());

            strArr.SetNumberOfValues(hdlist.listSize);

            strArr.SetName("111");
            for (int i = 0; i < hdlist.listSize; i++)
            {
                pointsrc.InsertNextPoint(hdlist.list[i].X, 0, -hdlist.list[i].Y);
                strArr.SetValue(i, hdlist.list[i].Name);
                //MessageBox.Show(hdlist.list[i].Name);
                cellArr.InsertNextCell(1);
                cellArr.InsertCellPoint(i);
            }
        }
Ejemplo n.º 9
0
        /*********************************************
        * VTK functions:
        * DrawModel -- Basic function to draw model
        * DrawEdgesModel -- Add grids to the model
        * LabelGetter -- Add label to the model
        *********************************************/
        public int VTKDrawModel(ref vtkPoints points,
                                ref vtkCellArray strips,
                                ref vtkFloatArray scalars,
                                ref int pointsNum,
                                FormParas paras)
        {
            // The following routine is built for general purpose

            for (int i = 0; i < NodeList.Count(); i++)
            {
                points.InsertPoint(i,
                                   NodeList[i].Node_Coord[0],
                                   0,
                                   -NodeList[i].Node_Coord[1]);
            }
            pointsNum = NodeList.Count();

            if (paras.StageID != -1)
            {
                scalars.SetNumberOfValues(ElemList.Count());
            }
            int    cnt          = 0;
            double MAX_R        = 0;
            double MAX_R_VALUE  = 0;
            int    MAX_ELEM_NUM = 0;

            foreach (ListElemBase elem in ElemList)
            {
                strips.InsertNextCell(8);
                if (paras.StageID == -1)
                {
                    scalars.InsertNextValue(elem.Elem_Modeltype[0]);
                }
                else
                {
                    if (IfElemToPropertyKeyExists(elem.Elem_Number))
                    {
                        scalars.SetValue(cnt, (float)GetElemToProperty(elem.Elem_Number));
                    }
                    else
                    {
                        scalars.SetValue(cnt, 0);
                    }
                    //MessageBox.Show(((float)GetElemToProperty(elem.Elem_Number)).ToString());
                }

                for (int i = 0; i < 8; i++)
                {
                    int NodeId = elem.Elem_Nodes[i];
                    int NodePosInPointsArray = GetNodePositionInNodeListFromNodeId(NodeId);
                    strips.InsertCellPoint(NodePosInPointsArray);
                    if (paras.StageID != -1)
                    {
                        if (NodeList[NodePosInPointsArray].Node_Coord[0] > MAX_R)
                        {
                            MAX_R = NodeList[NodePosInPointsArray].Node_Coord[0];
                            if (IfElemToPropertyKeyExists(elem.Elem_Number))
                            {
                                MAX_R_VALUE = GetElemToProperty(elem.Elem_Number);
                            }
                            else
                            {
                                MAX_R_VALUE = 0;
                            }
                            MAX_ELEM_NUM = elem.Elem_Number;
                        }
                    }
                }

                cnt++;
            }
            //MessageBox.Show(MAX_R.ToString() + ' ' + MAX_R_VALUE.ToString() + ' ' + MAX_ELEM_NUM.ToString());

            return(1);
        }
Ejemplo n.º 10
0
        public void ImportModel(string fnNode, string fnEle, FormParas paras)
        {
            ElemList      = new List <ListElemBase>();
            NodeList      = new List <ListNodeBase>();
            NodeElemTable = new Dictionary <int, int>();
            //ElemColorMatcher = new Dictionary<int, int>();

            FileStream   fsNode = new FileStream(fnNode, FileMode.Open, FileAccess.Read);
            FileStream   fsElem = new FileStream(fnEle, FileMode.Open, FileAccess.Read);
            StreamReader srNode = new StreamReader(fsNode);
            StreamReader srElem = new StreamReader(fsElem);

            srNode.BaseStream.Seek(0, SeekOrigin.Begin);
            srElem.BaseStream.Seek(0, SeekOrigin.Begin);

            NodeListSize = ElemListSize = 0;

            // iterate NLIST.lis
            string tmpNode   = srNode.ReadLine();
            int    NodeBegin = 0;

            while (tmpNode != null)
            {
                string[] tmpNodeSplit = Regex.Split(tmpNode.Trim(), " ", RegexOptions.IgnoreCase);
                if (tmpNodeSplit[0] == "NODE")
                {
                    NodeBegin = 1;
                }
                else if (NodeBegin == 1 && tmpNodeSplit[0] != "")
                {
                    int NodeNumber = int.Parse(tmpNodeSplit[0]);

                    double[] Coord = new double[3];
                    int      cnt   = 0;
                    int      start = 0;
                    foreach (string str in tmpNodeSplit)
                    {
                        if (start == 0)
                        {
                            start = 1;
                        }
                        else if (str != "")
                        {
                            Coord[cnt] = System.Convert.ToDouble(str);
                            cnt++;
                        }
                    }
                    NodeList.Add(new ListNodeBase(NodeListSize, NodeNumber, Coord[0], Coord[1], Coord[2]));
                    NodeListSize++;
                }
                tmpNode = srNode.ReadLine();
            }

            /*
             * NodeElemTabel is a map from the node list id to real node id
             */
            int cntn = 0;

            foreach (ListNodeBase node in NodeList)
            {
                NodeElemTable.Add(node.Node_Number, cntn);
                cntn++;
            }


            // iterate ELIST.lis
            string tmpElem   = srElem.ReadLine();
            int    ElemBegin = 0;

            while (tmpElem != null)
            {
                string[] tmpElemSplit = Regex.Split(tmpElem.Trim(), " ", RegexOptions.IgnoreCase);
                if (tmpElemSplit[0] == "ELEM")
                {
                    ElemBegin = 1;
                }
                else if (ElemBegin == 1 && tmpElemSplit[0] != "")
                {
                    int   ElemNumber = int.Parse(tmpElemSplit[0]);
                    int[] M = new int[5];
                    int[] N = new int[8];
                    int   cntM = 0, cntN = 0;
                    int   start = 0;
                    foreach (string str in tmpElemSplit)
                    {
                        if (start == 0)
                        {
                            start++;
                        }
                        else if (str != "")
                        {
                            if (cntM == 5)
                            {
                                N[cntN] = int.Parse(str);
                                cntN++;
                            }
                            else
                            {
                                M[cntM] = int.Parse(str);
                                cntM++;
                            }
                        }
                    }
                    //Elemlist reorder
                    int[] new_N = new int[8];
                    new_N[0] = N[0];
                    new_N[2] = N[1];
                    new_N[4] = N[2];
                    new_N[6] = N[3];
                    new_N[1] = N[4];
                    new_N[3] = N[5];
                    new_N[5] = N[6];
                    new_N[7] = N[7];

                    ElemList.Add(new ListElemBase(ElemNumber, M, new_N));
                    ElemListSize++;
                }
                tmpElem = srElem.ReadLine();
            }

            paras.Using3DTower = 1;
        }