meshlabxml/transfer.py
def vert_attr_2_meshes(script, source_mesh=0, target_mesh=1,
                             geometry=False, normal=False, color=True,
                             quality=False, selection=False,
                             quality_distance=False, max_distance=0.5):
    """Vertex Attribute Transfer (between 2 meshes)

    Transfer the chosen per-vertex attributes from one mesh to another. Useful to transfer attributes to different representations of the same object. For each vertex of the target mesh the closest point (not vertex!) on the source mesh is computed, and the requested interpolated attributes from that source point are copied into the target vertex.

    The algorithm assumes that the two meshes are reasonably similar and aligned.

    UpperBound: absolute value (not percentage)

    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 vertexes will receive the data from the source
        geometry (bool): If enabled, the position of each vertex of the target mesh will be snapped onto the corresponding closest point on the source mesh
        normal (bool): If enabled, the normal of each vertex of the target mesh will get the (interpolated) normal of the corresponding closest point on the source mesh
        color (bool): If enabled, the color of each vertex of the target mesh will become the color of the corresponding closest point on the source mesh
        quality (bool): If enabled, the quality of each vertex of the target mesh will become the quality of the corresponding closest point on the source mesh
        selection (bool): If enabled, each vertex of the target mesh will be selected if the corresponding closest point on the source mesh falls in a selected face
        quality_distance (bool): If enabled, we store the distance of the transferred value as in the vertex quality
        max_distance (float): Sample points for which we do not find anything within this distance are rejected and not considered for recovering attributes

    """
    filter_xml = ''.join([
        '  <filter name="Vertex Attribute Transfer">\n',
        '    <Param name="SourceMesh" ',
        'value="{:d}" '.format(source_mesh),
        'description="Source Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="TargetMesh" ',
        'value="{:d}" '.format(target_mesh),
        'description="Target Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="GeomTransfer" ',
        'value="{}" '.format(str(geometry).lower()),
        'description="Transfer Geometry" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="NormalTransfer" ',
        'value="{}" '.format(str(normal).lower()),
        'description="Transfer Normal" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="ColorTransfer" ',
        'value="{}" '.format(str(color).lower()),
        'description="Transfer Color" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="QualityTransfer" ',
        'value="{}" '.format(str(quality).lower()),
        'description="Transfer quality" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="SelectionTransfer" ',
        'value="{}" '.format(str(selection).lower()),
        'description="Transfer Selection" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="QualityDistance" ',
        'value="{}" '.format(str(quality_distance).lower()),
        'description="Store dist. as quality" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="UpperBound" ',
        'value="{}" '.format(max_distance),
        'description="Max Dist Search" ',
        'min="0" ',
        'max="100" ',
        'type="RichAbsPerc" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    return None
def vert_attr_2_meshes(script, source_mesh=0, target_mesh=1,
                             geometry=False, normal=False, color=True,
                             quality=False, selection=False,
                             quality_distance=False, max_distance=0.5):
    """Vertex Attribute Transfer (between 2 meshes)

    Transfer the chosen per-vertex attributes from one mesh to another. Useful to transfer attributes to different representations of the same object. For each vertex of the target mesh the closest point (not vertex!) on the source mesh is computed, and the requested interpolated attributes from that source point are copied into the target vertex.

    The algorithm assumes that the two meshes are reasonably similar and aligned.

    UpperBound: absolute value (not percentage)

    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 vertexes will receive the data from the source
        geometry (bool): If enabled, the position of each vertex of the target mesh will be snapped onto the corresponding closest point on the source mesh
        normal (bool): If enabled, the normal of each vertex of the target mesh will get the (interpolated) normal of the corresponding closest point on the source mesh
        color (bool): If enabled, the color of each vertex of the target mesh will become the color of the corresponding closest point on the source mesh
        quality (bool): If enabled, the quality of each vertex of the target mesh will become the quality of the corresponding closest point on the source mesh
        selection (bool): If enabled, each vertex of the target mesh will be selected if the corresponding closest point on the source mesh falls in a selected face
        quality_distance (bool): If enabled, we store the distance of the transferred value as in the vertex quality
        max_distance (float): Sample points for which we do not find anything within this distance are rejected and not considered for recovering attributes

    """
    filter_xml = ''.join([
        '  <filter name="Vertex Attribute Transfer">\n',
        '    <Param name="SourceMesh" ',
        'value="{:d}" '.format(source_mesh),
        'description="Source Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="TargetMesh" ',
        'value="{:d}" '.format(target_mesh),
        'description="Target Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="GeomTransfer" ',
        'value="{}" '.format(str(geometry).lower()),
        'description="Transfer Geometry" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="NormalTransfer" ',
        'value="{}" '.format(str(normal).lower()),
        'description="Transfer Normal" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="ColorTransfer" ',
        'value="{}" '.format(str(color).lower()),
        'description="Transfer Color" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="QualityTransfer" ',
        'value="{}" '.format(str(quality).lower()),
        'description="Transfer quality" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="SelectionTransfer" ',
        'value="{}" '.format(str(selection).lower()),
        'description="Transfer Selection" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="QualityDistance" ',
        'value="{}" '.format(str(quality_distance).lower()),
        'description="Store dist. as quality" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="UpperBound" ',
        'value="{}" '.format(max_distance),
        'description="Max Dist Search" ',
        'min="0" ',
        'max="100" ',
        'type="RichAbsPerc" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    return None
def vert_attr_2_meshes ( script , source_mesh = 0 , target_mesh = 1 , geometry = False , normal = False , color = True , quality = False , selection = False , quality_distance = False , max_distance = 0.5 ) : filter_xml = '' . join ( [ '  <filter name="Vertex Attribute Transfer">\n' , '    <Param name="SourceMesh" ' , 'value="{:d}" ' . format ( source_mesh ) , 'description="Source Mesh" ' , 'type="RichMesh" ' , '/>\n' , '    <Param name="TargetMesh" ' , 'value="{:d}" ' . format ( target_mesh ) , 'description="Target Mesh" ' , 'type="RichMesh" ' , '/>\n' , '    <Param name="GeomTransfer" ' , 'value="{}" ' . format ( str ( geometry ) . lower ( ) ) , 'description="Transfer Geometry" ' , 'type="RichBool" ' , '/>\n' , '    <Param name="NormalTransfer" ' , 'value="{}" ' . format ( str ( normal ) . lower ( ) ) , 'description="Transfer Normal" ' , 'type="RichBool" ' , '/>\n' , '    <Param name="ColorTransfer" ' , 'value="{}" ' . format ( str ( color ) . lower ( ) ) , 'description="Transfer Color" ' , 'type="RichBool" ' , '/>\n' , '    <Param name="QualityTransfer" ' , 'value="{}" ' . format ( str ( quality ) . lower ( ) ) , 'description="Transfer quality" ' , 'type="RichBool" ' , '/>\n' , '    <Param name="SelectionTransfer" ' , 'value="{}" ' . format ( str ( selection ) . lower ( ) ) , 'description="Transfer Selection" ' , 'type="RichBool" ' , '/>\n' , '    <Param name="QualityDistance" ' , 'value="{}" ' . format ( str ( quality_distance ) . lower ( ) ) , 'description="Store dist. as quality" ' , 'type="RichBool" ' , '/>\n' , '    <Param name="UpperBound" ' , 'value="{}" ' . format ( max_distance ) , 'description="Max Dist Search" ' , 'min="0" ' , 'max="100" ' , 'type="RichAbsPerc" ' , '/>\n' , '  </filter>\n' ] ) util . write_filter ( script , filter_xml ) return None
Vertex Attribute Transfer (between 2 meshes)

    Transfer the chosen per-vertex attributes from one mesh to another. Useful to transfer attributes to different representations of the same object. For each vertex of the target mesh the closest point (not vertex!) on the source mesh is computed, and the requested interpolated attributes from that source point are copied into the target vertex.

    The algorithm assumes that the two meshes are reasonably similar and aligned.

    UpperBound: absolute value (not percentage)

    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 vertexes will receive the data from the source
        geometry (bool): If enabled, the position of each vertex of the target mesh will be snapped onto the corresponding closest point on the source mesh
        normal (bool): If enabled, the normal of each vertex of the target mesh will get the (interpolated) normal of the corresponding closest point on the source mesh
        color (bool): If enabled, the color of each vertex of the target mesh will become the color of the corresponding closest point on the source mesh
        quality (bool): If enabled, the quality of each vertex of the target mesh will become the quality of the corresponding closest point on the source mesh
        selection (bool): If enabled, each vertex of the target mesh will be selected if the corresponding closest point on the source mesh falls in a selected face
        quality_distance (bool): If enabled, we store the distance of the transferred value as in the vertex quality
        max_distance (float): Sample points for which we do not find anything within this distance are rejected and not considered for recovering attributes
Vertex Attribute Transfer ( between 2 meshes )