def _export_fired(self): """ export domains to stl todo: create an export window, to override default bound curves """ partitions = self.datamodel.partition() filename = r'C:\Users\Eelco\Dropbox\Git\Escheresque\data\part{0}.stl' if True: from mayavi import mlab from escheresque import stl, computational_geometry, brushes ## if False: ## x,y,z = curve_p.T ## # Create the points ## src = mlab.pipeline.scalar_scatter(x, y, z) ## # Connect them ## src.mlab_source.dataset.lines = curve_idx ## # The stripper filter cleans up connected lines ## lines = mlab.pipeline.stripper(src) ## # Finally, display the set of lines ## mlab.pipeline.surface(lines, colormap='Accent', line_width=10) for i,(p,t) in enumerate(partitions): p = p * self.datamodel.sample(p)[:,None] # p,t = computational_geometry.extrude(p*1, p*0.95, t) p,t = computational_geometry.swept_extrude(p, t, 0.1) stl.save_STL(filename.format(i), p[t]) q = p.mean(axis=0) x,y,z= p.T + q[:,None]/4 mlab.triangular_mesh(x,y,z, t) mlab.triangular_mesh(x,y,z, t, color = (0,0,0), representation='wireframe')
def _export_fired(self): """ export domains to stl create an export window; override default bounds, export functionality itself is better placed in datamodel, no? """ partitions = self.datamodel.partition() filename = r'C:\Users\Eelco\Dropbox\Escheresque\examples\part{0}.stl' if True: from mayavi import mlab from escheresque import stl from escheresque import computational_geometry if False: x,y,z = curve_p.T # Create the points src = mlab.pipeline.scalar_scatter(x, y, z) # Connect them src.mlab_source.dataset.lines = curve_idx # The stripper filter cleans up connected lines lines = mlab.pipeline.stripper(src) # Finally, display the set of lines mlab.pipeline.surface(lines, colormap='Accent', line_width=10) for i,(p,t) in enumerate(partitions): p,t = computational_geometry.extrude(p, t, 1, 0.95) q = p.mean(axis=0) x,y,z= p.T + q[:,None]/4 mlab.triangular_mesh(x,y,z, t) mlab.triangular_mesh(x,y,z, t, color = (0,0,0), representation='wireframe') stl.save_STL(filename.format(i), p[t]) mlab.show()
if __name__=='__main__': if True: # load .sch file and export parts to stl from escheresque.datamodel import DataModel from escheresque import stl, brushes import os path = r'..\data' filename = 'turtles.sch' datamodel = DataModel.load(os.path.join(path, filename)) # datamodel.generate(5) partitions = datamodel.partition() filename = r'..\data\part{0}.stl' for i, mesh in enumerate(partitions): mesh.vertices *= datamodel.sample(mesh.vertices)[:, None] thickness = 0.03 mesh = mesh.swept_extrude(thickness) assert mesh.is_orientated() stl.save_STL(filename.format(i), mesh) mesh.plot() quit()