coupon = coupon | coupon.web('laser', 1, 5).setMaterial(3) # Add mold to coupon model coupon = coupon | mold_model.setMaterial(3) end = time.time() processingTime = (end - start) print("Processing time = %s" % processingTime) # Create mesh data print('Meshing') mesh1 = Mesh.fromVoxelModel(coupon) # Create plot print('Plotting') plot1 = Plot(mesh1, grids=True) plot1.show() app1.processEvents() if export: print('Exporting') # Get non-cast components # Find all voxels containing <50% material 2 material_vector = np.zeros(len(material_properties) + 1) material_vector[0] = 1 material_vector[3] = 0.5 printed_components = coupon - coupon.setMaterialVector(material_vector) printed_components.materials = np.around(printed_components.materials, 0) printed_components = printed_components.scaleValues() printed_components = printed_components.setMaterial(1)
import PyQt5.QtGui as qg import sys from voxelfuse.voxel_model import VoxelModel from voxelfuse.mesh import Mesh from voxelfuse.plot import Plot from voxelfuse.primitives import * if __name__ == '__main__': app1 = qg.QApplication(sys.argv) model1 = cube(11, (0, 0, 0), 1) model2 = cuboid((11, 20, 6), (13, 0, 0), 2) model3 = sphere(5, (31, 5, 5), 3) model4 = cylinder(5, 15, (44, 5, 0), 4) model5 = cone(1, 5, 15, (57, 5, 0), 5) model6 = pyramid(0, 5, 15, (70, 5, 0), 6) model_result = model1 | model2 | model3 | model4 | model5 | model6 # Create mesh data mesh1 = Mesh.fromVoxelModel(model_result) mesh1.export('primitives.stl') # Create plot plot1 = Plot(mesh1) plot1.show() app1.processEvents() app1.exec_()
model.coords = (0, 0, 0) # Apply scale factor # model = model.scale(scaleFactor) # Apply rubber material # modelRubber = model.isolateMaterial(1) # modelRubber = modelRubber.setMaterial(5) # model = modelRubber | model # Cleanup operations if cleanup: model.materials = np.round(model.materials, 3) model = model.removeDuplicateMaterials() model.saveVF(file) # Create stl files if export: for m in range(1, len(model.materials)): mesh = Mesh.fromVoxelModel(model.isolateMaterial(m).fitWorkspace(), 5) mesh.export(file + '-' + str(m) + '.stl') # Display viewer window if display: mesh = Mesh.fromVoxelModel(model) # Create Plot plot1 = Plot(mesh, grids=True) plot1.show() app1.processEvents() app1.exec_()
# Create base model box1 = cuboid((box_x, box_y, box_z), (0, 0, 0), 1) box2 = cuboid((box_x, box_y, box_z), (box_x, 0, 0), 3) result1 = box1.union(box2) print('Model Created') # Process Model ditherResult = dither(result1, int(round(box_x/2)), use_full=False, y_error=1/3) # Scale result ditherResult = ditherResult.scale(5) # 15 # Isolate materials result1 = ditherResult.isolateMaterial(1) result2 = ditherResult.isolateMaterial(2) result1 = result1.closing(2, Axes.XY) # 7 result1 = thin(result1, 3) #100 # Save result result1.saveVF('thin-test') # Create mesh ditherMesh = Mesh.fromVoxelModel(result1) # Create plot plot1 = Plot(ditherMesh) plot1.show() app1.processEvents() app1.exec_()
# Isolate materials with blurring requested modelBlur = VoxelModel.emptyLike(modelIn) for i in blur: modelBlur = modelBlur + modelIn.isolateMaterial(i) # Blur compatible materials # modelBlur = modelBlur.dither(blurRadius) modelBlur = modelBlur.blur(blurRadius) # Add unmodified voxels to result modelResult = modelBlur.union(modelIn) # Clean up result modelResult = modelResult.scaleValues() # Create mesh data mesh1 = Mesh.fromVoxelModel(modelIn) mesh2 = Mesh.fromVoxelModel(modelResult) # Create plots plot1 = Plot(mesh1) plot1.show() app1.processEvents() #plot1.export('input.png') plot2 = Plot(mesh2) plot2.show() app1.processEvents() #plot2.export('output.png') app1.exec_()
print("Processing time = %s" % processingTime) if display: # Create mesh data print('Meshing') mesh1 = Mesh.fromVoxelModel( coupon_input.difference(transition_regions).setMaterial(3) | coupon, resolution=res) # Create plot print('Plotting') plot1 = Plot(mesh1, grids=True, drawEdges=True, positionOffset=(35, 2, 0), viewAngle=(50, 40, 200), resolution=(720, 720), name=filename) plot1.show() app1.processEvents() if save: try: os.mkdir(outputFolder) except OSError: print('Output folder already exists') else: print('Output folder successfully created') print('Saving')
t = T.voxels.shape[0] size = M.voxels.shape # Create empty model to hold result V = VoxelModel.empty(size) # Add tiled lattice elements for x in range(int(np.ceil(size[0]/t))): for y in range(int(np.ceil(size[1] / t))): for z in range(int(np.ceil(size[2]/t))): T = T.setCoords((M.coords[0]+(x*t), M.coords[1]+(y*t), M.coords[2]+(z*t))) V = V | T # Intersect lattice with target volume V = M & V # Create Mesh mesh1 = Mesh.fromVoxelModel(T) mesh2 = Mesh.fromVoxelModel(M) mesh3 = Mesh.fromVoxelModel(V) mesh1.export('T.stl') mesh2.export('M.stl') mesh3.export('V.stl') # Create Plot plot3 = Plot(mesh3) plot3.show() app1.processEvents() app1.exec_()