meshlabxml/transfer.py
def vert_attr2tex_2_meshes(script, source_mesh=0, target_mesh=1, attribute=0,
                           max_distance=0.5, tex_name='TEMP3D_texture.png',
                           tex_width=1024, tex_height=1024,
                           overwrite_tex=True, assign_tex=False,
                           fill_tex=True):
    """Transfer Vertex Attributes to Texture (between 2 meshes)

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        source_mesh (int): The mesh that contains the source data that we want to transfer
        target_mesh (int): The mesh whose texture will be filled according to source mesh data
        attribute (int): Choose what attribute has to be transferred onto the target texture. You can choose between Per vertex attributes (color, normal, quality) or to transfer color information from source mesh texture
        max_distance (float): Sample points for which we do not find anything within this distance are rejected and not considered for recovering data
        tex_name (str): The texture file to be created
        tex_width (int): The texture width
        tex_height (int): The texture height
        overwrite_tex (bool): If target mesh has a texture will be overwritten (with provided texture dimension)
        assign_tex (bool): Assign the newly created texture to target mesh
        fill_tex (bool): If enabled the unmapped texture space is colored using a pull push filling algorithm, if false is set to black

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    if script.ml_version == '1.3.4BETA':
        filter_name = 'Transfer Vertex Attributes to Texture (between 2 meshes)'
    else:
        filter_name = 'Transfer: Vertex Attributes to Texture (1 or 2 meshes)'
    filter_xml = ''.join([
        '  <filter name="{}">\n'.format(filter_name),
        '    <Param name="sourceMesh" ',
        'value="%d" ' % source_mesh,
        'description="Source Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="targetMesh" ',
        'value="%d" ' % target_mesh,
        'description="Target Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="AttributeEnum" ',
        'value="%d" ' % attribute,
        'description="Color Data Source" ',
        'enum_val0="Vertex Color" ',
        'enum_val1="Vertex Normal" ',
        'enum_val2="Vertex Quality" ',
        'enum_val3="Texture Color" ',
        'enum_cardinality="4" ',
        'type="RichEnum" ',
        '/>\n',
        '    <Param name="upperBound" ',
        'value="%s" ' % max_distance,
        'description="Max Dist Search" ',
        'min="0" ',
        'max="100" ',
        'type="RichAbsPerc" ',
        '/>\n',
        '    <Param name="textName" ',
        'value="%s" ' % tex_name,
        'description="Texture file" ',
        'type="RichString" ',
        '/>\n',
        '    <Param name="textW" ',
        'value="%d" ' % tex_width,
        'description="Texture width (px)" ',
        'type="RichInt" ',
        '/>\n',
        '    <Param name="textH" ',
        'value="%d" ' % tex_height,
        'description="Texture height (px)" ',
        'type="RichInt" ',
        '/>\n',
        '    <Param name="overwrite" ',
        'value="%s" ' % str(overwrite_tex).lower(),
        'description="Overwrite Target Mesh Texture" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="assign" ',
        'value="%s" ' % str(assign_tex).lower(),
        'description="Assign Texture" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="pullpush" ',
        'value="%s" ' % str(fill_tex).lower(),
        'description="Fill texture" ',
        'type="RichBool" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    return None
def vert_attr2tex_2_meshes(script, source_mesh=0, target_mesh=1, attribute=0,
                           max_distance=0.5, tex_name='TEMP3D_texture.png',
                           tex_width=1024, tex_height=1024,
                           overwrite_tex=True, assign_tex=False,
                           fill_tex=True):
    """Transfer Vertex Attributes to Texture (between 2 meshes)

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        source_mesh (int): The mesh that contains the source data that we want to transfer
        target_mesh (int): The mesh whose texture will be filled according to source mesh data
        attribute (int): Choose what attribute has to be transferred onto the target texture. You can choose between Per vertex attributes (color, normal, quality) or to transfer color information from source mesh texture
        max_distance (float): Sample points for which we do not find anything within this distance are rejected and not considered for recovering data
        tex_name (str): The texture file to be created
        tex_width (int): The texture width
        tex_height (int): The texture height
        overwrite_tex (bool): If target mesh has a texture will be overwritten (with provided texture dimension)
        assign_tex (bool): Assign the newly created texture to target mesh
        fill_tex (bool): If enabled the unmapped texture space is colored using a pull push filling algorithm, if false is set to black

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    if script.ml_version == '1.3.4BETA':
        filter_name = 'Transfer Vertex Attributes to Texture (between 2 meshes)'
    else:
        filter_name = 'Transfer: Vertex Attributes to Texture (1 or 2 meshes)'
    filter_xml = ''.join([
        '  <filter name="{}">\n'.format(filter_name),
        '    <Param name="sourceMesh" ',
        'value="%d" ' % source_mesh,
        'description="Source Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="targetMesh" ',
        'value="%d" ' % target_mesh,
        'description="Target Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="AttributeEnum" ',
        'value="%d" ' % attribute,
        'description="Color Data Source" ',
        'enum_val0="Vertex Color" ',
        'enum_val1="Vertex Normal" ',
        'enum_val2="Vertex Quality" ',
        'enum_val3="Texture Color" ',
        'enum_cardinality="4" ',
        'type="RichEnum" ',
        '/>\n',
        '    <Param name="upperBound" ',
        'value="%s" ' % max_distance,
        'description="Max Dist Search" ',
        'min="0" ',
        'max="100" ',
        'type="RichAbsPerc" ',
        '/>\n',
        '    <Param name="textName" ',
        'value="%s" ' % tex_name,
        'description="Texture file" ',
        'type="RichString" ',
        '/>\n',
        '    <Param name="textW" ',
        'value="%d" ' % tex_width,
        'description="Texture width (px)" ',
        'type="RichInt" ',
        '/>\n',
        '    <Param name="textH" ',
        'value="%d" ' % tex_height,
        'description="Texture height (px)" ',
        'type="RichInt" ',
        '/>\n',
        '    <Param name="overwrite" ',
        'value="%s" ' % str(overwrite_tex).lower(),
        'description="Overwrite Target Mesh Texture" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="assign" ',
        'value="%s" ' % str(assign_tex).lower(),
        'description="Assign Texture" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="pullpush" ',
        'value="%s" ' % str(fill_tex).lower(),
        'description="Fill texture" ',
        'type="RichBool" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    return None
Transfer Vertex Attributes to Texture (between 2 meshes)

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        source_mesh (int): The mesh that contains the source data that we want to transfer
        target_mesh (int): The mesh whose texture will be filled according to source mesh data
        attribute (int): Choose what attribute has to be transferred onto the target texture. You can choose between Per vertex attributes (color, normal, quality) or to transfer color information from source mesh texture
        max_distance (float): Sample points for which we do not find anything within this distance are rejected and not considered for recovering data
        tex_name (str): The texture file to be created
        tex_width (int): The texture width
        tex_height (int): The texture height
        overwrite_tex (bool): If target mesh has a texture will be overwritten (with provided texture dimension)
        assign_tex (bool): Assign the newly created texture to target mesh
        fill_tex (bool): If enabled the unmapped texture space is colored using a pull push filling algorithm, if false is set to black

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA