home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p043 / 7.ddi / GWCAD / OPPS / FORMPARA.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-23  |  6.9 KB  |  201 lines

  1. #include "opps.h"
  2.  
  3. /*   opps() is a main function for drawing true part's graphics.
  4.      When adding a part, you must insert a segment program to control
  5.      parameters extraction and call keypoint generation function  */
  6.  
  7. opps()
  8. {
  9. char     substr[16],record[50][80],type[10];
  10. int      len,len1,i,zjflag,size;
  11. float    m,rs,D,D1,D2,D3,D4,D5,B,B1,b,d,d0,d1,d2,d3,d4,C,C1,C2,C3,f,f1;
  12. float    e,e1,e2,n,n1,l,L,R,R1,R2,R3,H,wg,t1;
  13. float    B2,B3,B4,B5,B6,B7,h1,H1,H2,h2,h,R4,R5,R6,R7,b2,b1;
  14. double   a,a1,rotation,alpha,insangle;
  15. FILE     *pa1pnter,*pa2pnter;
  16. USvar_val *vval,mval;
  17.  
  18. /*  When you need to call GWCLIB, you must call GWInit() to initialize
  19.     graphics environment. in addition, you need to extract values of 
  20.     system varible in GWLISP function.   */
  21.  
  22.     GWInit();
  23.     vval = GWGetVar("USERI5");
  24.     nFlag = vval->key;
  25.     vval = GWGetVar("USERP5");
  26.     ins_point.x = vval->point.x;
  27.     ins_point.y = vval->point.y;
  28.  
  29.     vval = GWGetVar("USERR5");
  30.     rotang = vval->dis;
  31.     vval = GWGetVar("USERI4");
  32.     dimflag = vval->key;
  33.  
  34. /*  Default linetype is CONTINUOUS, default color is RED  */
  35.     ltflag = 0 ;
  36.     coflag = 1 ;
  37.  
  38. /*  There are searching result in file opps.pa1   */
  39.     if(( pa1pnter = fopen("..\\tmp\\opps.pa1","r+t")) == NULL)
  40.     {
  41.         errorno = 1;
  42.         goto exit;
  43.     }
  44.     fgets(record[0],80,pa1pnter);
  45.     strcpy(PRname,record[0]);
  46.     len=strlen(PRname) - 1;
  47.     PRname[len]='\0';
  48.     fgets(record[0],80,pa1pnter);
  49.     size = atoi(record[0]);
  50.     for( i = 0 ; i < size ; i++ )
  51.     {
  52.         fgets(record[i],80,pa1pnter);
  53.     }
  54.  
  55.    len = strlen( PRname );
  56.    if ((( len == 6 ) && (strncmp(PRname,"zb123y",len) == 0 ))
  57.    || (( len == 7 ) && (strncmp(PRname,"zb123zj",len) == 0 )))
  58.    {
  59.            D = atof( record[3] );    /* process zb123y's parameters */
  60.            D1 = atof( record[4] );
  61.            D2 = atof( record[5] );
  62.            B = atof( record[6] );
  63.            R1 = atof( record[7] );
  64.            R2 = atof( record[8] );
  65.            C = atof( record[9] );
  66.            C1 = atof( record[10] );
  67.            C2 = atof( record[11] );
  68.            f = atof( record[12] ) * 180.0 / PI ;
  69.            f1 = atof( record[13] ) * 180.0 / PI ;
  70. /* process varible parameters in MDT file */
  71.            arrayparam[1][1] = f1 ; 
  72.            arrayparam[0][0] = atof( record[14] );
  73.            arrayparam[0][1] = 360.0 / arrayparam[0][0] ;
  74.            arrayparam[1][0] = atof( record[15] );
  75.  
  76.            H = atof( record[16] );
  77.            strcpy( type, record[17] );
  78.            len1 = strlen( type );
  79.            Formsubstr( type, 1, len1, substr );
  80.            d4 = atof( substr );
  81.            d3 = atof( record[18] );
  82.            if(( len == 7 ) && (strncmp(PRname,"zb123zj",len) == 0 ))
  83.            {
  84. /* process zb123zj's parameters that are different from zb123y's  */
  85.                D3 = atof( record[19] );
  86.                D4 = atof( record[20] );
  87.                D5 = atof( record[21] );
  88.                B1 = atof( record[22] );
  89.                R3 = atof( record[23] );
  90.                C3 = atof( record[24] );
  91.                d2 = atof( record[25] );
  92.                L = atof( record[26] );
  93.                l = atof( record[27] );
  94.                wg = atof( record[28] );
  95.                b = atof( record[29] );
  96.                t1 = atof( record[30] );
  97.            }
  98.            else
  99.            {
  100.                d2 = atof( record[19] );
  101.                L = atof( record[20] );
  102.                wg = atof( record[21] );
  103.                b = atof( record[22] );
  104.                t1 = atof( record[23] );
  105.            }
  106.            e1 = 2.0;
  107.            e2 = 1.0;
  108.            if( nFlag == 0 )
  109.            {
  110.                if (( len == 6 ) && (strncmp(PRname,"zb123y",len) == 0 ))
  111.                {
  112.                    FormPzb123yR((double)D,(double)D1,(double)D2,(double)B,
  113.                        (double)R1,(double)R2,(double)C,(double)C1,
  114.                        (double)C2,(double)d3,(double)d2,(double)L,
  115.                        (double)b,(double)e1,(double)e2);
  116.                }
  117.                else
  118.                {
  119.                    vval = GWGetVar("USERI1");
  120.                    zjflag = vval->key;
  121.                    FormPzb123zjR((double)D,(double)D1,(double)D2,(double)B,
  122.                        (double)R1,(double)R2,(double)C,(double)C1,
  123.                        (double)C2,(double)d3,(double)D3,(double)D4,
  124.                        (double)D5,(double)B1,(double)R3,(double)C3,
  125.                        (double)d2,(double)L,(double)l,(double)b,
  126.                        (double)e1,(double)e2,zjflag);
  127.                }
  128.            }
  129.            else
  130.            {
  131.                FormPzb123yX((double)D,(double)D1,(double)D2,(double)C,
  132.                            (double)C1,(double)C2,(double)f,(double)f1,
  133.                            (double)d2,(double)d3,(double)d4,(double)b,
  134.                            (double)t1,(double)e1,(double)e2);
  135.                if (( len == 7 ) && (strncmp(PRname,"zb123zj",len) == 0 ))
  136.                {
  137.                    ptArray[33].x= D3 / 2.0 - C3 ;
  138.                    ptArray[33].y= 0.0 ;
  139.                    ptArray[34].x= D3 / 2.0 ;
  140.                    ptArray[34].y= 0.0 ;
  141.                }
  142.            }
  143.     }
  144.     if (( len == 4 ) && (strncmp(PRname,"zb80",len) == 0 ))
  145.     {
  146.         D = atof( record[1] );     /* process zb80 's parameters */
  147.         D1 = atof( record[2] );
  148.         D2 = atof( record[3] );
  149.         D3 = atof( record[4] );
  150.         C  = atof( record[5] );
  151.         C1 = atof( record[6] );
  152.         B2 = atof( record[9] );
  153.         B3 = atof( record[10] );
  154.         B4 = atof( record[11] );
  155.         B6 = atof( record[13] );
  156.         B7 = atof( record[14] );
  157.         L  = atof( record[15] );
  158.         h  = atof( record[16] );
  159.         h1 = atof( record[17] );
  160.         h2 = atof( record[18] );
  161.         H  = atof( record[19] );
  162.         H1 = atof( record[20] );
  163.         H2 = atof( record[21] );
  164.         b  = atof( record[22] );
  165.         R1 = atof( record[25] );
  166.         R2 = atof( record[26] );
  167.         R6 = atof( record[30] );
  168.         d1 = atof( record[32] );
  169.         e1 = atof( record[33] );
  170.         wg = atof( record[34] );
  171.         FormPzb80R((double)D,(double)D1,(double)D2,(double)D3,
  172.         (double)C ,(double)C1,(double)B2,(double)B3,(double)B4,
  173.         (double)B6,(double)B7,(double)L ,(double)h ,(double)h1,
  174.         (double)h2,(double)H,(double)H1,(double)H2,(double)b,
  175.         (double)R1,(double)R2,(double)R6,(double)d1,(double)e1);
  176.     }  
  177.  
  178. /* You can add more part parameter controlling programs here */
  179.  
  180.     fclose(pa1pnter);
  181.  
  182. /* Call opps.lib to draw entities that is describe by MDT file */
  183.  
  184.     FormIGR( "..\\lib\\partmdf.mdf", "..\\lib\\partmdf.inx" );
  185.  
  186. /*  LOADGWD statement in opps.lsp will use this GWD file  */
  187.     GWSave("opps");  
  188.  
  189. exit:
  190.     
  191.     if(( pa2pnter = fopen("..\\tmp\\opps.pa2","w+t")) != NULL)
  192.     {
  193.         sprintf(type,"%d\n",errorno );
  194.         fwrite( type, strlen(type),1,pa2pnter );
  195.         fclose(pa2pnter);
  196.     }
  197.     exit();
  198. }
  199.  
  200.  
  201.