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

Function extrude

scripts/repousse.py:383–411  ·  view source on GitHub ↗
(mesh, depth, logger)

Source from the content-addressed store, hash-verified

381 return mesh;
382
383def extrude(mesh, depth, logger):
384 start_time = time();
385 num_vertices = mesh.num_vertices;
386 num_faces = mesh.num_faces;
387
388 top_vertices = mesh.vertices;
389 top_faces = mesh.faces;
390
391 if mesh.dim == 2:
392 top_vertices = np.hstack((top_vertices, np.zeros((mesh.num_vertices, 1))));
393
394 bottom_vertices = np.copy(top_vertices);
395 bottom_vertices[:,2] -= depth;
396 bottom_faces = top_faces[:,[0,2,1]] + num_vertices;
397
398 bd_edges = mesh.boundary_edges;
399 bd_faces = np.array([
400 [e[1], e[0], e[0]+num_vertices,
401 e[0]+num_vertices, e[1]+num_vertices, e[1] ]
402 for e in bd_edges]).reshape((-1, 3), order="C");
403
404 vertices = np.vstack([top_vertices, bottom_vertices]);
405 faces = np.vstack([top_faces, bottom_faces, bd_faces]);
406
407 finish_time = time();
408 t = finish_time - start_time;
409 logger.info("Extrusion running time: {}".format(t));
410
411 return pymesh.form_mesh(vertices, faces);
412
413def main():
414 args = parse_args();

Callers 1

mainFunction · 0.85

Calls 2

copyMethod · 0.45
form_meshMethod · 0.45

Tested by

no test coverage detected