meshlabxml/layers.py
def split_parts(script, part_num=None, layer_num=None):
    """ Split current layer into many layers, one for each part (connected
        component)

    Mesh is split so that the largest part is the lowest named layer "CC 0"
    and the smallest part is the highest numbered "CC" layer.

    Args:
        script: the mlx.FilterScript object or script filename to write
            the filter to.
        part_num (int): the number of parts in the model. This is needed in
            order to properly create and manage the layer stack. Can be found
            with mlx.compute.measure_topology.
        layer_num (int): the number of the layer to split. Default is the
            current layer. Not supported on the file base API.

    Layer stack:
        Creates a new layer for each part named "CC 0", "CC 1", etc.
        Changes current layer to the last new layer

    MeshLab versions:
        2016.12
        1.3.4BETA

    Bugs:
        UV textures: not currently preserved, however will be in a future
            release. https://github.com/cnr-isti-vclab/meshlab/issues/127
    """
    filter_xml = '  <filter name="Split in Connected Components"/>\n'
    if isinstance(script, mlx.FilterScript):
        if (layer_num is not None) and (layer_num != script.current_layer()):
            change(script, layer_num)
        util.write_filter(script, filter_xml)
        if part_num is not None:
            for i in range(part_num):
                script.add_layer('CC {}'.format(i), True)
        else:
            script.add_layer('CC 0', True)
            print('Warning: the number of parts was not provided and cannot',
                  'be determined automatically. The layer stack is likely',
                  'incorrect!')
    else:
        util.write_filter(script, filter_xml)
    return None
def split_parts(script, part_num=None, layer_num=None):
    """ Split current layer into many layers, one for each part (connected
        component)

    Mesh is split so that the largest part is the lowest named layer "CC 0"
    and the smallest part is the highest numbered "CC" layer.

    Args:
        script: the mlx.FilterScript object or script filename to write
            the filter to.
        part_num (int): the number of parts in the model. This is needed in
            order to properly create and manage the layer stack. Can be found
            with mlx.compute.measure_topology.
        layer_num (int): the number of the layer to split. Default is the
            current layer. Not supported on the file base API.

    Layer stack:
        Creates a new layer for each part named "CC 0", "CC 1", etc.
        Changes current layer to the last new layer

    MeshLab versions:
        2016.12
        1.3.4BETA

    Bugs:
        UV textures: not currently preserved, however will be in a future
            release. https://github.com/cnr-isti-vclab/meshlab/issues/127
    """
    filter_xml = '  <filter name="Split in Connected Components"/>\n'
    if isinstance(script, mlx.FilterScript):
        if (layer_num is not None) and (layer_num != script.current_layer()):
            change(script, layer_num)
        util.write_filter(script, filter_xml)
        if part_num is not None:
            for i in range(part_num):
                script.add_layer('CC {}'.format(i), True)
        else:
            script.add_layer('CC 0', True)
            print('Warning: the number of parts was not provided and cannot',
                  'be determined automatically. The layer stack is likely',
                  'incorrect!')
    else:
        util.write_filter(script, filter_xml)
    return None
Split current layer into many layers, one for each part (connected
        component)

    Mesh is split so that the largest part is the lowest named layer "CC 0"
    and the smallest part is the highest numbered "CC" layer.

    Args:
        script: the mlx.FilterScript object or script filename to write
            the filter to.
        part_num (int): the number of parts in the model. This is needed in
            order to properly create and manage the layer stack. Can be found
            with mlx.compute.measure_topology.
        layer_num (int): the number of the layer to split. Default is the
            current layer. Not supported on the file base API.

    Layer stack:
        Creates a new layer for each part named "CC 0", "CC 1", etc.
        Changes current layer to the last new layer

    MeshLab versions:
        2016.12
        1.3.4BETA

    Bugs:
        UV textures: not currently preserved, however will be in a future
            release. https://github.com/cnr-isti-vclab/meshlab/issues/127