def __init__(self, name, mesh, paramNames, paramLists, global_minXYZ, height=None): self.name = name self.mesh = mesh self.paramNames = paramNames self.paramGen = zipVariables_gen(paramLists, repeat=True) self.currHeight = 0 self.outline = None self.localParams = None self.global_minXYZ = global_minXYZ if height is not None: try: section = _getSectionFromMesh(self.mesh, height + self.global_minXYZ[c.Z]) except Exception as e: raise Exception( 'Height for .STL slice did not intersect .STL\n' + str(e)) else: self.outline = outline_module.outlineFromMeshSection( section).translate(-self.global_minXYZ[c.X], -self.global_minXYZ[c.Y]) self.oneLevel = True else: self.oneLevel = False
def _getOutlineFromSTL(fname: str, height: float, change_units_from: str = 'mm') -> Outline: mesh = _getMesh(fname, change_units_from) section = _getSectionFromMesh(mesh, height) outline = outline_module.outlineFromMeshSection(section) outline._name = os.path.basename(fname) return outline
def fromSTL_oneLevel(fname: str, sliceHeight: float, change_units_from: str = 'mm') -> Outline: mesh = _getMesh(fname, change_units_from) _, _, minZ = mesh.bounding_box.bounds[0] section = _getSectionFromMesh(mesh, sliceHeight + minZ) outline = outline_module.outlineFromMeshSection(section) outline = outline.translate(-outline.minX, -outline.minY) outline._name = os.path.basename(fname) return outline
def setNextOutline(self): try: section = _getSectionFromMesh( self.mesh, self.currHeight + self.global_minXYZ[c.Z]) except Exception: # print('Exception. currHeight:', self.currHeight) self.outline = None else: self.outline = outline_module.outlineFromMeshSection( section).translate(-self.global_minXYZ[c.X], -self.global_minXYZ[c.Y])
def fromSTL_coro(): currHeight = minZ global_params = yield currHeight += global_params.layerHeight while True: try: section = mesh.section(plane_origin=[0, 0, currHeight], plane_normal=[0, 0, 1]) except Exception: return else: global_params = yield ( outline_module.outlineFromMeshSection(section).translate( -minX, -minY), ), (global_params, ) currHeight += global_params.layerHeight