// raw_and_pnts.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "mstring.h" // class for reading string until termination character #include #include #include #include #include using namespace std; int main(int argc, char* argv[]) // argv[1] ID type like, V_no_wt, i.e. vertical no weight // argv[2] name to ladder and trace ID, example 5_4, uses Connors numbering //int main() { if(argc!=3) return 0; ifstream ins; char buffer[50]; string in_file_name; string out_pnts_file_name,out_CMM_data_file_name; string out_pnts_tmp_file_name, out_CMM_tmp_file_name; int i; mstring ms; string data_ID = argv[1]; string trace_ID = argv[2]; in_file_name = "Curve Plane " + trace_ID; //cout << "i'm here "<< "\n"; //cout << in_file_name << endl; out_pnts_file_name = data_ID + "_pnts_" + trace_ID + ".txt"; out_CMM_data_file_name = data_ID + "_CMM_" + trace_ID + ".txt"; out_pnts_tmp_file_name = data_ID + "_pnts_" + trace_ID + ".tmpp"; out_CMM_tmp_file_name = data_ID + "_CMM_" + trace_ID + ".tmpd"; //return 0; //count number of x to see how many rows ins.open(in_file_name.c_str()); //if (ins.is_open()) cout << "ins was opened" << endl ; int length=0; do{ ins>>buffer; if(mstring(buffer)=="x"){ length++; } }while(ins.good()); char * *x=new char *[length]; char * *y=new char *[length]; char * *z=new char *[length]; char * *ux=new char *[length]; char * *uy=new char *[length]; char * *uz=new char *[length]; char * *r=new char *[length]; // create arrays with lenght to match number of rows for( i=0;i> buffer; if(mstring(buffer)=="x"){ xflag=1; // scans until finds the x and sets flag that has a row starting with x xsubindex=0; // initialize for count of x,y,z columns xindex++; // uping array counter according to x,y,z row number } if(mstring(buffer)=="kraft"){ uflag=1; // found a kraft row usubindex=0; uindex++; } if(mstring(buffer)=="status/taster"){ rflag=1; // same for the radius row rsubindex=0; rindex++; } // up xubindex only if just read x, otherwise get x y z from next reads after finding the x in column if(xflag==1){ if(xsubindex==1){sprintf(x[xindex],"%s",buffer);} // copy buffer only into element of the x string array if(xsubindex==2){sprintf(y[xindex],"%s",buffer);} if(xsubindex==3){sprintf(z[xindex],"%s",buffer);} xsubindex++; } if(uflag==1){ if(usubindex==1){sprintf(ux[uindex],"%s",buffer);} if(usubindex==2){sprintf(uy[uindex],"%s",buffer);} if(usubindex==3){sprintf(uz[uindex],"%s",buffer);} usubindex++; } if(rflag==1){ if(rsubindex==2){sprintf(r[rindex],"%s",buffer);} rsubindex++; } }while(ins2.good()); //double dx=atof(x[0]); ins2.close(); FILE *p=fopen(out_CMM_data_file_name.c_str(),"w"); //FILE *p=fopen("test.txt","w"); FILE *pnts=fopen(out_pnts_file_name.c_str(),"w"); //FILE *pnts=fopen("test pnts.txt","w"); FILE *pt=fopen(out_CMM_tmp_file_name.c_str(),"w"); FILE *pntst=fopen(out_pnts_tmp_file_name.c_str(),"w"); //cout << rindex ; //fprintf(p,"%10.20f \n",dx); for( i=0;i