Skip to content

Commit 5f10c56

Browse files
committed
Removed integer conversion, as it works better with floating points. Can now export to SVG with black lines
1 parent 0d47900 commit 5f10c56

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

Model3D.py

-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ def cross(self, other):
5151
self.z*other.x-self.x*other.z,
5252
self.x*other.y-self.y*other.x)
5353

54-
def integerise(self):
55-
self.x = int(self.x)
56-
self.y = int(self.y)
57-
self.z = int(self.z)
58-
5954
class Normal(Vector3):
6055
'''Class for a 3D Normal Vector in Cartesian Space'''
6156

pySlice.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def slice_file(f=None, resolution=0.1):
3232
print("Status: Loading File.")
3333

3434
stlobj = STLModel(f)
35-
scale = 10
35+
scale = 100
3636
stats = stlobj.stats()
3737

3838
sub_vertex = Vector3(stats['extents']['x']['lower'], stats['extents']['y']['lower'], stats['extents']['z']['lower'])
@@ -55,18 +55,13 @@ def slice_file(f=None, resolution=0.1):
5555
facet.vertices[1] = (facet.vertices[1] * scale) + add_vertex
5656
facet.vertices[2] = (facet.vertices[2] * scale) + add_vertex
5757

58-
facet.vertices[0].integerise()
59-
facet.vertices[1].integerise()
60-
facet.vertices[2].integerise()
61-
6258
# Recalculate the facet normal
6359

6460
u = stlobj.triangles[0].vertices[1] - stlobj.triangles[0].vertices[0]
6561
v = stlobj.triangles[0].vertices[2] - stlobj.triangles[0].vertices[0]
6662

6763
facet.n = Normal((u.y * v.z)-(u.z*v.y), (u.z*v.x)-(u.x*v.z), (u.x*v.y)-(u.y*v.x))
6864
stlobj.update_extents(facet)
69-
# So now, we have all of the points as integers...
7065

7166
print("Status: Calculating Slices")
7267

@@ -134,7 +129,7 @@ def findInterpolatedPoint(A, B):
134129
pair.append((int(facet.vertices[2].x), int(facet.vertices[2].y)))
135130

136131
if len(pair) == 2:
137-
dwg.add(dwg.line(pair[0], pair[1], stroke=rgb(50,50,50, '%')))
132+
dwg.add(dwg.line(pair[0], pair[1], stroke=rgb(0,0,0, '%')))
138133

139134
dwg.save()
140135

0 commit comments

Comments
 (0)