示例#1
0
    def matter(cls, m: Matter) -> List[Matter]:
        """
        function to split a matter by mesh
        others in one and mesh
        :param m: matter to split
        :return: List[Matter]
        """
        c = find_mesh(m.values)
        assert c != -1

        arr_list, mesh_arr = split_by_mesh(m.values, m.background_color)

        # reduce
        main_values = m.background_color * np.ones(m.shape, dtype=np.int)
        for arr, xy0 in arr_list:
            x0, y0 = xy0
            main_values[x0:x0 + arr.shape[0], y0:y0 + arr.shape[1]] = arr

        # main
        matter_main = Matter(main_values,
                             background_color=m.background_color,
                             new=True)

        # mesh
        matter_mesh = Matter(mesh_arr,
                             background_color=m.background_color,
                             new=True)
        matter_mesh.is_mesh = True

        return [matter_main, matter_mesh]
示例#2
0
    def matter(cls, m: Matter) -> List[Matter]:
        """
        function to split a matter by mesh
        split others by mesh, and mesh
        :param m: matter to split
        :return: List[Matter]
        """
        assert find_mesh(m.values) != -1
        arr_list, mesh_arr = split_by_mesh(m.values, m.background_color)
        res_list = []

        # split
        for arr, xy0 in arr_list:
            x0, y0 = xy0
            new_matter = Matter(arr, x0, y0, m.background_color, new=True)
            res_list.append(new_matter)

        # mesh
        matter_mesh = Matter(mesh_arr,
                             background_color=m.background_color,
                             new=True)
        matter_mesh.is_mesh = True
        res_list.append(matter_mesh)

        return res_list