meshlabxml/create.py
def cube_open_hires(script, size=1.0, x_segments=1, y_segments=1, z_segments=1,
                    center=False, color=None):
    """ Creates a square open tube, e.g. a box with no top or bottom.

    Useful if you want to wrap it around and join the open ends together, forming a torus.
    """
    """# Convert size to list if it isn't already
    if not isinstance(size, list):
        size = list(size)
    # If a single value was supplied use it for all 3 axes
    if len(size) == 1:
        size = [size[0], size[0], size[0]]"""
    size = util.make_list(size, 3)

    # Make big grid and bend
    grid(script, [2*(x_segments + y_segments), z_segments],
         x_segments=2*(x_segments + y_segments),
         y_segments=z_segments)
    transform.rotate(script, 'x', 90)
    # Bend 3 times into a rectangular tube
    if script.ml_version == '1.3.4BETA': # muparser version: 1.3.2
        transform.vert_function(script,
            x_func='if(x>{x_size}, {x_size}, x)'.format(x_size=x_segments),
            y_func='if(x>{x_size}, (x-{x_size}), y)'.format(x_size=x_segments),
            z_func='z')
        transform.vert_function(script,
            x_func='if(y>{y_size}, ({y_size}-y+{x_size}), x)'.format(x_size=x_segments, y_size=y_segments),
            y_func='if(y>{y_size}, {y_size}, y)'.format(y_size=y_segments),
            z_func='z')
        transform.vert_function(script,
            x_func='if(x<0, 0, x)',
            y_func='if(x<0, ({y_size}+x), y)'.format(y_size=y_segments),
            z_func='z')
    else: # muparser version: 2.2.5
        transform.vert_function(script,
            x_func='(x>{x_size} ? {x_size} : x)'.format(x_size=x_segments),
            y_func='(x>{x_size} ? (x-{x_size}) : y)'.format(x_size=x_segments),
            z_func='z')
        transform.vert_function(script,
            x_func='(y>{y_size} ? ({y_size}-y+{x_size}) : x)'.format(x_size=x_segments, y_size=y_segments),
            y_func='(y>{y_size} ? {y_size} : y)'.format(y_size=y_segments),
            z_func='z')
        transform.vert_function(script,
            x_func='(x<0 ? 0 : x)',
            y_func='(x<0 ? ({y_size}+x) : y)'.format(y_size=y_segments),
            z_func='z')
    clean.merge_vert(script, threshold=0.00002)
    transform.scale(script, [size[0]/x_segments, size[1]/y_segments, size[2]/z_segments])
    if center:
        transform.translate(script, [-size[0] / 2, -size[1] / 2, -size[2] / 2])
    if color is not None:
        vert_color.function(script, color=color)
    return None
def cube_open_hires(script, size=1.0, x_segments=1, y_segments=1, z_segments=1,
                    center=False, color=None):
    """ Creates a square open tube, e.g. a box with no top or bottom.

    Useful if you want to wrap it around and join the open ends together, forming a torus.
    """
    """# Convert size to list if it isn't already
    if not isinstance(size, list):
        size = list(size)
    # If a single value was supplied use it for all 3 axes
    if len(size) == 1:
        size = [size[0], size[0], size[0]]"""
    size = util.make_list(size, 3)

    # Make big grid and bend
    grid(script, [2*(x_segments + y_segments), z_segments],
         x_segments=2*(x_segments + y_segments),
         y_segments=z_segments)
    transform.rotate(script, 'x', 90)
    # Bend 3 times into a rectangular tube
    if script.ml_version == '1.3.4BETA': # muparser version: 1.3.2
        transform.vert_function(script,
            x_func='if(x>{x_size}, {x_size}, x)'.format(x_size=x_segments),
            y_func='if(x>{x_size}, (x-{x_size}), y)'.format(x_size=x_segments),
            z_func='z')
        transform.vert_function(script,
            x_func='if(y>{y_size}, ({y_size}-y+{x_size}), x)'.format(x_size=x_segments, y_size=y_segments),
            y_func='if(y>{y_size}, {y_size}, y)'.format(y_size=y_segments),
            z_func='z')
        transform.vert_function(script,
            x_func='if(x<0, 0, x)',
            y_func='if(x<0, ({y_size}+x), y)'.format(y_size=y_segments),
            z_func='z')
    else: # muparser version: 2.2.5
        transform.vert_function(script,
            x_func='(x>{x_size} ? {x_size} : x)'.format(x_size=x_segments),
            y_func='(x>{x_size} ? (x-{x_size}) : y)'.format(x_size=x_segments),
            z_func='z')
        transform.vert_function(script,
            x_func='(y>{y_size} ? ({y_size}-y+{x_size}) : x)'.format(x_size=x_segments, y_size=y_segments),
            y_func='(y>{y_size} ? {y_size} : y)'.format(y_size=y_segments),
            z_func='z')
        transform.vert_function(script,
            x_func='(x<0 ? 0 : x)',
            y_func='(x<0 ? ({y_size}+x) : y)'.format(y_size=y_segments),
            z_func='z')
    clean.merge_vert(script, threshold=0.00002)
    transform.scale(script, [size[0]/x_segments, size[1]/y_segments, size[2]/z_segments])
    if center:
        transform.translate(script, [-size[0] / 2, -size[1] / 2, -size[2] / 2])
    if color is not None:
        vert_color.function(script, color=color)
    return None
def cube_open_hires ( script , size = 1.0 , x_segments = 1 , y_segments = 1 , z_segments = 1 , center = False , color = None ) : """# Convert size to list if it isn't already
    if not isinstance(size, list):
        size = list(size)
    # If a single value was supplied use it for all 3 axes
    if len(size) == 1:
        size = [size[0], size[0], size[0]]""" size = util . make_list ( size , 3 ) # Make big grid and bend grid ( script , [ 2 * ( x_segments + y_segments ) , z_segments ] , x_segments = 2 * ( x_segments + y_segments ) , y_segments = z_segments ) transform . rotate ( script , 'x' , 90 ) # Bend 3 times into a rectangular tube if script . ml_version == '1.3.4BETA' : # muparser version: 1.3.2 transform . vert_function ( script , x_func = 'if(x>{x_size}, {x_size}, x)' . format ( x_size = x_segments ) , y_func = 'if(x>{x_size}, (x-{x_size}), y)' . format ( x_size = x_segments ) , z_func = 'z' ) transform . vert_function ( script , x_func = 'if(y>{y_size}, ({y_size}-y+{x_size}), x)' . format ( x_size = x_segments , y_size = y_segments ) , y_func = 'if(y>{y_size}, {y_size}, y)' . format ( y_size = y_segments ) , z_func = 'z' ) transform . vert_function ( script , x_func = 'if(x<0, 0, x)' , y_func = 'if(x<0, ({y_size}+x), y)' . format ( y_size = y_segments ) , z_func = 'z' ) else : # muparser version: 2.2.5 transform . vert_function ( script , x_func = '(x>{x_size} ? {x_size} : x)' . format ( x_size = x_segments ) , y_func = '(x>{x_size} ? (x-{x_size}) : y)' . format ( x_size = x_segments ) , z_func = 'z' ) transform . vert_function ( script , x_func = '(y>{y_size} ? ({y_size}-y+{x_size}) : x)' . format ( x_size = x_segments , y_size = y_segments ) , y_func = '(y>{y_size} ? {y_size} : y)' . format ( y_size = y_segments ) , z_func = 'z' ) transform . vert_function ( script , x_func = '(x<0 ? 0 : x)' , y_func = '(x<0 ? ({y_size}+x) : y)' . format ( y_size = y_segments ) , z_func = 'z' ) clean . merge_vert ( script , threshold = 0.00002 ) transform . scale ( script , [ size [ 0 ] / x_segments , size [ 1 ] / y_segments , size [ 2 ] / z_segments ] ) if center : transform . translate ( script , [ - size [ 0 ] / 2 , - size [ 1 ] / 2 , - size [ 2 ] / 2 ] ) if color is not None : vert_color . function ( script , color = color ) return None
Creates a square open tube, e.g. a box with no top or bottom.

    Useful if you want to wrap it around and join the open ends together, forming a torus.
Creates a square open tube e . g . a box with no top or bottom .