! ,
,
, . .

++ DXF-:

while(1){
    fscanf(in,"%s",str);
        if(strcmp(str,"ENDSEC")==0)break;
    if(strcmp(str,"KONTUR")==0){strcpy(layer,"KONTUR"); break;}
    }
fclose(in);
//---------------------------------------------------------------
ar=fopen("array.dat","w");
er=fopen("err.dat","w");
in=fopen("inp.dxf","r");

// ===>
//fprintf(ar,"npp name  xkrd  ykrd   r      l_arc    xst   yst     xen      yen\n");
//----------------------------------------------------------------------------
while(1){
    fscanf(in,"%s",str);all++;
    if(strcmp(str,"ENTITIES")==0)break;
    }
while(1)
    {
fscanf(in,"%s",str);
        if(strcmp(str,"ENDSEC")==0)break; //==>> ENDSEC
//==========================    A R C   ==================================
if(strcmp(str,"ARC")==0)varc=1;   
        if(varc==1&&strcmp(str,layer)==0)
    {
    all++; arc++; varc=0;
//    fprintf(ar,"=>arc=%d str=%s layer=%s\n",arc,str,layer);
    while(1){
//fprintf(er,"str=%s\nlayer=%s\n",str,layer);goto lin;
    fscanf(in,"%s",str);
        if(atof(str)==10){ //all++; arc++;
fscanf(in,"%s",str); x_krd=atof(str);
fscanf(in,"%s",str);
if(atof(str)==20){
    fscanf(in,"%s",str);
    fprintf(er,"ARC %d\n",all);
    fprintf(er,"%3.3lf\n",x_krd);
    y_krd=atof(str);fprintf(er,"%3.3lf\n",y_krd);
    goto l1;    }//=20
                    }//=10
        }// while
l1: read z_krd=atof(str);
read rad=atof(str);fprintf(er,"%3.3lf\n",rad);
read st_ang=atof(str);fprintf(er,"%3.3lf\n",st_ang);
read end_ang=atof(str);fprintf(er,"%3.3lf\n",end_ang);

//*     *
if(st_ang<90&&st_ang>=0){st_y=(sin(st_ang*0.017453)*rad);
                           st_y+=y_krd;
       st_x=(cos(st_ang*0.017453)*rad);
       st_x+=x_krd;
      }
if(end_ang<90&&end_ang>=0){end_y=(sin(end_ang*0.017453)*rad);
                           end_y+=y_krd;
       end_x=(cos(end_ang*0.017453)*rad);
       end_x+=x_krd;
      }
if(st_ang<180&&st_ang>=90){st_y=(sin((180-st_ang)*0.017453)*rad);
                              st_y+=y_krd;
          st_x=(cos((180-st_ang)*0.017453)*rad);
          st_x=x_krd-st_x;
          }
if(end_ang<180&&end_ang>=90){end_y=(sin((180-end_ang)*0.017453)*rad);
                             end_y+=y_krd;
         end_x=(cos((180-end_ang)*0.017453)*rad);
         end_x=x_krd-end_x;
        }
if(st_ang<270&&st_ang>=180){st_y=(sin((st_ang-180)*0.017453)*rad);
                            st_y=y_krd-st_y;
        st_x=(cos((st_ang-180)*0.017453)*rad);
        st_x=x_krd-st_x;
        }
if(end_ang<270&&end_ang>=180){end_y=(sin((end_ang-180)*0.017453)*rad);
                              end_y=y_krd-end_y;
          end_x=(cos((end_ang-180)*0.017453)*rad);
          end_x=x_krd-end_x;
          }
if(st_ang<360&&st_ang>=270){st_y=(sin((360-st_ang)*0.017453)*rad);
                            st_y=y_krd-st_y;
        st_x=(cos((360-st_ang)*0.017453)*rad);
        st_x=x_krd+st_x;
        }
if(end_ang<360&&end_ang>=270){end_y=(sin((360-end_ang)*0.017453)*rad);
                              end_y=y_krd-end_y;
          end_x=(cos((360-end_ang)*0.017453)*rad);
          end_x=x_krd+end_x;
          }

npp[m]=m; name[m]='a'; xkrd[m]=x_krd; ykrd[m]=y_krd; zkrd[m]=z_krd; r[m]=rad;
st_angle[m]=st_ang; end_angle[m]=end_ang;
l_arc[m]=fabs((end_angle[m]-st_angle[m])/360*2*3.1416*rad); //
xst[m]=st_x; yst[m]=st_y; zst[m]=-0.0001; xen[m]=end_x; yen[m]=end_y; zen[m]=-0.0001;
// ARRAY.DAT
//fprintf(ar,"%d %c %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf\n",
//npp[m],name[m],xkrd[m],ykrd[m],r[m],l_arc[m],xst[m],yst[m],xen[m],yen[m]);
m++;    } // END ARC
//=======================   L I N E   =========================
if(strcmp(str,"LINE")==0)vlin=1;   
    if(vlin==1&&strcmp(str,layer)==0)
    { all++; lin++; vlin=0;
    while(1){
    fscanf(in,"%s",str);
//if(strcmp(str,"KONTUR")!=0)break; //
    if(atof(str)==10){ //all++; lin++;
fscanf(in,"%s",str); st_x=atof(str);
fscanf(in,"%s",str);
if(atof(str)==20){
    fscanf(in,"%s",str); st_y=atof(str);
    fprintf(er,"LINE %d\n",all);
    fprintf(er,"%3.3lf\n",st_x);
    fprintf(er,"%3.3lf\n",st_y);
goto l2;        }
                    }
        }// while
l2: read st_z=atof(str);
read end_x=atof(str);fprintf(er,"%3.3lf\n",end_x);
read end_y=atof(str);fprintf(er,"%3.3lf\n",end_y);
read end_z=atof(str);

npp[m]=m; name[m]='l'; xkrd[m]=ykrd[m]=zkrd[m]=r[m]=l_arc[m]=-0.0001;
xst[m]=st_x; yst[m]=st_y; zst[m]=st_z; xen[m]=end_x; yen[m]=end_y; zen[m]=end_z;
// ARRAY.DAT
//fprintf(ar,"%d %c %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf\n",
//npp[m],name[m],xkrd[m],ykrd[m],r[m],l_arc[m],xst[m],yst[m],xen[m],yen[m]);
m++;    } // END LINE
// =================   C I R C L E   ==========================
if(strcmp(str,"CIRCLE")==0)vcir=1;
    if(vcir==1&&strcmp(str,layer)==0)
    { all++; cir++; vcir=0;
    while(1){
    fscanf(in,"%s",str);
//if(strcmp(str,"RASMER")==0)break; //
    if(atof(str)==10){
fscanf(in,"%s",str); x_krd=atof(str);
fscanf(in,"%s",str);
if(atof(str)==20){
    fscanf(in,"%s",str); y_krd=atof(str);
    fprintf(er,"CIRCLE %d\n",all);
    fprintf(er,"%3.3lf\n",x_krd);
    fprintf(er,"%3.3lf\n",y_krd);
goto l3;        }
                    }
        }// while
l3: read z_krd=atof(str);
read rad=atof(str);fprintf(er,"%3.3lf\n",rad);

npp[m]=m; name[m]='c'; xkrd[m]=x_krd; ykrd[m]=y_krd; zkrd[m]=z_krd; r[m]=rad;
xst[m]=yst[m]=zst[m]=xen[m]=yen[m]=zen[m]=l_arc[m]=-0.0001;
// ARRAY.DAT
//fprintf(ar,"%d %c %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf\n",
//npp[m],name[m],xkrd[m],ykrd[m],r[m],l_arc[m],xst[m],yst[m],xen[m],yen[m]);
m++;    } // END CIRCLE
// =================   P O I N T   ===========================
if(strcmp(str,"POINT")==0)vpoi=1;   
    if(vpoi==1&&strcmp(str,layer)==0)
    { all++; poi++; vpoi=0;
    while(1){
    fscanf(in,"%s",str);
//if(strcmp(str,"RASMER")==0)break; //
    if(atof(str)==10){
fscanf(in,"%s",str); st_x=atof(str);
fscanf(in,"%s",str);
if(atof(str)==20){
    fscanf(in,"%s",str); st_y=atof(str);
    fprintf(er,"POINT %d\n",all);
    fprintf(er,"%3.3lf\n",st_x);
    fprintf(er,"%3.3lf\n",st_y);
goto l4;        }
                    }
        }// while
l4: read st_z=atof(str);

npp[m]=m; name[m]='p'; xkrd[m]=ykrd[m]=zkrd[m]=r[m]=l_arc[m]=-0.0001;
xst[m]=xen[m]=st_x; yst[m]=yen[m]=st_y; zst[m]=zen[m]=st_z;
// ARRAY.DAT
//fprintf(ar,"%d %c %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf %3.4lf\n",
//npp[m],name[m],xkrd[m],ykrd[m],r[m],l_arc[m],xst[m],yst[m],xen[m],yen[m]);
m++;    } // END POINT
    gipot[m]=0;}  //*  ---> E N D   W H I L E   *