예제 #1
0
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_()
예제 #2
0
    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_()