备用代码

来源:互联网 发布:手机简谱制作软件 编辑:程序博客网 时间:2024/04/28 04:08
void CMFCApplication1Dlg::switchkeyword(CString  str){    int b = 4;    int c = a + b;    dxfData tempDXF;    int element = -1;    int symbol = 0;    CStdioFile myFile(path, CFile::modeRead);     myFile.ReadString(code);    mListDXF.ResetContent();    while (myFile.ReadString(code))    {        while ((strcmp(code, "LINE") == 0) || (strcmp(code, "CIRCLE") == 0) || (strcmp(code, "ARC") == 0) || (strcmp(code, "SPLINE") == 0) || (strcmp(code, "LWPOLYLINE") == 0))        {            if ((strcmp(code, "LINE") == 0)) element = 0;            if ((strcmp(code, "CIRCLE") == 0)) element = 1;            if ((strcmp(code, "ARC") == 0)) element = 2;            if ((strcmp(code, "SPLINE") == 0)) element = 3;            if ((strcmp(code, "LWPOLYLINE") == 0)) element = 4;            switch (element)            {            case LINE:                myFile.ReadString(code);//这行代码和下面一行的作用是如果是LINE则让它能进入循环,且没有循环完LINE则不能出来。没有这行则根本下面都进不去,关键是不会存在2个LINE一起存在。                while ((strcmp(code, "LINE") != 0) && (strcmp(code, "CIRCLE") != 0) && (strcmp(code, "ARC") != 0) && (strcmp(code, "SPLINE") != 0) && (strcmp(code, "LWPOLYLINE") != 0) && (strcmp(code, "ENDSEC") != 0))                {                    myFile.ReadString(code);                    symbol = atoi(code);                    switch (symbol)                    {                    case 10:                        myFile.ReadString(code);                        tempDXF.LINE[0] = atof(code);                        break;                    case 20:                        myFile.ReadString(code);                        tempDXF.LINE[1] = atof(code);                        break;                    case 30:                        myFile.ReadString(code);                        tempDXF.LINE[2] = atof(code);                        break;                    case 11:                        myFile.ReadString(code);                        tempDXF.LINE[3] = atof(code);                        break;                    case 21:                        myFile.ReadString(code);                        tempDXF.LINE[4] = atof(code);                        break;                    case 31:                        myFile.ReadString(code);                        tempDXF.LINE[5] = atof(code);                        str.Format("LINE:From: %.4lf, %.4lf, %.4lf To: %.4lf, %.4lf, %.4lf", tempDXF.LINE[0], tempDXF.LINE[1], tempDXF.LINE[2], tempDXF.LINE[3], tempDXF.LINE[4], tempDXF.LINE[5]);                        mListDXF.InsertString(-1, str);                    //CString stra =(CString)( tempDXF.LINE[0] + tempDXF[1]);                        //CString pluscode[6], addcode;                        /*for (int i = 0; i < 6; i++)                        {                            addcode + = tempDXF.LINE[i];                        }*/                        /*e = itoa( c, string,10);*/                        m_showdata.SetWindowTextA(str);//在这里给个循环,让之前所有累加起来。                        vdxfData.push_back(tempDXF);                    default: break;                    }                }                break;            case CIRCLE:                myFile.ReadString(code);                while ((strcmp(code, "LINE") != 0) && (strcmp(code, "CIRCLE") != 0) && (strcmp(code, "ARC") != 0) && (strcmp(code, "SPLINE") != 0) && (strcmp(code, "LWPOLYLINE") != 0) && (strcmp(code, "ENDSEC") != 0))                {                    myFile.ReadString(code);                    symbol = atoi(code);                    switch (symbol)                    {                    case 10:                        myFile.ReadString(code);                        tempDXF.CIRCLE[0] = atof(code);                        break;                    case 20:                        myFile.ReadString(code);                        tempDXF.CIRCLE[1] = atof(code);                        break;                    case 30:                        myFile.ReadString(code);                        tempDXF.CIRCLE[2] = atof(code);                        break;                    case 40:                        myFile.ReadString(code);                        tempDXF.CIRCLE[3] = atof(code);                        break;                    default: break;                    }                }                str.Format("CIRCLE: %.4lf, %.4lf, %.4lf , %.4lf", tempDXF.CIRCLE[0], tempDXF.CIRCLE[1], tempDXF.CIRCLE[2], tempDXF.CIRCLE[3]);                mListDXF.InsertString(-1, str);                //vdxfData.push_back(tempDXF);                break;            case ARC:                myFile.ReadString(code);                while ((strcmp(code, "LINE") != 0) && (strcmp(code, "CIRCLE") != 0) && (strcmp(code, "ARC") != 0) && (strcmp(code, "SPLINE") != 0) && (strcmp(code, "LWPOLYLINE") != 0) && (strcmp(code, "ENDSEC") != 0))                {                    myFile.ReadString(code);                    symbol = atoi(code);                    switch (symbol)                    {                    case 10:                        myFile.ReadString(code);                        tempDXF.ARC[0] = atof(code);                        break;                    case 20:                        myFile.ReadString(code);                        tempDXF.ARC[1] = atof(code);                        break;                    case 30:                        myFile.ReadString(code);                        tempDXF.ARC[2] = atof(code);                        break;                    case 40:                        myFile.ReadString(code);                        tempDXF.ARC[3] = atof(code);                        break;                    case 50:                        myFile.ReadString(code);                        tempDXF.ARC[4] = atof(code);                        break;                    case 51:                        myFile.ReadString(code);                        tempDXF.ARC[5] = atof(code);                        str.Format("ACR: %.4lf, %.4lf, %.4lf, %.4lf, %.4lf, %.4lf", tempDXF.ARC[0], tempDXF.ARC[1], tempDXF.ARC[2], tempDXF.ARC[3], tempDXF.ARC[4], tempDXF.ARC[5]);                        mListDXF.InsertString(-1, str);                        vdxfData.push_back(tempDXF);                    default: break;                    }                }                break;            case LWPOLYLINE:                myFile.ReadString(code);                while ((strcmp(code, "LINE") != 0) && (strcmp(code, "CIRCLE") != 0) && (strcmp(code, "ARC") != 0) && (strcmp(code, "SPLINE") != 0) && (strcmp(code, "LWPOLYLINE") != 0) && (strcmp(code, "ENDSEC") != 0))                {                    int i = 0;                    int j = 0;                    myFile.ReadString(code);                    symbol = atoi(code);                    switch (symbol)                    {                    case 10:                        /*myFile.ReadString(code);                        while ((strcmp(code, "10") != 0&&)*/                        myFile.ReadString(code);                        tempDXF.LWPOLYLINE[2*i] = atof(code);                        break;                    case 20:                        myFile.ReadString(code);                        tempDXF.LWPOLYLINE[2 * j + 1] = atof(code);                        str.Format("LWPOLYLINE: %.4lf, %.4lf", tempDXF.LWPOLYLINE[2*i], tempDXF.LWPOLYLINE[2*j+1]);                        mListDXF.InsertString(-1, str);                        vdxfData.push_back(tempDXF);                    /*  CFile file;                        file.Open("D:\\1.txt ", CFile::modeWrite | CFile::modeCreate);                        file.Write();*/                    default: break;                    }                }                break;            default:                break;            }        }    } //End file    }
0 0
原创粉丝点击