找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 370|回复: 0

[求助]:SOS!!!生死一线!高手们来接受挑战吧!!!

[复制链接]
发表于 2004-6-15 19:40:37 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
#include "rxdefs.h"
#include "adslib.h"
#include "adesk.h"
#include "adsdlg.h"
#include "acedads.h"
#include "rxregsvc.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "acutads.h"

#define ELEMENTS(array)  (sizeof(array)/sizeof((array)[0]))
#define D_TO_R(x)  ((x)/180.0*3.14159265)

#define LINE(from_pt,to_pt) acedCommand(RTSTR,"LINE",RT3DPOINT,from_pt,\
        RT3DPOINT,to_pt,RTSTR,"",RTNONE);
#define CIRCLE(center,radius) acedCommand(RTSTR,"CIRCLE",RT3DPOINT,center,\
        RTREAL,radius,RTNONE);
#define ARC(firstpt,secondpt,endpt) acedCommand(RTSTR,"ARC",RT3DPOINT,firstpt,\
        RT3DPOINT,secondpt,RT3DPOINT,endpt,RTNONE);
#define  ARCFCE(fpt,cpt,ept)  acedCommand(RTSTR,"arc",RT3DPOINT,fpt,RTSTR,"c",\
                         RT3DPOINT,pto2,RT3DPOINT,ept,RTNONE);

#define LAYER_LOAD(layer_name,color,linetype)  acedCommand(RTSTR,"-LAYER",\
        RTSTR,"M",RTSTR,layer_name,RTSTR,"L",RTSTR,linetype,RTSTR,"",RTSTR,"C",\
        RTSTR,color,RTSTR,"",RTSTR,"",RTNONE);
#define LAYER_SET(layer_name)  acedCommand(RTSTR,"-LAYER",RTSTR,"S",RTSTR,\
        layer_name, RTSTR,"",RTNONE);

#define INSERT(filename,bp,scale,angle)  acedCommand(RTSTR,"INSERT",RTSTR,filename,\
        RT3DPOINT,bp,RTREAL,scale,RTANG,angle,RTNONE);
#define INSERTXY(filename,bp,xscale,yscale,angle)  acedCommand(RTSTR,"INSERT",\
        RTSTR,filename,RT3DPOINT,bp,RTREAL,xscale,RTREAL,yscale,RTANG,angle,RTNONE);

#define SETUCS(zeropoint)  acedCommand(RTSTR,"UCS",RTSTR,"3",RT3DPOINT,zeropoint,\
        RTSTR,"",RTSTR,"",RTNONE);

#define FILLET(radius,point1,point2) acedCommand(RTSTR,"Fillet",RTSTR,"R",RTREAL,\
        radius,RTSTR,"fillet",RT3DPOINT,point1,RT3DPOINT,point2,RTNONE);

#define GET_DIST(pt,str,dist,current) {short statdist;\
        acutPrintf("\n%s<%f>:",str,current);\
    while((statdist=acedGetDist(pt,NULL,&(dist)))!=RTNORM)\
                {if(statdist==RTCAN)\
                        {acedRetVoid();\
                        return RTNORM;}\
                else if(statdist==RTNONE)\
                {dist=current;\
                 break;}\
                }\
        }       

#define GET_ANGLE(pt,str,angle,current) {short statangle;\
        acutPrintf("\n%s<%f>:",str,current);\
    while((statangle=acedGetAngle(pt,NULL,&(angle)))!=RTNORM)\
                {if(statangle==RTCAN)\
                        {acedRetVoid();\
                        return RTNORM;}\
                else if(statangle==RTNONE)\
                {angle=D_TO_R(current);\
                 break;}\
                }\
        }

#define GET_INT(str,intergle,current) {short statint;\
        acutPrintf("\n%s<%d>:",str,current);\
    while((statint=acedGetInt(NULL,&(intergle)))!=RTNORM)\
                {if(statint==RTCAN)\
                        {acedRetVoid();\
                        return RTNORM;}\
                else if(statint==RTNONE)\
                {intergle=current;\
                 break;}\
                }\
        }

#define GET_STRING(prompt,str) {short statstr;\
        acutPrintf("\n%s:",prompt);\
    while((statstr=acedGetString(1,NULL,str))!=RTNORM)\
                {if(statstr==RTCAN)\
                        {acedRetVoid();\
                        return RTNORM;}\
                else if(statstr==RTNONE)\
                {strcpy(str,"\0");\
                 break;}\
                }\
        }

static int funcload();
static int dofunc();
static int funcunload();
int initidlg(ads_real &scale,char *sizestr);
int imagedlg();
static int CALLB image_ok(ads_callback_packet *cpkt);
static int CALLB initi_ok(ads_callback_packet *cpkt);
static int CALLB initi_cancel(ads_callback_packet *cpkt);
static void curvercreat(ads_point basept,ads_point backpt1,ads_point backpt2,\
                                                int flag,char type[][2],ads_real data[],int &end);
static void curvercreat2(ads_point basept,ads_point backpt1,ads_point backpt2,\
                                                int flag,char type[][2],ads_real data[],int end);

int busdesign();
int init();

struct {
        char *fname;
        int (*func)();
}functab[]={
        {"c:busdesign",busdesign},
       
};

static  char *initistr[] = {"edit_box_k","popup_list_k",NULL};
static  char *radiobutton[]={"a0","a1","a2","a3","a4",NULL};
static  int  imageid=0;
static char dlgvalue[2][20];
static char sizebuttonvalue[4][2];
       

extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* ptr )
{

    switch(msg) {
    case AcRx::kInitAppMsg:
        acrxUnlockApplication(ptr);       
        break;               
                       
                               
    case AcRx::kLoadADSMsg:
        funcload();               
        break;       

        case AcRx::kInvkSubrMsg:
        dofunc();
        break;

        case AcRx::kUnloadAppMsg:
        acutPrintf("Unloading.\n");
        funcunload();
        break;

    default:
        break;
    }
    return AcRx::kRetOK;
}               


static int funcload()
{
        int i;
        for(i=0;i<ELEMENTS(functab);i++)
        {
                if(!ads_defun(functab.fname,(short)i))
                return RTERROR;
        }
        return RTNORM;
}

static int dofunc()
{
        int val;
        if((val=ads_getfuncode())<0)
        {
       
                return RTERROR;
        }
        (*functab[val].func)();
        ads_retvoid();
        return RTNORM;
}

static int funcunload()
{
        int i;
        for(i=0;i<ELEMENTS(functab);i++)
        {
                ads_undef(functab.fname,i);
        }
        return RTNORM;
}


int busdesign()
{
        ads_point ptz[11];
        ads_real scale,sizew,sizeh,A,A1,E0,E,D;
    char sizestr[3];
    static ads_real sizescale;
    long length; short flag;
    char *p,pstr[3],yn[2],ync[2],yn1[2],yn2[2],chuangtype[8];

        static int i,n,m,frontend=0,rearend=0;
        static char str1[2],str2[1],strdoor[5],fronttype[50][2],reartype[50][2];
        static ads_real H,L,W,Lz,Lf,Lr,Lw,L1,L3,Lc,L4,L5,L6,L7,L8,L9,L10,L11,L12,L13,L14,\
                Rf,Rr,R1,R2,R3,R4,R5,R6,R7,R8,Bf,Br,h0,h1,h2,h3,h5,h6,h7,h8,h9,h10,\
                a,r1,r2,b1,b2,xscale,yscale,angle,frontdata[100],reardata[100];
                       
        static ads_point bp0,bp1,bp2,p1,p2,p3,p4,ptb[35],pt0,pt1,pt2,pt[40],\
                ptxlj[3],ptkt[3],temp[2];


// 初始化绘图环境       
        ads_command(RTSTR,"CMDECHO",RTSHORT,0,RTNONE);
        ads_command(RTSTR,"BLIPMODE",RTSTR,"OFF",RTNONE);
       
        LAYER_LOAD("thick","white","continuous");
        LAYER_LOAD("center","red","center");
        LAYER_LOAD("dash","blue","dashed");
        LAYER_LOAD("divi","magenta","divide");
       
        strcpy(yn,"N");
    while(strcmp(_strupr(yn),"Y")!=0)
          {
                initidlg(sizescale,sizestr);
            p=strchr(dlgvalue[0],'6');
                if(p==NULL) { ads_alert("         警告\n\n您输入的客车型号错误!!\n\n更正后请重新输入!\n\n请注意客车代号为'6'."); continue;}
               
            p=p+1;          strcpy(pstr,p);  pstr[2]=NULL;
        length=atoi(pstr);
        if(length<20) length=length*1000;
        else     length=length*100;
        p=sizestr+1; flag=atoi(p);
                switch(flag)
                { case 0: {sizew=1189.0; sizeh=841.0; break;}
          case 1: {sizew=841.0; sizeh=594.0; break;}
          case 2: {sizew=594.0; sizeh=420.0; break;}
          case 3: {sizew=420.0; sizeh=297.0; break;}
          case 4: {sizew=297.0; sizeh=210.0; break;}
                }
                strcpy(yn,"Y");
                if(sizew*5.0/6.0/sizescale<2*length)
                  { ads_alert("          警告\n\n您所选图纸或比例不太合适!!\n\n敲'Y'键将忽略该问题并继续.\n\n敲其它键将重新选择.");
                    ads_getstring(1,"\n所选图纸太小! 继续吗?<Y/N>:",yn);
                  }
          }

        ptz[0][X]=0.0;ptz[0][Y]=0.0;ptz[0][Z]=0.0;
        ads_polar(ptz[0],0.0,sizew/sizescale,ptz[1]);
        ads_polar(ptz[1],D_TO_R(90),sizeh/sizescale,ptz[2]);
        ads_polar(ptz[2],D_TO_R(180),sizew/sizescale,ptz[3]);
        ptz[4][X]=25.0/sizescale;ptz[4][Y]=10.0/sizescale;ptz[4][Z]=0.0;
        ads_polar(ptz[4],0.0,(sizew-25.0-10.0)/sizescale,ptz[5]);
        ads_polar(ptz[5],D_TO_R(90),(sizeh-20.0)/sizescale,ptz[6]);
        ads_polar(ptz[4],D_TO_R(90),(sizeh-20.0)/sizescale,ptz[7]);
        ads_polar(ptz[5],D_TO_R(90),56.0/sizescale,ptz[9]);
        ads_polar(ptz[5],D_TO_R(180),180.0/sizescale,ptz[8]);
        ads_polar(ptz[8],D_TO_R(90),56.0/sizescale,ptz[10]);

        ads_command(RTSTR,"LIMITS",RT3DPOINT,ptz[0],
                RT3DPOINT,ptz[2],RTSTR,"ZOOM",RTSTR,"A",RTNONE);
       
        LAYER_SET("thick");
        LINE(ptz[0],ptz[1]); LINE(ptz[1],ptz[2]);
        LINE(ptz[2],ptz[3]); LINE(ptz[0],ptz[3]);
        LINE(ptz[4],ptz[5]); LINE(ptz[5],ptz[6]);
        LINE(ptz[6],ptz[7]); LINE(ptz[7],ptz[4]);
        LINE(ptz[8],ptz[10]); LINE(ptz[10],ptz[9]);
        scale=1.0/sizescale;
        angle=0.0;
        INSERT("*btl",ptz[5],scale,angle);

// 画左视图       

    bp0[X]=(sizew/18.0+85)/sizescale;
        bp0[Y]=(47.0+9*sizeh/16.0)/sizescale;
    bp0[Z]=0.0;
        SETUCS(bp0);
        bp1[X]=0.0;bp1[Y]=0.0;bp1[Z]=0.0;
        GET_DIST(bp1,"\n请输入轴距Lz(4000mm<Lz<7200mm):",Lz,6500.0);
        GET_DIST(bp1,"\n请输入前悬长Lf:",Lf,2300.0);
        GET_DIST(NULL,"\n请输入悬长Lr:",Lr,3200.0);
        L=Lf+Lz+Lr;
        GET_ANGLE(bp1,"\n请输入车架上平面倾斜角a:",a,0.0);
        ads_polar(bp1,0.0,Lz,bp2);
        ads_polar(bp1,D_TO_R(180),Lf,ptb[0]);
        ads_polar(ptb[0],D_TO_R(90),Lf*tan(a),ptb[0]);
        ads_polar(bp2,0.0,L-Lf-Lz,ptb[1]);
        ads_polar(ptb[1],D_TO_R(-90),(L-Lf)*tan(a),ptb[1]);
        LAYER_SET("thick");
        LINE(ptb[0],ptb[1]);
       
        GET_DIST(bp1,"\n请输入前轮滚动半径Rf:",Rf,550.0);
        GET_DIST(bp2,"\n请输入后轮滚动半径Rr:",Rr,Rf);
        ads_polar(bp2,D_TO_R(-90),Lz*tan(a),bp2);
        ads_polar(bp1,D_TO_R(90),Rf,ptb[2]);
        ads_polar(bp2,D_TO_R(90),Rr,ptb[3]);
        CIRCLE(ptb[2],Rf);  CIRCLE(ptb[3],Rr);
        Rf=Rf*3.1415926/3.05;
        Rr=Rr*3.1415926/3.05;
        CIRCLE(ptb[2],Rf);  CIRCLE(ptb[3],Rr);

        angle=0.0;
        scale=Rr/550.0;
        INSERT("*chelun",ptb[2],scale,angle);
        scale=Rf/550.0;
        INSERT("*chelun",ptb[3],scale,angle);
               
        GET_DIST(bp1,"\n请输入地板高h0:",h0,1060.0);
        ads_polar(bp1,D_TO_R(90),h0,ptb[4]);
        ads_polar(ptb[4],0.0,Lz+1000.0,ptb[5]);
        ads_polar(ptb[4],D_TO_R(180),1000.0,ptb[4]);
        LAYER_SET("dash");
        LINE(ptb[4],ptb[5]);
               
        GET_DIST(bp1,"\n请输入总高H(不含车顶附件高,H<=4000mm):",H,3000.0);
        GET_ANGLE(bp1,"\n请输入接近角γ1(γ1>=9):",r1,12.0);
        GET_ANGLE(bp2,"\n请输入离去角γ2(γ2>=7):",r2,12.0);

    ads_polar(ptb[0],D_TO_R(90),Lf*(tan(r1)-tan(a))+300.0,ptb[6]);
    ads_polar(ptb[0],D_TO_R(90),H,ptb[8]);
    ads_polar(ptb[1],D_TO_R(90),H,ptb[9]);
        LAYER_SET("thick");
        LINE(ptb[8],ptb[9]);

// 前围曲线生成函数
       
       
        GET_DIST(ptb[0],"\n请输入前围曲线最前端离地高h9:",h9,1000.0);
    ads_polar(ptb[0],D_TO_R(90),h9,ptb[7]);
        ads_printf("开始绘制前围曲线:");
        curvercreat(ptb[7],ptb[4],temp[1],0,fronttype,frontdata,frontend);
        ads_polar(ptb[8],0.0,Lf,temp[0]);
    GET_DIST(NULL,"\n请输入前围曲线与顶盖的圆角过渡半径R2:",R2,100.0);
    FILLET(R2,ptb[4],temp[0]);
    xscale=Lf/2300.0; yscale=1.0; angle=0.0;
        INSERTXY("modelt1",ptb[2],xscale,yscale,angle);

        
        GET_DIST(ptb[0],"\n请输入后围曲线最前端离地高h10:",h10,1100.0);
        ads_polar(ptb[1],D_TO_R(90),h10,ptb[10]);
        ads_printf("开始绘制后围曲线:");
    curvercreat(ptb[10],ptb[4],temp[1],1,reartype,reardata,rearend);
    ads_polar(ptb[1],D_TO_R(90),(L-Lf-Lz)*tan(r2),ptb[11]);
        ads_polar(ptb[9],D_TO_R(180),(L-Lf-Lz),temp[0]);
        GET_DIST(ptb[9],"\n请输入后围与顶盖过渡圆弧半径R3:",R3,100.0);
    FILLET(R3,ptb[4],temp[0]);

        GET_DIST(ptb[0],"\n请输入前风挡玻璃离地高h1:",h1,1300.0);
        GET_DIST(ptb[1],"\n请输入后风挡玻璃离地高h2:",h2,1500.0);

//        GET_ANGLE(ptb[7],"\n请输入前风挡玻璃倾角:",b1,14.0);
//        GET_ANGLE(ptb[10],"\n请输入后风挡玻璃倾角:",b2,5.0);
//        GET_DIST(ptb[8],"\n请输入前围与顶盖过渡圆弧半径R2:",R2,50.0);
//        GET_DIST(ptb[9],"\n请输入后围与顶盖过渡圆弧半径R3:",R3,200.0);
                       
        GET_DIST(ptb[0],"\n请输入裙部高h3:",h3,300.0);
        ads_polar(ptb[0],D_TO_R(90),h3,ptb[12]);
        scale=1.0; angle=0.0;
        INSERT("*chedengl",ptb[12],scale,angle);
        ads_polar(ptb[12],0.0,Lf-Rf-100.0,ptb[13]);
        ads_polar(ptb[12],0.0,276.0,ptb[12]);
        ads_polar(ptb[2],D_TO_R(90),Rf+100.0,ptb[14]);
        ads_polar(ptb[13],0.0,2.0*Rf+200.0,ptb[15]);
        ads_polar(ptb[15],0.0,Lz-Rf-Rr-200.0,ptb[16]);
        ads_polar(ptb[3],D_TO_R(90),Rr+100.0,ptb[17]);
        ads_polar(ptb[16],0.0,2.0*Rr+200.0,ptb[18]);
        ads_polar(ptb[18],0.0,h3/tan(r2)-Rr-100.0,ptb[19]);
       
        LINE(ptb[12],ptb[13]);
        ARC(ptb[15],ptb[14],ptb[13]);
        LINE(ptb[15],ptb[16]);
        ARC(ptb[18],ptb[17],ptb[16]);
        LINE(ptb[18],ptb[19]);
        LINE(ptb[19],ptb[11]);
       
        ads_polar(ptb[15],0.0,(Lz-Rf-Rr)/8.0,ptb[12]);
        ads_polar(ptb[12],0.0,(Lz-Rf-Rr)/4.0,ptb[13]);
        ads_polar(ptb[13],0.0,(Lz-Rf-Rr)/4.0,ptb[14]);
        ads_polar(ptb[14],0.0,(Lz-Rf-Rr)/4.0,ptb[15]);
        ads_polar(ptb[12],D_TO_R(90),Rf+100.0,ptb[16]);
        ads_polar(ptb[13],D_TO_R(90),Rf+100.0,ptb[17]);
        ads_polar(ptb[14],D_TO_R(90),Rf+100.0,ptb[18]);
        ads_polar(ptb[15],D_TO_R(90),Rf+100.0,ptb[19]);
        LINE(ptb[12],ptb[16]);  LINE(ptb[16],ptb[19]);
        LINE(ptb[15],ptb[19]);  LINE(ptb[14],ptb[18]);
        LINE(ptb[13],ptb[17]);
        ads_polar(ptb[12],0.0,(Lz-Rf-Rr)/8.0,ptb[12]);
        ads_polar(ptb[13],0.0,(Lz-Rf-Rr)/8.0,ptb[13]);
        ads_polar(ptb[14],0.0,(Lz-Rf-Rr)/8.0,ptb[14]);
        scale=(Lz-Rf-Rr)/5400.0;  angle=0.0;
        INSERT("*xlc1",ptb[12],scale,angle);
        INSERT("*xlc2",ptb[13],scale,angle);
        INSERT("*xlc2",ptb[14],scale,angle);
   
        ads_polar(ptb[11],D_TO_R(-180+r2),Lr/3.0,ptb[4]);
        GET_DIST(ptb[9],"\n请输入后围与裙边的圆弧过渡半径R5:",R5,50.0);
        FILLET(R5,ptb[4],temp[1]);

       
        GET_STRING("车顶安装空调<KT>还是行李架<XL>:",str1);
        if(strcmp(_strupr(str1),"KT")==0)
        {
                ads_polar(ptb[8],0.0,0.154*L,ptkt[0]);
                ads_polar(ptb[8],0.0,0.58*L,ptkt[1]);
                ads_polar(ptb[9],D_TO_R(180.0),0.16*L,ptkt[2]);
                xscale=1.0;                yscale=1.0;angle=0.0;
                INSERTXY("hqc",ptkt[0],xscale,yscale,angle);
                INSERTXY("hqc",ptkt[2],xscale,yscale,angle);
        xscale=L/12000;        yscale=0.95;angle=0.0;
                INSERTXY("kt",ptkt[1],xscale,yscale,angle);
        }
        else if(strcmp(_strupr(str1),"XL")==0)
        {
                ads_polar(ptb[8],0.0,0.685*L,ptxlj[0]);
                ads_polar(ptb[8],0.0,0.154*L,ptxlj[2]);
                ads_polar(ptb[8],0.0,0.39*L,ptxlj[1]);
                xscale=L/12000;        yscale=1.0;angle=0.0;
                INSERTXY("xlj",ptxlj[0],xscale,yscale,angle);
                INSERTXY("hqc",ptxlj[1],xscale,yscale,angle);
                INSERTXY("hqc",ptxlj[2],xscale,yscale,angle);
        }


        GET_DIST(NULL,"\n请输入司机门立柱离前轴距离L1:",L1,800.0);
        ptb[12][X]=-L1+100.0;ptb[12][Y]=2.0*Rf+150.0;ptb[12][Z]=0.0;
        ads_polar(ptb[12],D_TO_R(90),50.0,ptb[13]);
        ads_polar(ptb[12],0.0,L-Lf+L1-500.0,ptb[14]);
        ads_polar(ptb[13],0.0,L-Lf+L1-500.0,ptb[15]);
        LINE(ptb[12],ptb[13]);  LINE(ptb[12],ptb[14]);
        LINE(ptb[13],ptb[15]);  LINE(ptb[14],ptb[15]);
        ads_polar(ptb[12],0.0,50.0,ptb[12]);
        ads_polar(ptb[13],0.0,50.0,ptb[13]);
        ads_polar(ptb[14],D_TO_R(180),50.0,ptb[14]);
        ads_polar(ptb[15],D_TO_R(180),50.0,ptb[15]);
        LINE(ptb[12],ptb[13]);  LINE(ptb[14],ptb[15]);

        GET_DIST(NULL,"\n请输入司机门下缘离地高h7:",h7,600.0);
        ptb[19][X]=-L1-80.0;ptb[19][Y]=h7;ptb[19][Z]=0.0;
        xscale=0.9*Lf/2300.0;        yscale=H/3000;angle=0.0;
        INSERTXY("sjm",ptb[19],xscale,yscale,angle);

//        first 画侧窗  //        画侧窗

        GET_DIST(NULL,"\n请输入窗户下缘离地板高h5(h5>=680mm):",h5,700.0);
        GET_DIST(NULL,"\n请输入窗户高h6:",h6,1000.0);
        GET_DIST(NULL,"\n请输入窗户立柱宽度L4:",L4,60.0);
        GET_DIST(NULL,"\n请输入第一个侧窗立柱到前轴的距离Lc:",Lc,1210.0);
   
        imagedlg();
    switch(imageid)
        { case 1: strcpy(chuangtype,"tlch"); break;
      case 2: strcpy(chuangtype,"tlcha");break;
      case 3: strcpy(chuangtype,"fbch"); break;
      case 4: strcpy(chuangtype,"txch"); break;
      case 5: strcpy(chuangtype,"zhch1");break;
      case 6: strcpy(chuangtype,"zhch2");break;
     default: strcpy(chuangtype,NULL);
        }
   Lw=1850.0;
   for( i=1;i<3;i++)
   { if(i==1)
      { ads_getstring(1,"\n要向前(车头方向)生成侧窗吗?<Y\\N>:",yn1);
        if(strcmp(_strupr(yn1),"N")==0) continue; }
      else
          { ads_getstring(1,"\n要向后(车尾方向)生成侧窗吗?<Y\\N>:",yn1);
            if(strcmp(_strupr(yn1),"N")==0) continue;}
         
        ptb[24][X]=Lc;ptb[24][Y]=h5+h0+h6/2.0;ptb[24][Z]=0.0;

        strcpy(yn2,"Y");
         while(strcmp(_strupr(yn2),"N")!=0)
         { ads_getstring(1,"\n要改变侧窗形式吗?<Y/N>:",ync);
       if(strcmp(_strupr(ync),"Y")==0)
           {imagedlg();
        switch(imageid)
                { case 1: strcpy(chuangtype,"tlch"); break;
          case 2: strcpy(chuangtype,"tlcha");break;
          case 3: strcpy(chuangtype,"fbch"); break;
          case 4: strcpy(chuangtype,"txch"); break;
          case 5: strcpy(chuangtype,"zhch1");break;
          case 6: strcpy(chuangtype,"zhch2");break;
          default: strcpy(chuangtype,NULL);
                }
           }
           GET_DIST(NULL,"\n请输入侧窗长:",Lw,Lw);
       if(i==1) ads_polar(ptb[24],D_TO_R(180),Lw/2.0+L4,ptb[23]);
       else  ads_polar(ptb[24],0.0,Lw/2.0+L4,ptb[23]);

       xscale=Lw/1850.0;  yscale=h6/1000.0;angle=0.0;
           INSERTXY(chuangtype,ptb[23],xscale,yscale,angle);
          
          if(i==1) { ads_getstring(1,"\n要继续向前(车头方向)生成侧窗吗?<Y\\N>:",yn2);
                     ads_polar(ptb[24],D_TO_R(180),Lw+L4,ptb[24]);}
          else { ads_polar(ptb[24],0.0,Lw+L4,ptb[24]);
                 ads_getstring(1,"\n要继续向后(车尾方向)生成侧窗吗?<Y\\N>:",yn2);}
         }
  }
       
// 完成侧窗
  
        pt0[X]=-(sizew/18.0+85)/sizescale;
        pt0[Y]=-(47.0+9*sizeh/16.0)/sizescale;
        pt0[Z]=0.0;
        SETUCS(pt0);


// 俯剖视图
H=3000.0;h1=1300.0;h3=300.0; h2=1500.0;
        GET_DIST(bp1,"\n请输入轴距Lz(4000mm<Lz<7200mm):",Lz,6500.0);
        GET_DIST(bp1,"\n请输入前悬长Lf:",Lf,2300.0);
        GET_DIST(NULL,"\n请输入悬长Lr:",Lr,3200.0);
        L=Lz+Lf+Lr;


    bp0[X]=(sizew/18.0+85)/sizescale;
        bp0[Y]=(56.0+sizeh/4.0)/sizescale;
        bp0[Z]=0.0;
        SETUCS(bp0);
        pt1[X]=0.0;pt1[Y]=0.0;pt1[Z]=0.0;
        GET_DIST(NULL,"\n请输入总宽W(W<=2500mm):",W,2500.0);
        GET_DIST(NULL,"\n请输入前围与侧围过渡圆弧半径:R6:",R6,400.0);
        GET_DIST(NULL,"\n请输入后围与侧围过渡圆弧半径:R7:",R7,400.0);
        ads_polar(pt1,0.0,Lz,pt2);
        ads_polar(pt1,D_TO_R(-90),W/2.0,pt[0]);
        ads_polar(pt[0],D_TO_R(180),Lf,pt[2]);
        ads_polar(pt1,D_TO_R(-90),W/2.0+500.0,pt[0]);
        ads_polar(pt1,D_TO_R(90),W/2.0,pt[1]);
        ads_polar(pt[1],D_TO_R(180),Lf,pt[3]);
        ads_polar(pt1,D_TO_R(90),W/2.0+500.0,pt[1]);
        ads_polar(pt2,D_TO_R(-90),W/2.0+500.0,pt[4]);
        ads_polar(pt2,D_TO_R(90),W/2.0+500.0,pt[5]);
        ads_polar(pt[2],0.0,L,pt[6]);
        ads_polar(pt[3],0.0,L,pt[7]);
        ads_polar(pt1,D_TO_R(180),Lf+500.0,pt[8]);
        ads_polar(pt2,0.0,L-Lf-Lz+500.0,pt[9]);
        ads_polar(pt[2],D_TO_R(90),W/2.0,pt[10]);
        ads_polar(pt[10],0.0,L,pt[11]);
        ads_polar(pt[3],0.0,1000.0,pt[13]);
        ads_polar(pt[2],0.0,1000.0,pt[12]);

        LAYER_SET("thick");
        LINE(pt[2],pt[3]);
        LINE(pt[2],pt[6]);
        LINE(pt[3],pt[7]);
        LINE(pt[6],pt[7]);
        FILLET(R6,pt[10],pt[12]);
        FILLET(R6,pt[10],pt[13]);
        FILLET(R7,pt[13],pt[11]);
        FILLET(R7,pt[12],pt[11]);
        LAYER_SET("center");
        LINE(pt[8],pt[9]);  
        LINE(pt[0],pt[1]);
        LINE(pt[4],pt[5]);
       
        do{GET_STRING("\n需要布置多少个乘客门<1>或<2>",str2);}
        while(strcmp(str2,"1")!=0&&strcmp(str2,"2")!=0);
        if(strcmp(str2,"1")==0){
        GET_DIST(NULL,"\n乘客门后立柱离前轴距离L5:",L5,800.0);
        GET_DIST(NULL,"\n乘客门宽度L6:",L6,1100.0);
        ads_polar(pt1,D_TO_R(90),W/2.0,pt[1]);
        ads_polar(pt[1],D_TO_R(180),L5,pt[14]);
        ads_polar(pt[14],D_TO_R(-90),350.0,pt[15]);
        ads_polar(pt[15],D_TO_R(-90),300.0,pt[16]);
        ads_polar(pt[14],D_TO_R(180),L6,pt[17]);
        ads_polar(pt[17],D_TO_R(-90),350.0,pt[18]);
        ads_polar(pt[18],D_TO_R(-90),300.0,pt[19]);
        LAYER_SET("thick");
        LINE(pt[14],pt[16]);
        LINE(pt[17],pt[19]);
        LINE(pt[16],pt[19]);
        LINE(pt[15],pt[18]);

        GET_DIST(NULL,"\n通道宽L7(310<=L7<=540):",L7,350.0);
        ads_polar(pt1,D_TO_R(180),L5,pt[20]);
        ads_polar(pt[20],D_TO_R(90),L7/2.0,pt[21]);
        ads_polar(pt[20],D_TO_R(-90),L7/2.0,pt[22]);
        ads_polar(pt[21],0.0,L-Lf+L5-1500.0,pt[23]);
        ads_polar(pt[22],0.0,L-Lf+L5-1500.0,pt[24]);
        LINE(pt[21],pt[23]);
        LINE(pt[22],pt[24]);

        GET_DIST(NULL,"\n左侧第一排座椅距前轴距离L8:",L8,-300.0);
        GET_DIST(NULL,"\n右侧第一排座椅距前轴距离L9:",L9,-300.0);
        GET_DIST(NULL,"\n座椅间距L10(650<=L10<=800):",L10,800.0);
        GET_INT("\n座椅排数n<2+2>型:",n,12);
        pt[25][X]=L8; pt[25][Y]=-L7/2.0; pt[25][Z]=0.0;
        pt[26][X]=L9; pt[26][Y]=L7/2.0; pt[26][Z]=0.0;

        for(i=1;i<n;i++){
                xscale=L10/800;yscale=(W-L7)/2150.0;angle=0.0;
                INSERTXY("zyl2",pt[25],xscale,yscale,angle);
                ads_polar(pt[25],0.0,L10,pt[25]);
        }
       
        for(i=1;i<n;i++){
        xscale=L10/800;yscale=(W-L7)/2150.0;angle=0.0;
                INSERTXY("zyr2",pt[26],xscale,yscale,angle);
                ads_polar(pt[26],0.0,L10,pt[26]);
        }
               
        ads_polar(pt1,0.0,(n)*L10+L8,pt[27]);
    xscale=L10/800;yscale=(W-L7)/2150.0;angle=0.0;
        INSERTXY("zyrear2",pt[27],xscale,yscale,angle);
        ads_polar(pt1,D_TO_R(-90),(W+L7)/4.0,pt[28]);
    ads_polar(pt[28],D_TO_R(180),Lf-90,pt[28]);
    xscale=(Lf-L8)/2600.0;yscale=W/2500.0;angle=0.0;
        INSERTXY("jsyzy",pt[28],xscale,yscale,angle);
        }

        else if(strcmp(str2,"2")==0){
        GET_DIST(NULL,"\n前开门后立柱离前轴距离L5:",L5,900.0);
        GET_DIST(NULL,"\n前开门宽度L6:",L6,1100.0);
        ads_polar(pt1,D_TO_R(90),W/2.0,pt[1]);
        ads_polar(pt[1],D_TO_R(180),L5,pt[14]);
        ads_polar(pt[14],D_TO_R(-90),650.0,pt[15]);
        ads_polar(pt[15],D_TO_R(180),L6,pt[16]);
        ads_polar(pt[16],D_TO_R(90),650.0,pt[17]);
        LAYER_SET("thick");
        LINE(pt[14],pt[15]);
        LINE(pt[15],pt[16]);
        LINE(pt[16],pt[17]);

        GET_DIST(NULL,"\n中开门前立柱离前轴距离L11:",L11,3250.0);
        GET_DIST(NULL,"\n中开门宽度L12:",L12,1500.0);
        ads_polar(pt1,D_TO_R(90),W/2.0,pt[1]);
        ads_polar(pt[1],0.0,L11,pt[29]);
        ads_polar(pt[29],D_TO_R(-90),650.0,pt[30]);
        ads_polar(pt[30],0.0,L12,pt[31]);
        ads_polar(pt[31],D_TO_R(90),650.0,pt[32]);
        LINE(pt[29],pt[30]);
        LINE(pt[30],pt[31]);
        LINE(pt[31],pt[32]);

        GET_DIST(NULL,"\n通道宽L7(310<=L7<=540):",L7,350.0);
        ads_polar(pt1,D_TO_R(180),L5,pt[20]);
        ads_polar(pt[20],D_TO_R(90),L7/2.0,pt[21]);
        ads_polar(pt[20],D_TO_R(-90),L7/2.0,pt[22]);
        ads_polar(pt[21],0.0,L-Lf+L5-1500.0,pt[23]);
        ads_polar(pt[22],0.0,L-Lf+L5-1500.0,pt[24]);
        LINE(pt[21],pt[23]);
        LINE(pt[22],pt[24]);

        GET_DIST(NULL,"\n左侧第一排座椅距前轴距离L8:",L8,-300.0);
        GET_DIST(NULL,"\n右侧第一排座椅距前轴距离L9:",L9,-300.0);
        GET_DIST(NULL,"\n座椅间距L10(650<=L10<=800):",L10,800.0);
        GET_INT("\n左侧座椅排数n<2+2>型:",m,12);
        pt[25][X]=L8; pt[25][Y]=-L7/2.0; pt[25][Z]=0.0;
        scale=1.0;
        angle=0.0;
        for(i=1;i<m;i++){
                xscale=L10/800;yscale=(W-L7)/2150.0;angle=0.0;
                INSERTXY("zyl2",pt[25],xscale,yscale,angle);
                ads_polar(pt[25],0.0,L10,pt[25]);
        }
        GET_INT("\n右侧前开门与中开门间布置座椅排数n<2+2>型:",n,4);
        pt[26][X]=L9; pt[26][Y]=L7/2.0; pt[26][Z]=0.0;
        for(i=1;i<=n;i++){
                xscale=L10/800;yscale=(W-L7)/2150.0;angle=0.0;
                INSERTXY("zyr2",pt[26],xscale,yscale,angle);
                ads_polar(pt[26],0.0,L10,pt[26]);
        }
        GET_INT("\n右侧中开门以后布置座椅排数n<2+2>型:",n,5);
        GET_DIST(NULL,"\n第一排座椅距中开门后立柱间距L13:",L13,500.0);
        pt[26][X]=L11+L12+L13; pt[26][Y]=L7/2.0; pt[26][Z]=0.0;
        for(i=1;i<n;i++){
            xscale=L10/800;yscale=(W-L7)/2150.0;angle=0.0;
        INSERTXY("zyr2",pt[26],xscale,yscale,angle);
                ads_polar(pt[26],0.0,L10,pt[26]);
        }
        ads_polar(pt1,0.0,(m)*L10+L8,pt[27]);
        xscale=L10/800;yscale=(W-L7)/2150.0;angle=0.0;
        INSERTXY("zyrear2",pt[27],xscale,yscale,angle);
        ads_polar(pt[22],D_TO_R(-90),(W-L7)/4.0,pt[28]);
    ads_polar(pt[28],D_TO_R(180),500.0,pt[28]);
        xscale=(Lf-L8)/2600.0;yscale=W/2500.0;angle=0.0;
        INSERTXY("jsyzy",pt[28],xscale,yscale,angle);
        }
    pt0[X]=-(sizew/18.0+85)/sizescale;
        pt0[Y]=-(56.0+sizeh/4.0)/sizescale;
        pt0[Z]=0.0;
        SETUCS(pt0);

       
// 右视图
               
    bp0[X]=(10*sizew/18.0+95)/sizescale;
        bp0[Y]=(47.0+9*sizeh/16.0)/sizescale;
    bp0[Z]=0.0;
        SETUCS(bp0);
        bp1[X]=0.0;bp1[Y]=0.0;bp1[Z]=0.0;
// 输入->del
        ads_polar(bp1,0.0,Lz,bp2);
        ads_polar(bp1,D_TO_R(180),Lr,ptb[0]);
        ads_polar(ptb[0],D_TO_R(-90),Lr*tan(a),ptb[0]);
        ads_polar(bp2,0.0,L-Lr-Lz,ptb[1]);
        ads_polar(ptb[1],D_TO_R(90),(L-Lr)*tan(a),ptb[1]);
        LAYER_SET("thick");
        LINE(ptb[0],ptb[1]);
       
// 输入->del
        ads_polar(bp2,D_TO_R(90),Lz*tan(a),bp2);
        ads_polar(bp1,D_TO_R(90),Rr,ptb[2]);
        ads_polar(bp2,D_TO_R(90),Rf,ptb[3]);
        CIRCLE(ptb[2],Rr);  CIRCLE(ptb[3],Rf);
        Rf=Rf*3.1415926/3.05;
        Rr=Rr*3.1415926/3.05;
        CIRCLE(ptb[2],Rr);  CIRCLE(ptb[3],Rf);
        angle=0.0;
        scale=Rr/550.0;
        INSERT("*chelun",ptb[2],scale,angle);
        scale=Rf/550.0;
        INSERT("*chelun",ptb[3],scale,angle);
       
// 输入->del
        ads_polar(bp1,D_TO_R(90),h0,ptb[4]);
        ads_polar(ptb[4],0.0,Lz+1000.0,ptb[5]);
        ads_polar(ptb[4],D_TO_R(180.0),1000.0,ptb[4]);
        LAYER_SET("dash");
        LINE(ptb[4],ptb[5]);

        ads_polar(ptb[1],D_TO_R(90),Lf*tan(r1)+300.0,ptb[11]);
        ads_polar(ptb[1],D_TO_R(90),H,ptb[9]);
        ads_polar(ptb[0],D_TO_R(90),H,ptb[8]);
    LAYER_SET("thick");
        LINE(ptb[8],ptb[9]);

//        画前围曲线       
       
        ads_polar(ptb[9],D_TO_R(180.0),Lf,temp[0]);
        ads_polar(ptb[1],D_TO_R(90),h9,ptb[10]);
        curvercreat2(ptb[10],ptb[4],temp[1],1,fronttype,frontdata,frontend);
    FILLET(R2,ptb[4],temp[0]);
    xscale=Lf/2300.0; yscale=1.0; angle=0.0;
        INSERTXY("modelt2",ptb[3],xscale,yscale,angle);

        ads_polar(ptb[8],0.0,Lr,temp[0]);
        ads_polar(ptb[0],D_TO_R(90),Lr*(tan(r2)-tan(a)),ptb[6]);
    ads_polar(ptb[0],D_TO_R(90),h10,ptb[7]);
    curvercreat2(ptb[7],ptb[4],temp[1],0,reartype,reardata,rearend);
    //R3->后围与顶盖过渡圆弧半径
        FILLET(R3,ptb[4],temp[0]);


//        GET_STRING("车顶安装空调<KT>还是行李架<XL>:",str1);
        if(strcmp(_strupr(str1),"KT")==0)
        {
                ads_polar(ptb[8],0.0,0.16*L,ptkt[0]);
                ads_polar(ptb[9],D_TO_R(180.0),0.58*L,ptkt[1]);
                ads_polar(ptb[9],D_TO_R(180.0),0.154*L,ptkt[2]);
                xscale=1.0;                yscale=1.0;angle=0.0;
                INSERTXY("hqc",ptkt[0],xscale,yscale,angle);
                INSERTXY("hqc",ptkt[2],xscale,yscale,angle);
                xscale=L/12000.0;yscale=0.95;
                INSERTXY("kt",ptkt[1],xscale,yscale,angle);
        }
        else if(strcmp(_strupr(str1),"XL")==0)
        {
                ads_polar(ptb[9],D_TO_R(180.0),0.685*L,ptxlj[0]);
                ads_polar(ptb[9],D_TO_R(180.0),0.154*L,ptxlj[2]);
                ads_polar(ptb[9],D_TO_R(180.0),0.39*L,ptxlj[1]);
                xscale=W/2500.0;
                yscale=1.0;angle=0.0;
                INSERTXY("xlj",ptxlj[0],xscale,yscale,angle);
                xscale=1.0;
                INSERTXY("hqc1",ptxlj[1],xscale,yscale,angle);
                INSERTXY("hqc1",ptxlj[2],xscale,yscale,angle);
        }
                       
//        GET_DIST(ptb[0],"\n请输入裙部高h3:",h3,300.0);
        ads_polar(ptb[0],D_TO_R(90),h3,ptb[12]);
        ads_polar(ptb[12],0.0,Lr-Rr-100.0,ptb[13]);
        ads_polar(ptb[12],0.0,Lr-(h3/tan(r2)),ptb[12]);
        ads_polar(ptb[2],D_TO_R(90),Rr+100.0,ptb[14]);
        ads_polar(ptb[13],0.0,2.0*Rr+200.0,ptb[15]);
        ads_polar(ptb[15],0.0,Lz-Rf-Rr-200.0,ptb[16]);
        ads_polar(ptb[3],D_TO_R(90),Rf+100.0,ptb[17]);
        ads_polar(ptb[16],0.0,2.0*Rf+200.0,ptb[18]);
        ads_polar(ptb[18],0.0,h3/tan(r1)-Rf+540.0,ptb[19]);
       
        LINE(ptb[6],ptb[12]);
        LINE(ptb[12],ptb[13]);
        ads_polar(ptb[6],D_TO_R(-r2),Lr/3.0,ptb[4]);
        //后围与裙边的圆弧过渡半径->R5 =50.0);
        FILLET(R5,ptb[4],temp[1]);

        ARC(ptb[15],ptb[14],ptb[13]);
        LINE(ptb[15],ptb[16]);
        ARC(ptb[18],ptb[17],ptb[16]);
        LINE(ptb[18],ptb[19]);
        ptb[11][Y]=ptb[19][Y];
//        ads_polar(ptb[11],D_TO_R(-90),639.0,ptb[11]);
    xscale=1.0; yscale=1.0;angle=0.0;
        INSERTXY("chedengr",ptb[11],xscale,yscale,angle);

//        GET_STRING("\n需要布置多少个乘客门<1>或<2>",str2);
        if(strcmp(str2,"1")==0){
        ads_polar(ptb[15],0.0,350.0,ptb[12]);
        ads_polar(ptb[12],0.0,(Lz-Rf-Rr-1000.0)*4.5/14.0,ptb[13]);
        ads_polar(ptb[13],0.0,(Lz-Rf-Rr-1000.0)*4.5/14.0,ptb[14]);
        ads_polar(ptb[14],0.0,(Lz-Rf-Rr-1000.0)*5.0/14.0,ptb[15]);
        ads_polar(ptb[12],D_TO_R(90),Rf+100.0,ptb[16]);
        ads_polar(ptb[13],D_TO_R(90),Rf+100.0,ptb[17]);
        ads_polar(ptb[14],D_TO_R(90),Rf+100.0,ptb[18]);
        ads_polar(ptb[15],D_TO_R(90),Rf+100.0,ptb[19]);
        LINE(ptb[12],ptb[16]);  LINE(ptb[16],ptb[19]);
        LINE(ptb[15],ptb[19]);  LINE(ptb[14],ptb[18]);
        LINE(ptb[13],ptb[17]);
        ads_polar(ptb[12],0.0,(Lz-Rf-Rr-1000.0)*4.5/(14.0*2.0),ptb[12]);
        ads_polar(ptb[13],0.0,(Lz-Rf-Rr-1000.0)*4.5/(14.0*2.0),ptb[13]);
        ads_polar(ptb[14],0.0,(Lz-Rf-Rr-1000.0)*5.0/(14.0*2.0),ptb[14]);
        xscale=Lz/6500.0; yscale=h0/1100.0; angle=0.0;
    INSERTXY("xlc2",ptb[12],xscale,yscale,angle);
        INSERTXY("xlc2",ptb[13],xscale,yscale,angle);
        INSERTXY("xlc1",ptb[14],xscale,yscale,angle);

//        GET_DIST(NULL,"\n请输入乘客门后立柱离前轴距离L5:",L5,800.0);
        ptb[12][X]=Lz+L5-100.0;ptb[12][Y]=2.0*Rf+200.0;ptb[12][Z]=0.0;
        ads_polar(ptb[12],D_TO_R(90),50.0,ptb[13]);
        ads_polar(ptb[12],D_TO_R(180),Lz+Lr+L5-600.0,ptb[14]);
        ads_polar(ptb[14],D_TO_R(90),50.0,ptb[15]);
        LINE(ptb[12],ptb[13]);  LINE(ptb[12],ptb[14]);
        LINE(ptb[13],ptb[15]);  LINE(ptb[14],ptb[15]);
        ads_polar(ptb[12],D_TO_R(180),50.0,ptb[12]);
        ads_polar(ptb[13],D_TO_R(180),50.0,ptb[13]);
        ads_polar(ptb[14],0.0,50.0,ptb[14]);
        ads_polar(ptb[15],0.0,50.0,ptb[15]);
        LINE(ptb[12],ptb[13]);  LINE(ptb[14],ptb[15]);

        GET_DIST(NULL,"\n请输入乘客门一级踏步高h7:",h7,350.0);
        ptb[19][X]=Lz+L5+100.0;ptb[19][Y]=h7;ptb[19][Z]=0.0;
        xscale=L6/1100.0;
        yscale=H/3000.0;angle=0.0;
        GET_STRING("\n请选择门的形式(折叠门<ZDM>或外摆门<WBM>):",strdoor);
        INSERTXY(strdoor,ptb[19],xscale,yscale,angle);
//        INSERTXY("qkm",ptb[19],xscale,yscale,angle);
       
//        画侧窗
               
        GET_DIST(NULL,"\n请输入乘客门后第一个侧窗立柱到前轴的距离Lc:",Lc,-1190.0);
        Lc=Lz+Lc;
   for( int i=1;i<3;i++)
   { if(i==1)
      { ads_getstring(1,"\n要向前(车头方向)生成侧窗吗?<Y\\N>:",yn1);
        if(strcmp(_strupr(yn1),"N")==0) continue; }
      else
          { ads_getstring(1,"\n要向后(车尾方向)生成侧窗吗?<Y\\N>:",yn1);
            if(strcmp(_strupr(yn1),"N")==0) continue;}
     
          ptb[24][X]=Lc;ptb[24][Y]=h5+h0+h6/2.0;ptb[24][Z]=0.0;
  
         strcpy(yn2,"Y");
         while(strcmp(_strupr(yn2),"N")!=0)
         {if(strcmp(_strupr(yn2),"N")!=0)
           { ads_getstring(1,"\n要改变侧窗形式吗?<Y/N>:",ync);
         if(strcmp(_strupr(ync),"Y")==0)
                 {imagedlg();
           switch(imageid)
                   { case 1: strcpy(chuangtype,"tlch"); break;
             case 2: strcpy(chuangtype,"tlcha");break;
             case 3: strcpy(chuangtype,"fbch"); break;
             case 4: strcpy(chuangtype,"txch"); break;
             case 5: strcpy(chuangtype,"zhch1");break;
             case 6: strcpy(chuangtype,"zhch2");break;
            default: strcpy(chuangtype,NULL);
                   }
                 }
             GET_DIST(NULL,"\n请输入侧窗长:",Lw,Lw);
             if(i==1) ads_polar(ptb[24],0.0,Lw/2.0+L4,ptb[23]);
             else    ads_polar(ptb[24],D_TO_R(180),Lw/2.0+L4,ptb[23]);
             xscale=Lw/1850.0;  yscale=h6/1000.0;angle=0.0;
             INSERTXY(chuangtype,ptb[23],xscale,yscale,angle);

                 if(i==1) { ads_getstring(1,"\n要继续向前(车头方向)生成侧窗吗?<Y\\N>:",yn2);
                            ads_polar(ptb[24],0.0,Lw+L4,ptb[24]);}
                 else  { ads_getstring(1,"\n要继续向后(车尾方向)生成侧窗吗?<Y\\N>:",yn2);
                 ads_polar(ptb[24],D_TO_R(180),Lw+L4,ptb[24]);}
           }
         }
   }
// 完成侧窗       
        }

    else if(strcmp(str2,"2")==0){
//        GET_DIST(NULL,"\n请输入前开门后立柱离前轴距离L5:",L5,900.0);
        GET_DIST(NULL,"\n请输入前开门一级踏步高h7:",h7,350.0);
        ptb[19][X]=Lz+L5+100.0;ptb[19][Y]=h7;ptb[19][Z]=0.0;
        xscale=L6/1100.0;
        yscale=H/3000.0;angle=0.0;
        INSERTXY("qkm",ptb[19],xscale,yscale,angle);

        GET_DIST(NULL,"\n请输入中开门一级踏步高h8:",h8,350.0);
        ptb[19][X]=Lz-L11;ptb[19][Y]=h8;ptb[19][Z]=0.0;
        xscale=0.95*L12/1500.0;
        yscale=0.95*H/3000.0; angle=0.0;
        INSERTXY("zkm",ptb[19],xscale,yscale,angle);


//        画侧窗
   for(int j=1;j<3;j++)
   {
        if(j==1) {GET_DIST(NULL,"\n请输入前开门后第一个侧窗立柱到前轴的距离Lc:",Lc,-1190.0);}
        else     {GET_DIST(NULL,"\n请输入中开门后第一个侧窗立柱到前轴的距离Lc:",Lc,-6510.0);}
           Lc=Lz+Lc;
   for( int i=1;i<3;i++)
   { if(i==1)
      { ads_getstring(1,"\n要向前(车头方向)生成侧窗吗?<Y\\N>:",yn1);
        if(strcmp(_strupr(yn1),"N")==0) continue; }
      else
          { ads_getstring(1,"\n要向后(车尾方向)生成侧窗吗?<Y\\N>:",yn1);
            if(strcmp(_strupr(yn1),"N")==0) continue;}
     
          ptb[24][X]=Lc;ptb[24][Y]=h5+h0+h6/2.0;ptb[24][Z]=0.0;
  
         strcpy(yn2,"Y");
         while(strcmp(_strupr(yn2),"N")!=0)
         {if(strcmp(_strupr(yn2),"N")!=0)
           { ads_getstring(1,"\n要改变侧窗形式吗?<Y/N>:",ync);
         if(strcmp(_strupr(ync),"Y")==0)
                 {imagedlg();
           switch(imageid)
                   { case 1: strcpy(chuangtype,"tlch"); break;
             case 2: strcpy(chuangtype,"tlcha");break;
             case 3: strcpy(chuangtype,"fbch"); break;
             case 4: strcpy(chuangtype,"txch"); break;
             case 5: strcpy(chuangtype,"zhch1");break;
             case 6: strcpy(chuangtype,"zhch2");break;
            default: strcpy(chuangtype,NULL);
                   }
                 }
             GET_DIST(NULL,"\n请输入侧窗长:",Lw,Lw);
             if(i==1) ads_polar(ptb[24],0.0,Lw/2.0+L4,ptb[23]);
             else    ads_polar(ptb[24],D_TO_R(180),Lw/2.0+L4,ptb[23]);
             xscale=Lw/1850.0;  yscale=h6/1000.0;angle=0.0;
             INSERTXY(chuangtype,ptb[23],xscale,yscale,angle);

                 if(i==1) { ads_getstring(1,"\n要继续向前(车头方向)生成侧窗吗?<Y\\N>:",yn2);
                            ads_polar(ptb[24],0.0,Lw+L4,ptb[24]);}
                 else  { ads_getstring(1,"\n要继续向后(车尾方向)生成侧窗吗?<Y\\N>:",yn2);
                 ads_polar(ptb[24],D_TO_R(180),Lw+L4,ptb[24]);}
           }
         }
   }}
// 完成侧窗       
// 完成侧窗       

  }
    pt0[X]=-(10*sizew/18.0+95)/sizescale;
        pt0[Y]=-(47.0+9*sizeh/16.0)/sizescale;
        pt0[Z]=0.0;
        SETUCS(pt0);


//前视图       

        bp0[X]=(10*sizew/18.0)/sizescale;
        bp0[Y]=(56.0+sizeh/17.0)/sizescale;
        bp0[Z]=0.0;
        SETUCS(bp0);
        pt1[X]=0.0;pt1[Y]=0.0;pt1[Z]=0.0;
        ads_polar(pt1,D_TO_R(180),2500.0,pt[1]);
        ads_polar(pt1,0.0,2500.0,pt[2]);
        LAYER_SET("thick");
        LINE(pt[1],pt[2]);
    // 车轮和地线
        GET_DIST(pt1,"\n请输入前轮距Bf(1740mm<Bf<2050mm):",Bf,1900.0);
        ads_polar(pt1,D_TO_R(180),Bf/2.0,pt[1]);
        ads_polar(pt1,0.0,Bf/2.0,pt[2]);
        ads_polar(pt[1],D_TO_R(180),100.0,pt[3]);
        ads_polar(pt[1],0.0,100.0,pt[5]);
        ads_polar(pt[3],D_TO_R(90),h3,pt[4]);
        ads_polar(pt[5],D_TO_R(90),h3,pt[6]);
        ads_polar(pt[2],D_TO_R(180),100.0,pt[7]);
        ads_polar(pt[2],0.0,100.0,pt[9]);
        ads_polar(pt[7],D_TO_R(90),h3,pt[8]);
        ads_polar(pt[9],D_TO_R(90),h3,pt[10]);
        ads_polar(pt1,D_TO_R(90),h3,pt[11]);
        ads_polar(pt[11],D_TO_R(180),W/2.0,pt[12]);
        ads_polar(pt[11],0.0,W/2.0,pt[13]);
        ads_polar(pt[6],D_TO_R(45),80.0,pt[14]);
        ads_polar(pt[8],D_TO_R(135),80.0,pt[15]);

        LINE(pt[3],pt[4]);
        LINE(pt[5],pt[6]);
        LINE(pt[7],pt[8]);
        LINE(pt[9],pt[10]);
        LINE(pt[12],pt[6]);
        LINE(pt[6],pt[14]);
        LINE(pt[14],pt[15]);
        LINE(pt[15],pt[8]);
        LINE(pt[8],pt[13]);
    // 侧围线、车顶线       
        ads_polar(pt[12],D_TO_R(90),H-h3,pt[16]);
        ads_polar(pt[13],D_TO_R(90),H-h3,pt[17]);
        ads_polar(pt[12],D_TO_R(90),80.0,pt[18]);
        ads_polar(pt[13],D_TO_R(90),80.0,pt[19]);
        ads_polar(pt[16],0.0,W/2.0,pt[20]);
        GET_DIST(NULL,"\n请输入侧围与顶盖过渡圆弧半径R8:",R8,200.0);
        LINE(pt[12],pt[16]);
        LINE(pt[16],pt[17]);
        LINE(pt[13],pt[17]);
        ads_polar(pt[12],D_TO_R(90),600.0,p1);
        ads_polar(pt[13],D_TO_R(90),600.0,p2);
        FILLET(R8,p1,pt[20]);
        FILLET(R8,p2,pt[20]);
       
//        ads_polar(pt[18],D_TO_R(90),200.0,pt[21]);
//        ads_polar(pt[19],D_TO_R(90),200.0,pt[22]);
//        ads_polar(pt[21],D_TO_R(90),10.0,pt[23]);
//        ads_polar(pt[22],D_TO_R(90),10.0,pt[24]);
//        ads_polar(pt[23],0.0,W/2.0,pt[25]);

        xscale=W/2500.0; yscale=H/3000.0;        angle=0.0;
        INSERTXY("chedengf",pt[18],xscale,yscale,angle);

       
        pt[26][X]=-W/2.0;pt[26][Y]=h1;pt[26][Z]=0.0;
        ads_polar(pt[26],0.0,W,pt[27]);
        ads_polar(pt[26],D_TO_R(90-0.35),130.0,pt[28]);
        ads_polar(pt[27],D_TO_R(90+0.35),130.0,pt[29]);
        ads_polar(pt[26],D_TO_R(90-0.35),H-h1-120.0,pt[30]);
        ads_polar(pt[27],D_TO_R(90+0.35),H-h1-120.0,pt[31]);
        ads_polar(pt[26],0.0,800.0,p1);
        ads_polar(pt[27],D_TO_R(90+0.25),500.0,p2);
        ads_polar(pt[30],0.0,800.0,p3);
   // ads_polar(p3,D_TO_R(-90.0),200.0,p3);
        ads_polar(pt[26],D_TO_R(90-0.25),500.0,p4);
        LINE(pt[30],pt[31]);
        LINE(pt[26],pt[27]);
        LINE(pt[26],pt[30]);
        LINE(pt[27],pt[31]);
        FILLET(300.0,p1,p2);
        FILLET(220.0,p2,p3);
        FILLET(220.0,p3,p4);
        FILLET(300.0,p4,p1);

        ads_polar(pt[28],D_TO_R(90-0.25),H-h1-330.0,pt[32]);
        ads_polar(pt[29],D_TO_R(90+0.25),H-h1-330.0,pt[33]);
        LINE(pt[28],pt[29]);
        LINE(pt[29],pt[33]);
        LINE(pt[33],pt[32]);
        LINE(pt[32],pt[28]);
        ads_polar(pt[28],0.0,W/2.0,p1);
        ads_polar(pt[29],D_TO_R(90+0.25),600.0,p2);
        ads_polar(pt[33],D_TO_R(180),W/2.0,p3);
        ads_polar(pt[28],D_TO_R(90-0.25),600.0,p4);
        FILLET(150.0,p1,p2);
        FILLET(150.0,p2,p3);
        FILLET(150.0,p3,p4);
        FILLET(150.0,p4,p1);

        ads_polar(pt[32],D_TO_R(-45),10.0,pt[32]);
        ads_polar(pt[28],D_TO_R(45),10.0,pt[28]);
        ads_polar(pt[33],D_TO_R(-135),10.0,pt[33]);
        ads_polar(pt[29],D_TO_R(135),10.0,pt[29]);
        LINE(pt[28],pt[29]);
        LINE(pt[29],pt[33]);
        LINE(pt[33],pt[32]);
        LINE(pt[32],pt[28]);
        ads_polar(pt[28],0.0,(W-10.0*sqrt(2.0))/2.0,p1);
        ads_polar(pt[29],D_TO_R(90+0.25),600.0,p2);
        ads_polar(pt[33],D_TO_R(180),(W-10.0*sqrt(2.0))/2.0,p3);
        ads_polar(pt[28],D_TO_R(90-0.25),600.0,p4);
        FILLET(150.0,p1,p2);
        FILLET(150.0,p2,p3);
        FILLET(150.0,p3,p4);
        FILLET(150.0,p4,p1);

//        LINE(p1,p3);
        xscale=W/2500.0;yscale=1.0;angle=0.0;
        INSERTXY("gyq",p1,xscale,yscale,angle);
        xscale=W/2500.0;yscale=0.9;angle=0.0;
        INSERTXY("hqc1",pt[20],xscale,yscale,angle);
       
        ads_polar(pt[26],D_TO_R(90-0.25),(H-h1+900)/2.0,p1);
        ads_polar(pt[27],D_TO_R(90+0.25),(H-h1+600.0)/2.0,p2);
        xscale=1.0;        yscale=1.0;angle=0.0;
        INSERTXY("hsjf1",p1,xscale,yscale,angle);
        INSERTXY("hsjf2",p2,xscale,yscale,angle);
   
        pt0[X]=-(10*sizew/18.0)/sizescale;  
        pt0[Y]=-(56.0+sizeh/17.0)/sizescale;
        pt0[Z]=0.0;
        SETUCS(pt0);
       

// 后视图

        bp0[X]=(12*sizew/18.0)/sizescale;
        bp0[Y]=(56.0+sizeh/17.0)/sizescale;
        bp0[Z]=0.0;
        SETUCS(bp0);
        pt1[X]=0.0;pt1[Y]=0.0;pt1[Z]=0.0;
        ads_polar(pt1,D_TO_R(180),2500.0,pt[1]);
        ads_polar(pt1,0.0,2500.0,pt[2]);
        LINE(pt[1],pt[2]);
   
//        W=2500.0;H=3000.0;h1=1300.0;h3=300.0; h2=1500.0;


//        GET_DIST(NULL,"\n请输入总宽W(W<=2500mm):",W,2500.0);
        GET_DIST(pt1,"\n请输入后轮距Br(1740mm<Br<2050mm):",Br,1800.0);
        ads_polar(pt1,D_TO_R(180),Br/2.0,pt[1]);
        ads_polar(pt1,0.0,Br/2.0,pt[2]);
        ads_polar(pt[1],D_TO_R(180),200.0,pt[3]);
        ads_polar(pt[1],0.0,200.0,pt[5]);
        ads_polar(pt[3],D_TO_R(90),h3,pt[4]);
        ads_polar(pt[5],D_TO_R(90),h3,pt[6]);
        ads_polar(pt[2],D_TO_R(180),200.0,pt[7]);
        ads_polar(pt[2],0.0,200.0,pt[9]);
        ads_polar(pt[7],D_TO_R(90),h3,pt[8]);
        ads_polar(pt[9],D_TO_R(90),h3,pt[10]);
        ads_polar(pt1,D_TO_R(90),h3,pt[11]);
        ads_polar(pt[11],D_TO_R(180),W/2.0,pt[12]);
        ads_polar(pt[11],0.0,W/2.0,pt[13]);
        ads_polar(pt[6],D_TO_R(180),200.0,pt[14]);
        ads_polar(pt[8],0.0,200.0,pt[15]);

        LINE(pt[3],pt[4]);
        LINE(pt[5],pt[6]);
        LINE(pt[7],pt[8]);
        LINE(pt[9],pt[10]);
        LINE(pt[12],pt[13]);
        LINE(pt[1],pt[14]);
        LINE(pt[2],pt[15]);
       
        ads_polar(pt[12],D_TO_R(90),h2-h3,pt[16]);
        ads_polar(pt[13],D_TO_R(90),h2-h3,pt[17]);
        ads_polar(pt[16],D_TO_R(90-0.25),(H-h2)/cos(0.25),pt[18]);
        ads_polar(pt[17],D_TO_R(90+0.25),(H-h2)/cos(0.25),pt[19]);
        ads_polar(pt[18],0.0,W/2.0,pt[20]);
        LINE(pt[12],pt[16]);
        LINE(pt[16],pt[18]);
        LINE(pt[13],pt[17]);
        LINE(pt[17],pt[19]);
        LINE(pt[18],pt[19]);

//        GET_DIST(NULL,"\n请输入侧围与顶盖过渡圆弧半径R8:",R8,200.0);
        FILLET(R8,pt[16],pt[20]);
        FILLET(R8,pt[17],pt[20]);

        ads_polar(pt[16],0.0,200.0,pt[29]);
        ads_polar(pt[17],D_TO_R(180),200.0,pt[30]);
        ads_polar(pt[29],D_TO_R(90),200.0,pt[29]);
        ads_polar(pt[30],D_TO_R(90),200.0,pt[30]);
        ads_polar(pt[29],D_TO_R(90-0.25),(H-h2-500.0)/cos(0.25),pt[32]);
        ads_polar(pt[30],D_TO_R(90+0.25),(H-h2-500.0)/cos(0.25),pt[31]);
        LINE(pt[30],pt[31]);
        LINE(pt[31],pt[32]);
        LINE(pt[29],pt[32]);
        LINE(pt[29],pt[30]);

        ads_polar(pt[29],0.0,500.0,p1);
        ads_polar(pt[31],D_TO_R(180),500.0,p3);
        ads_polar(pt[29],D_TO_R(90-0.25),500.0,p4);
        ads_polar(pt[30],D_TO_R(90+0.25),500.0,p2);
        FILLET(150.0,p1,p2);
        FILLET(150.0,p2,p3);
        FILLET(150.0,p3,p4);
        FILLET(150.0,p4,p1);

        ads_polar(pt[29],D_TO_R(45),40.0,pt[29]);
        ads_polar(pt[30],D_TO_R(135),40.0,pt[30]);
        ads_polar(pt[31],D_TO_R(-135),40.0,pt[31]);
        ads_polar(pt[32],D_TO_R(-45),40.0,pt[32]);
        LINE(pt[29],pt[30]);
        LINE(pt[30],pt[31]);
        LINE(pt[31],pt[32]);
        LINE(pt[32],pt[29]);
        ads_polar(pt[29],0.0,500.0,p1);
        ads_polar(pt[31],D_TO_R(180),500.0,p3);
        ads_polar(pt[29],D_TO_R(90-0.25),500.0,p4);
        ads_polar(pt[30],D_TO_R(90+0.25),500.0,p2);
       
        FILLET(150.0,p1,p2);
        FILLET(150.0,p2,p3);
        FILLET(150.0,p3,p4);
        FILLET(150.0,p4,p1);

        if(strcmp(_strupr(str1),"KT")==0)
        {
                xscale=W/2500.0; yscale=0.9;angle=0.0;
                INSERTXY("hqc1",pt[20],xscale,yscale,angle);
        }

        else if(strcmp(_strupr(str1),"XL")==0)
        {
                xscale=W/2500.0; yscale=1.0;angle=0.0;
                INSERTXY("xljr",pt[20],xscale,yscale,angle);
        }
       
        xscale=W/2500;        yscale=(H-h2)/1500.0; angle=0.0;
        INSERTXY("cdrear",pt[11],xscale,yscale,angle);

        ads_polar(pt[6],D_TO_R(-90),50.0,pt[33]);
        ads_polar(pt[8],D_TO_R(-90),50.0,pt[37]);
        ads_polar(pt[33],0.0,(Br-400.0)/2.5,pt[34]);
        ads_polar(pt[37],D_TO_R(180),(Br-400.0)/2.5,pt[36]);
        ads_polar(pt[11],D_TO_R(-90),(Br-400.0)/10.0,pt[35]);
        LINE(pt[33],pt[34]);
        ARC(pt[34],pt[35],pt[36]);
        LINE(pt[36],pt[37]);
    pt0[X]=-(12*sizew/18.0)/sizescale;
        pt0[Y]=-(56.0+sizeh/17.0)/sizescale;
        pt0[Z]=0.0;
        SETUCS(pt0);
       
// 画横剖视图

    bp0[X]=(14*sizew/18.0)/sizescale;
        bp0[Y]=(56.0+sizeh/17.0)/sizescale;
        bp0[Z]=0.0;
        SETUCS(bp0);
        pt1[X]=0.0;pt1[Y]=0.0;pt1[Z]=0.0;
        ads_polar(pt1,D_TO_R(180),2500.0,pt[1]);
        ads_polar(pt1,0.0,2500.0,pt[2]);
//        LAYER_SET("thick");
        LINE(pt[1],pt[2]);
    // 车轮和地线

//W=2500.0;H=3000.0;h1=1300.0;h3=300.0; h2=1500.0;Bf=1900.0;
//h0=1050.0;L7=350.0;

        ads_polar(pt1,D_TO_R(180),Bf/2.0,pt[1]);
        ads_polar(pt1,0.0,Bf/2.0,pt[2]);
        ads_polar(pt[1],D_TO_R(180),100.0,pt[3]);
        ads_polar(pt[1],0.0,100.0,pt[5]);
        ads_polar(pt[3],D_TO_R(90),h3,pt[4]);
        ads_polar(pt[5],D_TO_R(90),h3,pt[6]);
        ads_polar(pt[2],D_TO_R(180),100.0,pt[7]);
        ads_polar(pt[2],0.0,100.0,pt[9]);
        ads_polar(pt[7],D_TO_R(90),h3,pt[8]);
        ads_polar(pt[9],D_TO_R(90),h3,pt[10]);
        ads_polar(pt1,D_TO_R(90),h3,pt[11]);
        ads_polar(pt[11],D_TO_R(180),W/2.0,pt[12]);
        ads_polar(pt[11],0.0,W/2.0,pt[13]);
        ads_polar(pt1,D_TO_R(180),W/2.0,pt[14]);

        LINE(pt[3],pt[4]);
        LINE(pt[5],pt[6]);
        LINE(pt[7],pt[8]);
        LINE(pt[9],pt[10]);
        LINE(pt[12],pt[13]);

    // 侧围线、车顶线       
        ads_polar(pt[12],D_TO_R(90),H-h3,pt[16]);
        ads_polar(pt[13],D_TO_R(90),H-h3,pt[17]);
        ads_polar(pt[16],0.0,W/2.0,pt[18]);
        GET_DIST(NULL,"\n请输入侧围与顶盖过渡圆弧半径R8:",R8,200.0);
        LINE(pt[12],pt[16]);
        LINE(pt[16],pt[17]);
        LINE(pt[13],pt[17]);
        ads_polar(pt[12],D_TO_R(90),800.0,p1);
        ads_polar(pt[13],D_TO_R(90),800.0,p2);
        FILLET(R8,p1,pt[18]);
        FILLET(R8,p2,pt[18]);
        xscale=W/2500.0;yscale=0.9;angle=0.0;
        INSERTXY("hqc1",pt[18],xscale,yscale,angle);
       
        ads_polar(pt1,D_TO_R(90),h0,pt[19]);
        ads_polar(pt[19],D_TO_R(180.0),W/2.0,pt[20]);
        ads_polar(pt[19],D_TO_R(0.0),W/2.0,pt[21]);
        ads_polar(pt[19],D_TO_R(180.0),L7/2.0,pt[22]);
        ads_polar(pt[22],D_TO_R(90),120,pt[23]);
        ads_polar(pt[23],D_TO_R(180.0),(W-L7)/2.0,pt[24]);
    ads_polar(pt[19],D_TO_R(0.0),L7/2.0,pt[25]);
        ads_polar(pt[25],D_TO_R(90.0),120.0,pt[26]);
        ads_polar(pt[26],D_TO_R(0.0),(W-L7)/2.0,pt[27]);
        LINE(pt[20],pt[21]);
        LINE(pt[22],pt[23]);
        LINE(pt[23],pt[24]);
        LINE(pt[25],pt[26]);
        LINE(pt[26],pt[27]);

        ads_polar(pt[18],D_TO_R(-90.0),0.06*H,pt[28]);
        ads_polar(pt[28],D_TO_R(180.0),0.45*W,pt[29]);
        ads_polar(pt[28],D_TO_R(0.0),0.45*W,pt[30]);
        LINE(pt[29],pt[30]);
        scale=1.0;angle=0.0;
        INSERT("*leftxl",pt[29],scale,angle);
        INSERT("*rightxl",pt[30],scale,angle);

        ads_polar(pt[23],D_TO_R(180.0),70,pt[31]);
        ads_polar(pt[26],D_TO_R(0.0),70,pt[32]);
        xscale=(W-L7)/2180.0; yscale=(H-h0)/2000.0;angle=0.0;
        INSERTXY("pzyl",pt[31],xscale,yscale,angle);
        INSERTXY("pzyr",pt[32],xscale,yscale,angle);

        GET_INT("\n踏步共分几级?(n<8)",n,3);
    A=300.0; E=340.0; E0=0.0;
        for( i=1;i<=n;i++)
        {  
                if(i==1){ GET_DIST(NULL,"\n请输入第1级踏步高D(150.0<=D<=400.0):",D,380.0);
                                GET_DIST(NULL,"\n请输入第1级踏步深A1(300.0<=A1):",A1,360.0);
                                ads_polar(pt[14],D_TO_R(90.0),D,pt[33]);
                                ads_polar(pt[33],D_TO_R(0.0),A1,pt[34]);
                                LINE(pt[33],pt[34]);
                                E0=E0+D;
                }
                else if(i==n){
                            E=h0-E0;
                            ads_polar(pt[34],D_TO_R(95.0),E/cos(D_TO_R(5.0)),pt[35]);
                                LINE(pt[34],pt[35]);
                }

                else  { ads_printf("\n请输入第%d级踏步高E(150.0<=E<=350.0):",i);
                                GET_DIST(NULL,"\0",E,E);
                                ads_printf("\n请输入第%d级踏步深A(200.0<=A):",i);
                                GET_DIST(NULL,"\0",A,A);
                                ads_polar(pt[34],D_TO_R(95.0),E/cos(D_TO_R(5.0)),pt[35]);
                                ads_polar(pt[35],D_TO_R(0.0),A,pt[36]);
                                LINE(pt[34],pt[35]); LINE(pt[35],pt[36]);
                                ads_polar(pt[36],D_TO_R(0.0),0.0,pt[34]);
                                E0=E0+E;
                }
        }



    pt0[X]=-(14*sizew/18.0)/sizescale;
        pt0[Y]=-(56.0+sizeh/17.0)/sizescale;
        pt0[Z]=0.0;
        SETUCS(pt0);

        return ads_retvoid();
        return RTNORM;
}


void set_initivars(ads_hdlg hdlg)
{ char *bitem;
  char **blist = initistr;
  
  for ( int i=0; (bitem = *blist) != NULL; ++blist,i++)
       ads_get_tile(hdlg, bitem, dlgvalue,20);

  blist = radiobutton;
  for ( int j=0; (bitem = *blist) != NULL; ++blist,j++)
       ads_get_tile(hdlg, bitem, sizebuttonvalue[j],2);
  return;
}

static int CALLB initi_ok(ads_callback_packet *cpkt)
{         set_initivars(cpkt->dialog);
    ads_done_dialog(cpkt->dialog, 1);
        return 0;
}

static int CALLB initi_cancel(ads_callback_packet *cpkt)
{        
    ads_done_dialog(cpkt->dialog, 1);
        return 0;
}

int initidlg(ads_real &scale,char *sizestr)
{         
  ads_hdlg hdlg;
  int dlg_status;
  char scalestr[6];
  char *p,**p1;
  int dcl_id;   
  char  *scalelist[]={"1:5","1:10","1:15","1:20","1:25","1:30","1:40","1:45","1:50",NULL};

   ads_load_dialog("diatzh.dcl", &dcl_id);
   if (dcl_id < 0)     
   { ads_printf("Error loading \"dialog.dcl\"\n");
     return RTERROR;  }

   ads_new_dialog("initi", dcl_id, (CLIENTFUNC)0, &hdlg);
   if (hdlg == NULL)
   { ads_printf("new_dialog for initialization failed\n");
     ads_unload_dialog(dcl_id);
     return RTERROR;
    }
  
  ads_action_tile(hdlg, "accept", (CLIENTFUNC)initi_ok);

  ads_start_list(hdlg, "popup_list_k", LIST_NEW, 0);
  for (p1=scalelist; *p1!=NULL; p1++)    ads_add_list(*p1);
  ads_end_list();
  ads_set_tile(hdlg,"popup_list_k","6");

  ads_start_dialog(hdlg, &dlg_status);
  ads_unload_dialog(dcl_id);

  strcpy(scalestr,scalelist[atoi(dlgvalue[1])]);

  p=strchr(scalestr,':'); p=p+1;
  scale=1.0/atof(p);

  for(int i=0;i<4;i++)
   if(atoi(sizebuttonvalue)==1)
   {  strcpy(sizestr,radiobutton);break; }
  
   return RTNORM;
}


static int CALLB image_ok(ads_callback_packet *cpkt)
{ char *bitem,imagebuttonvalue[6][2],imagestr[4],*p;
  char **blist;
  static  char *imageradio_k[]={"ch1","ch2","ch3","ch4","ch5","ch6",NULL};

  blist =imageradio_k;
  for ( int j=0; (bitem = *blist) != NULL; ++blist,j++)
      ads_get_tile(cpkt->dialog, bitem, imagebuttonvalue[j],2);
  
  for(int i=0;i<6;i++)
   if(atoi(imagebuttonvalue)==1)
   {  strcpy(imagestr,imageradio_k);break; }       
     //ads_printf("imagestr:%s\n",imagestr);
      p=imagestr+2; imageid=atoi(p);
      ads_done_dialog(cpkt->dialog, 1);
  return 0;
}


int imagedlg()
{        
  ads_hdlg hdlg;
  int dlg_status;
  short width,height;
  char **p1,**p2;
  int dcl_id;   
  char  *imagekey[]={"image1","image2","image3","image4","image5","image6",NULL};
  char  *imagename[]={"tlch","tlcha","fbch","txch","zhch1","zhch2",NULL};
  
   ads_load_dialog("diatzh.dcl", &dcl_id);
    if (dcl_id < 0)     
    { ads_printf("Error loading \"dialog.dcl\"\n");
     return RTERROR;  }
   ads_new_dialog("imagev", dcl_id, (CLIENTFUNC)0, &hdlg);
    if (hdlg == NULL)
    { ads_printf("new_dialog for initialization failed\n");
      ads_unload_dialog(dcl_id);
      return RTERROR;
        }

  ads_action_tile(hdlg, "accept", (CLIENTFUNC)image_ok);

  ads_dimensions_tile(hdlg,"imageview",&width,&height);

  for (p1=imagekey,p2=imagename; *p1!=NULL; p1++,p2++)
  { ads_start_image(hdlg, *p1);
    ads_fill_image(0,0,width,height,0);
    ads_slide_image(-3,0,width,height,*p2);
    ads_end_image();
  }

  ads_start_dialog(hdlg, &dlg_status);
  ads_unload_dialog(dcl_id);

  return RTNORM;
}


static void curvercreat(ads_point basept,ads_point backpt1,ads_point backpt2,\
                                                int flag,char type[][2],ads_real data[],int &end)
{ char yesno[2],yn1[2],yn2[2];
   static ads_real l,r0,r1,r2,height,angle;
   static ads_point pto1,pto2,firstpt,endpt;
   char type1[2],type2[2],type3[2];
   short j=0,k=0;

// basept        是前围曲线的最前端点或后曲线的最后端点
// backpt1和backpt2分别返回曲线的最上端和最下端
// flag=0 表示绘制前围曲线 flag=1 表示绘制后围曲线
  
  for(int i=1;i<3;i++)
  { endpt[X]=basept[X]; endpt[Y]=basept[Y];
          if(i==1) { ads_getstring(1,"\n要绘制上半段曲线吗?<Y\\N>:",yn1);  
                if(strcmp(_strupr(yn1),"N")!=0)
                            ads_getreal("请输入第一段圆弧的半径:",&r0);
                           else { backpt1[X]=endpt[X]; backpt1[Y]=endpt[Y];continue;}
             }
    else    {  ads_getstring(1,"\n要绘制下半段曲线吗?<Y\\N>:",yn2);  
               if(strcmp(_strupr(yn2),"N")==0)   { backpt2[X]=endpt[X]; backpt2[Y]=endpt[Y];continue;}
                   else if(strcmp(_strupr(yn1),"N")==0)
                                    ads_getreal("请输入第一段圆弧的半径:",&r0);
                }
   
        data[k++]=r0;
        ads_getreal("请输入第一段圆弧的高(注意正负):",&height);
        data[k++]=height;
        r2=r0;
        if(r2<height) {ads_printf("\n错误! 半径太小!\n"); i=i-1;continue;}
  
        if(flag==0)        { pto2[X]=basept[X]+r2; pto2[Y]=basept[Y];}
        else if(flag==1) { pto2[X]=basept[X]-r2; pto2[Y]=basept[Y];}
    else {ads_printf("\n错误!\n"); break; return;}

    firstpt[X]=basept[X]; firstpt[Y]=basept[Y];
    endpt[Y]=firstpt[Y]+height;
        endpt[X]=pow(-1,flag+1)*sqrt((r2+endpt[Y]-pto2[Y])*(r2-endpt[Y]+pto2[Y]))+pto2[X];
   
        if(i==1&&height>0)
         switch(flag)
           {case 0: { ARCFCE(endpt,pto2,firstpt); break;}
                case 1: { ARCFCE(firstpt,pto2,endpt); break;}
                default:break;}
        else if(i==2&&height<0)
         switch(flag)
           {case 0: { ARCFCE(firstpt,pto2,endpt); break;}
                case 1: { ARCFCE(endpt,pto2,firstpt); break;}
                default:break;}
       
    else { ads_printf("\n错误!上半段曲线高度应为正值!\n下半段曲线高度应为负值!\n");
                i=i-1; continue;}
       
        strcpy(type2,"A"); strcpy(type[j++],type2);
    if(i==1) ads_getstring(1,"继续绘制上半段曲线吗?<Y\\N>:",yesno);
    else  ads_getstring(1,"继续绘制下半段曲线吗?<Y\\N>:",yesno);

        while(strcmp(_strupr(yesno),"N")!=0)
        {           
      strcpy(type3,type1);
      strcpy(type1,type2);
          do{ ads_getstring(1,"请输入下一段曲线的构成形式,圆弧<A>、直线<L>:",type2);}
          while(strcmp(_strupr(type2),"A")!=0&&strcmp(_strupr(type2),"L")!=0);
      strcpy(type[j++],type2);
          
          if(strcmp(_strupr(type2),"L")==0)     // 要画直线
          { if(strcmp(_strupr(type1),"L")==0)
               {ads_printf("\n错误!不能连接两条直线!\n"); continue;}
            else         // 上段为弧线
            { ads_getreal("请输入直线的高度(注意正负):",&height);
                  data[k++]=height;
                  if(i==1&&height<0||i==2&&height>0)
                      { ads_printf("\n错误!\n上半段曲线高度应为正值!\n下半段曲线高度应为负值!\n");
                       strcpy(type2,type1);   strcpy(type1,type3); continue;}
                  angle=asin((pto2[X]-endpt[X])/r2);
                  firstpt[X]=endpt[X];  firstpt[Y]=endpt[Y];
                  endpt[X]=firstpt[X]+fabs(height)/tan(angle);
          endpt[Y]=firstpt[Y]+height;
                  LINE(firstpt,endpt);
                }
          }
     else          // 要画弧线
          { r1=r2;
            ads_getreal("请输入圆弧的半径:",&r2);
                data[k++]=r2;
        ads_getreal("请输入圆弧的高度(注意正负):",&height);       
                data[k++]=height;

                if(i==1&&height<0||i==2&&height>0)
                      { ads_printf("\n错误!\n上半段曲线高度应为正值!\n下半段曲线高度应为负值!\n");
                       strcpy(type2,type1);   strcpy(type1,type3); continue;}
        if(r2<height) {ads_printf("\n错误! 半径太小!\n"); continue;}
                if(strcmp(_strupr(type1),"L")==0)  // 上段为直线
                  { pto1[X]=pto2[X]; pto1[Y]=pto2[Y];
                    pto2[X]=endpt[X]+r2*sin(angle);
            pto2[Y]=endpt[Y]-r2*cos(angle)*height/fabs(height);
                  }
                else                               // 上段为弧线
                  {  pto1[X]=pto2[X]; pto1[Y]=pto2[Y];                     
                     pto2[X]=(1-r2/r1)*endpt[X]+r2/r1*pto1[X];
             pto2[Y]=(1-r2/r1)*endpt[Y]+r2/r1*pto1[Y];
                  }

        firstpt[X]=endpt[X];  firstpt[Y]=endpt[Y];
        endpt[Y]=firstpt[Y]+height;
                endpt[X]=pow(-1,flag+1)*sqrt((r2+endpt[Y]-pto2[Y])*(r2-endpt[Y]+pto2[Y]))+pto2[X];

            if(i==1&&height>0)
               switch(flag)
                 {case 0: { ARCFCE(endpt,pto2,firstpt); break;}
                      case 1: { ARCFCE(firstpt,pto2,endpt); break;}
                      default:break;}
            else if(i==2&&height<0)
               switch(flag)
                 {case 0: { ARCFCE(firstpt,pto2,endpt); break;}
                      case 1: { ARCFCE(endpt,pto2,firstpt); break;}
                      default:break;}
        else { ads_printf("\n错误!上半段曲线高度应为正值!\n下半段曲线高度应为负值!\n");
                continue;}
          }
   
    if(i==1) ads_getstring(1,"继续绘制上半段曲线吗?<Y\\N>:",yesno);
    else  ads_getstring(1,"继续绘制下半段曲线吗?<Y\\N>:",yesno);
        }
        if(i==1&&strcmp(_strupr(yn1),"N")!=0)
            { backpt1[X]=endpt[X]; backpt1[Y]=endpt[Y];}

        else if(i==2&&strcmp(_strupr(yn2),"N")!=0)
            { backpt2[X]=endpt[X]; backpt2[Y]=endpt[Y];}
   }
    end=j;
        return;
}

static void curvercreat2(ads_point basept,ads_point backpt1,ads_point backpt2,int flag,\
                                                 char type[][2],ads_real data[],int end)
{ static ads_real l,r0,r1,r2,height,angle;
   static ads_point pto1,pto2,firstpt,endpt;
   char type1[2],type2[2];
   short j=0,k=0;

// basept        是前围曲线的最前端点或后曲线的最后端点
// backpt1和backpt2分别返回曲线的最上端和最下端
// flag=0 表示绘制前围曲线 flag=1 表示绘制后围曲线
  
  for(int i=1;i<3;i++)
  { endpt[X]=basept[X]; endpt[Y]=basept[Y];
    if(i==1&&data[1]<=0)  { backpt1[X]=endpt[X]; backpt1[Y]=endpt[Y];continue;}
    if(i==2&&j>=end)  { backpt2[X]=endpt[X]; backpt2[Y]=endpt[Y];continue;}        
   
    r2=data[k++];
        if(flag==0)        { pto2[X]=basept[X]+r2; pto2[Y]=basept[Y];}
        else if(flag==1) { pto2[X]=basept[X]-r2; pto2[Y]=basept[Y];}
    else {ads_printf("\n错误!\n"); break; return;}
   
        height=data[k++];
    firstpt[X]=basept[X]; firstpt[Y]=basept[Y];
    endpt[Y]=firstpt[Y]+height;
        endpt[X]=pow(-1,flag+1)*sqrt((r2+endpt[Y]-pto2[Y])*(r2-endpt[Y]+pto2[Y]))+pto2[X];
   
        if(i==1&&height>0)
         switch(flag)
           {case 0: { ARCFCE(endpt,pto2,firstpt); break;}
                case 1: { ARCFCE(firstpt,pto2,endpt); break;}
                default:break;}
        else
         switch(flag)
           {case 0: { ARCFCE(firstpt,pto2,endpt); break;}
                case 1: { ARCFCE(endpt,pto2,firstpt); break;}
                default:break;}
               
        strcpy(type2,type[j++]);
   
        while(j<end)
        {
          if(i==1&&(data[k]<=0||data[k+1]<=0))  break;
      //if(i==2&&data[k]>=0)  break;         
          
      strcpy(type1,type2);
          strcpy(type2,type[j++]);
     
          if(strcmp(_strupr(type2),"L")==0)     // 要画直线
          { if(strcmp(_strupr(type1),"L")==0)
               {ads_printf("\n错误!不能连接两条直线!\n"); continue;}
            else         // 上段为弧线
            { height=data[k++];       
                  angle=asin((pto2[X]-endpt[X])/r2);
                  firstpt[X]=endpt[X];  firstpt[Y]=endpt[Y];
                  endpt[X]=firstpt[X]+fabs(height)/tan(angle);
          endpt[Y]=firstpt[Y]+height;
                  LINE(firstpt,endpt);
                }
          }
     else          // 要画弧线
          { r1=r2;
            r2=data[k++]; height=data[k++];
                if(strcmp(_strupr(type1),"L")==0)  // 上段为直线
                  { pto1[X]=pto2[X]; pto1[Y]=pto2[Y];
                    pto2[X]=endpt[X]+r2*sin(angle);
            pto2[Y]=endpt[Y]-r2*cos(angle)*height/fabs(height);
                  }
                else                               // 上段为弧线
                  {  pto1[X]=pto2[X]; pto1[Y]=pto2[Y];                     
                     pto2[X]=(1-r2/r1)*endpt[X]+r2/r1*pto1[X];
             pto2[Y]=(1-r2/r1)*endpt[Y]+r2/r1*pto1[Y];
                  }

        firstpt[X]=endpt[X];  firstpt[Y]=endpt[Y];
        endpt[Y]=firstpt[Y]+height;
                endpt[X]=pow(-1,flag+1)*sqrt((r2+endpt[Y]-pto2[Y])*(r2-endpt[Y]+pto2[Y]))+pto2[X];

            if(i==1&&height>0)
               switch(flag)
                 {case 0: { ARCFCE(endpt,pto2,firstpt); break;}
                      case 1: { ARCFCE(firstpt,pto2,endpt); break;}
                      default:break;}
            else
               switch(flag)
                 {case 0: { ARCFCE(firstpt,pto2,endpt); break;}
                      case 1: { ARCFCE(endpt,pto2,firstpt); break;}
                      default:break;}
          }
        }
        if(i==1&&(data[k]<=0||data[k+1]<=0))
            { backpt1[X]=endpt[X]; backpt1[Y]=endpt[Y];}
        else  
            { backpt2[X]=endpt[X]; backpt2[Y]=endpt[Y];}
  }
}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-21 19:53 , Processed in 0.193323 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表