コード例 #1
0
ファイル: WFEM_NegVideo.cs プロジェクト: wuxiaod1987/WCAE
        public static WFEM_NegOut Create(ref WFEM_NegPara NP, WMesh2D_Mesh Mesh, string ResultFile, String ProgramPath, String[] Titles)
        {
            double[] RESM = new double[2];
            RESM = FindLimit(ResultFile);   /////如果不限制最大/最小值则需要找到最大/最小值
            StreamReader sr = new StreamReader(ResultFile);

            sr.ReadLine();
            int Quan_Frames = Convert.ToInt16(sr.ReadLine());

            sr.ReadLine();
            int Quan_Nodes = Convert.ToInt16(sr.ReadLine());

            sr.ReadLine();
            /////
            double[] RES  = new double[Quan_Nodes + 1];
            String   Path = NP.PicPath;
            String   Name = NP.PicName;

            NP.PicPath = Path + "VT" + DateTime.Now.TimeOfDay.ToString().Replace(":", "");
            Directory.CreateDirectory(NP.PicPath);
            NP.PicPath += "\\";
            WFEM_NegOut ParaOut = null;

            for (int i = 0; i < Quan_Frames; i++)
            {
                if (NP.VidTitleOut == true && Titles.Length == Quan_Frames)
                {
                    NP.PicTitle = Titles[i];
                }
                //Debugger.Break();
                for (int j = 1; j <= Quan_Nodes; j++)
                {
                    RES[j] = Convert.ToDouble(sr.ReadLine());
                }
                sr.ReadLine();
                NP.PicName = (i + 1).ToString();
                ParaOut    = WFEM_NegContour.Draw_to_PNG(ref NP, Mesh, ref RES, ref RESM);
            }
            //=============================//
            Process Proc = new Process();
            String  Arg  = NP.PicPath + ",";

            Arg += (Path + Name + ".avi" + ",");
            Arg += (NP.PicWidth.ToString() + ",");
            Arg += (NP.PicHeight.ToString() + ",");
            Arg += (NP.VidFrameRate.ToString() + ",");
            Arg += (Quan_Frames.ToString() + ",");
            /////
            Proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            Proc.StartInfo.FileName    = ProgramPath + "\\VideoCreator\\VideoCreator.exe";
            //Console.WriteLine(Proc.StartInfo.FileName);
            Proc.StartInfo.Arguments = Arg;
            Proc.Start();
            ///
            NP.PicPath = Path;
            NP.PicName = Name;
            return(ParaOut); /////返回最后一帧的结果
        }
コード例 #2
0
        /// 绘制2D结果的云图
        /// <summary>
        /// 绘制2D结果的云图
        /// </summary>
        /// <param name="NP">云图绘制参数</param>
        /// <param name="Mesh">需要绘制的Mesh</param>
        /// <param name="RES">每个节点的结果数组,数组编号应与节点编号一致</param>
        /// <returns></returns>
        public static WFEM_NegOut Draw_to_PNG(ref WFEM_NegPara NP, WMesh2D_Mesh Mesh, ref double[] RES)
        {
            WFEM_NegOut ParaOut = new WFEM_NegOut();

            ParaOut.RES = RES;
            Bitmap bitmap = Draw_to_Bitmap(ref NP, Mesh, ref RES, ref ParaOut);

            /////保存并结束
            bitmap.Save(NP.PicPath + NP.PicName + ".png");
            bitmap.Dispose();
            return(ParaOut);
        }
コード例 #3
0
        private static Bitmap Draw_to_Bitmap(ref WFEM_NegPara NP, WMesh2D_Mesh Mesh, ref double[] RES, ref WFEM_NegOut ParaOut)
        {
            #region 结果的最小值,最大值
            double[] RESM_in = new double[0]; int[] NodeM_in = new int[0];
            Compute_ResPara(ref RES, ref RESM_in, ref NodeM_in);
            //Debugger.Break();
            if (ParaOut.RESM == null)
            {
                ParaOut.RESM  = RESM_in;
                ParaOut.NodeM = NodeM_in;
            }
            #endregion

            #region 求取颜色变量
            ParaOut.Res_Each = Compute_ResEach(ref NP, ref RES, ref ParaOut.RESM);
            #endregion

            #region "初始化绘图工具"
            Bitmap   bitmap  = new Bitmap(NP.PicWidth, NP.PicHeight);
            Graphics graphic = Graphics.FromImage(bitmap);
            graphic.Clear(NP.Color_BackGround);
            #endregion

            #region 绘制Lable及Title
            int LableHeight = NP.PicRim;
            if (NP.ShowLable == true)
            {
                LableHeight = Draw_Label(ref NP, ref graphic, ref ParaOut.Res_Each);  /////绘制Label
            }
            int TitleHeight = NP.PicRim;
            if (NP.ShowTitle == true)
            {
                TitleHeight = Draw_Title(ref NP, ref graphic, NP.PicTitle);   /////绘制Title
            }
            #endregion

            #region 求取绘图比例
            double[] DrawRate = Compute_DrawRate((Mesh.Xmax - Mesh.Xmin),     /////求取绘图比例
                                                 (Mesh.Ymax - Mesh.Ymin),
                                                 NP.PicWidth - NP.PicRim * 2,
                                                 NP.PicHeight - TitleHeight - LableHeight);
            #endregion

            /////绘制所有单元
            ParaOut.Areas = Draw_Elements(ref NP, ref Mesh,
                                          ref RES, ref ParaOut.Res_Each,
                                          ref graphic, ref DrawRate, LableHeight);

            /////绘制最大值最小值
            Draw_MaxMin(ref NP, ref graphic, Mesh,
                        RESM_in, NodeM_in,
                        DrawRate, NP.PicHeight - LableHeight, TitleHeight);

            graphic.Dispose();
            return(bitmap);
        }