コード例 #1
0
ファイル: mesh_join.py プロジェクト: wassimj/sverchok
    def process(self):
        if not self.inputs['Vertices'].is_linked:
            return

        vertices = self.inputs['Vertices'].sv_get(deepcopy=False)
        edges = []
        polygons = []

        poly_edges = self.inputs['PolyEdge'].sv_get(deepcopy=False, default=[])
        first_elements = [obj[0] for obj in poly_edges]
        if first_elements:
            if all([len(el) == 2 for el in first_elements]):
                edges = poly_edges
                self.outputs['PolyEdge'].label = "Edges"
            elif all([len(el) != 2 for el in first_elements]):
                polygons = poly_edges
                self.outputs['PolyEdge'].label = "Polygons"
            else:
                raise TypeError(
                    'PoyEdge socket should consist either all edges or all faces'
                )  # Sv architecture law

        is_py_input = isinstance(vertices[0], (list, tuple))
        meshes = (meshes_py if is_py_input else meshes_np)(vertices, edges,
                                                           polygons)
        meshes = join_meshes(meshes)
        out_vertices, out_edges, out_polygons = to_elements(meshes)

        self.outputs['Vertices'].sv_set(out_vertices)
        self.outputs['PolyEdge'].sv_set(out_edges or out_polygons)
コード例 #2
0
ファイル: mesh_join_mk2.py プロジェクト: wassimj/sverchok
def mesh_join(vertices, edges, polygons):
    is_py_input = isinstance(vertices[0], (list, tuple))
    meshes = (meshes_py if is_py_input else meshes_np)(vertices, edges,
                                                       polygons)
    meshes = join_meshes(meshes)
    out_vertices, out_edges, out_polygons = to_elements(meshes)

    return out_vertices, out_edges, out_polygons
コード例 #3
0
ファイル: apply.py プロジェクト: wassimj/sverchok
    def process(self):
        if not self.inputs['Vectors'].is_linked:
            return

        vertices = self.inputs['Vectors'].sv_get(deepcopy=False)
        matrices = self.inputs['Matrixes'].sv_get(deepcopy=False, default=[])

        is_py_input = isinstance(vertices[0], (list, tuple))
        meshes = (meshes_py if is_py_input or not self.output_numpy else
                  meshes_np)(vertices)
        object_number = max([len(vertices), len(matrices)]) if vertices else 0
        meshes = repeat_meshes(meshes, object_number)
        if matrices:
            is_flat = not isinstance(matrices[0], (list, tuple))
            meshes = (apply_matrix if is_flat else apply_matrices)(
                meshes, repeat_last(matrices))
        out_vertices, *_ = to_elements(meshes)

        self.outputs['Vectors'].sv_set(out_vertices)
コード例 #4
0
ファイル: apply_and_join.py プロジェクト: vktcl/sverchok
    def process(self):
        vertices = self.inputs['Vertices'].sv_get(default=[], deepcopy=False)
        edges = self.inputs['Edges'].sv_get(default=[], deepcopy=False)
        faces = self.inputs['Faces'].sv_get(default=[], deepcopy=False)
        matrices = self.inputs['Matrices'].sv_get(default=[], deepcopy=False)

        object_number = max([len(vertices), len(matrices)]) if vertices else 0
        meshes = (meshes_py if self.implementation == 'Python' else meshes_np)(
            vertices, edges, faces)
        meshes = repeat_meshes(meshes, object_number)

        if matrices:
            is_flat_list = not isinstance(matrices[0], (list, tuple))
            meshes = (apply_matrix if is_flat_list else apply_matrices)(
                meshes, repeat_last(matrices))

        if self.do_join:
            meshes = join_meshes(meshes)

        out_vertices, out_edges, out_polygons = to_elements(meshes)
        self.outputs['Vertices'].sv_set(out_vertices)
        self.outputs['Edges'].sv_set(out_edges)
        self.outputs['Faces'].sv_set(out_polygons)