syntax: { # opitional options: "trim": bool, "periodic": bool, "subdiv": #, "subdiv_method": "simple" or "loop" "rel_geometry_correction": [#, #, #], "abs_geometry_correction": [#, #, #], "geometry_correction_cap": #, "geom
(config_file)
| 15 | from find_file import find_file |
| 16 | |
| 17 | def parse_config_file(config_file): |
| 18 | """ syntax: |
| 19 | { |
| 20 | # opitional options: |
| 21 | "trim": bool, |
| 22 | "periodic": bool, |
| 23 | "subdiv": #, |
| 24 | "subdiv_method": "simple" or "loop" |
| 25 | "rel_geometry_correction": [#, #, #], |
| 26 | "abs_geometry_correction": [#, #, #], |
| 27 | "geometry_correction_cap": #, |
| 28 | "geometry_spread": # |
| 29 | "geometry_correction_lookup": filename, |
| 30 | "output_wire_network": filename, |
| 31 | |
| 32 | # options for specifying parameters |
| 33 | "thickness": float, |
| 34 | "modifier_file": modifier_file, |
| 35 | "dof_file": dof_file, |
| 36 | |
| 37 | # options needed by guide bbox |
| 38 | "wire_network": single_cell_wire_network, |
| 39 | "bbox_min": [min_x, min_y, min_z], |
| 40 | "bbox_max": [max_x, max_y, max_z], |
| 41 | "repeats": [x_reps, y_reps, z_reps], |
| 42 | |
| 43 | # options needed by guide mesh |
| 44 | "wire_network": single_cell_wire_network, |
| 45 | "guide_mesh": guide_mesh, |
| 46 | "dof_type": "isotropic" | "orthotropic", |
| 47 | "thickness_type": "vertex" | "edge" |
| 48 | |
| 49 | # options neede by mixed pattern tiling |
| 50 | "guide_mesh": guide_mesh, |
| 51 | "wire_list_file": wire_list_file, |
| 52 | } |
| 53 | """ |
| 54 | config_dir = os.path.dirname(config_file); |
| 55 | with open(config_file, 'r') as fin: |
| 56 | config = json.load(fin); |
| 57 | |
| 58 | def convert_to_abs_path(field_name): |
| 59 | field = config[field_name]; |
| 60 | if isinstance(field, str): |
| 61 | config[field_name] = str(find_file(field, config_dir)); |
| 62 | |
| 63 | if "wire_network" in config: |
| 64 | convert_to_abs_path("wire_network"); |
| 65 | if "guide_mesh" in config: |
| 66 | convert_to_abs_path("guide_mesh"); |
| 67 | if "modifier_file" in config: |
| 68 | convert_to_abs_path("modifier_file"); |
| 69 | if "dof_file" in config: |
| 70 | convert_to_abs_path("dof_file"); |
| 71 | if "wire_list_file" in config: |
| 72 | convert_to_abs_path("wire_list_file"); |
| 73 | if "geometry_correction_lookup" in config: |
| 74 | convert_to_abs_path("geometry_correction_lookup"); |
no test coverage detected