()
| 184 | return mesh; |
| 185 | |
| 186 | def main(): |
| 187 | args = parse_args(); |
| 188 | logger = get_logger(args.log); |
| 189 | logger.info("Triangulation engine: {}".format(args.engine)); |
| 190 | |
| 191 | wires = pymesh.wires.WireNetwork.create_from_file(args.input_svg); |
| 192 | wires = drop_zero_dim(wires); |
| 193 | |
| 194 | if wires.num_vertices == 0: |
| 195 | logger.warn("Input is empty"); |
| 196 | |
| 197 | if args.with_frame and args.engine != "triwild": |
| 198 | wires = add_frame(wires); |
| 199 | if args.resolve_self_intersection: |
| 200 | wires = resolve_self_intersection(wires, logger); |
| 201 | if args.with_cleanup: |
| 202 | wires = cleanup(wires, logger); |
| 203 | if args.with_features: |
| 204 | json_file = "{}.json".format(os.path.splitext(args.input_svg)[0]); |
| 205 | assert(os.path.exists(json_file)); |
| 206 | else: |
| 207 | json_file = None; |
| 208 | |
| 209 | basename = os.path.splitext(args.output_mesh)[0]; |
| 210 | wire_file = basename + ".wire"; |
| 211 | wires.write_to_file(wire_file); |
| 212 | |
| 213 | if args.with_triangulation: |
| 214 | if os.path.splitext(args.input_svg)[1] != ".svg" and args.engine == "triwild": |
| 215 | # Avoid data loss from conversion. |
| 216 | assert(not args.with_cleanup); |
| 217 | assert(not args.resolve_self_intersection); |
| 218 | with open(args.input_svg, 'r') as fin: |
| 219 | data = fin.read(); |
| 220 | with open(wire_file, 'w') as fout: |
| 221 | fout.write(data); |
| 222 | mesh = triangulate(wires, args.engine, args.stage, args.epsilon, logger, wire_file, json_file); |
| 223 | |
| 224 | if mesh.num_vertices > 0 and args.with_cell_label: |
| 225 | compute_cell_labels(wires, mesh, logger); |
| 226 | mesh = solve_heat_equation(mesh); |
| 227 | pymesh.save_mesh(args.output_mesh, mesh, "cell", "sq_dist"); |
| 228 | else: |
| 229 | pymesh.save_mesh(args.output_mesh, mesh); |
| 230 | |
| 231 | if __name__ == "__main__": |
| 232 | main(); |
no test coverage detected