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

Function add_base

scripts/support_gen.py:30–53  ·  view source on GitHub ↗
(support_mesh, print_dir, support_length)

Source from the content-addressed store, hash-verified

28 return mesh;
29
30def add_base(support_mesh, print_dir, support_length):
31 Z_dir = np.array([0.0, 0.0, 1.0]);
32 vertices = support_mesh.vertices.reshape((-1, 3), order="C");
33 faces = support_mesh.faces.reshape((-1, 3), order="C");
34
35 height = np.dot(print_dir, vertices.T).ravel();
36 projection = vertices - np.outer(height, print_dir);
37
38 if np.all(print_dir == Z_dir):
39 rot = Quaternion().to_matrix();
40 else:
41 rot = Quaternion.fromData(print_dir, Z_dir).to_matrix();
42 projection = np.dot(rot, projection.T);
43 bbox_min = np.amin(projection, axis=1) - Z_dir * 0.15;
44 bbox_max = np.amax(projection, axis=1) + Z_dir * 0.15;
45 base = generate_box_mesh(bbox_min, bbox_max);
46 base_vertices = np.dot(rot.T, base.vertices.T).T\
47 + print_dir * np.amin(height);
48
49 num_support_vertices = support_mesh.num_vertices;
50 vertices = np.vstack([vertices, base_vertices]);
51 faces = np.vstack([faces, base.faces + num_support_vertices]);
52
53 return form_mesh(vertices, faces);
54
55def generate_supports(wire_network, print_dir, support_length,
56 support_thickness, tol):

Callers 1

mainFunction · 0.85

Calls 5

QuaternionClass · 0.90
generate_box_meshFunction · 0.90
form_meshFunction · 0.90
to_matrixMethod · 0.80
fromDataMethod · 0.80

Tested by

no test coverage detected