/* 対応入出力基本要素  入力 出力 * mesh ;color,vertex,scalar,normal, * normal_and_color --->color * disjoint polygon ;color,vertex    --->color * polyhedron ;color,vertex    --->color * sphere ;color,vertex    --->color * column ;normal_and_color,normal, * vertex,color,dvertex, * dvertex_and_color   --->normal_and_color * circle ;normal_and_color,normal, * vertex,color --->normal_and_color * disjoint line ;color,vertex    --->color * polyline ;color,vertex    --->color * label ;color,vertex(label number=1)  --->color(label number=1) * polytri ;color,vertex,normal,    * normal_and_color --->color * * actorの仕様 *   シナリオは、すべてactorで書かなければならない。 * actorに対しては、一回のアクションでその中の全基本オブジェクトの動作ができる。 *   actorは、重複してオブジェクトを共有できる。 * 全actorで共通のデフォルトアクションを設定できる。(actsetdefault〜actordefstart) *   actorは、dim_size-1個定義できる。 * actorの定義方法 *  actor定義は、actordefstart〜actordefendで定義される *  actorの番号は、1から連番でなければならない。 *  actorは、利用する基本オブジェクトの数と番号(obj3の場合、3)をブランクでつないで定義する。 *  各actorは、デフォルトアクションを設定できる。(共通のデフォルトより優先) * 例) * template gtemplate.mgf :テンプレートファイルの定義 * avsfile outavsg.mgf :Animation Virtual Stage ファイル(出力)の定義 * actsetdefault :全actorで共通のデフォルトアクションを設定開始 * ratio_x 1.0 * ratio_y 1.0 * ratio_z 2.0 * shift_x -1.0 * shift_y -3.0 * rot_xy 0.0 * actordefstart :各actorの定義と個別デフォルトアクションを設定開始 * actor1 6 * 1 2 3 4 5 6 * ratio_x 4.0 * ratio_y 4.0 * ratio_z 4.0 *   actor2 3 * 6 9 11 * shift_y 2.0 * rot_xy 4.0 * actordefend :各actorの定義と個別デフォルトアクションを設定終了 * steps 2 :シナリオ開始、総ステップ数設定 * step 1 :第一ステップ開始 * actor 1 :第一ステップでのactorのインスタンスとアクション設定 * shift_z -5.0 * rot_yz 3.0 * actor 2 * shift_z -2.0 * rot_yz 1.0 * step 2 :第二ステップ開始 *  * *  * *  * * end :シナリオ終了 */ /*----------------------------------------------------------------------------------------------------------------*/ #define dim_size 128 #define num_actor 2048 #define mode_sw 0 #include #include #include #include #include #include FILE *file_p0,*file_p1,*file_p2,*file_p3,*file_p4,*file_p5; char str01[dim_size],str02[dim_size],str03[dim_size],str04[dim_size],str05[dim_size],str2d[dim_size][dim_size]; char str03n[dim_size],str04n[dim_size],str05n[dim_size],strtemp[dim_size],strtempn[dim_size]; char str11[dim_size],str12[dim_size],str13[dim_size],str14[dim_size],str15[dim_size],str16[dim_size]; char strtmp0[dim_size],strtmp1[dim_size],strtmp2[dim_size],strtmp3[dim_size],strtmp4[dim_size], strtmp5[dim_size],strtmp6[dim_size],strtmp7[dim_size],strtmp8[dim_size],strtmp9[dim_size]; char strtmp10[dim_size],strtmp11[dim_size],strtmp12[dim_size],strtmp13[dim_size],strtmp14[dim_size], strtmp15[dim_size],strtmp20[dim_size],strtmp30[dim_size],strtmpc[dim_size],strtmpcn[dim_size]; int *n_dim,*imesh_tmp; int dim11,dim12,cnt_x,cnt_y,icont,steps,step,istep,n_obj,ioloop,itemp,iloop,idim,iactcount,nact; int objtmp1,objtmp2,objtmp3,obj[dim_size][num_actor],objg[num_actor],tmpcha,isteps; int icountg,icount,icountc,icntg,nobj,icnt,nactor,dimt1,dimt2,dimt3,dimt4,dimt5,dimt6; float *mesh_x,*mesh_y,*mesh_z,*mesh_r,*mesh_g,*mesh_b,*mesh_rad,*mesh_h,*mesh_nx,*mesh_ny,*mesh_nz; float x_point, y_point, z_point, rad_len, h_len, nx_vector,ny_vector,nz_vector,r_value,g_value,b_value; float shift_x,shift_y,shift_z,rot_xy,rot_yz,rot_zx,ratio_x,ratio_y,ratio_z; float center_x,center_y,center_z,ftemp,max_x,min_x,max_y,min_y,max_z,min_z; float temp_x,temp_y,temp_z,temp_xo,temp_yo,temp_zo; float dist_type,dist_p1,dist_p2,dist_p3,dist_p4,dist_p5,dist_p6,dist_p7,dist_p8,dist_p9, dist_p10,dist_p11,dist_p12,dist_p13,dist_p14,dist_p15,dist_p16,dist_p17,dist_p18,dist_p19; float color_type,color_p1,color_p2,color_p3,color_p4,color_p5, color_p6,color_p7,color_p8,color_p9,color_p10,color_p11; float objtmp11,objtmp12,objtmp13,objp[dim_size],actset[dim_size][num_actor]; /*----------------------------------------------------------------------------------------------------------------*/ int file_open_i(int *argc, char *argv[]) { /* * プログラム実行時に引数の数を確認 */ if(*argc < 2) { printf("ファイルを指定してください\n"); printf("use: mgfanime 'sinario file name'\n"); exit(0); } /* * プログラム実行時に引数で指定したシナリオファイル名を開く */ file_p0 = fopen(argv[1],"r"); if(file_p0 == NULL) { printf("読み込みファイルが開けません\n"); printf("ファイル名 = %s", argv[1]); exit(0); } printf("読み出しファイル%sを開きました。\n", argv[1]); return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int variable_0clr(void) { /* * 文字列配列の初期化 */ memset(strtmp0, 0x00, sizeof(char)*dim_size); memset(strtmp1, 0x00, sizeof(char)*dim_size); memset(strtmp2, 0x00, sizeof(char)*dim_size); memset(strtmp3, 0x00, sizeof(char)*dim_size); memset(strtmp4, 0x00, sizeof(char)*dim_size); memset(strtmp5, 0x00, sizeof(char)*dim_size); memset(strtmp6, 0x00, sizeof(char)*dim_size); memset(strtmp7, 0x00, sizeof(char)*dim_size); memset(strtmp8, 0x00, sizeof(char)*dim_size); memset(strtmp9, 0x00, sizeof(char)*dim_size); memset(strtmp10, 0x00, sizeof(char)*dim_size); memset(strtmp11, 0x00, sizeof(char)*dim_size); memset(strtmp12, 0x00, sizeof(char)*dim_size); memset(strtmp13, 0x00, sizeof(char)*dim_size); memset(strtmp14, 0x00, sizeof(char)*dim_size); memset(strtmp15, 0x00, sizeof(char)*dim_size); memset(strtmp20, 0x00, sizeof(char)*dim_size); memset(strtmp30, 0x00, sizeof(char)*dim_size); memset(str01, 0x00, sizeof(char)*dim_size); memset(str02, 0x00, sizeof(char)*dim_size); memset(str03, 0x00, sizeof(char)*dim_size); memset(str04, 0x00, sizeof(char)*dim_size); memset(str05, 0x00, sizeof(char)*dim_size); memset(str03n, 0x00, sizeof(char)*dim_size); memset(str04n, 0x00, sizeof(char)*dim_size); memset(str05n, 0x00, sizeof(char)*dim_size); memset(strtemp, 0x00, sizeof(char)*dim_size); memset(strtempn, 0x00, sizeof(char)*dim_size); memset(strtmpc, 0x00, sizeof(char)*dim_size); memset(strtmpcn, 0x00, sizeof(char)*dim_size); memset(str11, 0x00, sizeof(char)*dim_size); memset(str12, 0x00, sizeof(char)*dim_size); memset(str13, 0x00, sizeof(char)*dim_size); memset(str14, 0x00, sizeof(char)*dim_size); memset(str15, 0x00, sizeof(char)*dim_size); memset(str16, 0x00, sizeof(char)*dim_size); memset(str2d, 0x00, sizeof(char)*dim_size*dim_size); /* * 4Byte浮整数配列の初期化 */ memset(objg, 0x00, sizeof(int)*num_actor); memset(obj, 0x00, sizeof(int)*dim_size*num_actor); /* * 4Byte浮動小数点配列の初期化 */ memset(objp, 0x00, sizeof(float)*dim_size); memset(actset, 0x00, sizeof(float)*dim_size*num_actor); return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int file_open_f_expand(char *argv[]){ /* * シナリオファイルを展開したフルシナリオファイル名を作成し、ファイルを開く */ strtmp0[0] = '\0'; strcpy(strtmp0, "full"); strcat(strtmp0,argv[1]); file_p1 = fopen(strtmp0,"w"); if(file_p1 == NULL) { printf("シナリオ展開出力が開けません\n"); printf("ファイル名 = %s", strtmp0); exit(0); } printf("シナリオ展開出力ファイル%sを開きました。\n", strtmp0); /* * テンプレート、出力ファイル設定 */ fgets(strtmp4, dim_size, file_p0); fgets(strtmp5, dim_size, file_p0); fputs(strtmp4, file_p1); fputs(strtmp5, file_p1); /* * 空白文字の設定 */ strtmp14[0] = ' '; strtmp14[1] = '\0'; strcpy(strtmp20,strtmp14); strcpy(strtmp2,strtmp14); return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int action_default(void){ /* * 次の行に"actsetdefault"と言う宣言があるかどうかを確認 */ fgets(strtmp4, dim_size, file_p0); if ( strcmp(strtmp4,"actsetdefault\n") != 0 ) { printf("error: sinario format at line 3 actsetdefault!=%s\n",strtmp4); exit(0); } /* * str2dにアクション制御変数名と数を設定 */ strcpy((char *)&str2d[0],"ratio_x"); strcpy((char *)&str2d[1],"ratio_y"); strcpy((char *)&str2d[2],"ratio_z"); strcpy((char *)&str2d[3],"shift_x"); strcpy((char *)&str2d[4],"shift_y"); strcpy((char *)&str2d[5],"shift_z"); strcpy((char *)&str2d[6],"center_x"); strcpy((char *)&str2d[7],"center_y"); strcpy((char *)&str2d[8],"center_z"); strcpy((char *)&str2d[9],"rot_xy"); strcpy((char *)&str2d[10],"rot_yz"); strcpy((char *)&str2d[11],"rot_zx"); strcpy((char *)&str2d[12],"dist_type"); strcpy((char *)&str2d[13],"dist_p1"); strcpy((char *)&str2d[14],"dist_p2"); strcpy((char *)&str2d[15],"dist_p3"); strcpy((char *)&str2d[16],"dist_p4"); strcpy((char *)&str2d[17],"dist_p5"); strcpy((char *)&str2d[18],"dist_p6"); strcpy((char *)&str2d[19],"dist_p7"); strcpy((char *)&str2d[20],"dist_p8"); strcpy((char *)&str2d[21],"dist_p9"); strcpy((char *)&str2d[22],"dist_p10"); strcpy((char *)&str2d[23],"dist_p11"); strcpy((char *)&str2d[24],"dist_p12"); strcpy((char *)&str2d[25],"dist_p13"); strcpy((char *)&str2d[26],"dist_p14"); strcpy((char *)&str2d[27],"dist_p15"); strcpy((char *)&str2d[28],"dist_p16"); strcpy((char *)&str2d[29],"dist_p17"); strcpy((char *)&str2d[30],"dist_p18"); strcpy((char *)&str2d[31],"color_type"); strcpy((char *)&str2d[32],"color_p1"); strcpy((char *)&str2d[33],"color_p2"); strcpy((char *)&str2d[34],"color_p3"); strcpy((char *)&str2d[35],"color_p4"); strcpy((char *)&str2d[36],"color_p5"); strcpy((char *)&str2d[37],"color_p6"); strcpy((char *)&str2d[38],"color_p7"); strcpy((char *)&str2d[39],"color_p8"); strcpy((char *)&str2d[40],"color_p9"); strcpy((char *)&str2d[41],"color_p10"); strcpy((char *)&str2d[42],"color_p11"); strcpy((char *)&str2d[43],"dist_p19"); nact = 44; /* * 各アクターのデフォルトアクションの格納領域であるactsetにデフォルト値を設定 */ for(iactcount = 0; iactcount < dim_size; iactcount++) { actset[0][iactcount] = 1.0; actset[1][iactcount] = 1.0; actset[2][iactcount] = 1.0; actset[3][iactcount] = 0.0; actset[4][iactcount] = 0.0; actset[5][iactcount] = 0.0; actset[6][iactcount] = 0.0; actset[7][iactcount] = 0.0; actset[8][iactcount] = 0.0; actset[9][iactcount] = 0.0; actset[10][iactcount] = 0.0; actset[11][iactcount] = 0.0; actset[12][iactcount] = 0.0; actset[13][iactcount] = -1.0; actset[14][iactcount] = 1.0; actset[15][iactcount] = -1.0; actset[16][iactcount] = 1.0; actset[17][iactcount] = 4.0; actset[18][iactcount] = 0.285; actset[19][iactcount] = 0.0; actset[20][iactcount] = 0.005; actset[21][iactcount] = 0.0; actset[22][iactcount] = 400.0; actset[23][iactcount] = 6.0; actset[24][iactcount] = 0.0; actset[25][iactcount] = 400.0; actset[26][iactcount] = 6.0; actset[27][iactcount] = 6.0; actset[28][iactcount] = 0.0; actset[29][iactcount] = 400.0; actset[30][iactcount] = 6.0; actset[31][iactcount] = -1.0; actset[32][iactcount] = 1.0; actset[33][iactcount] = 1.0; actset[34][iactcount] = 1.0; actset[35][iactcount] = -1.0; actset[36][iactcount] = -1.0; actset[37][iactcount] = -1.0; actset[38][iactcount] = -1.0; actset[39][iactcount] = 1.0; actset[40][iactcount] = 1.0; actset[41][iactcount] = 1.0; actset[42][iactcount] = 1.0; actset[43][iactcount] = 0.0; } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int action_common_set(void){ fscanf(file_p0, "%s %f", strtmp2, &objtmp11); /* * シナリオファイルの全アクター共通のデフォルトアクション定義を読み込み */ while( strcmp(strtmp2,"actordefstart") != 0 ) { strcpy(strtmp1,strtmp2); action_select(); /* * 読み込んだ全アクター共通のデフォルトアクションを全アクターのactsetに設定 */ for(iactcount = 0; iactcount < dim_size; iactcount++) { actset[icont][iactcount] = objtmp11; } fscanf(file_p0, "%s %f", strtmp2, &objtmp11); if( strcmp(strtmp2,"actor1") == 0) { printf("error: 'actordefstart' does not exist in the sinario, %s was found.\n", strtmp2); exit(0); } } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int action_select(void){ /* * 読み込まれた文字列からアクションの種類を分類し、icontに数値を入れる */ if ( strcmp(strtmp1,"ratio_x") == 0 ) { icont=0; } else if( strcmp(strtmp1,"ratio_y") == 0 ) { icont=1; } else if( strcmp(strtmp1,"ratio_z") == 0 ) { icont=2; } else if( strcmp(strtmp1,"shift_x") == 0 ) { icont=3; } else if( strcmp(strtmp1,"shift_y") == 0 ) { icont=4; } else if( strcmp(strtmp1,"shift_z") == 0 ) { icont=5; } else if( strcmp(strtmp1,"center_x") == 0 ) { icont=6; } else if( strcmp(strtmp1,"center_y") == 0 ) { icont=7; } else if( strcmp(strtmp1,"center_z") == 0 ) { icont=8; } else if( strcmp(strtmp1,"rot_xy") == 0 ) { icont=9; } else if( strcmp(strtmp1,"rot_yz") == 0 ) { icont=10; } else if( strcmp(strtmp1,"rot_zx") == 0 ) { icont=11; } else if( strcmp(strtmp1,"dist_type") == 0 ) { icont=12; } else if( strcmp(strtmp1,"dist_p1") == 0 ) { icont=13; } else if( strcmp(strtmp1,"dist_p2") == 0 ) { icont=14; } else if( strcmp(strtmp1,"dist_p3") == 0 ) { icont=15; } else if( strcmp(strtmp1,"dist_p4") == 0 ) { icont=16; } else if( strcmp(strtmp1,"dist_p5") == 0 ) { icont=17; } else if( strcmp(strtmp1,"dist_p6") == 0 ) { icont=18; } else if( strcmp(strtmp1,"dist_p7") == 0 ) { icont=19; } else if( strcmp(strtmp1,"dist_p8") == 0 ) { icont=20; } else if( strcmp(strtmp1,"dist_p9") == 0 ) { icont=21; } else if( strcmp(strtmp1,"dist_p10") == 0 ) { icont=22; } else if( strcmp(strtmp1,"dist_p11") == 0 ) { icont=23; } else if( strcmp(strtmp1,"dist_p12") == 0 ) { icont=24; } else if( strcmp(strtmp1,"dist_p13") == 0 ) { icont=25; } else if( strcmp(strtmp1,"dist_p14") == 0 ) { icont=26; } else if( strcmp(strtmp1,"dist_p15") == 0 ) { icont=27; } else if( strcmp(strtmp1,"dist_p16") == 0 ) { icont=28; } else if( strcmp(strtmp1,"dist_p17") == 0 ) { icont=29; } else if( strcmp(strtmp1,"dist_p18") == 0 ) { icont=30; } else if( strcmp(strtmp1,"color_type") == 0 ) { icont=31; } else if( strcmp(strtmp1,"color_p1") == 0 ) { icont=32; } else if( strcmp(strtmp1,"color_p2") == 0 ) { icont=33; } else if( strcmp(strtmp1,"color_p3") == 0 ) { icont=34; } else if( strcmp(strtmp1,"color_p4") == 0 ) { icont=35; } else if( strcmp(strtmp1,"color_p5") == 0 ) { icont=36; } else if( strcmp(strtmp1,"color_p6") == 0 ) { icont=37; } else if( strcmp(strtmp1,"color_p7") == 0 ) { icont=38; } else if( strcmp(strtmp1,"color_p8") == 0 ) { icont=39; } else if( strcmp(strtmp1,"color_p9") == 0 ) { icont=40; } else if( strcmp(strtmp1,"color_p10") == 0 ) { icont=41; } else if( strcmp(strtmp1,"color_p11") == 0 ) { icont=42; } else if( strcmp(strtmp1,"dist_p19") == 0 ) { icont=43; } else { printf("error: '%s' is not a reserved action name \n",strtmp1); exit(0); } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int actor_define(void){ /* * カウンタ、文字列配列の初期化とシナリオ読み込み */ icountg = 0; icount = 0; memset(strtmp1, 0x00, sizeof(char)*dim_size); memset(strtmp2, 0x00, sizeof(char)*dim_size); fscanf(file_p0, "%s %d", strtmp1, &objtmp1); if ( strcmp(strtmp1,"actor1") != 0 ) { printf("error: 1st actor definition is not actor1, but %s %d\n",strtmp1,objtmp1); exit(0); } /* * 改行文字をstrtmp15に設定 */ fread(strtmp2,1,1,file_p0); strcpy(strtmp15,strtmp2); /* * アクターの定義 */ if ( strcmp(strtmp1,"actordefend") != 0 ) { while( strcmp(strtmp2,"actordefend") != 0 ){ /* * objgへアクターを構成するオブジェクト数の記録 */ objg[icountg] = objtmp1; icountg = icountg + 1; icount = 0; strcpy(strtempn,"actor"); sprintf(strtemp,"%d",icountg); strcat(strtempn,strtemp); if ( strcmp(strtmp1,strtempn) != 0 ) { printf("error: nth actor definition is not %s, but %s\n",strtempn,strtmp1); exit(0); } strcpy(strtmp2,strtmp20); /* * 前行の改行の読み飛ばし */ if ( icountg != 1 ) { fread(strtmp2,1,1,file_p0); } /* * 改行があるまで1文字ずつシナリオを読み込みアクターを構成するオブジェクト番号群を * obj[アクターを構成するオブジェクトの記述順番][アクター番号ー1]に格納 */ fread(strtmp2,1,1,file_p0); objtmp3 = 0; while( strcmp(strtmp2,strtmp15) != 0 ){ while( strcmp(strtmp2,strtmp14) != 0 && strcmp(strtmp2,strtmp15) != 0){ if ( strtmp2[0] >= '0' && strtmp2[0] <= '9' ) { objtmp3 = 10*objtmp3+strtmp2[0] - '0'; if ( 1 > objtmp3 > 128 ) { printf("error: object number in actor%d order=%d/%d num=%d\n" ,icountg,icount+1,objg[icountg-1],objtmp3); exit(0); } } fread(strtmp2,1,1,file_p0); } if ( icount > dim_size-1 ) { printf("error: number of objects in actor%d order=%d/%d num=%d\n" ,icountg,icount+1,objg[icountg-1],objtmp3); exit(0); } obj[icount][icountg-1] = objtmp3; objtmp3 = 0; icount = icount + 1; if ( strcmp(strtmp2,strtmp15) != 0 ) { fread(strtmp2,1,1,file_p0); } } /* * icountのループカウントとシナリオのアクター定義で行ったアクターを構成するオブジェクト数 * が一致しているか確認 */ if ( icount != objg[icountg-1] ) { printf("error: obj total number in actor%d %d!=%d\n",icountg,icount,objg[icountg-1]); exit(0); } icount = 0; /* * 次の行にアクター個別のデフォルトアクション設定がある場合、アクション設定を読み込む */ fscanf(file_p0, "%s %f", strtmp1, &objtmp11); while( !(strtmp1[0] == 'a' && strtmp1[1] == 'c' && strtmp1[2] == 't' && strtmp1[3] == 'o' && strtmp1[4] == 'r') ){ action_select(); strcpy((char *)&str2d[icont],strtmp1); actset[icont][icountg-1] = objtmp11; fscanf(file_p0, "%s %f", strtmp1, &objtmp11); } /* * 次のループのための変数の更新 */ strcpy(strtmp2,strtmp1); objtmp1 = (int) objtmp11; if ( !(strtmp1[0] == 'a' && strtmp1[1] == 'c' && strtmp1[2] == 't' && strtmp1[3] == 'o' && strtmp1[4] == 'r') ) { printf("error: nth actor definition is %s %d\n",strtmp1,objtmp1); exit(0); } } } else { printf("error: between actordefstart-end, sinario discription=%s\n",strtmp1); exit(0); } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int sinario_expand(void){ /* * 総ステップ数の書き出しと第一ステップの読み込み */ fscanf(file_p0, "%s %f", strtmp6, &objtmp11); isteps = (int)objtmp11; sprintf(strtempn,"%d\n",isteps); strcat(strtmp6," "); strcat(strtmp6,strtempn); fputs(strtmp6, file_p1); fscanf(file_p0, "%s %f", strtmp7, &objtmp11); if ( strcmp(strtmp7,"step") != 0 ) { printf("error: 'step1' is %s\n",strtmp7); exit(0); } /* * 各ステップのシナリオ展開 */ istep = 0; while( strcmp(strtmp7,"step") == 0 ) { /* * シナリオの読み込みステップとステップループカウンタの一致を確認 */ istep = istep +1; tmpcha = (int) objtmp11; if ( istep != tmpcha ) { printf("error: read step=%d is different from loop count step=%d\n",tmpcha,istep); exit(0); } /* * 1ステップ目での2行の先読み込みとその他のステップでの1行の先読み込み */ fprintf(file_p1, "%s %d\n", strtmp7, tmpcha); if ( objtmp11 == 1.0 ) { fscanf(file_p0, "%s %f", strtmp8, &objtmp11); fscanf(file_p0, "%s %f", strtmp9, &objtmp12); } else { objtmp11 = objtmp12; strcpy(strtmp8,strtmp9); fscanf(file_p0, "%s %f", strtmp9, &objtmp12); } while( strcmp(strtmp8,"actor") == 0 ) { /* * アクターにアクションが指定されていない場合 * =現在行の読み込み部分strtmp8が"actor"で *次行の読み込み部分strtmp9両方が"actor"、"end"、"step"の場合 */ if ( strcmp(strtmp9,"actor") == 0 || strcmp(strtmp9,"end") == 0 || strcmp(strtmp9,"step") == 0) { /* * デフォルトアクションをactsetのテンポラリ領域にコピーし、 * それをフルシナリオファイルに出力 */ defaultaction_write(); } /* * アクターにアクションが指定されている場合 * =次行の読み込み部分strtmp9が"actor"、"step"、"end"ではない */ else { /* * アクションが設定されているのでそれをactsetのテンポラリ領域にコピーし、 * それをフルシナリオファイルに出力 */ chnageaction_write(); } /* * ステップ内における次行読み込みと変数の更新(次行を現在行に変更) */ objtmp11 = objtmp12; strcpy(strtmp8,strtmp9); strcpy(strtmp7,strtmp8); fscanf(file_p0, "%s %f", strtmp9, &objtmp12); step_count_check(); if ( strcmp(strtmp8,"step") == 0 && strcmp(strtmp9,"step") == 0) { printf("error: discription of double step at step%d, step%d\n" ,(int)objtmp11,(int)objtmp12); exit(0); } } /* * ステップ間における変数の更新(次行を現在行に変更) */ strcpy(strtmp8,strtmp9); step_count_check(); if ( strcmp(strtmp7,"end") != 0 && strcmp(strtmp7,"step") != 0) { printf("error: 'end' is %s\n",strtmp7); exit(0); } if ( strcmp(strtmp8,"end") == 0 && strcmp(strtmp7,"step") == 0) { printf("error: discription of step before end step%d\n",(int)objtmp11); exit(0); } } /* * "end"を検知したら、シナリオファイル、フルシナリオファイルを閉じる。 */ if ( strcmp(strtmp7,"end") == 0 && istep != isteps) { printf("error: step=%d is larger than steps=%d\n",istep,isteps); exit(0); } istep =0; fprintf(file_p1, "end"); fclose(file_p0); fclose(file_p1); return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int step_count_check(){ if ( strcmp(strtmp8,"step") == 0 && (int) objtmp11 > isteps) { printf("error: step over at strtmp8 steps=%d, step=%d\n",isteps,(int)objtmp11); exit(0); } if ( strcmp(strtmp9,"step") == 0 && (int) objtmp12 > isteps) { printf("error: step over at strtmp9 steps=%d, step=%d\n",isteps,(int)objtmp12); exit(0); } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int defaultaction_write(void){ /* * nactorにstrtmp8のアクター番号(objtmp11)−1の値を代入 * nobjにアクターを構成するオブジェクト数を代入 */ icountc = 0; nactor = (int) objtmp11 - 1; nobj = (int) objg[nactor]; /* * nobj < 1=>定義されていないactorをシナリオで使っているという警告 */ if ( nobj < 1 ) { printf("error: using of undefined actor%d\n",nactor+1); exit(0); } /* * icntgループで現在行の読み込み部分strtmp8のアクターを構成するオブジェクトを * icntループでデフォルトアクションをactsetのテンポラリ領域にコピーし、 * それをフルシナリオファイルに出力 */ for(icntg = 0; icntg < nobj; icntg++) { fprintf(file_p1, "obj %d\n", obj[icntg][nactor]); for(icnt = 0; icnt < nact; icnt++) { actset[icnt][num_actor-1] = actset[icnt][nactor]; fprintf(file_p1, "%s %f\n",(char *)&str2d[icnt] ,actset[icnt][num_actor-1]); } } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int chnageaction_write(void){ icount = 0; strcpy(strtmp11,strtmp30); while( strcmp(strtmp9,"actor") != 0 && strcmp(strtmp9,"step") != 0 && strcmp(strtmp9,"end") != 0) { /* * strtmp9はアクション名、objtmp12はアクション値であり、 * 次の読み込みが"actor"、"step"、"end"になるまで * アクション名をブランク区切りでstrtmp11に * アクション値は、objp[」の配列ごとに保存していく。 */ objp[icount] = objtmp12; strcat(strtmp11,strtmp9); strcat(strtmp11,strtmp14); icount = icount + 1; fscanf(file_p0, "%s %f", strtmp9, &objtmp12); strcpy(strtmp8,strtmp9); } /* * nactorにアクター番号−1の値を代入 * nobjにアクターを構成するオブジェクト数を代入 */ nactor = (int) objtmp11-1; nobj = (int) objg[nactor]; strcpy(strtmp2,strtmp30); strtmp2[0] = '\0'; strtmp13[0] = '\0'; memset(strtmp13, 0x00, sizeof(char)*dim_size); /* * nobj < 1=>定義されていないactorをシナリオで使っているという警告 */ if ( nobj < 1 ) { printf("error: using of undefined actor%d\n",nactor+1); exit(0); } /* * icntgループで現在行の読み込み部分strtmp8のアクターを構成するオブジェクトを * 出力し、アクターのデフォルトアクションすべてをactsetのテンポラリ領域にコピーする。 */ for(icntg = 0; icntg < nobj; icntg++) { icountc = 0; fprintf(file_p1, "obj %d\n", obj[icntg][nactor]); for(icont = 0; icont < nact; icont++) { actset[icont][num_actor-1] = actset[icont][nactor]; } /* * actsetのテンポラリ領域に保存しているのデフォルトアクション値を * strtmp11とobjp[」に保存しているアクション名とアクション値で上書きする。 */ for(icnt = 0; icnt < icount; icnt++) { strtmp13[0] = strtmp11[icountc]; while( strtmp13[0] != strtmp14[0] ) { strcat(strtmp2,strtmp13); icountc = icountc + 1; strtmp13[0] = strtmp11[icountc]; } strcpy(strtmp1,strtmp2); action_select(); /* * mode_sw == 1では、デフォルトアクション値自体を更新し、 * mode_sw == 0では、元のデフォルトアクション値は更新しない。 */ if ( mode_sw == 1 ) { actset[icont][nactor] = objp[icnt]; } else if ( mode_sw == 0 ) { actset[icont][num_actor-1] = objp[icnt]; } icountc = icountc + 1; strcpy(strtmp2,strtmp30); strtmp2[0] = '\0'; strtmp13[0] = '\0'; memset(strtmp13, 0x00, sizeof(char)*dim_size); } /* * icontループで更新されたアクションを含むすべてのアクションを * フルシナリオファイルに出力 */ for(icont = 0; icont < nact; icont++) { /* * mode_sw == 1では、デフォルトアクション値自体を更新し、 * mode_sw == 0では、元のデフォルトアクション値は更新しない。 */ if ( mode_sw == 1 ) { actset[icont][num_actor-1] = actset[icont][nactor]; } else if ( mode_sw == 0 ) { } fprintf(file_p1, "%s %f\n",(char *)&str2d[icont] ,actset[icont][num_actor-1]); } } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int file_open_f_action(void){ /* * フルシナリオファイルを開く。 */ file_p0 = fopen(strtmp0,"r"); if(file_p0 == NULL) { printf("読み込みファイルが開けません\n"); printf("ファイル名 = %s", strtmp0); exit(0); } printf("読み出しファイル%sを開きました。\n", strtmp0); /* * フルシナリオファイルの初期読み込みと文字列結合=obj+数値 */ fscanf(file_p0, "%s %s", strtemp,str01); fscanf(file_p0, "%s %s", strtemp,str02); fscanf(file_p0, "%s %d", str03, &steps); fscanf(file_p0, "%s %d", str04, &step); printf("トータルstepはsteps=%dです。\n",steps); strcpy(strtemp,str04); sprintf(strtempn,"%d\n",steps); strcpy(str03n,str03); strcat(str03n,strtempn); sprintf(strtempn,"%d\n",step); strcpy(str04n,str04); strcat(str04n,strtempn); /* * テンプレートファイル、AVS出力ファイルを開く。 */ file_p1 = fopen(str01,"r"); if(file_p1 == NULL) { printf("読み出しファイルが開けません\n"); printf("ファイル名 = %s", str01); exit(0); } printf("読み出しファイル%sを開きました。\n", str01); file_p2 = fopen(str02,"w"); if(file_p2 == NULL) { printf("書き出しファイルが開けません\n"); printf("ファイル名 = %s", str02); exit(0); } printf("書き出しファイル%sを開きました。\n", str02); return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int initial_set(void){ /* * テンプレートファイルの各オブジェクトのヘッダ読み込み */ fgets(str11, dim_size, file_p1); fgets(str12, dim_size, file_p1); fgets(str13, dim_size, file_p1); fgets(str14, dim_size, file_p1); /* * テンプレートファイルの各オブジェクト依存部分のヘッダ読み込み */ if (strcmp(str12,"mesh\n") == 0) { fscanf(file_p1, "%d %d", &dim11, &dim12); } else if ( strcmp(str12,"disjoint polygon\n") == 0) { fgets(str15, dim_size, file_p1); fscanf(file_p1, "%d", &dim12); dim11 = 200; } else if ( strcmp(str12,"polyhedron\n") == 0) { fgets(str15, dim_size, file_p1); fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"sphere\n") == 0) { fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"column\n") == 0) { fscanf(file_p1, "%d", &idim); fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"circle\n") == 0) { fgets(str15, dim_size, file_p1); fscanf(file_p1, "%d", &idim); fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"disjoint line\n") == 0 || strcmp(str12,"polyline\n") == 0) { fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"label\n") == 0) { fgets(str15, dim_size, file_p1); fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"polytri\n") == 0 ) { fscanf(file_p1, "%d", &dim12); dim11 = 1; } fputs(str11, file_p2); fprintf(file_p2, "%d\n", steps); /* * 次のステップの準備とエラー処理 */ ioloop = 0; istep = 0; if(strcmp(strtemp,"step") != 0) { printf("error: inital step"); exit(0); } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int allocation_memory(void){ /* * テンプレートファイルの各オブジェク座標等データ読み込みのための配列準備 */ if (strcmp(str12,"mesh\n") == 0 ) { } else if ( strcmp(str12,"disjoint polygon\n") == 0) { n_dim =(int *)malloc(sizeof(int)*dim12); if( n_dim == NULL ) { printf("メモリが確保できません\n"); } memset(n_dim, 0x00, sizeof(int)*dim12); } else if ( strcmp(str12,"polyhedron\n") == 0) { } else if ( strcmp(str12,"sphere\n") == 0) { mesh_rad =(float *)malloc(sizeof(float)*dim11*dim12); if( mesh_rad == NULL ) { printf("メモリが確保できません\n"); } memset(mesh_rad, 0x00, sizeof(float)*dim11*dim12); } else if ( strcmp(str12,"column\n") == 0) { mesh_nx =(float *)malloc(sizeof(float)*dim11*dim12); mesh_ny =(float *)malloc(sizeof(float)*dim11*dim12); mesh_nz =(float *)malloc(sizeof(float)*dim11*dim12); mesh_rad =(float *)malloc(sizeof(float)*dim11*dim12); mesh_h =(float *)malloc(sizeof(float)*dim11*dim12); if( mesh_rad== NULL || mesh_h == NULL || mesh_nx == NULL || mesh_ny == NULL || mesh_nz == NULL) { printf("メモリが確保できません\n"); } memset(mesh_nx, 0x00, sizeof(float)*dim11*dim12); memset(mesh_ny, 0x00, sizeof(float)*dim11*dim12); memset(mesh_nz, 0x00, sizeof(float)*dim11*dim12); memset(mesh_rad, 0x00, sizeof(float)*dim11*dim12); memset(mesh_h, 0x00, sizeof(float)*dim11*dim12); } else if ( strcmp(str12,"circle\n") == 0) { mesh_nx =(float *)malloc(sizeof(float)*dim11*dim12); mesh_ny =(float *)malloc(sizeof(float)*dim11*dim12); mesh_nz =(float *)malloc(sizeof(float)*dim11*dim12); mesh_rad =(float *)malloc(sizeof(float)*dim11*dim12); if( mesh_rad== NULL || mesh_nx == NULL || mesh_ny == NULL || mesh_nz == NULL) { printf("メモリが確保できません\n"); } memset(mesh_nx, 0x00, sizeof(float)*dim11*dim12); memset(mesh_ny, 0x00, sizeof(float)*dim11*dim12); memset(mesh_nz, 0x00, sizeof(float)*dim11*dim12); memset(mesh_rad, 0x00, sizeof(float)*dim11*dim12); } else if ( strcmp(str12,"disjoint line\n") == 0 || strcmp(str12,"polyline\n") == 0) { } else if ( strcmp(str12,"label\n") == 0) { } else if ( strcmp(str12,"polytri\n") == 0 ) { } else if ( strcmp(str12,"end\n") == 0 || strcmp(str12,"end") == 0 ) { } else { printf("error: can not object type %s",str12); exit(0); } mesh_x =(float *)malloc(sizeof(float)*dim11*dim12); mesh_y =(float *)malloc(sizeof(float)*dim11*dim12); mesh_z =(float *)malloc(sizeof(float)*dim11*dim12); mesh_r =(float *)malloc(sizeof(float)*dim11*dim12); mesh_g =(float *)malloc(sizeof(float)*dim11*dim12); mesh_b =(float *)malloc(sizeof(float)*dim11*dim12); if( mesh_x == NULL || mesh_y == NULL || mesh_z == NULL || mesh_r == NULL || mesh_g == NULL || mesh_b == NULL ) { printf("メモリが確保できません\n"); } memset(mesh_x, 0x00, sizeof(float)*dim11*dim12); memset(mesh_y, 0x00, sizeof(float)*dim11*dim12); memset(mesh_z, 0x00, sizeof(float)*dim11*dim12); memset(mesh_r, 0x00, sizeof(float)*dim11*dim12); memset(mesh_g, 0x00, sizeof(float)*dim11*dim12); memset(mesh_b, 0x00, sizeof(float)*dim11*dim12); return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int skip_template(void){ /* * テンプレートファイルの各オブジェクト依存部分の空読み込み */ if ( strcmp(str12,"mesh\n") == 0 && strcmp(str14,"color\n") == 0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f", &x_point, &y_point , &z_point, &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } } else if ( strcmp(str12,"mesh\n") == 0 && strcmp(str14,"vertex\n") == 0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f", &x_point, &y_point, &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } } else if ( strcmp(str12,"mesh\n") == 0 && strcmp(str14,"scalar\n") == 0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f", &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = (float)cnt_x; mesh_y[(cnt_y*dim11) + cnt_x] = (float)cnt_y; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } } else if ( strcmp(str12,"mesh\n") == 0 && strcmp(str14,"normal\n") == 0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f" , &x_point, &y_point, &z_point, &nx_vector , &ny_vector, &nz_vector); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } } else if ( strcmp(str12,"mesh\n") == 0 && strcmp(str14,"normal_and_color\n") == 0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point , &nx_vector, &ny_vector, &nz_vector , &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } } else if ( strcmp(str12,"disjoint polygon\n") == 0 && strcmp(str15,"color\n") == 0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { fscanf(file_p1, "%d", &idim); n_dim[cnt_y] = idim; for(cnt_x = 0; cnt_x < idim; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f",&x_point,&y_point , &z_point, &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } free(n_dim); } else if ( strcmp(str12,"disjoint polygon\n") == 0 && strcmp(str15,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { fscanf(file_p1, "%d", &idim); n_dim[cnt_y] = idim; for(cnt_x = 0; cnt_x < idim; cnt_x++) { fscanf(file_p1, "%f %f %f", &x_point, &y_point, &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } free(n_dim); } else if ( strcmp(str12,"polyhedron\n") == 0 && strcmp(str15,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f", &x_point, &y_point , &z_point, &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fscanf(file_p1, "%d", &idim); for(cnt_x = 0; cnt_x < idim; cnt_x++) { fgets(str11, dim_size, file_p1); fgets(str11, dim_size, file_p1); } } else if ( strcmp(str12,"polyhedron\n") == 0 && strcmp(str15,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f", &x_point, &y_point, &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } fscanf(file_p1, "%d", &idim); for(cnt_x = 0; cnt_x < idim; cnt_x++) { fgets(str11, dim_size, file_p1); fgets(str11, dim_size, file_p1); } } else if ( strcmp(str12,"sphere\n") == 0 && strcmp(str14,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f", &x_point, &y_point ,&z_point,&rad_len,&r_value,&g_value,&b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } free(mesh_rad); } else if ( strcmp(str12,"sphere\n") == 0 && strcmp(str14,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f", &x_point, &y_point , &z_point, &rad_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; } } free(mesh_rad); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"normal_and_color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point, &nx_vector , &ny_vector, &nz_vector,&rad_len, &h_len , &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = h_len; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } free(mesh_nx); free(mesh_ny); free(mesh_nz); free(mesh_rad); free(mesh_h); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"normal\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point, &nx_vector , &ny_vector, &nz_vector,&rad_len, &h_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = h_len; } } free(mesh_nx); free(mesh_ny); free(mesh_nz); free(mesh_rad); free(mesh_h); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f" , &nx_vector, &x_point, &y_point, &z_point , &rad_len, &h_len, &r_value, &g_value , &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = 0.0; mesh_ny[(cnt_y*dim11) + cnt_x] = 0.0; mesh_nz[(cnt_y*dim11) + cnt_x] = 0.0; if ( nx_vector == 0.0 ) { mesh_nx[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 1.0 ) { mesh_ny[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 2.0 ) { mesh_nz[(cnt_y*dim11) + cnt_x] = 1.0; } mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = h_len; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } free(mesh_nx); free(mesh_ny); free(mesh_nz); free(mesh_rad); free(mesh_h); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f" , &nx_vector, &x_point, &y_point, &z_point , &rad_len, &h_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = 0.0; mesh_ny[(cnt_y*dim11) + cnt_x] = 0.0; mesh_nz[(cnt_y*dim11) + cnt_x] = 0.0; if ( nx_vector == 0.0 ) { mesh_nx[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 1.0 ) { mesh_ny[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 2.0 ) { mesh_nz[(cnt_y*dim11) + cnt_x] =1.0; } mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = h_len; } } free(mesh_nx); free(mesh_ny); free(mesh_nz); free(mesh_rad); free(mesh_h); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"dvertex_and_color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point, &nx_vector , &ny_vector, &nz_vector,&rad_len , &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector-x_point; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector-y_point; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector-z_point; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = sqrt( (nx_vector-x_point)*(nx_vector-x_point) + (ny_vector-y_point)*(ny_vector-y_point) + (nz_vector-z_point)*(nz_vector-z_point) ); mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } free(mesh_nx); free(mesh_ny); free(mesh_nz); free(mesh_rad); free(mesh_h); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"dvertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f" , &x_point, &y_point, &z_point, &nx_vector , &ny_vector, &nz_vector,&rad_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector-x_point; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector-y_point; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector-z_point; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = sqrt( (nx_vector-x_point)*(nx_vector-x_point) + (ny_vector-y_point)*(ny_vector-y_point) + (nz_vector-z_point)*(nz_vector-z_point) ); } } free(mesh_nx); free(mesh_ny); free(mesh_nz); free(mesh_rad); free(mesh_h); } else if ( strcmp(str12,"circle\n") == 0 && strcmp(str15,"normal_and_color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point, &nx_vector , &ny_vector, &nz_vector,&rad_len, &r_value , &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } free(mesh_nx); free(mesh_ny); free(mesh_nz); free(mesh_rad); } else if ( strcmp(str12,"circle\n") == 0 && strcmp(str15,"normal\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f" , &x_point, &y_point, &z_point, &nx_vector , &ny_vector, &nz_vector,&rad_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; } } free(mesh_nx); free(mesh_ny); free(mesh_nz); free(mesh_rad); } else if ( strcmp(str12,"circle\n") == 0 && strcmp(str15,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f" , &nx_vector, &x_point, &y_point, &z_point , &rad_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = 0.0; mesh_ny[(cnt_y*dim11) + cnt_x] = 0.0; mesh_nz[(cnt_y*dim11) + cnt_x] = 0.0; if ( nx_vector == 0.0 ) { mesh_nx[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 1.0 ) { mesh_ny[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 2.0 ) { mesh_nz[(cnt_y*dim11) + cnt_x] = 1.0; } mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; } } free(mesh_nx); free(mesh_ny); free(mesh_nz); free(mesh_rad); } else if ( strcmp(str12,"circle\n") == 0 && strcmp(str15,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f" , &nx_vector, &x_point, &y_point, &z_point , &rad_len, &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = 0.0; mesh_ny[(cnt_y*dim11) + cnt_x] = 0.0; mesh_nz[(cnt_y*dim11) + cnt_x] = 0.0; if ( nx_vector == 0.0 ) { mesh_nx[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 1.0 ) { mesh_ny[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 2.0 ) { mesh_nz[(cnt_y*dim11) + cnt_x] = 1.0; } mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } free(mesh_nx); free(mesh_ny); free(mesh_nz); free(mesh_rad); } else if ( (strcmp(str12,"disjoint line\n") == 0 && strcmp(str14,"color\n") == 0) || (strcmp(str12,"polyline\n") == 0 && strcmp(str14,"color\n") == 0)) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f", &x_point, &y_point , &z_point, &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } } else if ( (strcmp(str12,"disjoint line\n") == 0 && strcmp(str14,"vertex\n") == 0) || (strcmp(str12,"polyline\n") == 0 && strcmp(str14,"vertex\n") == 0)) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f", &x_point, &y_point, &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } } else if ( strcmp(str12,"label\n") == 0 && strcmp(str14,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %s", &x_point, &y_point , &z_point, &r_value, &g_value, &b_value , str16); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } } else if ( strcmp(str12,"label\n") == 0 && strcmp(str14,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %s", &x_point, &y_point , &z_point, str16); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } } else if ( strcmp(str12,"polytri\n") == 0 && strcmp(str14,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f", &x_point, &y_point , &z_point, &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } } else if ( strcmp(str12,"polytri\n") == 0 && strcmp(str14,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f", &x_point, &y_point, &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } } else if ( strcmp(str12,"polytri\n") == 0 && strcmp(str14,"normal_and_color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point , &nx_vector, &ny_vector, &nz_vector , &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } } else if ( strcmp(str12,"polytri\n") == 0 && strcmp(str14,"normal\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f" , &x_point, &y_point, &z_point , &nx_vector, &ny_vector, &nz_vector); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } } /* * メモリの開放とテンプレートの次のオブジェクトの先読み */ free(mesh_x); free(mesh_y); free(mesh_z); free(mesh_r); free(mesh_g); free(mesh_b); fgets(str11, dim_size, file_p1); fgets(str12, dim_size, file_p1); return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int check_template_end(void){ /* * "end"を検知したら、ファイルをいったん閉じて、再オープン */ if ( strcmp(str12,"end") == 0 || strcmp(str11,"end") == 0 || strcmp(str12,"end\n") == 0 || strcmp(str11,"end\n") == 0) { /* * オブジェクト探査を2回以上行っている場合は、強制終了 * テンプレートに該当オブジェクトが無い可能性あり */ ioloop = ioloop + 1; if(ioloop > 2) { printf("error: check template reading because ioloop > 2 at %s" ,str05n); exit(0); } fclose(file_p1); file_p1 = fopen(str01,"r"); if(file_p1 == NULL) { printf("読み出しファイルが開けません\n"); printf("ファイル名 = %s", str01); return(0); } printf("読み出しファイル%sを開きました。\n", str01); fgets(str11, dim_size, file_p1); fgets(str12, dim_size, file_p1); } fgets(str13, dim_size, file_p1); fgets(str14, dim_size, file_p1); /* * テンプレートファイルの各オブジェクト座標等データ読み込みのための配列準備 */ dimension_set(); printf("読み出しファイルを開きました2。%d %d\n", dim11,dim12); printf("after vacume read %s %s %s %d %d\n",str12,str13,str14,dim11,dim12); return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int dimension_set(void){ /* * テンプレートファイルの各オブジェクト座標等データ読み込みのための配列準備 */ if (strcmp(str12,"mesh\n") == 0) { fscanf(file_p1, "%d %d", &dim11, &dim12); } else if ( strcmp(str12,"disjoint polygon\n") == 0) { fgets(str15, dim_size, file_p1); fscanf(file_p1, "%d", &dim12); dim11 = 200; } else if ( strcmp(str12,"polyhedron\n") == 0) { fgets(str15, dim_size, file_p1); fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"sphere\n") == 0) { fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"column\n") == 0) { fscanf(file_p1, "%d", &idim); fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"circle\n") == 0) { fgets(str15, dim_size, file_p1); fscanf(file_p1, "%d", &idim); fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"disjoint line\n") == 0 || strcmp(str12,"polyline\n") == 0) { fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"label\n") == 0) { fgets(str15, dim_size, file_p1); fscanf(file_p1, "%d", &dim12); dim11 = 1; } else if ( strcmp(str12,"polytri\n") == 0 ) { fscanf(file_p1, "%d", &dim12); dim11 = 1; } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int check_sinario_end(void){ printf("error: read end"); exit(0); return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int check_next_resinario(void){ /* * ファイルをいったん閉じて、再オープン */ fclose(file_p1); file_p1 = fopen(str01,"r"); if(file_p1 == NULL) { printf("読み出しファイルが開けません\n"); printf("ファイル名 = %s", str01); exit(0); } printf("読み出しファイル%sを開きました。\n", str01); fgets(str11, dim_size, file_p1); fgets(str12, dim_size, file_p1); if ( strcmp(str12,"end") == 0 ) { printf("error stopobj %s %s\n",str11,str12); exit(0); } fgets(str13, dim_size, file_p1); fgets(str14, dim_size, file_p1); /* * テンプレートファイルの各オブジェクト座標等データ読み込みのための配列準備 */ dimension_set(); /* * エラー処理 */ if( strcmp(strtemp,"end") == 0 ) { printf("after restart read %s %s %s %d %d\n",str12,str13,str14,dim11,dim12); printf("erro: =read end2"); exit(0); } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int check_next_samesinario(void){ /* * 同一ステップに次のオブジェクトがある場合の次データの読み込み */ if( strcmp(str05n,str13) == 0 ) { if (strcmp(str12,"mesh\n") == 0 && strcmp(str14,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f", &x_point , &y_point, &z_point, &r_value , &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if (strcmp(str12,"mesh\n") == 0 && strcmp(str14,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f", &x_point, &y_point , &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } fgets(str11, dim_size, file_p1); } else if (strcmp(str12,"mesh\n") == 0 && strcmp(str14,"scalar\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f",&z_point); mesh_x[(cnt_y*dim11) + cnt_x] = (float)cnt_x; mesh_y[(cnt_y*dim11) + cnt_x] = (float)cnt_y; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } fgets(str11, dim_size, file_p1); } else if (strcmp(str12,"mesh\n") == 0 && strcmp(str14,"normal\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f" , &x_point, &y_point, &z_point, &nx_vector , &ny_vector, &nz_vector); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } fgets(str11, dim_size, file_p1); } if (strcmp(str12,"mesh\n") == 0 && strcmp(str14,"normal_and_color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point , &nx_vector, &ny_vector, &nz_vector , &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"disjoint polygon\n") == 0 && strcmp(str15,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { fscanf(file_p1, "%d", &idim); n_dim[cnt_y] = idim; for(cnt_x = 0; cnt_x < idim; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f", &x_point , &y_point, &z_point, &r_value , &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"disjoint polygon\n") == 0 && strcmp(str15,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { fscanf(file_p1, "%d", &idim); n_dim[cnt_y] = idim; for(cnt_x = 0; cnt_x < idim; cnt_x++) { fscanf(file_p1, "%f %f %f", &x_point, &y_point , &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"polyhedron\n") == 0 && strcmp(str15,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f", &x_point , &y_point, &z_point, &r_value , &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"polyhedron\n") == 0 && strcmp(str15,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f", &x_point, &y_point , &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"sphere\n") == 0 && strcmp(str14,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f", &x_point , &y_point, &z_point, &rad_len , &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"sphere\n") == 0 && strcmp(str14,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f", &x_point, &y_point , &z_point, &rad_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"normal_and_color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point , &nx_vector, &ny_vector, &nz_vector ,&rad_len, &h_len, &r_value, &g_value , &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = h_len; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"normal\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point , &nx_vector, &ny_vector, &nz_vector ,&rad_len, &h_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = h_len; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f" , &nx_vector, &x_point, &y_point, &z_point , &rad_len, &h_len, &r_value, &g_value , &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = 0.0; mesh_ny[(cnt_y*dim11) + cnt_x] = 0.0; mesh_nz[(cnt_y*dim11) + cnt_x] = 0.0; if ( nx_vector == 0.0 ) { mesh_nx[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 1.0 ) { mesh_ny[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 2.0 ) { mesh_nz[(cnt_y*dim11) + cnt_x] = 1.0; } mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = h_len; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f" , &nx_vector, &x_point, &y_point, &z_point , &rad_len, &h_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = 0.0; mesh_ny[(cnt_y*dim11) + cnt_x] = 0.0; mesh_nz[(cnt_y*dim11) + cnt_x] = 0.0; if ( nx_vector == 0.0 ) { mesh_nx[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 1.0 ) { mesh_ny[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 2.0 ) { mesh_nz[(cnt_y*dim11) + cnt_x] = 1.0; } mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = h_len; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"dvertex_and_color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point, &nx_vector , &ny_vector, &nz_vector,&rad_len , &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector-x_point; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector-y_point; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector-z_point; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = sqrt( (nx_vector-x_point)*(nx_vector-x_point) + (ny_vector-y_point)*(ny_vector-y_point) + (nz_vector-z_point)*(nz_vector-z_point) ); mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"column\n") == 0 && strcmp(str14,"dvertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f" , &x_point, &y_point, &z_point, &nx_vector , &ny_vector, &nz_vector,&rad_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector-x_point; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector-y_point; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector-z_point; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_h[(cnt_y*dim11) + cnt_x] = sqrt( (nx_vector-x_point)*(nx_vector-x_point) + (ny_vector-y_point)*(ny_vector-y_point) + (nz_vector-z_point)*(nz_vector-z_point) ); } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"circle\n") == 0 && strcmp(str15,"normal_and_color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point , &nx_vector, &ny_vector, &nz_vector , &rad_len, &r_value, &g_value , &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"circle\n") == 0 && strcmp(str15,"normal\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f" , &x_point, &y_point, &z_point , &nx_vector, &ny_vector, &nz_vector ,&rad_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = nx_vector; mesh_ny[(cnt_y*dim11) + cnt_x] = ny_vector; mesh_nz[(cnt_y*dim11) + cnt_x] = nz_vector; mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"circle\n") == 0 && strcmp(str15,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f" , &nx_vector, &x_point, &y_point, &z_point , &rad_len); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = 0.0; mesh_ny[(cnt_y*dim11) + cnt_x] = 0.0; mesh_nz[(cnt_y*dim11) + cnt_x] = 0.0; if ( nx_vector == 0.0 ) { mesh_nx[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 1.0 ) { mesh_ny[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 2.0 ) { mesh_nz[(cnt_y*dim11) + cnt_x] = 1.0; } mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"circle\n") == 0 && strcmp(str15,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f" , &nx_vector, &x_point, &y_point, &z_point , &rad_len, &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_nx[(cnt_y*dim11) + cnt_x] = 0.0; mesh_ny[(cnt_y*dim11) + cnt_x] = 0.0; mesh_nz[(cnt_y*dim11) + cnt_x] = 0.0; if ( nx_vector == 0.0 ) { mesh_nx[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 1.0 ) { mesh_ny[(cnt_y*dim11) + cnt_x] = 1.0; } if ( nx_vector == 2.0 ) { mesh_nz[(cnt_y*dim11) + cnt_x] = 1.0; } mesh_rad[(cnt_y*dim11) + cnt_x] = rad_len; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( ( strcmp(str12,"disjoint line\n") == 0 && strcmp(str14,"color\n") == 0 ) || ( strcmp(str12,"polyline\n") == 0 && strcmp(str14,"color\n") == 0 ) ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f", &x_point , &y_point, &z_point, &r_value , &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( ( strcmp(str12,"disjoint line\n") == 0 && strcmp(str14,"vertex\n") == 0 ) || ( strcmp(str12,"polyline\n") == 0 && strcmp(str14,"vertex\n") == 0 ) ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f", &x_point, &y_point , &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"label\n") == 0 && strcmp(str14,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %s", &x_point , &y_point, &z_point, &r_value , &g_value, &b_value, str16); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"label\n") == 0 && strcmp(str14,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %s", &x_point, &y_point , &z_point, str16); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"polytri\n") == 0 && strcmp(str14,"color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f", &x_point , &y_point, &z_point, &r_value , &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"polytri\n") == 0 && strcmp(str14,"vertex\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f", &x_point, &y_point , &z_point); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"polytri\n") == 0 && strcmp(str14,"normal_and_color\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f %f %f %f" , &x_point, &y_point, &z_point , &nx_vector, &ny_vector, &nz_vector , &r_value, &g_value, &b_value); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; mesh_r[(cnt_y*dim11) + cnt_x] = r_value; mesh_g[(cnt_y*dim11) + cnt_x] = g_value; mesh_b[(cnt_y*dim11) + cnt_x] = b_value; } } fgets(str11, dim_size, file_p1); } else if ( strcmp(str12,"polytri\n") == 0 && strcmp(str14,"normal\n") == 0) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { fscanf(file_p1, "%f %f %f %f %f %f" , &x_point, &y_point, &z_point , &nx_vector, &ny_vector, &nz_vector); mesh_x[(cnt_y*dim11) + cnt_x] = x_point; mesh_y[(cnt_y*dim11) + cnt_x] = y_point; mesh_z[(cnt_y*dim11) + cnt_x] = z_point; } } fgets(str11, dim_size, file_p1); } printf("after read %s %s %s %s %d %d\n",str12,str13,str14,str15,dim11,dim12); } else { printf("error: match obj not found in p1"); exit(0); } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int action_setting(void){ /* * フルシナリオファイルの各オブジェクトのアクションデータを読み込み、変数に代入 */ printf("step=%s obj=%s",str04n,str05n); fscanf(file_p0, "%s %f", strtemp, &ftemp); while( strcmp(strtemp,"step") != 0 & strcmp(strtemp,"obj") != 0 & strcmp(strtemp,"end") != 0 ) { printf("%s=%f\n",strtemp,ftemp); if ( strcmp(strtemp,"ratio_x") == 0 ) { ratio_x=ftemp; } else if( strcmp(strtemp,"ratio_y") == 0 ) { ratio_y=ftemp; } else if( strcmp(strtemp,"ratio_z") == 0 ) { ratio_z=ftemp; } else if( strcmp(strtemp,"shift_x") == 0 ) { shift_x=ftemp; } else if( strcmp(strtemp,"shift_y") == 0 ) { shift_y=ftemp; } else if( strcmp(strtemp,"shift_z") == 0 ) { shift_z=ftemp; } else if( strcmp(strtemp,"center_x") == 0 ) { center_x=ftemp; } else if( strcmp(strtemp,"center_y") == 0 ) { center_y=ftemp; } else if( strcmp(strtemp,"center_z") == 0 ) { center_z=ftemp; } else if( strcmp(strtemp,"rot_xy") == 0 ) { rot_xy=ftemp; } else if( strcmp(strtemp,"rot_yz") == 0 ) { rot_yz=ftemp; } else if( strcmp(strtemp,"rot_zx") == 0 ) { rot_zx=ftemp; } else if( strcmp(strtemp,"dist_type") == 0 ) { dist_type=ftemp; } else if( strcmp(strtemp,"dist_p1") == 0 ) { dist_p1=ftemp; } else if( strcmp(strtemp,"dist_p2") == 0 ) { dist_p2=ftemp; } else if( strcmp(strtemp,"dist_p3") == 0 ) { dist_p3=ftemp; } else if( strcmp(strtemp,"dist_p4") == 0 ) { dist_p4=ftemp; } else if( strcmp(strtemp,"dist_p5") == 0 ) { dist_p5=ftemp; } else if( strcmp(strtemp,"dist_p6") == 0 ) { dist_p6=ftemp; } else if( strcmp(strtemp,"dist_p7") == 0 ) { dist_p7=ftemp; } else if( strcmp(strtemp,"dist_p8") == 0 ) { dist_p8=ftemp; } else if( strcmp(strtemp,"dist_p9") == 0 ) { dist_p9=ftemp; } else if( strcmp(strtemp,"dist_p10") == 0 ) { dist_p10=ftemp; } else if( strcmp(strtemp,"dist_p11") == 0 ) { dist_p11=ftemp; } else if( strcmp(strtemp,"dist_p12") == 0 ) { dist_p12=ftemp; } else if( strcmp(strtemp,"dist_p13") == 0 ) { dist_p13=ftemp; } else if( strcmp(strtemp,"dist_p14") == 0 ) { dist_p14=ftemp; } else if( strcmp(strtemp,"dist_p15") == 0 ) { dist_p15=ftemp; } else if( strcmp(strtemp,"dist_p16") == 0 ) { dist_p16=ftemp; } else if( strcmp(strtemp,"dist_p17") == 0 ) { dist_p17=ftemp; } else if( strcmp(strtemp,"dist_p18") == 0 ) { dist_p18=ftemp; } else if( strcmp(strtemp,"color_type") == 0 ) { color_type=ftemp; } else if( strcmp(strtemp,"color_p1") == 0 ) { color_p1=ftemp; } else if( strcmp(strtemp,"color_p2") == 0 ) { color_p2=ftemp; } else if( strcmp(strtemp,"color_p3") == 0 ) { color_p3=ftemp; } else if( strcmp(strtemp,"color_p4") == 0 ) { color_p4=ftemp; } else if( strcmp(strtemp,"color_p5") == 0 ) { color_p5=ftemp; } else if( strcmp(strtemp,"color_p6") == 0 ) { color_p6=ftemp; } else if( strcmp(strtemp,"color_p7") == 0 ) { color_p7=ftemp; } else if( strcmp(strtemp,"color_p8") == 0 ) { color_p8=ftemp; } else if( strcmp(strtemp,"color_p9") == 0 ) { color_p9=ftemp; } else if( strcmp(strtemp,"color_p10") == 0 ) { color_p10=ftemp; } else if( strcmp(strtemp,"color_p11") == 0 ) { color_p11=ftemp; } else if( strcmp(strtemp,"dist_p19") == 0 ) { dist_p19=ftemp; } fscanf(file_p0, "%s %f\n", strtemp, &ftemp); } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int static_distore(void){ /* * 平行移動、回転、拡大縮小 */ for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; if ( strcmp(str12,"column\n") == 0 || strcmp(str12,"circle\n") == 0 ) { temp_x = mesh_nx[icont] * cos(rot_xy) - mesh_ny[icont] * sin(rot_xy); temp_y = mesh_nx[icont] * sin(rot_xy) + mesh_ny[icont] * cos(rot_xy); mesh_nx[icont] = temp_x; mesh_ny[icont] = temp_y; temp_y = mesh_ny[icont] * cos(rot_yz) - mesh_nz[icont] * sin(rot_yz); temp_z = mesh_ny[icont] * sin(rot_yz) + mesh_nz[icont] * cos(rot_yz); mesh_ny[icont] = temp_y; mesh_nz[icont] = temp_z; temp_z = mesh_nz[icont] * cos(rot_zx) - mesh_nx[icont] * sin(rot_zx); temp_x = mesh_nz[icont] * sin(rot_zx) + mesh_nx[icont] * cos(rot_zx); mesh_nz[icont] = temp_z; mesh_nx[icont] = temp_x; mesh_nx[icont] = mesh_nx[icont]; mesh_ny[icont] = mesh_ny[icont]; mesh_nz[icont] = mesh_nz[icont]; } mesh_x[icont] = mesh_x[icont] * ratio_x; mesh_y[icont] = mesh_y[icont] * ratio_y; mesh_z[icont] = mesh_z[icont] * ratio_z; mesh_x[icont] = mesh_x[icont] - center_x; mesh_y[icont] = mesh_y[icont] - center_y; mesh_z[icont] = mesh_z[icont] - center_z; temp_x = mesh_x[icont] * cos(rot_xy) - mesh_y[icont] * sin(rot_xy); temp_y = mesh_x[icont] * sin(rot_xy) + mesh_y[icont] * cos(rot_xy); mesh_x[icont] = temp_x; mesh_y[icont] = temp_y; temp_y = mesh_y[icont] * cos(rot_yz) - mesh_z[icont] * sin(rot_yz); temp_z = mesh_y[icont] * sin(rot_yz) + mesh_z[icont] * cos(rot_yz); mesh_y[icont] = temp_y; mesh_z[icont] = temp_z; temp_z = mesh_z[icont] * cos(rot_zx) - mesh_x[icont] * sin(rot_zx); temp_x = mesh_z[icont] * sin(rot_zx) + mesh_x[icont] * cos(rot_zx); mesh_z[icont] = temp_z; mesh_x[icont] = temp_x; mesh_x[icont] = mesh_x[icont] + center_x + shift_x; mesh_y[icont] = mesh_y[icont] + center_y + shift_y; mesh_z[icont] = mesh_z[icont] + center_z + shift_z; if ( strcmp(str12,"column\n") == 0) { mesh_rad[icont] = mesh_rad[icont] * ratio_z; mesh_h[icont] = mesh_h[icont] * ratio_z; } else if ( strcmp(str12,"circle\n") == 0 ) { mesh_rad[icont] = mesh_rad[icont] * ratio_z; } else if ( strcmp(str12,"sphere\n") == 0 ) { mesh_rad[icont] = mesh_rad[icont] * ratio_z; } else if ( strcmp(str12,"label\n") == 0 ) { } else { } } } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int dynamic_distore(void){ /* *表面波生成 dist_p1 = 80.0; dist_p2 = 50.0; dist_p3 = 40.0; dist_p4 = 10.0; dist_p5 = 7.0; dist_p6 = 100.0; dist_p7 = 1.0; dist_p8 = 3.0; dist_p9 = 9.0; dist_p10= 0.1; */ if ( dist_type == -4.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; mesh_x[icont] = (dist_p1+dist_p2+dist_p3)/dim11*(float)(cnt_x+1); mesh_y[icont] = (dist_p1+dist_p2+dist_p3)/dim12*(float)(cnt_y+1); mesh_z[icont] = dist_p1*sin(mesh_x[icont]/dist_p4-istep*dist_p7) + dist_p2*cos(mesh_y[icont]/dist_p5-istep*dist_p8) + dist_p3*sin(mesh_x[icont]*mesh_y[icont] /dist_p6-istep*dist_p9); mesh_z[icont] = dist_p10*mesh_z[icont]; } } } /* *ジュリア集合 dist_p1 = -1.0; dist_p2 = 1.0; dist_p3 = -1.0; dist_p4 = 1.0; dist_p5 = 4.0; dist_p6 = 0.285; dist_p7 = 0.020; dist_p8 = 0.005; dist_p9 = 0.0005; dist_p10 = 400.0; dist_p11 = 6.0 */ if ( dist_type == -3.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; mesh_x[icont] = dist_p1+(dist_p2-dist_p1)/dim11*(float)(cnt_x+1); mesh_y[icont] = dist_p3+(dist_p4-dist_p3)/dim12*(float)(cnt_y+1); temp_x = mesh_x[icont]; temp_y = mesh_y[icont]; for( iloop=0; iloop<(int) dist_p10;iloop++){ temp_z = temp_x*temp_x -temp_y*temp_y + dist_p6 + istep*dist_p7; temp_y = 2.0*temp_x*temp_y + dist_p8 + istep*dist_p9; if(temp_z*temp_z+temp_y*temp_y > dist_p5 ){ break; } else { temp_x=temp_z; } } if(iloop == (int)dist_p10 ){ temp_z=0.0; } else { temp_z=iloop; mesh_z[icont]=sqrt((float)temp_z/dist_p10)+dist_p11; } } } } /* *スパイラル dist_p1 0.03; dist_p2 0.03; dist_p3 0.05; dist_p4 0.05; dist_p5 0.5; */ if ( dist_type == -2.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; mesh_x[icont] = (dist_p1*cnt_y+dist_p3*cnt_x) *cos((istep-1)*dist_p2*cnt_y+dim11); mesh_y[icont] = (dist_p1*cnt_y+dist_p3*cnt_x) *sin((istep-1)*dist_p2*cnt_y+dim11); mesh_z[icont] = (istep-1)*dist_p4*cnt_y+(istep-1)*dist_p5*cnt_x; } } } /* *初期化および単純曲面 dist_p1 0.05; dist_p2 0.05; dist_p3 0.05; dist_p4 0.05; dist_p5 -0.5; */ if ( dist_type == -1.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; mesh_x[icont] = cnt_x-dist_p5*dim11; mesh_y[icont] = cnt_y-dist_p5*dim12; mesh_z[icont] = dist_p1*cnt_x+dist_p2*cnt_x*cnt_x +dist_p3*cnt_y+dist_p4*cnt_y*cnt_y; } } } /* *波模様 *  dist_p1 = 0.03; dist_p2 = 0.1; dist_p3 = 0.2; */ if ( dist_type == 1.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; mesh_x[icont] = mesh_x[icont] + dist_p1*( mesh_x[icont]*sin(dist_p2*istep*mesh_x[icont]) + mesh_y[icont]*cos(dist_p3*istep*mesh_x[icont])); mesh_y[icont] = mesh_y[icont] + dist_p1*( mesh_x[icont]*cos(dist_p2*istep*mesh_x[icont]) + mesh_y[icont]*sin(dist_p3*istep*mesh_y[icont])); mesh_z[icont] = mesh_z[icont] + dist_p1*( mesh_x[icont]*cos(dist_p2*istep*mesh_z[icont]) + mesh_y[icont]*cos(dist_p3*istep*mesh_z[icont])); } } } /* *等加速度運動 *加速度   :dist_p1-p3 *初速度   :dist_p4-p6 *回転速度  :dist_p7-p9 *回転中心  :dist_p10-p12 *中心ドリフト:dist_p13-p15 *単振動   :dist_p16-p18 *時刻オフセット:dist_p19 dist_p1 = 0.0; dist_p2 = 0.0; dist_p3 = -0.05; dist_p4 = 0.0; dist_p5 = 0.0; dist_p6 = 0.0; dist_p7 = 0.0; dist_p8 = 0.0; dist_p9 = 0.0; dist_p10= 0.0; dist_p11= 0.0; dist_p12= 0.0; dist_p13= 0.0; dist_p14= 0.0; dist_p15= 0.0; dist_p16= 0.0; dist_p17= 0.0; dist_p18= 0.0; dist_p19= 0.0; */ if ( dist_type == 2.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; if ( strcmp(str12,"column\n") == 0 || strcmp(str12,"circle\n") == 0 ) { temp_x = mesh_nx[icont] * cos(dist_p7*(istep-dist_p19)) - mesh_ny[icont] * sin(dist_p7*(istep-dist_p19)); temp_y = mesh_nx[icont] * sin(dist_p7*(istep-dist_p19)) + mesh_ny[icont] * cos(dist_p7*(istep-dist_p19)); mesh_nx[icont] = temp_x; mesh_ny[icont] = temp_y; temp_y = mesh_ny[icont] * cos(dist_p8*(istep-dist_p19)) - mesh_nz[icont] * sin(dist_p8*(istep-dist_p19)); temp_z = mesh_ny[icont] * sin(dist_p8*(istep-dist_p19)) + mesh_nz[icont] * cos(dist_p8*(istep-dist_p19)); mesh_ny[icont] = temp_y; mesh_nz[icont] = temp_z; temp_z = mesh_nz[icont] * cos(dist_p9*(istep-dist_p19)) - mesh_nx[icont] * sin(dist_p9*(istep-dist_p19)); temp_x = mesh_nz[icont] * sin(dist_p9*(istep-dist_p19)) + mesh_nx[icont] * cos(dist_p9*(istep-dist_p19)); mesh_nz[icont] = temp_z; mesh_nx[icont] = temp_x; } mesh_x[icont] = ( mesh_x[icont] - dist_p13*( 0.5*dist_p1*pow(istep-dist_p19,2) +dist_p4*(istep-dist_p19)) - dist_p10 ) * cos(dist_p16*(istep-dist_p19)); mesh_y[icont] = ( mesh_y[icont] - dist_p14*( 0.5*dist_p2*pow(istep-dist_p19,2) +dist_p5*(istep-dist_p19)) - dist_p11 ) * cos(dist_p17*(istep-dist_p19)); mesh_z[icont] = ( mesh_z[icont] - dist_p15*(0.5*dist_p3*pow(istep-dist_p19,2) +dist_p6*(istep-dist_p19)) - dist_p12 ) * cos(dist_p18*(istep-dist_p19)); temp_x = mesh_x[icont] * cos(dist_p7*(istep-dist_p19)) - mesh_y[icont] * sin(dist_p7*(istep-dist_p19)); temp_y = mesh_x[icont] * sin(dist_p7*(istep-dist_p19)) + mesh_y[icont] * cos(dist_p7*(istep-dist_p19)); mesh_x[icont] = temp_x; mesh_y[icont] = temp_y; temp_y = mesh_y[icont] * cos(dist_p8*(istep-dist_p19)) - mesh_z[icont] * sin(dist_p8*(istep-dist_p19)); temp_z = mesh_y[icont] * sin(dist_p8*(istep-dist_p19)) + mesh_z[icont] * cos(dist_p8*(istep-dist_p19)); mesh_y[icont] = temp_y; mesh_z[icont] = temp_z; temp_z = mesh_z[icont] * cos(dist_p9*(istep-dist_p19)) - mesh_x[icont] * sin(dist_p9*(istep-dist_p19)); temp_x = mesh_z[icont] * sin(dist_p9*(istep-dist_p19)) + mesh_x[icont] * cos(dist_p9*(istep-dist_p19)); mesh_z[icont] = temp_z; mesh_x[icont] = temp_x; mesh_x[icont] = mesh_x[icont] + dist_p13*(0.5*dist_p1*pow(istep-dist_p19,2) + dist_p4*(istep-dist_p19)) + dist_p10; mesh_y[icont] = mesh_y[icont] + dist_p14*(0.5*dist_p2*pow(istep-dist_p19,2) + dist_p5*(istep-dist_p19)) + dist_p11; mesh_z[icont] = mesh_z[icont] + dist_p15*(0.5*dist_p3*pow(istep-dist_p19,2) + dist_p6*(istep-dist_p19)) + dist_p12; mesh_x[icont] = mesh_x[icont] + 0.5*dist_p1*pow(istep-dist_p19,2) + dist_p4*(istep-dist_p19); mesh_y[icont] = mesh_y[icont] + 0.5*dist_p2*pow(istep-dist_p19,2) + dist_p5*(istep-dist_p19); mesh_z[icont] = mesh_z[icont] + 0.5*dist_p3*pow(istep-dist_p19,2) + dist_p6*(istep-dist_p19); } } } /* *回転中心へ吸い込む等角速度運動 *回転中心  :dist_p1-p3 *中心ドリフト:dist_p4-p6 *回転速度  :dist_p7-p9 *吸い込み能力:dist_p10 *時刻オフセット:dist_p11 dist_p1 = 10.0; dist_p2 = 10.0; dist_p3 = 10.0; dist_p4 = 0.0; dist_p5 = 0.0; dist_p6 = -0.1; dist_p7 = 0.5; dist_p8 = 0.0; dist_p9 = 0.0; dist_p10= 1.0; dist_p11= 0.0; */ if ( dist_type == 3.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; mesh_x[icont] = ( mesh_x[icont] - dist_p4*(istep-dist_p11) - dist_p1 ); mesh_y[icont] = ( mesh_y[icont] - dist_p5*(istep-dist_p11) - dist_p2 ); mesh_z[icont] = ( mesh_z[icont] - dist_p6*(istep-dist_p11) - dist_p3 ); temp_x = mesh_x[icont] * cos(dist_p7*(istep-dist_p11)) - mesh_y[icont] * sin(dist_p7*(istep-dist_p11)); temp_y = mesh_x[icont] * sin(dist_p7*(istep-dist_p11)) + mesh_y[icont] * cos(dist_p7*(istep-dist_p11)); mesh_x[icont] = temp_x; mesh_y[icont] = temp_y; temp_y = mesh_y[icont] * cos(dist_p8*(istep-dist_p11)) - mesh_z[icont] * sin(dist_p8*(istep-dist_p11)); temp_z = mesh_y[icont] * sin(dist_p8*(istep-dist_p11)) + mesh_z[icont] * cos(dist_p8*(istep-dist_p11)); mesh_y[icont] = temp_y; mesh_z[icont] = temp_z; temp_z = mesh_z[icont] * cos(dist_p9*(istep-dist_p11)) - mesh_x[icont] * sin(dist_p9*(istep-dist_p11)); temp_x = mesh_z[icont] * sin(dist_p9*(istep-dist_p11)) + mesh_x[icont] * cos(dist_p9*(istep-dist_p11)); mesh_z[icont] = temp_z; mesh_x[icont] = temp_x; temp_x = 1.0 - dist_p10/sqrt(mesh_x[icont]*mesh_x[icont] +mesh_y[icont]*mesh_y[icont]+mesh_z[icont]*mesh_z[icont]); if ( temp_x < 0.0 ) { temp_x = 0.0; } mesh_x[icont] = mesh_x[icont] * temp_x; mesh_y[icont] = mesh_y[icont] * temp_x; mesh_z[icont] = mesh_z[icont] * temp_x; mesh_x[icont] = mesh_x[icont] + dist_p4*(istep-dist_p11) + dist_p1; mesh_y[icont] = mesh_y[icont] + dist_p5*(istep-dist_p11) + dist_p2; mesh_z[icont] = mesh_z[icont] + dist_p6*(istep-dist_p11) + dist_p3; } } } /* *粗密進行波 *波の大きさ  :dist_p1-p3 *位相ずれ   :dist_p4-p6 *波数     :dist_p7-p9 *振動数    :dist_p10-p12 *波の中心   :dist_p13-p15 *波の半値幅  :dist_p16-p18 *時刻オフセット:dist_p19 dist_p1 = 1.0; dist_p2 = 5.0; dist_p3 = 8.0; dist_p4 = 0.0; dist_p5 = 0.0; dist_p6 = 0.0; dist_p7 = 0.2; dist_p8 = 0.2; dist_p9 = 0.2; dist_p10= 0.2; dist_p11= 1.0; dist_p12= 1.0; dist_p13= 50.0; dist_p14= 100.0; dist_p15= 300.0; dist_p16= 30.0; dist_p17= 30.0; dist_p18= 100.0; dist_p19= 0.0; */ if ( dist_type == 4.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; temp_x = dist_p1 *cos(dist_p7*mesh_x[icont]-dist_p10*(istep-dist_p19)+dist_p4) *exp(-pow(mesh_x[icont]-dist_p13,2)/dist_p16/dist_p16); temp_y = dist_p2 *cos(dist_p8*mesh_x[icont]-dist_p11*(istep-dist_p19)+dist_p5) *exp(-pow(mesh_x[icont]-dist_p14,2)/dist_p17/dist_p17); temp_z = dist_p3 *cos(dist_p9*mesh_x[icont]-dist_p12*(istep-dist_p19)+dist_p6) *exp(-pow(mesh_x[icont]-dist_p15,2)/dist_p18/dist_p18); mesh_x[icont] = mesh_x[icont] + temp_x; mesh_y[icont] = mesh_y[icont] + temp_y; mesh_z[icont] = mesh_z[icont] + temp_z; } } } /* *2つの表面波(X-Y) *波の大きさ  :dist_p1-p2 *位相ずれ   :dist_p3-p4 *波数     :dist_p5-p8 *振動数    :dist_p9-p10 *波の中心   :dist_p11-p14 *波の半減幅  :dist_p15-p18 *時刻オフセット:dist_p19 dist_p1 = 10.0; dist_p2 = 10.0; dist_p3 = 0.0; dist_p4 = 0.0; dist_p5 = 0.3; dist_p6 = 0.3; dist_p7 = 0.3; dist_p8 = -0.3; dist_p9 = 0.9; dist_p10= 0.9; dist_p11= 20.0; dist_p12= 50.0; dist_p13= 20.0; dist_p14= 50.0; dist_p15= 40.0; dist_p16= 40.0; dist_p17= 40.0; dist_p18= 40.0; dist_p19= 0.0; */ if ( dist_type == 5.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; temp_z = istep-dist_p19; temp_x = dist_p1*cos(dist_p5*mesh_x[icont]+dist_p6*mesh_y[icont] -dist_p9*temp_z+dist_p3) *exp(-pow(mesh_x[icont]-dist_p11-temp_z*dist_p9/dist_p5,2) /dist_p15/dist_p15) *exp(-pow(mesh_y[icont]-dist_p12-temp_z*dist_p9/dist_p6,2) /dist_p16/dist_p16); temp_y = dist_p2*cos(dist_p7*mesh_x[icont]+dist_p8*mesh_y[icont] -dist_p10*temp_z+dist_p4) *exp(-pow(mesh_x[icont]-dist_p13-temp_z*dist_p10/dist_p7,2) /dist_p17/dist_p17) *exp(-pow(mesh_y[icont]-dist_p14-temp_z*dist_p10/dist_p8,2) /dist_p18/dist_p18); mesh_x[icont] = mesh_x[icont]; mesh_y[icont] = mesh_y[icont]; mesh_z[icont] = mesh_z[icont] + temp_x + temp_y; } } } /* *拡大・縮小・平行移動・回転のアニメーション *拡大・縮小  :dist_p1-p3 *平行移動   :dist_p4-p6 *回転角速度  :dist_p7-p9 *回転中心   :dist_p10-p12 *時刻オフセット:dist_p13 dist_p1 = 1.0; dist_p2 = 1.0; dist_p3 = 1.0; dist_p4 = 0.0; dist_p5 = 0.0; dist_p6 = 0.0; dist_p7 = 0.3; dist_p8 = 0.3; dist_p9 = 0.3; dist_p10= 0.0; dist_p11= 0.0; dist_p12= 0.0; dist_p13= 0.0; */ if ( dist_type == 6.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { icont = (cnt_y*dim11) + cnt_x; mesh_x[icont] = mesh_x[icont] * dist_p1 *(istep-dist_p13); mesh_y[icont] = mesh_y[icont] * dist_p2 *(istep-dist_p13); mesh_z[icont] = mesh_z[icont] * dist_p3 *(istep-dist_p13); mesh_x[icont] = mesh_x[icont] - dist_p10; mesh_y[icont] = mesh_y[icont] - dist_p11; mesh_z[icont] = mesh_z[icont] - dist_p12; temp_x = mesh_x[icont] * cos(dist_p7*(istep-dist_p13)) - mesh_y[icont] * sin(dist_p7*(istep-dist_p13)); temp_y = mesh_x[icont] * sin(dist_p7*(istep-dist_p13)) + mesh_y[icont] * cos(dist_p7*(istep-dist_p13)); mesh_x[icont] = temp_x; mesh_y[icont] = temp_y; temp_y = mesh_y[icont] * cos(dist_p8*(istep-dist_p13)) - mesh_z[icont] * sin(dist_p8*(istep-dist_p13)); temp_z = mesh_y[icont] * sin(dist_p8*(istep-dist_p13)) + mesh_z[icont] * cos(dist_p8*(istep-dist_p13)); mesh_y[icont] = temp_y; mesh_z[icont] = temp_z; temp_z = mesh_z[icont] * cos(dist_p9*(istep-dist_p13)) - mesh_x[icont] * sin(dist_p9*(istep-dist_p13)); temp_x = mesh_z[icont] * sin(dist_p9*(istep-dist_p13)) + mesh_x[icont] * cos(dist_p9*(istep-dist_p13)); mesh_z[icont] = temp_z; mesh_x[icont] = temp_x; mesh_x[icont] = mesh_x[icont] + dist_p10 + dist_p4*(istep-dist_p13); mesh_y[icont] = mesh_y[icont] + dist_p11 + dist_p5*(istep-dist_p13); mesh_z[icont] = mesh_z[icont] + dist_p12 + dist_p6*(istep-dist_p13); if ( strcmp(str12,"column\n") == 0) { mesh_rad[icont] = mesh_rad[icont] * dist_p3 *(istep-dist_p13); mesh_h[icont] = mesh_h[icont] * dist_p3 *(istep-dist_p13); } else if ( strcmp(str12,"circle\n") == 0 ) { mesh_rad[icont] = mesh_rad[icont] * dist_p3 *(istep-dist_p13); } else if ( strcmp(str12,"sphere\n") == 0 ) { mesh_rad[icont] = mesh_rad[icont] * dist_p3 *(istep-dist_p13); } else if ( strcmp(str12,"label\n") == 0 ) { } else { } } } } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int max_min(void){ /* * mesh_xの最大最小を探す */ max_x =mesh_x[0]; min_x =mesh_x[0]; for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if(max_x < mesh_x[(cnt_y*dim11) + cnt_x]){ max_x = mesh_x[(cnt_y*dim11) + cnt_x]; } if(min_x > mesh_x[(cnt_y*dim11) + cnt_x]){ min_x = mesh_x[(cnt_y*dim11) + cnt_x]; } } } if ( max_x < min_x ) { printf("error : min-max not correct min_x=%f>max_x=%f",min_x,max_x); exit(0); } /* * mesh_yの最大最小を探す */ max_y =mesh_y[0]; min_y =mesh_y[0]; for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if(max_y < mesh_y[(cnt_y*dim11) + cnt_x]){ max_y = mesh_y[(cnt_y*dim11) + cnt_x]; } if(min_y > mesh_y[(cnt_y*dim11) + cnt_x]){ min_y = mesh_y[(cnt_y*dim11) + cnt_x]; } } } if ( max_y < min_y ) { printf("error : min-max not correct min_y=%f>max_y=%f",min_y,max_y); exit(0); } /* * mesh_zの最大最小を探す */ max_z =mesh_z[0]; min_z =mesh_z[0]; for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if(max_z < mesh_z[(cnt_y*dim11) + cnt_x]){ max_z = mesh_z[(cnt_y*dim11) + cnt_x]; } if(min_z > mesh_z[(cnt_y*dim11) + cnt_x]){ min_z = mesh_z[(cnt_y*dim11) + cnt_x]; } } } if ( max_z < min_z ) { printf("error : min-max not correct min_z=%f>max_z=%f",min_z,max_z); exit(0); } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int color_set(void){ if ( color_type == -1.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { mesh_r[(cnt_y*dim11) + cnt_x] = 1.0*color_p1; mesh_g[(cnt_y*dim11) + cnt_x] = 1.0*color_p2; mesh_b[(cnt_y*dim11) + cnt_x] = 1.0*color_p3; } } } if ( color_type == 0.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } mesh_r[(cnt_y*dim11) + cnt_x] = temp_z*color_p1; mesh_g[(cnt_y*dim11) + cnt_x] = temp_z*color_p2; mesh_b[(cnt_y*dim11) + cnt_x] = temp_z*color_p3; } } } if ( color_type == 1.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } icont = (cnt_y*dim11) + cnt_x; if(temp_z > 0.28) { mesh_r[icont] = 1.04*(temp_z-0.28)*color_p1; mesh_g[icont] = 1.13-0.9*temp_z*color_p2; } else { mesh_r[icont] = 0.28-0.2*temp_z/0.28*color_p1; mesh_g[icont] = 0.9*temp_z/0.28*color_p2; } mesh_b[icont] = 1.0-mesh_r[icont]-mesh_g[icont]*color_p3; if(mesh_b[icont] < 0.0) { mesh_b[icont] = -mesh_b[icont]; } } } } if ( color_type == 2.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } mesh_r[(cnt_y*dim11) + cnt_x] = 0.5*(1.0+temp_z)*color_p1; mesh_g[(cnt_y*dim11) + cnt_x] = 0.5*(1.0-temp_z)*color_p2; mesh_b[(cnt_y*dim11) + cnt_x] = 0.5*(1.0-temp_z)*color_p3; } } } if ( color_type == 3.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } mesh_r[(cnt_y*dim11) + cnt_x] = 0.5*(1.0-temp_z)*color_p1; mesh_g[(cnt_y*dim11) + cnt_x] = 0.5*(1.0+temp_z)*color_p2; mesh_b[(cnt_y*dim11) + cnt_x] = 0.5*(1.0-temp_z)*color_p3; } } } if ( color_type == 4.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } mesh_r[(cnt_y*dim11) + cnt_x] = 0.5*(1.0-temp_z)*color_p1; mesh_g[(cnt_y*dim11) + cnt_x] = 0.5*(1.0-temp_z)*color_p2; mesh_b[(cnt_y*dim11) + cnt_x] = 0.5*(1.0+temp_z)*color_p3; } } } if ( color_type == 5.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } mesh_r[(cnt_y*dim11) + cnt_x] = (1.0-temp_z)*color_p1; mesh_g[(cnt_y*dim11) + cnt_x] = 0.0; mesh_b[(cnt_y*dim11) + cnt_x] = temp_z*color_p3; } } } if ( color_type == 6.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } mesh_r[(cnt_y*dim11) + cnt_x] = temp_z*color_p1; mesh_g[(cnt_y*dim11) + cnt_x] = 0.0; mesh_b[(cnt_y*dim11) + cnt_x] = (1.0-temp_z)*color_p3; } } } if ( color_type == 7.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } mesh_r[(cnt_y*dim11) + cnt_x] = 0.0; mesh_g[(cnt_y*dim11) + cnt_x] = temp_z*color_p2; mesh_b[(cnt_y*dim11) + cnt_x] = (1.0-temp_z)*color_p3; } } } if ( color_type == 8.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } mesh_r[(cnt_y*dim11) + cnt_x] = 0.0; mesh_g[(cnt_y*dim11) + cnt_x] = (1.0-temp_z)*color_p2; mesh_b[(cnt_y*dim11) + cnt_x] = temp_z*color_p3; } } } if ( color_type == 9.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } mesh_r[(cnt_y*dim11) + cnt_x] = temp_z*color_p1; mesh_g[(cnt_y*dim11) + cnt_x] = (1.0-temp_z)*color_p2; mesh_b[(cnt_y*dim11) + cnt_x] = 0.0; } } } if ( color_type == 10.0 ) { for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_z != min_z ){ temp_z = (mesh_z[(cnt_y*dim11) + cnt_x]-min_z)/(max_z-min_z); } else { temp_z = 0.5; } mesh_r[(cnt_y*dim11) + cnt_x] = (1.0-temp_z)*color_p1; mesh_g[(cnt_y*dim11) + cnt_x] = temp_z*color_p2; mesh_b[(cnt_y*dim11) + cnt_x] = 0.0; } } } /* *テクスチャーマップ */ if ( color_type == 11.0 ) { texture_mapping(); } return(0); } /*----------------------------------------------------------------------------------------------------------------*/ int texture_mapping(){ /* *R系ファイル名生成 */ tmpcha = (int)color_p1; strcpy(strtmpcn,"r_color"); sprintf(strtmpc,"%d",tmpcha); strcat(strtmpcn,strtmpc); /* *R系ファイルオープン */ file_p3 = fopen(strtmpcn,"r"); if(file_p3 == NULL) { printf("読み込みファイルが開けません\n"); printf("ファイル名 = %s", strtmpcn); exit(0); } printf("読み出しファイル%sを開きました。\n", strtmpcn); /* *G系ファイル名生成 */ tmpcha = (int)color_p2; strcpy(strtmpcn,"g_color"); sprintf(strtmpc,"%d",tmpcha); strcat(strtmpcn,strtmpc); /* *G系ファイルオープン */ file_p4 = fopen(strtmpcn,"r"); if(file_p4 == NULL) { printf("読み込みファイルが開けません\n"); printf("ファイル名 = %s", strtmpcn); exit(0); } printf("読み出しファイル%sを開きました。\n", strtmpcn); /* *B系ファイル名生成 */ tmpcha = (int)color_p3; strcpy(strtmpcn,"b_color"); sprintf(strtmpc,"%d",tmpcha); strcat(strtmpcn,strtmpc); /* *B系ファイルオープン */ file_p5 = fopen(strtmpcn,"r"); if(file_p5 == NULL) { printf("読み込みファイルが開けません\n"); printf("ファイル名 = %s", strtmpcn); exit(0); } printf("読み出しファイル%sを開きました。\n", strtmpcn); /* *R系ファイルのデータサイズを読み込み配列を準備し、読み込み */ fscanf(file_p3, "%d %d", &dimt1,&dimt2); imesh_tmp =(int *)malloc(sizeof(int)*dimt1*dimt2); if( imesh_tmp == NULL ) { printf("メモリが確保できません\n"); } memset(imesh_tmp, 0x00, sizeof(int)*dimt1*dimt2); for(cnt_y = 0; cnt_y < dimt2; cnt_y++) { for(cnt_x = 0; cnt_x < dimt1; cnt_x++) { fscanf(file_p3, "%d", &tmpcha); imesh_tmp[(cnt_y*dimt1) + cnt_x] = tmpcha; } } /* *color_p4、color_p5によりマッピングの拡大縮小率を決める */ if ( color_p4 <= 0.0 ) { if ( max_x-min_x != 0 ) { temp_x = (float)dimt1/(max_x-min_x); } } if ( color_p5 <= 0.0 ) { if ( max_y-min_y != 0 ) { temp_y = (float)dimt2/(max_y-min_y); } } if ( color_p4 > 0.0 ) { if ( max_x-min_x != 0 ) { temp_x = (color_p6-color_p4+1)/(max_x-min_x); } } if ( color_p5 > 0.0 ) { if ( max_y-min_y != 0 ) { temp_y = (color_p7-color_p5+1)/(max_y-min_y); } } if ( color_p8 == 1.0 ) { temp_y = temp_x; } if ( color_p8 == 2.0 ) { temp_x = temp_y; } if ( temp_x <= 0 || temp_y <= 0 ) { printf("error : region not correct min_x=%f, max_x=%f,min_y=%f, max_y=%f" ,color_p4,color_p6,color_p5,color_p7); exit(0); } /* *クロップ領域を考慮してR値をマッピング */ for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_x-min_x != 0 ) { if ( color_p4 <= 0 ) { dimt5 = temp_x *(mesh_x[(cnt_y*dim11)+cnt_x]-min_x); } else { dimt5 = color_p4 + temp_x *(mesh_x[(cnt_y*dim11)+cnt_x]-min_x); } } else { dimt5 = 1.0; } if ( max_y-min_y != 0 ) { if ( color_p5 <= 0 ) { dimt6 = temp_y *(mesh_y[(cnt_y*dim11)+cnt_x]-min_y); } else { dimt6 = color_p5 + temp_y *(mesh_y[(cnt_y*dim11)+cnt_x]-min_y); } } else { dimt6 = 1.0; } if ( dimt5 >= dimt1 || dimt6 >= dimt2 ) { mesh_r[(cnt_y*dim11) + cnt_x] = 0.0; } else { mesh_r[(cnt_y*dim11) + cnt_x] = (float) imesh_tmp[dimt1*dimt6 + dimt5] *color_p9/256; } } } /* *データ読み込み作業領域のメモリ開放 */ free(imesh_tmp); /* *G系ファイルのデータサイズを読み込み配列を準備し、読み込み */ fscanf(file_p4, "%d %d", &dimt1,&dimt2); imesh_tmp =(int *)malloc(sizeof(int)*dimt1*dimt2); if( imesh_tmp == NULL ) { printf("メモリが確保できません\n"); } memset(imesh_tmp, 0x00, sizeof(int)*dimt1*dimt2); for(cnt_y = 0; cnt_y < dimt2; cnt_y++) { for(cnt_x = 0; cnt_x < dimt1; cnt_x++) { fscanf(file_p4, "%d", &tmpcha); imesh_tmp[(cnt_y*dimt1) + cnt_x] =tmpcha; } } /* *color_p4、color_p5によりマッピングの拡大縮小率を決める */ if ( color_p4 <= 0.0 ) { if ( max_x-min_x != 0 ) { temp_x = (float)dimt1/(max_x-min_x); } } if ( color_p5 <= 0.0 ) { if ( max_y-min_y != 0 ) { temp_y = (float)dimt2/(max_y-min_y); } } if ( color_p4 > 0.0 ) { if ( max_x-min_x != 0 ) { temp_x = (color_p6-color_p4)/(max_x-min_x); } } if ( color_p5 > 0.0 ) { if ( max_y-min_y != 0 ) { temp_y = (color_p7-color_p5)/(max_y-min_y); } } /* *クロップ領域を考慮してG値をマッピング */ for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_x-min_x != 0 ) { if ( color_p4 <= 0 ) { dimt5 = temp_x *(mesh_x[(cnt_y*dim11)+cnt_x]-min_x); } else { dimt5 = color_p4 + temp_x *(mesh_x[(cnt_y*dim11)+cnt_x]-min_x); } } else { dimt5 = 1.0; } if ( max_y-min_y != 0 ) { if ( color_p5 <= 0 ) { dimt6 = temp_y *(mesh_y[(cnt_y*dim11)+cnt_x]-min_y); } else { dimt6 = color_p5 + temp_y *(mesh_y[(cnt_y*dim11)+cnt_x]-min_y); } } else { dimt6 = 1.0; } if ( dimt5 >= dimt1 || dimt6 >= dimt2 ) { mesh_g[(cnt_y*dim11) + cnt_x] = 0.0; } else { mesh_g[(cnt_y*dim11) + cnt_x] = (float) imesh_tmp[dimt1*dimt6 + dimt5] *color_p10/256; } } } /* *データ読み込み作業領域のメモリ開放 */ free(imesh_tmp); /* *B系ファイルのデータサイズを読み込み配列を準備し、読み込み */ fscanf(file_p5, "%d %d", &dimt1,&dimt2); imesh_tmp =(int *)malloc(sizeof(int)*dimt1*dimt2); if( imesh_tmp == NULL ) { printf("メモリが確保できません\n"); } memset(imesh_tmp, 0x00, sizeof(int)*dimt1*dimt2); for(cnt_y = 0; cnt_y < dimt2; cnt_y++) { for(cnt_x = 0; cnt_x < dimt1; cnt_x++) { fscanf(file_p5, "%d", &tmpcha); imesh_tmp[(cnt_y*dimt1) + cnt_x] =tmpcha; } } /* *color_p4、color_p5によりマッピングの拡大縮小率を決める */ if ( color_p4 <= 0.0 ) { if ( max_x-min_x != 0 ) { temp_x = (float)dimt1/(max_x-min_x); } } if ( color_p5 <= 0.0 ) { if ( max_y-min_y != 0 ) { temp_y = (float)dimt2/(max_y-min_y); } } if ( color_p4 > 0.0 ) { if ( max_x-min_x != 0 ) { temp_x = (color_p6-color_p4)/(max_x-min_x); } } if ( color_p5 > 0.0 ) { if ( max_y-min_y != 0 ) { temp_y = (color_p7-color_p5)/(max_y-min_y); } } /* *クロップ領域を考慮してB値をマッピング */ for(cnt_y = 0; cnt_y < dim12; cnt_y++) { for(cnt_x = 0; cnt_x < dim11; cnt_x++) { if ( max_x-min_x != 0 ) { if ( color_p4 <= 0 ) { dimt5 = temp_x *(mesh_x[(cnt_y*dim11)+cnt_x]-min_x); } else { dimt5 = color_p4 + temp_x *(mesh_x[(cnt_y*dim11)+cnt_x]-min_x); } } else { dimt5 = 1.0; } if ( max_y-min_y != 0 ) { if ( color_p5 <= 0 ) { dimt6 = temp_y *(mesh_y[(cnt_y*dim11)+cnt_x]-min_y); } else { dimt6 = color_p5 + temp_y *(mesh_y[(cnt_y*dim11)+cnt_x]-min_y); } } else { dimt6 = 1.0; } if ( dimt5 >= dimt1 || dimt6 >= dimt2 ) { mesh_b[(cnt_y*dim11) + cnt_x] = 0.0; } else { mesh_b[(cnt_y*dim11) + cnt_x] = (float) ime