Skip to content
Snippets Groups Projects
Commit 995061a6 authored by mehtank's avatar mehtank
Browse files

Only STL outputs in units of m

parent 0c6278b7
No related merge requests found
......@@ -35,6 +35,7 @@ function init() {
var mesh = new THREE.Mesh( geometry, material );
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.scale.set(1000, 1000, 1000);
geometry.computeFaceNormals();
geometry.computeVertexNormals();
......
......@@ -20,6 +20,8 @@ def inflate(face, thickness=.1, edges=False):
return faces
def STLWrite(faces, filename, **kwargs):
scale = .001 # roco units : mm ; STL units m
from stlwriter import Binary_STL_Writer
import triangle
......@@ -38,12 +40,12 @@ def STLWrite(faces, filename, **kwargs):
thickness = "thickness" in kwargs and kwargs["thickness"]
if thickness:
for t in [np.transpose(np.array([list(B['vertices'][x]) + [0,1] for x in (face[0], face[1], face[2])])) for face in B['triangles']]:
facets.extend([np.dot(r, x) for x in inflate(t, thickness=thickness)])
facets.extend([np.dot(r, x) * scale for x in inflate(t, thickness=thickness)])
for t in [np.transpose(np.array([list(A['vertices'][x]) + [0,1] for x in (edge[0], edge[1])])) for edge in A['segments']]:
facets.extend([np.dot(r, x) for x in inflate(t, thickness=thickness, edges=True)])
facets.extend([np.dot(r, x) * scale for x in inflate(t, thickness=thickness, edges=True)])
else:
for t in [np.transpose(np.array([list(B['vertices'][x]) + [0,1] for x in (face[0], face[1], face[2])])) for face in B['triangles']]:
facets.append(np.dot(r, t))
facets.append(np.dot(r, t) * scale)
triangles.extend(facets)
with open(filename.replace(".stl", "_%02d.stl" % i), 'wb') as fp:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment