public void FuncMainPostOff(string argv, string strRefMod, string strRefStr, string strOffMod, string strOffStr) { path = argv; this.m_RefMod = strRefMod; this.m_RefStr = strRefStr; this.m_OffMod = strOffMod; this.m_OffStr = strOffStr; pathfile = Path.Combine(path, "MODEL.FIL"); listmodelfilOld = new List <CLabtype>(); listmodelfilNew = new List <CLabtype>(); ViewerUtils.ReadModelFilFile(pathfile, ref listmodelfilOld); pathfile = Path.Combine(path, "OFFSET.FIL"); if (File.Exists(pathfile) == false) { return; } fp2 = new StreamReader(pathfile); fp4 = new StreamWriter(Path.Combine(path, "OFFSETS.REP"), true); fp5 = new StreamWriter(Path.Combine(path, "OFFDAT.FIL"), true); header(); write_input_rep(); fp4.WriteLine(""); //int fp1Pos = 0; while (fp2.EndOfStream == false) /* Input file */ { string strCurfp2Line = fp2.ReadLine(); string[] tok = strCurfp2Line.Split(new char[] { '\t' }); str1 = tok[0]; opnum = short.Parse(str1); if (opnum == 401) { str1 = tok[1]; refmod = tok[2]; str2 = tok[3]; refstr = tok[4]; offind = 0; chndiff = 0; last_chndiff = 0; chn1 = 0; //rewind(fp1); } else if (opnum == 402) { type = 1; str1 = tok[1]; offmod = tok[2]; str2 = tok[3]; offstr = tok[4]; str1 = tok[5]; ch1 = double.Parse(tok[6]); str2 = tok[7]; ch2 = double.Parse(tok[8]); str1 = tok[9]; ho1 = double.Parse(tok[10]); str2 = tok[11]; ho2 = double.Parse(tok[12]); str1 = tok[13]; vo1 = double.Parse(tok[14]); str2 = tok[15]; vo2 = double.Parse(tok[16]); //fscanf(fp2,"%s %s %s %s",str1, offmod, str2, offstr); //fscanf(fp2,"%s %lf %s %lf",str1, &ch1, str2, &ch2); //fscanf(fp2,"%s %lf %s %lf",str1, &ho1, str2, &ho2); //fscanf(fp2,"%s %lf %s %lf",str1, &vo1, str2, &vo2); //rec=0; //rewind(fp1); if (last_offstr != offstr) { offind = 0; } /* * buffer.Format("CREATING OFFSET STRING TYPE 1"); */ try { StreamWriter tmpFile = new StreamWriter(Path.Combine(path, "SCROLL.TMP"), true); tmpFile.WriteLine("CREATING OFFSET STRING TYPE 1"); tmpFile.Close(); } catch { msgstr = "Failed to write display file"; error_msg(); return; } fp4.Write(string.Format("\n MODEL = {0} REFERENCE-STRING LABEL = {1}\n", refmod, refstr)); fp4.Write(string.Format("\n MODEL = {0} OFFSET-STRING LABEL = {1}\n\n", offmod, offstr)); fp4.Write(" CHAINAGE(M) X (M) Y(M) Z(M) H-OFF(M) V-OFF(M)\n\n"); //fprintf(fp4,"\n MODEL = %s REFERENCE-STRING LABEL = %s\n", refmod, refstr); //fprintf(fp4,"\n MODEL = %s OFFSET-STRING LABEL = %s\n\n", offmod, offstr); //fprintf(fp4, " CHAINAGE(M) X (M) Y(M) Z(M) H-OFF(M) V-OFF(M)\n\n"); fp5.Write(string.Format("{0} {1} {2} {3} CH1 {4:f3} CH2 {5:f3} HO1 {6:f3} HO2 {7:f3} VO1 {8:f3} VO2 {9:f3}\n", refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2)); //fprintf(fp5,"%s %s %s %s CH1 %.3f CH2 %.3f HO1 %.3f HO2 %.3f VO1 %.3f VO2 %.3f\n", refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2); reference_string(); //if(find != 1 && label != 999) //{ // //fprintf(fp1,"999\n"); //} } else if (opnum == 403) { type = 2; str1 = tok[1]; offmod = tok[2]; str2 = tok[3]; offstr = tok[4]; str1 = tok[5]; ch1 = double.Parse(tok[6]); str2 = tok[7]; ch2 = double.Parse(tok[8]); str1 = tok[9]; ho1 = double.Parse(tok[10]); str2 = tok[11]; ho2 = double.Parse(tok[12]); str1 = tok[13]; se1 = double.Parse(tok[14]); str2 = tok[15]; se2 = double.Parse(tok[16]); //fscanf(fp2,"%s %s %s %s",str1, offmod, str2, offstr); //fscanf(fp2,"%s %lf %s %lf",str1, &ch1, str2, &ch2); //fscanf(fp2,"%s %lf %s %lf",str1, &ho1, str2, &ho2); //fscanf(fp2,"%s %lf %s %lf",str1, &se1, str2, &se2); //rec=0; //rewind(fp1); if (last_offstr != offstr) { offind = 0; } try { StreamWriter tmpFile = new StreamWriter(Path.Combine(path, "SCROLL.TMP"), true); tmpFile.WriteLine("CREATING OFFSET STRING TYPE 2"); tmpFile.Close(); } catch { msgstr = "Failed to write display file"; error_msg(); return; } fp4.Write(string.Format("\n MODEL = {0} REFERENCE-STRING LABEL = {1}\n", refmod, refstr)); fp4.Write(string.Format("\n MODEL = {0} OFFSET-STRING LABEL = {1}\n", offmod, offstr)); fp4.Write(" CHAINAGE(M) X (M) Y(M) Z(M) H-OFF(M) V-OFF(M)\n\n"); //fprintf(fp4,"\n MODEL = %s REFERENCE-STRING LABEL = %s\n", refmod, refstr); //fprintf(fp4,"\n MODEL = %s OFFSET-STRING LABEL = %s\n", offmod, offstr); //fprintf(fp4, " CHAINAGE(M) X (M) Y(M) Z(M) H-OFF(M) V-OFF(M)\n\n"); vo1 = Math.Abs(ho1) * se1 / 100.0; vo2 = Math.Abs(ho2) * se2 / 100.0; fp5.Write(string.Format("{0} {1} {2} {3} CH1 {4:f3} CH2 {5:f3} HO1 {6:f3} HO2 {7:f3} VO1 {8:f3} VO2 {9:f3}\n" , refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2)); //fprintf(fp5,"%s %s %s %s CH1 %.3f CH2 %.3f HO1 %.3f HO2 %.3f VO1 %.3f VO2 %.3f\n", refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2); reference_string(); //if(find != 1 && label != 999) //{ // //fprintf(fp1,"999\n"); //} } else if (opnum == 404) { type = 3; str1 = tok[1]; offmod = tok[2]; str2 = tok[3]; offstr = tok[4]; str1 = tok[5]; ch1 = double.Parse(tok[6]); str2 = tok[7]; ch2 = double.Parse(tok[8]); str1 = tok[9]; se1 = double.Parse(tok[10]); str2 = tok[11]; se2 = double.Parse(tok[12]); //fscanf(fp2,"%s %s %s %s",str1, submod, str2, substr); //fscanf(fp2,"%s %lf %s %lf",str1, &ch1, str2, &ch2); //fscanf(fp2,"%s %lf %s %lf",str1, &se1, str2, &se2); //rec = 0; //rewind(fp1); if (last_substr != substr) { offind = 0; } try { StreamWriter tmpFile = new StreamWriter(Path.Combine(path, "SCROLL.TMP"), true); tmpFile.WriteLine("CREATING OFFSET STRING TYPE 3"); tmpFile.Close(); } catch { msgstr = "Failed to write display file"; error_msg(); return; } fp4.Write(string.Format("\n MODEL = {0} REFERENCE-STRING LABEL = {1}\n", refmod, refstr)); fp4.Write(string.Format("\n MODEL = {0} OFFSET-STRING LABEL = {1}\n", submod, substr)); fp4.Write(" CHAINAGE(M) CHAINAGE(M) X (M) Y(M) Z(M) H-OFF(M) V-OFF(M)\n"); fp4.Write(" REF. STR. SUB. STR.\n\n"); //fprintf(fp4,"\n MODEL = %s REFERENCE-STRING LABEL = %s\n", refmod, refstr); //fprintf(fp4,"\n MODEL = %s OFFSET-STRING LABEL = %s\n", submod, substr); //fprintf(fp4, " CHAINAGE(M) CHAINAGE(M) X (M) Y(M) Z(M) H-OFF(M) V-OFF(M)\n"); //fprintf(fp4, " REF. STR. SUB. STR.\n\n"); ok2 = 0; //hit = 0; ss_found = 0; vo1 = Math.Abs(ho1) * se1 / 100.0; vo2 = Math.Abs(ho2) * se2 / 100.0; fp5.Write(string.Format("{0} {1} {2} {3} CH1 {4:f3} CH2 {5:f3} HO1 {6:f3} HO2 {7:f3} VO1 {8:f3} VO2 {9:f3}\n", refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2)); //fprintf(fp5,"%s %s %s %s CH1 %.3f CH2 %.3f HO1 %.3f HO2 %.3f VO1 %.3f VO2 %.3f\n", refmod, refstr, offmod, offstr, ch1, ch2, ho1, ho2, vo1, vo2); reference_string(); if (ss_found == 0) { fp4.Write(string.Format("Master Sub-String {0} {1} not found in {2}...!!!" , submod, substr, Path.Combine(path, "MODEL.FIL"))); msgstr = string.Format("Master Sub-String {0} {1} not found in {2}...!!!", submod, substr, Path.Combine(path, "MODEL.FIL")); System.Windows.Forms.MessageBox.Show(msgstr, HeadsUtils.Constants.ProductName); break; } if (find != 1 && label != CLabtype.Type.EndCode) { CLabtype lab = new CLabtype(); lab.attr = CLabtype.Type.EndCode; listmodelfilOld.Add(lab); } last_submod = submod; last_substr = substr; //fclose(fp5); } else { break; } last_offmod = offmod; last_offstr = offstr; } /* while feof */ footer(); listmodelfilOld.AddRange(listmodelfilNew); ViewerUtils.WriteModelFilFile(Path.Combine(path, "MODEL.FIL"), listmodelfilOld); //fclose(fp1); fp2.Close(); fp4.Close(); fp5.Close(); System.Windows.Forms.MessageBox.Show("Design Report is written in file OFFSETS.REP", HeadsUtils.Constants.ProductName); }
void offset_alignment() { CLabtype.Type label = CLabtype.Type.Unknown; short ok; double temp; CLabtype lab; CPTStype pts = new CPTStype(); //CTXTtype txt; CModType mod = null; CStgType stg; ok = 0; cont_ind = 0; if (chn1 > chn2) { temp = chn2; chn2 = chn1; chn1 = temp; } pathfile = Path.Combine(path, "MODEL.FIL"); if (File.Exists(pathfile) == false) { return; } List <CLabtype> listmodelfil = new List <CLabtype>(); ViewerUtils.ReadModelFilFile(pathfile, ref listmodelfil); for (int iIndex = 0; iIndex < listmodelfil.Count; iIndex++) { lab = listmodelfil[iIndex]; label = lab.attr; if (label == CLabtype.Type.EndCode) { ok = 0; } else if (label == CLabtype.Type.Model) { mod = (CModType)lab.Tag; } else if (label == CLabtype.Type.String) { stg = (CStgType)lab.Tag; if (refmod.ToLower() == mod.name.ToLower() && refstg.ToLower() == stg.label.ToLower()) { ok = 1; } } else if (label == CLabtype.Type.Point) { pts = (CPTStype)lab.Tag; chn = pts.mc; mx = pts.mx; my = pts.my; mz = pts.mz; if (ok == 1) { if (cont_ind == 0) { store_last(); lab = listmodelfil[iIndex + 1]; pts = (CPTStype)lab.Tag; chn = pts.mc; mx = pts.mx; my = pts.my; mz = pts.mz; //fsetpos(fp1, &loc1); } if (last_chn2 == chn) { continue; } if (last_x == mx) { mx += 0.001; } if (last_y == my) { my += 0.001; } if ((chn > chn1 && chn < chn2) && chn != last_chn2) { calc_offset(); write_drg(); } if (chn >= chn2) { break; } if (cont_ind == 1) { store_last(); } cont_ind = 1; } // OK=1 } //103 } if (ok == 1) { store_last(); chn = pts.mc + 0.001; mx = pts.mx + 0.001; my = pts.my + 0.001; mz = pts.mz; calc_offset(); write_drg(); } }