home *** CD-ROM | disk | FTP | other *** search
- #include "opps.h"
-
- /* opps() is a main function for drawing true part's graphics.
- When adding a part, you must insert a segment program to control
- parameters extraction and call keypoint generation function */
-
- opps()
- {
- char substr[16],record[50][80],type[10];
- int len,len1,i,zjflag,size;
- float m,rs,D,D1,D2,D3,D4,D5,B,B1,b,d,d0,d1,d2,d3,d4,C,C1,C2,C3,f,f1;
- float e,e1,e2,n,n1,l,L,R,R1,R2,R3,H,wg,t1;
- float B2,B3,B4,B5,B6,B7,h1,H1,H2,h2,h,R4,R5,R6,R7,b2,b1;
- double a,a1,rotation,alpha,insangle;
- FILE *pa1pnter,*pa2pnter;
- USvar_val *vval,mval;
-
- /* When you need to call GWCLIB, you must call GWInit() to initialize
- graphics environment. in addition, you need to extract values of
- system varible in GWLISP function. */
-
- GWInit();
- vval = GWGetVar("USERI5");
- nFlag = vval->key;
- vval = GWGetVar("USERP5");
- ins_point.x = vval->point.x;
- ins_point.y = vval->point.y;
-
- vval = GWGetVar("USERR5");
- rotang = vval->dis;
- vval = GWGetVar("USERI4");
- dimflag = vval->key;
-
- /* Default linetype is CONTINUOUS, default color is RED */
- ltflag = 0 ;
- coflag = 1 ;
-
- /* There are searching result in file opps.pa1 */
- if(( pa1pnter = fopen("..\\tmp\\opps.pa1","r+t")) == NULL)
- {
- errorno = 1;
- goto exit;
- }
- fgets(record[0],80,pa1pnter);
- strcpy(PRname,record[0]);
- len=strlen(PRname) - 1;
- PRname[len]='\0';
- fgets(record[0],80,pa1pnter);
- size = atoi(record[0]);
- for( i = 0 ; i < size ; i++ )
- {
- fgets(record[i],80,pa1pnter);
- }
-
- len = strlen( PRname );
- if ((( len == 6 ) && (strncmp(PRname,"zb123y",len) == 0 ))
- || (( len == 7 ) && (strncmp(PRname,"zb123zj",len) == 0 )))
- {
- D = atof( record[3] ); /* process zb123y's parameters */
- D1 = atof( record[4] );
- D2 = atof( record[5] );
- B = atof( record[6] );
- R1 = atof( record[7] );
- R2 = atof( record[8] );
- C = atof( record[9] );
- C1 = atof( record[10] );
- C2 = atof( record[11] );
- f = atof( record[12] ) * 180.0 / PI ;
- f1 = atof( record[13] ) * 180.0 / PI ;
- /* process varible parameters in MDT file */
- arrayparam[1][1] = f1 ;
- arrayparam[0][0] = atof( record[14] );
- arrayparam[0][1] = 360.0 / arrayparam[0][0] ;
- arrayparam[1][0] = atof( record[15] );
-
- H = atof( record[16] );
- strcpy( type, record[17] );
- len1 = strlen( type );
- Formsubstr( type, 1, len1, substr );
- d4 = atof( substr );
- d3 = atof( record[18] );
- if(( len == 7 ) && (strncmp(PRname,"zb123zj",len) == 0 ))
- {
- /* process zb123zj's parameters that are different from zb123y's */
- D3 = atof( record[19] );
- D4 = atof( record[20] );
- D5 = atof( record[21] );
- B1 = atof( record[22] );
- R3 = atof( record[23] );
- C3 = atof( record[24] );
- d2 = atof( record[25] );
- L = atof( record[26] );
- l = atof( record[27] );
- wg = atof( record[28] );
- b = atof( record[29] );
- t1 = atof( record[30] );
- }
- else
- {
- d2 = atof( record[19] );
- L = atof( record[20] );
- wg = atof( record[21] );
- b = atof( record[22] );
- t1 = atof( record[23] );
- }
- e1 = 2.0;
- e2 = 1.0;
- if( nFlag == 0 )
- {
- if (( len == 6 ) && (strncmp(PRname,"zb123y",len) == 0 ))
- {
- FormPzb123yR((double)D,(double)D1,(double)D2,(double)B,
- (double)R1,(double)R2,(double)C,(double)C1,
- (double)C2,(double)d3,(double)d2,(double)L,
- (double)b,(double)e1,(double)e2);
- }
- else
- {
- vval = GWGetVar("USERI1");
- zjflag = vval->key;
- FormPzb123zjR((double)D,(double)D1,(double)D2,(double)B,
- (double)R1,(double)R2,(double)C,(double)C1,
- (double)C2,(double)d3,(double)D3,(double)D4,
- (double)D5,(double)B1,(double)R3,(double)C3,
- (double)d2,(double)L,(double)l,(double)b,
- (double)e1,(double)e2,zjflag);
- }
- }
- else
- {
- FormPzb123yX((double)D,(double)D1,(double)D2,(double)C,
- (double)C1,(double)C2,(double)f,(double)f1,
- (double)d2,(double)d3,(double)d4,(double)b,
- (double)t1,(double)e1,(double)e2);
- if (( len == 7 ) && (strncmp(PRname,"zb123zj",len) == 0 ))
- {
- ptArray[33].x= D3 / 2.0 - C3 ;
- ptArray[33].y= 0.0 ;
- ptArray[34].x= D3 / 2.0 ;
- ptArray[34].y= 0.0 ;
- }
- }
- }
- if (( len == 4 ) && (strncmp(PRname,"zb80",len) == 0 ))
- {
- D = atof( record[1] ); /* process zb80 's parameters */
- D1 = atof( record[2] );
- D2 = atof( record[3] );
- D3 = atof( record[4] );
- C = atof( record[5] );
- C1 = atof( record[6] );
- B2 = atof( record[9] );
- B3 = atof( record[10] );
- B4 = atof( record[11] );
- B6 = atof( record[13] );
- B7 = atof( record[14] );
- L = atof( record[15] );
- h = atof( record[16] );
- h1 = atof( record[17] );
- h2 = atof( record[18] );
- H = atof( record[19] );
- H1 = atof( record[20] );
- H2 = atof( record[21] );
- b = atof( record[22] );
- R1 = atof( record[25] );
- R2 = atof( record[26] );
- R6 = atof( record[30] );
- d1 = atof( record[32] );
- e1 = atof( record[33] );
- wg = atof( record[34] );
- FormPzb80R((double)D,(double)D1,(double)D2,(double)D3,
- (double)C ,(double)C1,(double)B2,(double)B3,(double)B4,
- (double)B6,(double)B7,(double)L ,(double)h ,(double)h1,
- (double)h2,(double)H,(double)H1,(double)H2,(double)b,
- (double)R1,(double)R2,(double)R6,(double)d1,(double)e1);
- }
-
- /* You can add more part parameter controlling programs here */
-
- fclose(pa1pnter);
-
- /* Call opps.lib to draw entities that is describe by MDT file */
-
- FormIGR( "..\\lib\\partmdf.mdf", "..\\lib\\partmdf.inx" );
-
- /* LOADGWD statement in opps.lsp will use this GWD file */
- GWSave("opps");
-
- exit:
-
- if(( pa2pnter = fopen("..\\tmp\\opps.pa2","w+t")) != NULL)
- {
- sprintf(type,"%d\n",errorno );
- fwrite( type, strlen(type),1,pa2pnter );
- fclose(pa2pnter);
- }
- exit();
- }
-
-