MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / main

Function main

scripts/svg_to_mesh.py:186–229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

184 return mesh;
185
186def 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
231if __name__ == "__main__":
232 main();

Callers 1

svg_to_mesh.pyFile · 0.70

Calls 13

add_frameFunction · 0.85
compute_cell_labelsFunction · 0.85
solve_heat_equationFunction · 0.85
create_from_fileMethod · 0.80
parse_argsFunction · 0.70
get_loggerFunction · 0.70
drop_zero_dimFunction · 0.70
cleanupFunction · 0.70
triangulateFunction · 0.70
write_to_fileMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected