src/compas_vol/utilities/utils.py
def export_layer(distfield, resolution, level, filename='layerimage.png'):
    """
    Exports a slice through a distance field as an image.
    """

    import numpy as np
    from skimage import io
    # add support for marching squares > outline

    # x, y = np.ogrid[-10:10:resolution+0j, -10:10:resolution+0j]
    y, x = np.ogrid[-10:10:resolution*1j, -10:10:resolution*1j]
    d = distfield.get_distance_numpy(x, y, level)

    # linear gradient
    # d = d - d.min()
    # m = d / d.max()

    # binary image
    # m = (d < 0)*1.0

    # absolute
    # d = np.abs(d)
    # m = d / d.max()

    # with aliasing
    m = 1-(np.tanh(d)+1)/2

    io.imsave(filename, m)
    return d

    Exports a slice through a distance field as an image.
    
Exports a slice through a distance field as an image.
Exports a slice through a distance field as an image .
def export_layer(distfield, resolution, level, filename='layerimage.png'):
    import numpy as np
    from skimage import io
    y, x = np.ogrid[-10:10:resolution*1j, -10:10:resolution*1j]
    d = distfield.get_distance_numpy(x, y, level)
    m = 1-(np.tanh(d)+1)/2
    io.imsave(filename, m)
    return d
def export_layer ( distfield , resolution , level , filename = 'layerimage.png' ) : import numpy as np from skimage import io y , x = np . ogrid [ - 10 : 10 : resolution * 1j , - 10 : 10 : resolution * 1j ] d = distfield . get_distance_numpy ( x , y , level ) m = 1 - ( np . tanh ( d ) + 1 ) / 2 io . imsave ( filename , m ) return d
Exports a slice through a distance field as an image.
Exports a slice through a distance field as an image .
"""
    Exports a slice through a distance field as an image.
    """ # add support for marching squares > outline # x, y = np.ogrid[-10:10:resolution+0j, -10:10:resolution+0j] # linear gradient # d = d - d.min() # m = d / d.max() # binary image # m = (d < 0)*1.0 # absolute # d = np.abs(d) # m = d / d.max() # with aliasing
distfield
resolution
level
filename