static void mesh_dump(Lib3dsMesh *mesh) { int i; float p[3]; assert(mesh); printf(" %s vertices=%ld faces=%ld\n", mesh->name, mesh->nvertices, mesh->nfaces); printf(" matrix:\n"); matrix_dump(mesh->matrix); printf(" vertices (x, y, z, u, v):\n"); for (i = 0; i < mesh->nvertices; ++i) { lib3ds_vector_copy(p, mesh->vertices[i]); printf(" %10.5f %10.5f %10.5f", p[0], p[1], p[2]); if (mesh->texcos) { printf("%10.5f %10.5f", mesh->texcos[i][0], mesh->texcos[i][1]); } printf("\n"); } printf(" facelist:\n"); for (i = 0; i < mesh->nfaces; ++i) { printf(" %4d %4d %4d flags:%X smoothing:%X material:\"%d\"\n", mesh->faces[i].index[0], mesh->faces[i].index[1], mesh->faces[i].index[2], mesh->faces[i].flags, mesh->faces[i].smoothing_group, mesh->faces[i].material ); } }
void main_routine(){ // Basic iterations if (ITERFLAG == 1){ for (int iter = 0; iter < ITER_NUM; iter++){ iterGlobal = iter; Cal(); printf("[INFO] ROUND %02d: CALCULATION DONE\n", iter+1); if (ITER_ALGO == 0){ Norm(); printf("[INFO] ROUND %02d: NORMALIZATION DONE\n", iter+1); } } matrix_dump(); } else matrix_retrieve(); //Compute the matrix of same node pair; node_info(); //The greedy approach of matrix mapping matrix_mapping(ITER_NUM, 0); //Using the mapped pairs to induce other mapping if (PICK_ALGO != 0) mapping_induction(); }
int main(int argc, char * argv[]) { char cmdStr[MAX_PATH_LEN] = {0}; char allready = 1; clock_t start_time, end_time; FILE_INFO_NODE * matrix_source[26] = { NULL }; FILE_INFO_NODE * matrix_refer[26] = { NULL }; char refer_file_list[MAX_PATH_LEN] = "refer_file_list"; char source_file_list[MAX_PATH_LEN] = "source_file_list"; #if DEBUG_TRACE == 2 { unsigned short argNums = argc; fprintf(stdout, "argc=%d\n",argc); while (argNums != 0) { fprintf(stdout, "argv[%d]=%s\n",argNums,argv[argNums]); argNums--; } } #endif //////////////////////////////////////////////////////////////////////// switch(argc) { case 2: /* e.g. $lsd --help */ if (argv[1][0] == '-' && argv[1][1] == '-' && argv[1][2] == 'h' && argv[1][3] == 'e' && argv[1][4] == 'l' && argv[1][5] == 'p') { fprintf(stdout, "Usage: lsd [SOURCE_DIR] [SUFFIX] [REFERENCE_DIR] [SUFFIX]\n"); fprintf(stdout, " or: lsd -c SOURCE_FILE REFERENCE_FILE\n"); fprintf(stdout, " or: lsd -a SOURCE_DIR REFERENCE_DIR\n"); fprintf(stdout, "Print file path of the file that in SOURCE DIR but not in REFERENCE DIR with same PREFIX and difference SUFFIX\n"); fprintf(stdout, "\n"); fprintf(stdout, " -c comparinf specify SOURCE and REFERENCE file instead of DIR\n"); fprintf(stdout, " -a comparing all types of file in specify SOURCE and REFERENCE directory\n"); fprintf(stdout, "\n"); fprintf(stdout, "For example:\n"); fprintf(stdout, " List file's path that in /home/src/cfiles/ but not in /home/src/objfiles/ with same PREFIX but difference SUFFIX.\n"); fprintf(stdout, " $lsd /home/src/cfiles/ .c /home/src/objfiles/ .obj\n"); fprintf(stdout, "\n"); fprintf(stdout, " If already has SOURCE or REFERENCE file generated by,for example\n"); fprintf(stdout, " '$ls -name '*.c' > source_file_list'\n"); fprintf(stdout, " and '$ls -name '*.obj' > refer_file_list'\n"); fprintf(stdout, " then using '-c' option directly,as below:\n"); fprintf(stdout, " $lsd -c source_file_list refer_list_file\n"); } else { goto MISSING_FILE_OPERAND; } allready = 0; break; case 4: /* e.g. $lsd -c source_file_list target_file_list */ /* or $lsd -a source_path target_path */ if (argv[1][0] == '-' && argv[1][1] =='c') { fprintf(stdout,"Running...\n"); strncpy(source_file_list,argv[2],MAX_PATH_LEN); strncpy(refer_file_list,argv[3],MAX_PATH_LEN); } else if (argv[1][0] == '-' && argv[1][1] =='a') { fprintf(stdout,"Running...\n"); fprintf(stdout,"Generating source file list...\n"); /* find all files but ignore hidden file and directory */ sprintf(cmdStr,"find %s \\( ! -regex '.*/\\..*' \\) -xtype f -name '*' > source_file_list", argv[2]); printf("Generating source_file_list:\n"); printf(" %s",cmdStr); if (system(cmdStr) != 0) { fprintf(stderr, "Can not get source file list, please check your shell or path\n"); allready = 0; break; } else { fprintf(stdout,"Generating c file list...DONE\n"); } fprintf(stdout,"Generating reference file list...\n"); sprintf(cmdStr,"find %s \\( ! -regex '.*/\\..*' \\) -xtype f -name '*' > refer_file_list", argv[3]); printf("Generating refer_file_list:\n"); printf(" %s",cmdStr); if (system(cmdStr) != 0) { fprintf(stderr, "Can not get reference file list, please check your shell or path\n"); allready = 0; break; } else { fprintf(stdout,"Generating reference file list...DONE\n"); } } else { goto MISSING_FILE_OPERAND; } break; case 5: /* e.g. $lsd source_path .obj target_path .c */ fprintf(stdout,"Running...\n"); fprintf(stdout,"Generating source file list...\n"); sprintf(cmdStr,"find %s \\( ! -regex '.*/\\..*' \\) -xtype f -name '*%s' > source_file_list", argv[1], argv[2]); if (system(cmdStr) != 0) { fprintf(stderr, "Can not get source file list, please check your shell or path\n"); allready = 0; break; } else { fprintf(stdout,"Generating c file list...DONE\n"); } fprintf(stdout,"Generating reference file list...\n"); sprintf(cmdStr,"find %s \\( ! -regex '.*/\\..*' \\) -xtype f -name '*%s' > refer_file_list", argv[3], argv[4]); if (system(cmdStr) != 0) { fprintf(stderr, "Can not get reference file list, please check your shell or path\n"); allready = 0; break; } else { fprintf(stdout,"Generating reference file list...DONE\n"); } break; default: MISSING_FILE_OPERAND: fprintf(stdout, "lsd: missing file operand\n"); fprintf(stdout, "Try `lsd --help' for more information.\n"); allready = 0; break; } //////////////////////////////////////////////////////////////////////// if (allready) { start_time = clock(); matrix_get(refer_file_list,matrix_refer); matrix_get(source_file_list,matrix_source); #if DEBUG_TRACE == 1 || DEBUG_TRACE == 2 matrix_dump(matrix_source); #endif matrix_difference(matrix_refer,matrix_source); matrix_dump(matrix_source); end_time = clock(); fprintf(stdout,"Time consumation is %.4f seconds\n",(end_time - start_time)/(double)CLOCKS_PER_SEC); } return 0; }