00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00029 void Save_Iv(const char * filename)
00030 {
00031 FILE *fp;
00032 fp = fopen(filename,"wb");
00033 fprintf(fp,"#Inventor V2.1 ascii \n" );
00034 fprintf(fp," \n" );
00035 fprintf(fp,"Separator { \n " );
00036 fprintf(fp,"ShapeHints {\n");
00037 fprintf(fp,"vertexOrdering COUNTERCLOCKWISE\n");
00038 fprintf(fp,"shapeType UNKNOWN_SHAPE_TYPE\n");
00039 fprintf(fp,"}\n");
00040 fprintf(fp,"MaterialBinding {\n");
00041 fprintf(fp," value PER_FACE\n");
00042 fprintf(fp,"}\n");
00043 fprintf(fp,"Material{\n");
00044 fprintf(fp," diffuseColor [\n");
00045 fprintf(fp," ]\n");
00046 fprintf(fp,"}\n");
00047
00048 fprintf(fp,"Coordinate3 { \n " );
00049 fprintf(fp,"point [ " );
00050
00051 face_iterator fi;
00052 vertex_iterator vi;
00053 map<vertex_pointer,int> index;
00054 int ind;
00055 for(ind=0,vi=vert.begin(); vi!=vert.end(); ++vi,++ind)
00056 {
00057 fprintf(fp,"%f%s",(*vi).P()[0]," " );
00058 fprintf(fp,"%f%s",(*vi).P()[1]," " );
00059 fprintf(fp,"%f%s",(*vi).P()[2],",\n");
00060 index[&*vi] = ind;
00061 }
00062 fprintf(fp," ] \n" );
00063 fprintf(fp,"} \n" );
00064
00065 fprintf(fp,"IndexedFaceSet { \n" );
00066 fprintf(fp,"coordIndex [ " );
00067 for (fi=face.begin(); fi!=face.end(); ++fi)
00068 {
00069 for (int j = 0; j < 3; j++)
00070 fprintf(fp,"%i%s",index[(*fi).V(j)],", ");
00071 fprintf(fp,"%s","-1, \n");
00072 }
00073 fprintf(fp," ] \n" );
00074 fprintf(fp," } \n" );
00075 fprintf(fp," } \n" );
00076
00077 fclose(fp);
00078 }