meshlabxml/transfer.py
def tex2vc_2_meshes(script, source_mesh=0, target_mesh=1, max_distance=0.5):
    """Transfer texture colors to vertex colors (between 2 meshes)

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        source_mesh (int): The mesh with associated texture that we want to sample from
        target_mesh (int): The mesh whose vertex color will be filled according to 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 color

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    if script.ml_version == '1.3.4BETA':
        filter_name = 'Texture to Vertex Color (between 2 meshes)'
    else:
        filter_name = 'Transfer: Texture to Vertex Color (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="upperBound" ',
        'value="%s" ' % max_distance,
        'description="Max Dist Search" ',
        'min="0" ',
        'max="100" ',
        'type="RichAbsPerc" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    return None
def tex2vc_2_meshes(script, source_mesh=0, target_mesh=1, max_distance=0.5):
    """Transfer texture colors to vertex colors (between 2 meshes)

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        source_mesh (int): The mesh with associated texture that we want to sample from
        target_mesh (int): The mesh whose vertex color will be filled according to 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 color

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    if script.ml_version == '1.3.4BETA':
        filter_name = 'Texture to Vertex Color (between 2 meshes)'
    else:
        filter_name = 'Transfer: Texture to Vertex Color (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="upperBound" ',
        'value="%s" ' % max_distance,
        'description="Max Dist Search" ',
        'min="0" ',
        'max="100" ',
        'type="RichAbsPerc" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    return None
Transfer texture colors to vertex colors (between 2 meshes)

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        source_mesh (int): The mesh with associated texture that we want to sample from
        target_mesh (int): The mesh whose vertex color will be filled according to 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 color

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA