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

Function triangulate

scripts/svg_to_mesh.py:128–152  ·  view source on GitHub ↗
(wires, engine, stage, eps, logger, wire_file, json_file)

Source from the content-addressed store, hash-verified

126 return wires;
127
128def triangulate(wires, engine, stage, eps, logger, wire_file, json_file):
129 if wires.num_vertices == 0:
130 return pymesh.form_mesh(np.zeros((0, 2)), np.zeros((0,3)));
131 basename = os.path.splitext(wire_file)[0];
132 if engine == "triwild":
133 out_mesh = "{}_linear.msh".format(basename);
134 log_file = "{}_triwild.log".format(basename);
135 if json_file is not None:
136 command = "TriWild --mute-log --feature-envelope-r {} --stage {} --log-file {} --feature-input {} --output-linear-mesh --skip-eps --input {} --output {}".format(
137 eps, stage, log_file, json_file, wire_file, basename);
138 else:
139 command = "TriWild --mute-log --feature-envelope-r {} --stage {} --log-file {} --output-linear-mesh --skip-eps --input {} --output {}".format(
140 eps, stage, log_file, wire_file, basename);
141 print(command);
142 start_time = time();
143 check_call(command.split());
144 finish_time = time();
145 t = finish_time - start_time;
146 mesh = pymesh.load_mesh(out_mesh, drop_zero_dim=True);
147 else:
148 mesh, t = pymesh.triangulate_beta(wires.vertices, wires.edges,
149 engine=engine, with_timing=True);
150 logger.info("Triangulation running time: {}".format(t));
151
152 return mesh;
153
154def compute_cell_labels(wires, mesh, logger):
155 start_time = time();

Callers 3

mainFunction · 0.70
test_2DMethod · 0.50
test_3DMethod · 0.50

Calls 2

form_meshMethod · 0.45
load_meshMethod · 0.45

Tested by 2

test_2DMethod · 0.40
test_3DMethod · 0.40