app1 = qg.QApplication(sys.argv)

    # Settings
    # scaleFactor = 1 # Scale the model to increase/decrease resolution
    trim = True # Remove end bumps
    cleanup = False # Remove duplicate materials and save file
    export = True # STL file for slicing
    display = False # Display output

    # Open File
    location = 'stl_files_v3_combined/output-'
    variations = ['A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K']

    for var in variations:
        file = location + var + '.vf'
        model = VoxelModel.openVF(file)

        # Remove end bumps
        if trim:
            modelCutTool1 = cuboid((model.voxels.shape[0], model.voxels.shape[1], 12), (0, 0, model.voxels.shape[2] - 12), 3)
            modelCutTool2 = cuboid((1, model.voxels.shape[1], model.voxels.shape[2]), (0, 0, 0), 3)
            modelCutTool3 = cuboid((1, model.voxels.shape[1], model.voxels.shape[2]), (model.voxels.shape[0] - 1, 0, 0), 3)
            model = model.difference(modelCutTool1 | modelCutTool2 | modelCutTool3)
            model = model.fitWorkspace()
            model.coords = (0, 0, 0)

        # Apply scale factor
        # model = model.scale(scaleFactor)

        # Apply rubber material
        # modelRubber = model.isolateMaterial(1)
예제 #2
0
from voxelfuse.mesh import Mesh
from voxelfuse.plot import Plot
from voxelfuse.primitives import *

# Start Application
if __name__=='__main__':
    app1 = qg.QApplication(sys.argv)

    res = 5 # voxels per mm
    clearance = 50
    defaultModelName = 'stl_files_v5_combined/output_B1_default'
    normalizedModelName = 'stl_files_v5_combined/output_B2_normalized'

    # Open Files
    outputFolder = 'stl_files_v5_combined/'
    dModel = VoxelModel.openVF(defaultModelName)
    nModel = VoxelModel.openVF(normalizedModelName)

    # Markers
    size = dModel.voxels.shape
    markerSize = int((size[2] * 0.7)/2) * 2
    marker1 = cylinder(int(markerSize/2), size[2], (0, 0, 0), resolution=res)
    marker2 = marker1 | cylinder(int(markerSize/2), size[2], (0, markerSize*2, 0), resolution=res)
    marker3 = marker2 | cylinder(int(markerSize/2), size[2], (0, markerSize*4, 0), resolution=res)

    # Init result model
    resultModel = VoxelModel.emptyLike(dModel)

    # Add vertical coupons
    resultModel = resultModel | dModel.setCoords((0, 0, 0))
    resultModel = resultModel | nModel.setCoords((350, 100 + clearance, 0))
    app1 = qg.QApplication(sys.argv)

    cleanup = False  # Remove duplicate materials

    # Open File
    couponsIDs = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K']
    #folder = 'stl_files_v3_combined/output-'
    folder = 'stl_files_v4.2_combined/output_'

    rigidMaterial = 2
    flexibleMaterial = 1
    rigidPercentages = np.zeros(len(couponsIDs))
    flexiblePercentages = np.zeros(len(couponsIDs))

    for pattern in range(len(couponsIDs)):
        model = VoxelModel.openVF(folder + couponsIDs[pattern])
        model.resolution = 5  # Manually set resolution if not set in file
        res = model.resolution

        # Cleanup operations
        if cleanup:
            model.materials = np.round(model.materials, 3)
            model = model.removeDuplicateMaterials()

        _, totalVolume = model.getVolume()
        _, rigidVolume = model.getVolume(material=rigidMaterial)
        _, flexibleVolume = model.getVolume(material=flexibleMaterial)

        rigidPercentages[pattern] = rigidVolume / totalVolume
        flexiblePercentages[pattern] = flexibleVolume / totalVolume
예제 #4
0
    display = False  # Display output
    cleanup = True  # Remove duplicate materials and save file
    export = True  # STL file for slicing

    # Open Files
    outputFolder = 'stl_files_fdm_v1/'
    outputFile = 'output_combined'
    files = [
        'output_A', 'output_D', 'output_E', 'output_F', 'output_G', 'output_H',
        'output_I', 'output_J', 'output_K'
    ]
    # files = ['output_J', 'output_K']

    model = empty(resolution=res)
    for i in range(len(files)):
        new_model = VoxelModel.openVF(outputFolder + files[i])
        new_model = new_model.setCoords((0, i * 110, 0))
        model = model | new_model

    # Cleanup operations
    if cleanup:
        model.materials = np.round(model.materials, 1)
        model = model.removeDuplicateMaterials()
        model.saveVF(outputFolder + outputFile)

    # Create stl files
    if export:
        for m in range(1, len(model.materials)):
            mesh = Mesh.fromVoxelModel(model.isolateMaterial(m),
                                       resolution=res)
            mesh.export(
"""

# Import Libraries
import PyQt5.QtGui as qg
import sys
from voxelfuse.voxel_model import VoxelModel
from voxelfuse.voxel_model import Dir
from voxelfuse.mesh import Mesh
from voxelfuse.plot import Plot

# Start Application
if __name__ == '__main__':
    app1 = qg.QApplication(sys.argv)

    export = False  # STL file for slicing

    # Open File
    file = 'thin-test'
    model = VoxelModel.openVF(file).dilate()  #.projection(Dir.BOTH)
    mesh = Mesh.fromVoxelModel(model)

    # Create Plot
    plot1 = Plot(mesh)
    plot1.show()
    app1.processEvents()

    # Create stl files
    if export:
        mesh.export(file + '.stl')

    app1.exec_()