예제 #1
0
파일: joint.py 프로젝트: cdbrauer/VoxelFuse
import numpy as np
import time

from voxelfuse.voxel_model import VoxelModel, Axes, Process
from voxelfuse.mesh import Mesh
from voxelfuse.materials import material_properties

if __name__ == '__main__':
    # User preferences
    modelName = 'joint-2.vox'
    # modelName = 'tail-holder-1r.vox'

    # Import model
    start = time.time()
    modelIn = VoxelModel.fromVoxFile(modelName)
    end = time.time()
    importTime = (end - start)

    start = time.time()

    # Rotate to best orientation for printing
    modelIn = modelIn.rotate90(axis=Axes.Y)

    # Initialize object to hold result
    modelResult = VoxelModel.copy(modelIn)

    # Initialize array for identifying library materials
    library_materials = np.identity(len(material_properties))
    library_materials[0, 0] = 0
    a = np.ones((len(material_properties), 1))
예제 #2
0
Copyright 2020 - Cole Brauer, Dan Aukes
"""

# Import Libraries
import numpy as np
from voxelfuse.voxel_model import VoxelModel
from voxelfuse.mesh import Mesh
from voxelfuse.primitives import cylinder

# Start Application
if __name__ == '__main__':
    dilate_radius = 2

    # Import element template
    T = VoxelModel.fromVoxFile('lattice_element_1m.vox')
    T = T.dilateBounded(dilate_radius)

    # Create target volume model
    M = cylinder(30, 60).translate((30, 30, 0))
    M = M.setCoords((0, 0, 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))):
예제 #3
0
        # Set materials
        end1 = end1.setMaterial(1)
        end2 = end2.setMaterial(1)
        center = center.setMaterial(2)

        # Combine components
        coupon = Linkage.copy(end1.union(center.union(end2)))
    else:  # use vox file
        coupon = Linkage.fromVoxFile(
            'coupon.vox')  # Should use materials 1 and 2 (red and green)

    # Apply effects to material interface
    if tabs:  # Add connecting tabs
        # Load tab template
        tab_template = VoxelModel.fromVoxFile('tab_' + tabDesign + '.vox')

        # Set tab locations
        xVals = [79, 46]
        yVals = [9, 9]
        rVals = [0, 2]

        # Generate tabs
        coupon = coupon.insertTabs(tab_template, xVals, yVals, rVals)

    if blur:  # Blur materials
        coupon = coupon.blur(blurRadius)
        coupon = coupon.scaleValues()

    # Add support features
    coupon_supported = VoxelModel.copy(coupon)
예제 #4
0
    # Import coupon components
    print('Importing Files')
    if stl:
        if highRes:
            end1 = VoxelModel.fromMeshFile('end1x10.stl', (0, 0, 0), 1)
            center = VoxelModel.fromMeshFile('centerx10.stl', (670, 30, 0), 2)
            end2 = VoxelModel.fromMeshFile('end2x10.stl', (980, 0, 0), 1)
        else:
            end1 = VoxelModel.fromMeshFile('end1.stl', (0, 0, 0), 1)
            center = VoxelModel.fromMeshFile('center.stl', (66, 4, 0), 2)
            end2 = VoxelModel.fromMeshFile('end2.stl', (98, 0, 0), 1)

        # Combine components
        coupon = end1 | center | end2
    else: # use vox file
        coupon = VoxelModel.fromVoxFile('coupon.vox') # Should use materials 1 and 2 (red and green)

    start = time.time()

    if blur: # Blur materials
        print('Blurring')
        coupon = coupon.blur(blurRadius)
        coupon = coupon.scaleValues()

    if mold: # Generate mold feature around material 2
        print('Generating Mold')

        # Find all voxels containing <50% material 2
        material_vector = np.zeros(len(material_properties) + 1)
        material_vector[0] = 1
        material_vector[3] = 0.5
        transition_1 = cuboid((blurRadius * res * 2, coupon.voxels.shape[1],
                               coupon.voxels.shape[2]),
                              (center.coords[0] - (blurRadius * res), 0, 0), 3)
        transition_2 = cuboid(
            (blurRadius * res * 2, coupon.voxels.shape[1],
             coupon.voxels.shape[2]),
            (center.coords[0] - (blurRadius * res) + newCenterLength, 0, 0), 3)
        transition_regions = transition_1 | transition_2
        transition_regions = transition_regions.getComponents()

        # Generate lattice elements
        latticeSize = None
        lattice_elements = None
        if latticeEnable:
            # Import Models
            lattice_model = VoxelModel.fromVoxFile("lattice_elements/" +
                                                   latticeElementFile + '.vox')
            latticeSize = lattice_model.voxels.shape[0]
            print('Lattice Element Imported')

            # Generate Dilated Lattice Elements
            lattice_elements = [VoxelModel.emptyLike(lattice_model)]
            for r in range(minRadius, maxRadius + 1):
                lattice_elements.append(lattice_model.dilate(r))
            lattice_elements.append(cuboid(lattice_model.voxels.shape))
            print('Lattice Elements Generated')

        elif gyroidEnable:
            # Import Models
            s = center.voxels.shape[2]

            if gyroidType == 2:
예제 #6
0
Used by the Mesh class to improve meshing speed.

----

Copyright 2019 - Cole Brauer, Dan Aukes
"""

from voxelfuse.voxel_model import VoxelModel

if __name__=='__main__':
    # User preferences
    modelName = 'cylinder-blue.vox'

    # Import model
    model1 = VoxelModel.fromVoxFile(modelName, (0, 0, 0))

    # Find exterior voxels
    interiorVoxels = model1.erode(radius=1, connectivity=1)
    exteriorVoxels = model1.difference(interiorVoxels)

    x_len = len(exteriorVoxels.voxels[:, 0, 0])
    y_len = len(exteriorVoxels.voxels[0, :, 0])
    z_len = len(exteriorVoxels.voxels[0, 0, :])

    # Create list of exterior voxel coordinates
    exterior_voxels = []
    for x in range(x_len):
        for y in range(y_len):
            for z in range(z_len):
                if exteriorVoxels.voxels[x, y, z] != 0:
import PyQt5.QtGui as qg
import sys
import time
from voxelfuse.voxel_model import VoxelModel
from voxelfuse.mesh import Mesh
from voxelfuse.plot import Plot

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

    min_radius = 3  # min radius that results in a printable structure
    max_radius = 6  # max radius that results in a viable lattice element

    # Import Models
    latticeModel = VoxelModel.fromVoxFile(
        'lattice_elements/lattice_element_1_30x30.vox')
    lattice_size = latticeModel.voxels.shape[0]

    start = time.time()

    # Process Model
    modelResult = VoxelModel.copy(latticeModel)
    modelResult1 = modelResult.dilateBounded(min_radius)
    modelResult2 = modelResult.dilateBounded(max_radius)

    end = time.time()
    m1Time = (end - start)
    print(m1Time)

    # Create Mesh
    mesh1 = Mesh.fromVoxelModel(modelResult1)
import PyQt5.QtGui as qg
import sys
import time
from voxelfuse.voxel_model import VoxelModel
from voxelfuse.mesh import Mesh
from voxelfuse.plot import Plot

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

    min_radius = 0  # min radius that results in a printable structure    (1,  7)
    max_radius = 2  # max radius that results in a viable lattice element (4, 22)

    # Import Models
    latticeModel = VoxelModel.fromVoxFile('lattice_element_4_15x15.vox')
    lattice_size = latticeModel.voxels.shape[0]

    start = time.time()

    # Process Model
    modelResult = VoxelModel.copy(latticeModel)
    modelResult1 = modelResult.dilateBounded(min_radius)
    modelResult2 = modelResult.dilateBounded(max_radius)

    # modelResult1 = modelResult1 | modelResult1.setCoords((lattice_size, 0, 0))
    # modelResult2 = modelResult2 | modelResult2.setCoords((lattice_size, 0, 0))

    end = time.time()
    m1Time = (end - start)
    print(m1Time)
예제 #9
0
import sys

from voxelfuse.mesh import Mesh
from voxelfuse.plot import Plot
from voxelfuse.voxel_model import VoxelModel

from dithering.thin import thin

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

    box_x = 25
    box_y = 10
    box_z = 10

    # Create base model
    result1 = VoxelModel.fromVoxFile('centerline-test.vox')
    print('Model Created')

    # Process Model
    result1 = thin(result1, 50)

    # Create mesh
    mesh1 = Mesh.fromVoxelModel(result1)

    # Create plot
    plot1 = Plot(mesh1)
    plot1.show()

    app1.processEvents()
    app1.exec_()