meshlabxml/mp_func.py
def vert_attr(script, name='radius', function='x^2 + y^2'):
    """ Add a new Per-Vertex scalar attribute to current mesh and fill it with
        the defined function.

    The specified name can be used in other filter functions.

    It's possible to use parenthesis, per-vertex variables and boolean operator:
        (, ), and, or, <, >, =
    It's possible to use the following per-vertex variables in the expression:

    Variables:
        x, y, z (coordinates)
        nx, ny, nz (normal)
        r, g, b, a (color)
        q (quality)
        rad
        vi (vertex index)
        ?vtu, vtv (texture coordinates)
        ?ti (texture index)
        ?vsel (is the vertex selected? 1 yes, 0 no)
        and all custom vertex attributes already defined by user.

    Args:
        script: the FilterScript object or script filename to write
            the filter] to.
        name (str): the name of new attribute. You can access attribute in
            other filters through this name.
        function (str): function to calculate custom attribute value for each
            vertex

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    filter_xml = ''.join([
        '  <filter name="Define New Per Vertex Attribute">\n',
        '    <Param name="name" ',
        'value="{}" '.format(name),
        'description="Name" ',
        'type="RichString" ',
        '/>\n',
        '    <Param name="expr" ',
        'value="{}" '.format(str(function).replace('&', '&amp;').replace('<', '&lt;')),
        'description="Function" ',
        'type="RichString" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    return None
def vert_attr(script, name='radius', function='x^2 + y^2'):
    filter_xml = ''.join([
        '  <filter name="Define New Per Vertex Attribute">\n',
        '    <Param name="name" ',
        'value="{}" '.format(name),
        'description="Name" ',
        'type="RichString" ',
        '/>\n',
        '    <Param name="expr" ',
        'value="{}" '.format(str(function).replace('&', '&amp;').replace('<', '&lt;')),
        'description="Function" ',
        'type="RichString" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    return None
def vert_attr ( script , name = 'radius' , function = 'x^2 + y^2' ) : filter_xml = '' . join ( [ '  <filter name="Define New Per Vertex Attribute">\n' , '    <Param name="name" ' , 'value="{}" ' . format ( name ) , 'description="Name" ' , 'type="RichString" ' , '/>\n' , '    <Param name="expr" ' , 'value="{}" ' . format ( str ( function ) . replace ( '&' , '&amp;' ) . replace ( '<' , '&lt;' ) ) , 'description="Function" ' , 'type="RichString" ' , '/>\n' , '  </filter>\n' ] ) util . write_filter ( script , filter_xml ) return None
Add a new Per-Vertex scalar attribute to current mesh and fill it with
        the defined function.

    The specified name can be used in other filter functions.

    It's possible to use parenthesis, per-vertex variables and boolean operator:
        (, ), and, or, <, >, =
    It's possible to use the following per-vertex variables in the expression:

    Variables:
        x, y, z (coordinates)
        nx, ny, nz (normal)
        r, g, b, a (color)
        q (quality)
        rad
        vi (vertex index)
        ?vtu, vtv (texture coordinates)
        ?ti (texture index)
        ?vsel (is the vertex selected? 1 yes, 0 no)
        and all custom vertex attributes already defined by user.

    Args:
        script: the FilterScript object or script filename to write
            the filter] to.
        name (str): the name of new attribute. You can access attribute in
            other filters through this name.
        function (str): function to calculate custom attribute value for each
            vertex

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
Add a new Per - Vertex scalar attribute to current mesh and fill it with the defined function .