📄 input.c
字号:
#endif fprintf(stderr, "read_panels: can't open\n `%s'\nto read\n", cur_surf->name); exit(1); } /* input the panel list */ if(panel_list == NULL) { /* group names are set up in read_list_file() */ sprintf(surf_name, "%%%s", cur_surf->group_name); panel_list = cur_panel = patfront(fp, &patran_file, cur_surf->type, cur_surf->trans, name_list, num_cond, surf_name); patran_file_read = patran_file; panel_group = cur_panel; name_group = start_name; } else { if(cur_surf->prev->end_of_chain) { sprintf(surf_name, "%%%s", cur_surf->group_name); patran_file_read = FALSE; } cur_panel->next = patfront(fp, &patran_file, cur_surf->type, cur_surf->trans, name_list, num_cond, surf_name); if(!patran_file && patran_file_read) { fprintf(stderr, "read_panels: generic format file\n `%s'\nread after neutral file(s) in same group---reorder list file entries\n", cur_surf->name); exit(1); } patran_file_read = patran_file; cur_panel = cur_panel->next; if(cur_surf->prev->end_of_chain) { /* if previous surface was the end of a chain, set up new group */ panel_group = cur_panel; name_group = start_name_this_time; /* not really used anymore */ } } if(strcmp(cur_surf->name, "stdin") != 0) fclose(fp); cur_surf->panels = cur_panel; /* save the surface file's title */ CALLOC(cur_surf->title, strlen(title)+1, char, ON, AMSC); strcpy(cur_surf->title, title); title[0] = '\0'; /* not sure if needed */ /* if the surface is a DIELEC, make sure all conductor numbers are zero */ /* - also link each panel to its surface */ for(c_panel = cur_panel; c_panel != NULL; c_panel = c_panel->next) { if(cur_surf->type == DIELEC) c_panel->cond = 0; c_panel->surf = cur_surf; } /* align the normals and add dummy structs if dielec i/f */ initcalcp(cur_surf->panels);/* get normals, edges, perpendiculars */ if(cur_surf->type == DIELEC || cur_surf->type == BOTH) { /* if(patran_file) align_normals(cur_surf->panels); align_normals(cur_surf->panels, cur_surf); /* now done in calcp */ add_dummy_panels(cur_surf->panels); /* add dummy panels for field calc */ } /* make cur_panel = last panel in list, count panels */ num_panels = num_dummies = num_tris = num_quads = 0; for(cur_panel = cur_surf->panels ; ; cur_panel = cur_panel->next) { num_panels++; if(cur_panel->dummy) num_dummies++; else if(cur_panel->shape == 3) num_tris++; else if(cur_panel->shape == 4) num_quads++; else { fprintf(stderr, "read_panels: bad panel shape, %d\n", cur_panel->shape); exit(1); } /* SRW -- dummy panels don't have this set */ if (!cur_panel->surf) cur_panel->surf = cur_surf; if(cur_panel->next == NULL) break; } fprintf(stdout, "Surface %s has %d quads and %d tris\n", cur_surf->name, num_quads, num_tris); cur_surf->num_panels = num_panels; cur_surf->num_dummies = num_dummies;#if 1 == 0 /* now done implicitly with suffix names */ if(cur_surf->type == CONDTR || cur_surf->type == BOTH) { if(cur_surf->end_of_chain) { /* if the current surface is the end of a group to be #ed together, */ /* renumber the conductors in the newly input surface so numbering */ /* is unique and contiguous over the whole list */ if(cur_surf != surf_list) { /* if this is not the first surface */ negate_cond_numbers(panel_group, name_group); reassign_cond_numbers(panel_list, start_name, cur_surf->name); } else reassign_cond_numbers(panel_list, start_name, cur_surf->name); } }#endif } return(panel_list);}/* returns either conductor number or one of two error codes NOTUNI => no group name given and name by itself is not unique NOTFND => neither name by itself nor with group name is not in list - any unique leading part of the name%group_name string may be specified */int getUniqueCondNum(name, name_list)char *name;Name *name_list;{ int nlen, cond; char name_frag[BUFSIZ], *last_alias(), *cur_alias; Name *cur_name, *prev_name; int i, j, alias_match_name(), times_in_list; nlen = strlen(name); times_in_list = 0; /* fish through name list for name---check first nlen chars for match */ for(cur_name = name_list, i = 1; cur_name != NULL && times_in_list < 2; cur_name = cur_name->next, i++) { cur_alias = last_alias(cur_name); for(j = 0; j < nlen; j++) name_frag[j] = cur_alias[j]; name_frag[j] = '\0'; if(!strcmp(name_frag, name)) { times_in_list++; /* increment times name in list count */ cond = i; } prev_name = cur_name; } /* name can't be dealt with; return appropriate error code */ if(times_in_list > 2) return(NOTUNI); else if(times_in_list == 1) return(cond); else return(NOTFND);}/* called after all conductor names have been resolved to get list of conductor numbers that whose columns will not be calculated parses the conductor kill list spec from command line arg saved before (conds that get no solve); puts result in kill_num_list list string format: [<cond name>[%<group name>]],[<cond name>[%<group name>]]... - no spaces; group name may be omitted if conductor name is unique across all groups - conductor names can't have any %'s - redundant names are detected as errors*/ITER *get_kill_num_list(name_list, kill_name_list)char *kill_name_list;Name *name_list;{ int i, j, start_token, end_token, end_name, cond; char name[BUFSIZ], group_name[BUFSIZ]; ITER *kill_num_list; ITER *cur_cond; /* check for no name list given */ if(kill_name_list == NULL) return(NULL); start_token = 0; kill_num_list = NULL; while(kill_name_list[start_token] != '\0') { /* loop until next comma or end of list */ for(i = start_token; kill_name_list[i] != '\0' && kill_name_list[i] != ','; i++); end_token = i; /* extract the name%group_name string */ /* copy the name */ for(i = start_token, j = 0; i < end_token; i++, j++) name[j] = kill_name_list[i]; name[j] = '\0'; /* attempt to get conductor number from name and group_name */ cond = getUniqueCondNum(name, name_list); if(cond == NOTUNI) { fprintf(stderr, "get_kill_num_list: cannot find unique conductor name starting `%s'\n", name); exit(1); } else if(cond == NOTFND) { fprintf(stderr, "get_kill_num_list: cannot find conductor name starting `%s'\n", name); exit(1); } /* add conductor name to list of conductors to omit */ if(kill_num_list == NULL) { CALLOC(kill_num_list, 1, ITER, ON, AMSC); cur_cond = kill_num_list; } else { CALLOC(cur_cond->next, 1, ITER, ON, AMSC); cur_cond = cur_cond->next; } cur_cond->iter = cond; if(kill_name_list[end_token] == ',') start_token = end_token+1; else start_token = end_token; } return(kill_num_list);}/* command line parsing routine*/void parse_command_line(argv, argc, autmom, autlev, relperm, numMom, numLev, input_file, surf_list_file, read_from_stdin)int argc, *autmom, *autlev, *numMom, *numLev, *read_from_stdin;double *relperm;char *argv[], **input_file, **surf_list_file;{ int cmderr, i; char **chkp, *chk; long strtol(); extern char *kill_name_list, *kinp_name_list; extern ITER *kill_num_list, *kinp_num_list; extern double iter_tol;#if CAPVEW == ON extern int s_, n_, g_, c_, x_, k_, rc_, rd_, rb_, q_, rk_, m_, f_, dd_; extern double view[], moffset[], rotation, distance, linewd, scale, axeslen; extern double elevation, azimuth; extern int up_axis; extern char *line_file; extern char *ps_file_base; extern ITER *qpic_num_list; extern char *qpic_name_list; extern ITER *kq_num_list; extern char *kq_name_list; /* load default parameters */ azimuth = DEFAZM; /* azimuth */ elevation = DEFELE; /* elevation */ rotation = DEFROT; /* rotation relative to image of z axis */ distance = DEFDST; /* distance to view pnt = (1+distance)radius */ moffset[0] = OFFSETX; /* puts the origin this dist from lower left */ moffset[1] = OFFSETY; scale = DEFSCL; /* master scaling - applied to 2d image */ linewd = DEFWID; /* line width used in ps file */ axeslen = DEFAXE; /* length of axes lines in 3d */ up_axis = DEFUAX; /* upward-pointing axis in 2d image */ line_file = NULL; /* file of lines/arrows in .fig format */ ps_file_base = NULL; /* base used to form .ps file names */ qpic_num_list = NULL; /* list of cond nums to get shaded plots for */ qpic_name_list = NULL; /* list of cond names to get shaded plots */ kq_num_list = NULL; /* list of cond nums in shaded plots */ kq_name_list = NULL; /* list of cond names in shaded plots */ s_ = n_ = g_ = c_ = x_ = k_ = rc_ = rd_ = rb_ = q_ = rk_ = m_ = f_ = FALSE; dd_ = FALSE;#endif iter_tol = ABSTOL; kill_num_list = kinp_num_list = NULL; kill_name_list = kinp_name_list = NULL; cmderr = FALSE; chkp = &chk; /* pointers for error checking */ for(i = 1; i < argc && cmderr == FALSE; i++) { if(argv[i][0] == '-') { if(argv[i][1] == 'o') { *numMom = (int) strtol(&(argv[i][2]), chkp, 10); if(*chkp == &(argv[i][2]) || *numMom < 0) { fprintf(stderr, "%s: bad expansion order `%s'\n", argv[0], &argv[i][2]); cmderr = TRUE; break; } else *autmom = OFF; } else if(argv[i][1] == 'd' && argv[i][2] == 'c') { dd_ = TRUE; } else if(argv[i][1] == 'd') { *numLev = (int) strtol(&(argv[i][2]), chkp, 10); if(*chkp == &(argv[i][2]) || *numLev < 0) { fprintf(stderr, "%s: bad partitioning depth `%s'\n", argv[0], &argv[i][2]); cmderr = TRUE; break; } else *autlev = OFF; } else if(argv[i][1] == 'p') { if(sscanf(&(argv[i][2]), "%lf", relperm) != 1) cmderr = TRUE; else if(*relperm <= 0.0) cmderr = TRUE; if(cmderr) { fprintf(stderr, "%s: bad permittivity `%s'\n", argv[0], &argv[i][2]); break; } } else if(argv[i][1] == 'l') { *surf_list_file = &(argv[i][2]); } else if(argv[i][1] == 'r' && argv[i][2] == 's') { kill_name_list = &(argv[i][3]); } else if(argv[i][1] == 'r' && argv[i][2] == 'i') { kinp_name_list = &(argv[i][3]); } else if(argv[i][1] == '\0') { *read_from_stdin = TRUE; }#if CAPVEW == ON else if(argv[i][1] == 'f') { f_ = TRUE; } else if(argv[i][1] == 'b') { line_file = &(argv[i][2]); } else if(argv[i][1] == 'a') { if(sscanf(&(argv[i][2]), "%lf", &azimuth) != 1) { fprintf(stderr, "%s: bad view point azimuth angle '%s'\n", argv[0], &argv[i][2]); cmderr = TRUE; break; } } else if(argv[i][1] == 'e') { if(sscanf(&(argv[i][2]), "%lf", &elevation) != 1) { fprintf(stderr, "%s: bad view point elevation angle '%s'\n", argv[0], &argv[i][2]); cmderr = TRUE; break; } } else if(argv[i][1] == 't') { if(sscanf(&(argv[i][2]), "%lf", &iter_tol) != 1 || iter_tol <= 0.0) { fprintf(stderr, "%s: bad iteration tolerence '%s'\n", argv[0], &argv[i][2]); cmderr = TRUE; break; } } else if(argv[i][1] == 'r' && argv[i][2] == 'c') { kq_name_list = &(argv[i][3]); rc_ = TRUE; } else if(!strcmp(&(argv[i][1]), "rd")) rd_ = TRUE; /*else if(!strcmp(&(argv[i][1]), "rb")) rb_ = TRUE;*/ else if(!strcmp(&(argv[i][1]), "rk")) rk_ = TRUE; else if(argv[i][1] == 'r') { if(sscanf(&(argv[i][2]), "%lf", &rotation) != 1) { fprintf(stderr, "%s: bad image rotation angle '%s'\n", argv[0], &argv[i][2]); cmderr = TRUE; break; } } else if(argv[i][1] == 'h') { if(sscanf(&(argv[i][2]), "%lf", &distance) != 1) cmderr = TRUE; else if(distance <= 0.0) cmderr = TRUE; if(cmderr) { fprintf(stderr, "%s: bad view point distance '%s'\n", argv[0], &argv[i][2]); break; } } else if(argv[i][1] == 's') { if(sscanf(&(argv[i][2]), "%lf", &scale) != 1) cmderr = TRUE; else if(scale <= 0.0) cmderr = TRUE; if(cmderr) { fprintf(stderr, "%s: bad image scale factor '%s'\n", argv[0], &argv[i][2]); break; } } else if(argv[i][1] == 'w') { if(sscanf(&(argv[i][2]), "%lf", &linewd) != 1) { /* no check for < 0 so dash (-1) is pos. */ fprintf(stderr, "%s: bad line width '%s'\n", argv[0], &argv[i][2]); cmderr = TRUE; break; } } /* -x sets up axes of default length, -x<len> uses len as length */ else if(argv[i][1] == 'x') { if(argv[i][2] == '\0') x_ = TRUE; else { if(sscanf(&(argv[i][2]), "%lf", &axeslen) != 1) { /* no check for < 0 so axes can flip */ fprintf(stderr, "%s: bad axes length '%s'\n", argv[0], &argv[i][2]); cmderr = TRUE; break; } else x_ = TRUE; } } else if(argv[i][1] == 'v') s_ = TRUE; else if(argv[i][1] == 'n') n_ = TRUE; else if(argv[i][1] == 'g') g_ = TRUE; else if(argv[i][1] == 'c') c_ = TRUE; else if(argv[i][1] == 'm') m_ = TRUE; else if(argv[i][1] == 'q') { get_ps_file_base(argv, argc); /* set up the output file base */ qpic_name_list = &(argv[i][2]); q_ = TRUE; } else if(argv[i][1] == 'u') { if(!strcmp(&(argv[i][2]), "x") || !strcmp(&(argv[i][2]), "X")) up_axis = XI; else if(!strcmp(&(argv[i][2]), "y") || !strcmp(&(argv[i][2]), "Y")) up_axis = YI; else if(!strcmp(&(argv[i][2]), "z") || !strcmp(&(argv[i][2]), "Z")) up_axis = ZI; else { fprintf(stderr, "%s: bad up axis type `%s' -- use x, y or z\n"); cmderr = TRUE; break; } }#endif else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -