using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace vcsT2CNATM_gnuplot { public partial class Form1 : Form { double pi = Math.PI; public Form1() { InitializeComponent(); } //-------------------------------------------------------------------------------------------- private void Form1_Load(object sender, EventArgs e) { pictureBox1.Visible = true; toolStripStatusLabel1.Text = "size and Png file name"; } //-------------------------------------------------------------------------------------------- private void toolStripButton1_Click(object sender, EventArgs e) { main_part(); } //-------------------------------------------------------------------------------------------- private void main_part() { System.IO.StreamReader sr; string fnameR = ""; string fnameW = ""; string fnameF = ""; string fnameZ = ""; string dat; string[] sbuf; char delim = ','; double B, H, W, Ti, ts, tp; double rr, hh, dw, RL, theta, A1, A2, A3, Ae, Ac, Ls; int ksp; int nnn, iii; int[] bboxv=new int[4]; //入力ファイル指定 openFileDialog1.InitialDirectory = System.IO.Directory.GetCurrentDirectory(); if (openFileDialog1.ShowDialog() == DialogResult.OK) { fnameR = openFileDialog1.FileName; } //データ入力 sr = new System.IO.StreamReader(fnameR, System.Text.Encoding.Default); dat = sr.ReadLine(); sbuf = dat.Split(delim); nnn = int.Parse(sbuf[0]); for (iii = 1; iii <= nnn; iii++) { dat = sr.ReadLine(); sbuf = dat.Split(delim); fnameW = sbuf[0].Trim(); //コマンド記述ファイル名*/ fnameF = sbuf[1].Trim(); //出力画像ファイル名*/ ksp = int.Parse(sbuf[2]); //-1:モデル図,0:NATMトンネル*/ B = double.Parse(sbuf[3]); //内空幅*/ H = double.Parse(sbuf[4]); //内空高*/ W = double.Parse(sbuf[5]); //インバート内空幅*/ Ti = double.Parse(sbuf[6]); //インバート厚*/ ts = double.Parse(sbuf[7]); //吹付厚*/ tp = double.Parse(sbuf[8]); //設計線から支払線までの距離*/ bboxv[0] = int.Parse(sbuf[9]); //BoundingBox値*/ bboxv[1] = int.Parse(sbuf[10]); //BoundingBox値*/ bboxv[2] = int.Parse(sbuf[11]); //BoundingBox値*/ bboxv[3] = int.Parse(sbuf[12]); //BoundingBox値*/ // 掘削面積 (Pay line)*/ rr = 0.5 * B; hh = H - rr; dw = rr - 0.5 * W; RL = 0.5 * (hh * hh + dw * dw) / dw; rr = 0.5 * B + ts + tp; hh = H - rr + Ti + tp; theta = Math.Asin(hh / (RL + ts + tp)); A1 = (RL + ts + tp) * (RL + ts + tp) * (theta - Math.Sin(theta) * Math.Cos(theta)); A2 = (B + 2.0 * ts + 2.0 * tp - (RL + ts + tp) * (1.0 - Math.Cos(theta))) * hh; A3 = 0.5 * pi * rr * rr; Ae = A1 + A2 + A3; Ae = Ae * 1e-6; // インバートコン面積 (Concrete)*/ rr = 0.5 * B; hh = H - rr; theta = Math.Asin(hh / RL); Ac = 0.5 * (W + W - 2.0 * Ti * Math.Tan(theta)) * Ti; Ac = Ac * 1e-6; // 吹付長 (Shotcrete)*/ rr = 0.5 * B + ts; hh = H - rr + Ti; theta = Math.Asin(hh / (RL + ts)); Ls = rr * pi + 2.0 * (RL + ts) * theta; Ls = Ls * 1e-3; fnameW = System.IO.Path.GetDirectoryName(fnameR) + "\\" + fnameW; WGPL(fnameW, fnameF, ksp, B, H, W, Ti, ts, tp, Ae, Ac, Ls); //fnameF のフルパス指定 fnameF = System.IO.Path.GetDirectoryName(fnameR) + "\\" + fnameF; //************************************************************** //gnuplot 起動+epsファイル作成 (fnameW: コマンド記述ファイル名) //************************************************************** GPL(fnameW); System.Threading.Thread.Sleep(1000); //1秒待つ //************************************************************** //eps の BoundingBox 修正 (fnameF: eps画像ファイル名) //************************************************************** fnameZ = fnameF.Replace("_eps_", "_eps_z_"); BBOX(fnameF, fnameZ, bboxv); //************************************************************** //ImageMagick による png 画像作成 (fnameZ: eps画像ファイル名) //************************************************************** IMCVT(fnameZ); //************************************************************** //ImageMagick による 白背景合成 (fnameZ: png画像ファイル名) //************************************************************** fnameZ = fnameZ.Replace("eps", "png"); IMCMP(fnameZ); System.Threading.Thread.Sleep(1000); //1秒待つ //************************************************************** //png 画像画面表示 (fnameZ: png画像ファイル名) //************************************************************** fnameZ = fnameZ.Replace("_png_z_", "_png_zw_"); VIEWPNG(fnameZ); } sr.Close(); MessageBox.Show("計算完了","完了通知"); } //-------------------------------------------------------------------------------------------- private void GPL(string fnameR) { //***************************************************** //gnuplot 起動+epsファイル作成 //***************************************************** System.Diagnostics.Process pr; System.IO.StreamWriter sw; string dir = ""; string fname = ""; string dat = ""; dir = System.IO.Path.GetDirectoryName(fnameR); System.IO.Directory.SetCurrentDirectory(dir); fname = System.IO.Path.GetFileName(fnameR); pr = new System.Diagnostics.Process(); pr.StartInfo.FileName = "gnuplot.exe"; pr.StartInfo.RedirectStandardInput = true; pr.StartInfo.RedirectStandardOutput = true; pr.StartInfo.UseShellExecute = false; pr.StartInfo.CreateNoWindow = true; pr.Start(); sw = pr.StandardInput; dat = string.Format("load \"{0:s}\"", fname); sw.WriteLine(dat); sw.Close(); pr.WaitForExit(); pr.Close(); } //-------------------------------------------------------------------------------------------- private void BBOX(string fnameR, string fnameW, int[] bboxv) { System.IO.StreamReader sr; System.IO.StreamWriter sw; string dat; int i; Console.WriteLine("BBOX:fnameR=" + fnameR); Console.WriteLine("BBOX:fnameW=" + fnameW); //データ入力 sr = new System.IO.StreamReader(fnameR, System.Text.Encoding.Default); sw = new System.IO.StreamWriter(fnameW, false, System.Text.Encoding.Default); i = 0; while (!sr.EndOfStream) { i = i + 1; dat = sr.ReadLine(); if (i == 6) dat = string.Format("%%BoundingBox: {0:D} {1:D} {2:D} {3:D}", bboxv[0], bboxv[1], bboxv[2], bboxv[3]); sw.WriteLine(dat); } sr.Close(); sw.Close(); } //-------------------------------------------------------------------------------------------- private void IMCVT(string fnameF) { //***************************************************** //ImageMagick convert で png 画像作成 //***************************************************** string fnameP; System.Diagnostics.Process pr; System.IO.StreamWriter sw; string dat = ""; fnameP = fnameF.Replace("eps", "png"); pr = new System.Diagnostics.Process(); pr.StartInfo.FileName = "cmd.exe"; pr.StartInfo.RedirectStandardInput = true; pr.StartInfo.RedirectStandardOutput = true; pr.StartInfo.UseShellExecute = false; pr.StartInfo.CreateNoWindow = true; pr.Start(); sw = pr.StandardInput; dat = string.Format("convert -density 300 {0:s} {1:s}", fnameF, fnameP); sw.WriteLine(dat); sw.Close(); pr.WaitForExit(); pr.Close(); } //-------------------------------------------------------------------------------------------- private void IMCMP(string fnameZ) { //***************************************************** //ImageMagick convert で 白背景合成画像作成 //***************************************************** string fnameP; string fnameB; System.Diagnostics.Process pr; System.IO.StreamWriter sw; string dat = ""; Image img; int ww; int hh; img = Image.FromFile(fnameZ); ww = img.Width; hh = img.Height; img.Dispose(); fnameP = fnameZ.Replace("_z_", "_zw_"); fnameB = System.IO.Path.GetDirectoryName(fnameP) + "\\base.png"; pr = new System.Diagnostics.Process(); pr.StartInfo.FileName = "cmd.exe"; pr.StartInfo.RedirectStandardInput = true; pr.StartInfo.RedirectStandardOutput = true; pr.StartInfo.UseShellExecute = false; pr.StartInfo.CreateNoWindow = true; pr.Start(); sw = pr.StandardInput; dat = string.Format("convert -size {0:D}x{1:D} xc:\"#FFFFFF\" {2:s}", ww, hh, fnameB); sw.WriteLine(dat); dat = string.Format("convert {0:s} {1:s} -composite {2:s}", fnameB, fnameZ, fnameP); sw.WriteLine(dat); sw.Close(); pr.WaitForExit(); pr.Close(); Console.WriteLine(fnameB + " " + fnameZ + " " + fnameP); } //-------------------------------------------------------------------------------------------- private void VIEWPNG(string fnameZ) { //***************************************************** //png 画像画面表示 (50%縮尺) //***************************************************** Image img; Bitmap bmp; Graphics g; float ratio = 0.5f; int ww; int hh; int w_org; int h_org; img = Image.FromFile(fnameZ); w_org = img.Width; h_org = img.Height; ww = (int)(ratio * w_org); hh = (int)(ratio * h_org); pictureBox1.Size = new Size(ww, hh); bmp = new Bitmap(ww, hh); pictureBox1.Image = bmp; g = Graphics.FromImage(pictureBox1.Image); g.DrawImage(img, 0, 0, ww, hh); g.Dispose(); img.Dispose(); pictureBox1.Left = 0; pictureBox1.Top = toolStrip1.Height; this.ClientSize = new Size(pictureBox1.Width, pictureBox1.Height + toolStrip1.Height + statusStrip1.Height); toolStripStatusLabel1.Text = string.Format("{0:D} x {1:D} : {2:s}", w_org, h_org, fnameZ); } //-------------------------------------------------------------------------------------------- private void WGPL(string fnameW, string fnameF, int ksp, double B, double H, double W, double Ti, double ts, double tp, double Ae, double Ac, double Ls) { System.IO.StreamWriter sw; double xx, yy, x1, y1, x2, y2, x3, y3, x4, y4, xc, yc, phi; double BB, HU, HL, ds, dss, dl; double rr, hh, dw, RL, theta; string dat, str, sv; int i, n = 20; BB = B + 2.0 * ts + 2.0 * tp; HU = H + ts + tp; HL = (Ti + tp); ds = 1000.0; dss = 200.0; dl = 400.0; rr = 0.5 * B; hh = H - rr; dw = rr - 0.5 * W; RL = 0.5 * (hh * hh + dw * dw) / dw; sw = new System.IO.StreamWriter(fnameW, false, System.Text.Encoding.Default); dat = "reset"; sw.WriteLine(dat); dat = "set terminal postscript eps enhanced font \"Helvetica\" 16"; sw.WriteLine(dat); dat = string.Format("set output \"{0:s}\"", fnameF); sw.WriteLine(dat); dat = "#"; sw.WriteLine(dat); dat = "set multiplot"; sw.WriteLine(dat); dat = "#"; sw.WriteLine(dat); dat = "set origin 0,0"; sw.WriteLine(dat); dat = "set size ratio -1"; sw.WriteLine(dat); dat = "#"; sw.WriteLine(dat); dat = "set xrange [-7000:7000]"; sw.WriteLine(dat); dat = "set yrange [-4000:10000]"; sw.WriteLine(dat); dat = "set border 0"; sw.WriteLine(dat); dat = "set xtics 0,0,0"; sw.WriteLine(dat); dat = "set ytics 0,0,0"; sw.WriteLine(dat); dat = "set xtics nomirror"; sw.WriteLine(dat); dat = "set ytics nomirror"; sw.WriteLine(dat); dat = "#"; sw.WriteLine(dat); dat = "set style arrow 1 size graph 0.02,10 filled nohead linewidth 1 linetype 5"; sw.WriteLine(dat);//一点鎖線*/ dat = "set style arrow 2 size graph 0.02,10 filled nohead linewidth 1 linetype 1"; sw.WriteLine(dat);//実線*/ dat = "set style arrow 3 size graph 0.02,10 filled heads linewidth 1 linetype 1"; sw.WriteLine(dat);//両矢印*/ dat = "set style arrow 4 size graph 0.02,10 filled linewidth 1 linetype 1"; sw.WriteLine(dat);//片矢印*/ //一点鎖線*/ x1 = 0.5 * BB + ds + dss; y1 = H - 0.5 * B; x2 = -0.5 * BB - 0.5 * ds; y2 = y1; x3 = 0.0; y3 = -HL - 0.5 * ds; x4 = 0.0; y4 = HU + 0.5 * ds; dat = string.Format("set arrow as 1 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); dat = string.Format("set arrow as 1 from {0:F3},{1:F3} to {2:F3},{3:F3}", x3, y3, x4, y4); sw.WriteLine(dat); dat = "#"; sw.WriteLine(dat); //実線*/ x1 = 0.0; y1 = H + ts; x2 = 0.5 * BB + ds + dss; y2 = y1; dat = string.Format("set arrow as 2 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); x1 = 0.0; y1 = H; x2 = 0.5 * BB + 2.0 * ds + dss; y2 = y1; dat = string.Format("set arrow as 2 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); x1 = 0.0; y1 = 0.0; x2 = 0.5 * BB + 2.0 * ds + dss; y2 = y1; dat = string.Format("set arrow as 2 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); x1 = 0.0; y1 = -Ti; x2 = 0.5 * BB + ds + dss; y2 = y1; dat = string.Format("set arrow as 2 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); x1 = -0.5 * B; y1 = H - 0.5 * B; x2 = x1; y2 = -HL - 2.0 * ds - dss; dat = string.Format("set arrow as 2 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); x1 = 0.5 * B; y1 = H - 0.5 * B; x2 = x1; y2 = -HL - 2.0 * ds - dss; dat = string.Format("set arrow as 2 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); x1 = -0.5 * W; y1 = 0.0; x2 = x1; y2 = -HL - ds - dss; dat = string.Format("set arrow as 2 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); x1 = 0.5 * W; y1 = 0.0; x2 = x1; y2 = -HL - ds - dss; dat = string.Format("set arrow as 2 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); //両矢印*/ str = (0.5 * B).ToString("0"); sv = " rotate by 90"; x1 = 0.5 * BB + ds; y1 = H - 0.5 * B; x2 = x1; y2 = H; x3 = x1 - dl; y3 = 0.5 * (y1 + y2); dat = string.Format("set arrow as 3 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "r"; sv = ""; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center{3:s}", str, x3, y3, sv); sw.WriteLine(dat); str = hh.ToString("0"); sv = " rotate by 90"; x1 = 0.5 * BB + ds; y1 = 0.0; x2 = x1; y2 = H - 0.5 * B; x3 = x1 - dl; y3 = 0.5 * (y1 + y2); dat = string.Format("set arrow as 3 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "h"; sv = ""; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center{3:s}", str, x3, y3, sv); sw.WriteLine(dat); str = H.ToString("0"); sv = " rotate by 90"; x1 = 0.5 * BB + 2.0 * ds; y1 = 0.0; x2 = x1; y2 = H; x3 = x1 - dl; y3 = 0.5 * (y1 + y2); dat = string.Format("set arrow as 3 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "H"; sv = ""; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center{3:s}", str, x3, y3, sv); sw.WriteLine(dat); str = W.ToString("0"); x1 = -0.5 * W; y1 = -HL - ds; x2 = 0.5 * W; y2 = y1; x3 = 0.5 * (x1 + x2); y3 = y2 - dl; dat = string.Format("set arrow as 3 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "W"; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center", str, x3, y3); sw.WriteLine(dat); str = B.ToString("0"); x1 = -0.5 * B; y1 = -HL - 2.0 * ds; x2 = 0.5 * B; y2 = y1; x3 = 0.5 * (x1 + x2); y3 = y2 - dl; dat = string.Format("set arrow as 3 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "B"; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center", str, x3, y3); sw.WriteLine(dat); //片矢印*/ str = ts.ToString("0"); sv = " rotate by 90"; x1 = 0.5 * BB + ds; y1 = H + ts + 0.7 * ds; x2 = x1; y2 = H + ts; x3 = x1 + dl; y3 = 0.5 * (y2 + H); dat = string.Format("set arrow as 4 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "t{/=14 s}"; sv = ""; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center{3:s}", str, x3, y3, sv); sw.WriteLine(dat); str = Ti.ToString("0"); sv = " rotate by 90"; x1 = 0.5 * BB + ds; y1 = -(Ti + 0.7 * ds); x2 = x1; y2 = -Ti; x3 = x1 + dl; y3 = 0.5 * (y2); dat = string.Format("set arrow as 4 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "T{/=14 I}"; sv = ""; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center{3:s}", str, x3, y3, sv); sw.WriteLine(dat); str = dw.ToString("0"); x1 = -0.5 * B - 0.7 * ds; y1 = -HL - ds; x2 = -0.5 * B; y2 = y1; x3 = 0.5 * (x2 - 0.5 * W); y3 = y1 - dl; dat = string.Format("set arrow as 4 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "dw"; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center", str, x3, y3); sw.WriteLine(dat); str = dw.ToString("0"); x1 = 0.5 * B + 0.7 * ds; y1 = -HL - ds; x2 = 0.5 * B; y2 = y1; x3 = 0.5 * (x2 + 0.5 * W); y3 = y1 - dl; dat = string.Format("set arrow as 4 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "dw"; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center", str, x3, y3); sw.WriteLine(dat); str = string.Format("r={0:F0}", 0.5 * B); x1 = 0.0; y1 = H - 0.5 * B; x2 = rr * Math.Cos(45.0 / 180.0 * pi); y2 = y1 + rr * Math.Sin(45.0 / 180.0 * pi); x3 = 0.5 * x2 - dl * Math.Sin(45.0 / 180.0 * pi); y3 = y1 + 0.5 * rr * Math.Sin(45.0 / 180.0 * pi) + dl * Math.Cos(45.0 / 180.0 * pi); dat = string.Format("set arrow as 4 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "r"; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center rotate by 45", str, x3, y3); sw.WriteLine(dat); str = string.Format("R={0:F0}", RL); theta = 0.5 * Math.Asin(hh / RL) / pi * 180.0; x1 = (RL - rr) - (RL - 0.45 * W) * Math.Cos(theta / 180.0 * pi); y1 = (H - 0.5 * B) - (RL - 0.45 * W) * Math.Sin(theta / 180.0 * pi); x2 = (RL - rr) - RL * Math.Cos(theta / 180.0 * pi); y2 = (H - 0.5 * B) - RL * Math.Sin(theta / 180.0 * pi); x3 = (RL - rr) - (RL - 0.1 * W) * Math.Cos(theta / 180.0 * pi) - dl * Math.Sin(theta / 180.0 * pi); y3 = (H - 0.5 * B) - (RL - 0.1 * W) * Math.Sin(theta / 180.0 * pi) + dl * Math.Cos(theta / 180.0 * pi); dat = string.Format("set arrow as 4 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); if (ksp < 0) { str = "R"; } dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} left rotate by {3:F3}", str, x3, y3, theta); sw.WriteLine(dat); if (ksp < 0) { theta = 45.0; x1 = -(0.5 * B + ts - ds) * Math.Cos(theta / 180.0 * pi); y1 = H - 0.5 * B + (0.5 * B + ts - ds) * Math.Sin(theta / 180.0 * pi); x2 = -(0.5 * B + ts) * Math.Cos(theta / 180.0 * pi); y2 = H - 0.5 * B + (0.5 * B + ts) * Math.Sin(theta / 180.0 * pi); dat = string.Format("set arrow as 4 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); str = "t{/=14 p}"; x1 = -(0.5 * B + ts + tp + ds) * Math.Cos(theta / 180.0 * pi); y1 = H - 0.5 * B + (0.5 * B + ts + tp + ds) * Math.Sin(theta / 180.0 * pi); x2 = -(0.5 * B + ts + tp) * Math.Cos(theta / 180.0 * pi); y2 = H - 0.5 * B + (0.5 * B + ts + tp) * Math.Sin(theta / 180.0 * pi); x3 = 0.5 * (x1 + x2) + dl * Math.Sin(theta / 180.0 * pi); y3 = 0.5 * (y1 + y2) + dl * Math.Cos(theta / 180.0 * pi); dat = string.Format("set arrow as 4 from {0:F3},{1:F3} to {2:F3},{3:F3}", x1, y1, x2, y2); sw.WriteLine(dat); dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3} center rotate by {3:F3}", str, x3, y3, -theta); sw.WriteLine(dat); } dat = "#"; if (0<=ksp) { //数量描画*/ x3 = 0.0; str = string.Format("Ae={0:F1} {1:s}",Ae,"m^{/=10 2}"); y3 = 8000.0; dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3}", str, x3, y3); sw.WriteLine(dat); str = string.Format("Ac={0:F1} {1:s}",Ac,"m^{/=10 2}"); y3 = 7500.0; dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3}", str, x3, y3); sw.WriteLine(dat); str = string.Format("Ls={0:F1} {1:s}",Ls,"m"); y3 = 7000.0; dat = string.Format("set label \"{0:s}\" at {1:F3},{2:F3}", str, x3, y3); sw.WriteLine(dat); } dat = "#"; sw.WriteLine(dat); //構造線描画*/ dat = "plot \"-\" with lines linewidth 5 linetype 1 notitle,\\"; sw.WriteLine(dat); //吹付外形線*/ if (ksp < 0) { dat = "\"-\" with lines linewidth 3 linetype 2 notitle,\\"; sw.WriteLine(dat); } //支払い線*/ dat = "\"-\" with lines linewidth 5 linetype 1 notitle,\\"; sw.WriteLine(dat); //吹付内形線*/ dat = "\"-\" with lines linewidth 5 linetype 1 notitle,\\"; sw.WriteLine(dat); //吹付内形線*/ dat = "\"-\" with lines linewidth 5 linetype 1 notitle"; sw.WriteLine(dat); //インバート線*/ //吹付外形(一挙に書く)*/ xc = RL - rr; yc = H - 0.5 * B; yy = hh + Ti; theta = Math.Asin(yy / (RL + ts)) / pi * 180.0; phi = 0.0; for (i = 0; i <= n; i++) { phi = theta / (double)n * (double)i; xx = xc - (RL + ts) * Math.Cos(phi / 180.0 * pi); yy = yc - (RL + ts) * Math.Sin(phi / 180.0 * pi); dat = string.Format("{0:F3} {1:F3}", xx, yy); sw.WriteLine(dat); } xc = rr - RL; yc = H - 0.5 * B; phi = 0.0; for (i = n; i >= 0; i--) { phi = theta / (double)n * (double)i; xx = xc + (RL + ts) * Math.Cos(phi / 180.0 * pi); yy = yc - (RL + ts) * Math.Sin(phi / 180.0 * pi); dat = string.Format("{0:F3} {1:F3}", xx, yy); sw.WriteLine(dat); } dat = "e"; sw.WriteLine(dat); if (ksp < 0) { //支払い線(一挙に書く)*/ xc = RL - rr; yc = H - 0.5 * B; yy = hh + Ti + tp; theta = Math.Asin(yy / (RL + ts + tp)) / pi * 180.0; phi = 0.0; for (i = 0; i <= n; i++) { phi = theta / (double)n * (double)i; xx = xc - (RL + ts + tp) * Math.Cos(phi / 180.0 * pi); yy = yc - (RL + ts + tp) * Math.Sin(phi / 180.0 * pi); dat = string.Format("{0:F3} {1:F3}", xx, yy); sw.WriteLine(dat); } xc = rr - RL; yc = H - 0.5 * B; phi = 0.0; for (i = n; i >= 0; i--) { phi = theta / (double)n * (double)i; xx = xc + (RL + ts + tp) * Math.Cos(phi / 180.0 * pi); yy = yc - (RL + ts + tp) * Math.Sin(phi / 180.0 * pi); dat = string.Format("{0:F3} {1:F3}", xx, yy); sw.WriteLine(dat); } dat = "e"; sw.WriteLine(dat); } //吹付内形*/ xc = RL - rr; yc = H - 0.5 * B; yy = hh + Ti; theta = Math.Asin(yy / RL) / pi * 180.0; phi = 0.0; for (i = 0; i <= n; i++) { phi = theta / (double)n * (double)i; xx = xc - RL * Math.Cos(phi / 180.0 * pi); yy = yc - RL * Math.Sin(phi / 180.0 * pi); dat = string.Format("{0:F3} {1:F3}", xx, yy); sw.WriteLine(dat); } dat = "e"; sw.WriteLine(dat); xc = rr - RL; yc = H - 0.5 * B; phi = 0.0; for (i = 0; i <= n; i++) { phi = theta / (double)n * (double)i; xx = xc + RL * Math.Cos(phi / 180.0 * pi); yy = yc - RL * Math.Sin(phi / 180.0 * pi); dat = string.Format("{0:F3} {1:F3}", xx, yy); sw.WriteLine(dat); } dat = "e"; sw.WriteLine(dat); //インバート線*/ xx = -0.5 * W; yy = 0.0; dat = string.Format("{0:F3} {1:F3}", xx, yy); sw.WriteLine(dat); xx = 0.5 * W; yy = 0.0; dat = string.Format("{0:F3} {1:F3}", xx, yy); sw.WriteLine(dat); dat = "e"; sw.WriteLine(dat); //円形部描画*/ dat = "set origin 0,0"; sw.WriteLine(dat); dat = "set parametric"; sw.WriteLine(dat); dat = "set trange [0:pi]"; sw.WriteLine(dat); dat = string.Format("plot {0:F3}*cos(t),{1:F3}+{2:F3}*sin(t) with lines linewidth 5 linetype 1 notitle,\\", rr, H - 0.5 * B, rr); sw.WriteLine(dat); //内空*/ if (ksp < 0) { dat = string.Format("{0:F3}*cos(t),{1:F3}+{2:F3}*sin(t) with lines linewidth 3 linetype 2 notitle,\\", rr + ts + tp, H - 0.5 * B, rr + ts + tp); sw.WriteLine(dat); } //支払い線*/ dat = string.Format("{0:F3}*cos(t),{1:F3}+{2:F3}*sin(t) with lines linewidth 5 linetype 1 notitle", rr + ts, H - 0.5 * B, rr + ts); sw.WriteLine(dat); //掘削径*/ dat = "#"; sw.WriteLine(dat); dat = "#"; sw.WriteLine(dat); dat = "unset multiplot"; sw.WriteLine(dat); dat = "#"; sw.WriteLine(dat); dat = "quit"; sw.WriteLine(dat); dat = "#"; sw.WriteLine(dat); sw.Close(); } //-------------------------------------------------------------------------------------------- } }