Beispiel #1
0
    def update(self):
        if 'polygons' not in self.outputs:
            return

        if 'vertices' in self.inputs and self.inputs['vertices'].links and \
           'edges' in self.inputs and self.inputs['edges'].links:

            verts = dataCorrect(SvGetSocketAnyType(self, self.inputs['vertices']))
            edges = dataCorrect(SvGetSocketAnyType(self, self.inputs['edges']))
            sides = repeat_last(self.inputs['Sides'].sv_get()[0])
            verts_out = []
            edges_out = []
            polys_out = []

            for v, e, s in zip(verts, edges, sides):
                res = fill_holes(v, e, int(s))
                if not res:
                    return
                verts_out.append(res[0])
                edges_out.append(res[1])
                polys_out.append(res[2])

            if 'vertices' in self.outputs and self.outputs['vertices'].links:
                SvSetSocketAnyType(self, 'vertices', verts_out)

            if 'edges' in self.outputs and self.outputs['edges'].links:
                SvSetSocketAnyType(self, 'edges', edges_out)

            if 'polygons' in self.outputs and self.outputs['polygons'].links:
                SvSetSocketAnyType(self, 'polygons', polys_out)
Beispiel #2
0
    def update(self):
        global cache_viewer_baker
        # node id, used as ref
        n_id = node_id(self)
        if 'matrix' not in self.inputs:
            return

        cache_viewer_baker[n_id+'v'] = []
        cache_viewer_baker[n_id+'ep'] = []
        cache_viewer_baker[n_id+'m'] = []

        if not self.id_data.sv_show:
            callback_disable(n_id)
            return

        if self.activate and (self.inputs['vertices'].links or self.inputs['matrix'].links):
            callback_disable(n_id)

            if self.inputs['vertices'].links and \
                type(self.inputs['vertices'].links[0].from_socket) == VerticesSocket:

                propv = SvGetSocketAnyType(self, self.inputs['vertices'])
                cache_viewer_baker[n_id+'v'] = dataCorrect(propv)
            else:
                cache_viewer_baker[n_id+'v'] = []

            if self.inputs['edg_pol'].links and \
                type(self.inputs['edg_pol'].links[0].from_socket) == StringsSocket:
                prope = SvGetSocketAnyType(self, self.inputs['edg_pol'])
                cache_viewer_baker[n_id+'ep'] = dataCorrect(prope)
                #print (prope)
            else:
                cache_viewer_baker[n_id+'ep'] = []

            if self.inputs['matrix'].links and \
                type(self.inputs['matrix'].links[0].from_socket) == MatrixSocket:
                propm = SvGetSocketAnyType(self, self.inputs['matrix'])
                cache_viewer_baker[n_id+'m'] = dataCorrect(propm)
            else:
                cache_viewer_baker[n_id+'m'] = []

        else:
            callback_disable(n_id)

        if cache_viewer_baker[n_id+'v'] or cache_viewer_baker[n_id+'m']:
            callback_enable(n_id, cache_viewer_baker[n_id+'v'], cache_viewer_baker[n_id+'ep'], \
                cache_viewer_baker[n_id+'m'], self.Vertex_show, self.color_view.copy(), self.transparant, self.shading)

            self.use_custom_color = True
            self.color = (1, 0.3, 0)
        else:
            self.use_custom_color = True
            self.color = (0.1, 0.05, 0)
            #print ('отражения вершин ',len(cache_viewer_baker['v']), " рёбёры ", len(cache_viewer_baker['ep']), "матрицы",len(cache_viewer_baker['m']))
        if not self.inputs['vertices'].links and not self.inputs['matrix'].links:
            callback_disable(n_id)
Beispiel #3
0
    def update(self):
        global cache_viewer_baker
        # node id, used as ref
        n_id = node_id(self)
        if 'matrix' not in self.inputs:
            return

        cache_viewer_baker[n_id+'v'] = []
        cache_viewer_baker[n_id+'ep'] = []
        cache_viewer_baker[n_id+'m'] = []

        if not self.id_data.sv_show:
            callback_disable(n_id)
            return

        if self.activate and (self.inputs['vertices'].links or self.inputs['matrix'].links):
            callback_disable(n_id)

            if self.inputs['vertices'].links and \
                type(self.inputs['vertices'].links[0].from_socket) == VerticesSocket:

                propv = SvGetSocketAnyType(self, self.inputs['vertices'])
                cache_viewer_baker[n_id+'v'] = dataCorrect(propv)
            else:
                cache_viewer_baker[n_id+'v'] = []

            if self.inputs['edg_pol'].links and \
                type(self.inputs['edg_pol'].links[0].from_socket) == StringsSocket:
                prope = SvGetSocketAnyType(self, self.inputs['edg_pol'])
                cache_viewer_baker[n_id+'ep'] = dataCorrect(prope)
                #print (prope)
            else:
                cache_viewer_baker[n_id+'ep'] = []

            if self.inputs['matrix'].links and \
                type(self.inputs['matrix'].links[0].from_socket) == MatrixSocket:
                propm = SvGetSocketAnyType(self, self.inputs['matrix'])
                cache_viewer_baker[n_id+'m'] = dataCorrect(propm)
            else:
                cache_viewer_baker[n_id+'m'] = []

        else:
            callback_disable(n_id)

        if cache_viewer_baker[n_id+'v'] or cache_viewer_baker[n_id+'m']:
            callback_enable(n_id, cache_viewer_baker[n_id+'v'], cache_viewer_baker[n_id+'ep'], \
                cache_viewer_baker[n_id+'m'], self.Vertex_show, self.color_view.copy(), self.transparant, self.shading)

            self.use_custom_color = True
            self.color = (1, 0.3, 0)
        else:
            self.use_custom_color = True
            self.color = (0.1, 0.05, 0)
            #print ('отражения вершин ',len(cache_viewer_baker['v']), " рёбёры ", len(cache_viewer_baker['ep']), "матрицы",len(cache_viewer_baker['m']))
        if not self.inputs['vertices'].links and not self.inputs['matrix'].links:
            callback_disable(n_id)
Beispiel #4
0
 def execute(self, context):
     global cache_viewer_baker
     nid = node_id(bpy.data.node_groups[self.idtree].nodes[self.idname])
     if cache_viewer_baker[nid+'m'] and not cache_viewer_baker[nid+'v']:
         return {'CANCELLED'}
     vers = dataCorrect(cache_viewer_baker[nid+'v'])
     edg_pol = dataCorrect(cache_viewer_baker[nid+'ep'])
     if cache_viewer_baker[nid+'m']:
         matrixes = dataCorrect(cache_viewer_baker[nid+'m'])
     else:
         matrixes = []
         for i in range((len(vers))):
             matrixes.append(Matrix())
     self.makeobjects(vers, edg_pol, matrixes)
     return {'FINISHED'}
Beispiel #5
0
 def execute(self, context):
     global cache_viewer_baker
     nid = node_id(bpy.data.node_groups[self.idtree].nodes[self.idname])
     if cache_viewer_baker[nid+'m'] and not cache_viewer_baker[nid+'v']:
         return {'CANCELLED'}
     vers = dataCorrect(cache_viewer_baker[nid+'v'])
     edg_pol = dataCorrect(cache_viewer_baker[nid+'ep'])
     if cache_viewer_baker[nid+'m']:
         matrixes = dataCorrect(cache_viewer_baker[nid+'m'])
     else:
         matrixes = []
         for i in range((len(vers))):
             matrixes.append(Matrix())
     self.makeobjects(vers, edg_pol, matrixes)
     return {'FINISHED'}
Beispiel #6
0
    def update(self):
        # check if running during startup, cancel if True
        try:
            l = bpy.data.node_groups[self.id_data.name]
        except Exception as e:
            print("Bakery cannot run during startup", e)
            return

        if self.inputs['vertices'].links and self.inputs['edg_pol'].links and self.activate:
            if 'vertices' in self.inputs and self.inputs['vertices'].links and \
                    type(self.inputs['vertices'].links[0].from_socket) == VerticesSocket:
                propv = SvGetSocketAnyType(self, self.inputs['vertices'])
                vertices = dataCorrect(propv, nominal_dept=2)
            else:
                vertices = []

            if 'edg_pol' in self.inputs and self.inputs['edg_pol'].links and \
                    type(self.inputs['edg_pol'].links[0].from_socket) == StringsSocket:
                prope = SvGetSocketAnyType(self, self.inputs['edg_pol'])
                edges = dataCorrect(prope)
            else:
                edges = []

            if 'matrix' in self.inputs and self.inputs['matrix'].links and \
                    type(self.inputs['matrix'].links[0].from_socket) == MatrixSocket:
                propm = SvGetSocketAnyType(self, self.inputs['matrix'])
                matrices = dataCorrect(propm)
            else:
                matrices = []
                if vertices and edges:
                    for i in vertices:
                        matrices.append(Matrix())

            if vertices and edges:
                self.makeobjects(vertices, edges, matrices)
            self.use_custom_color = True
            self.color = (1, 0.3, 0)
        else:
            self.use_custom_color = True
            self.color = (0.1, 0.05, 0)

            for obj in bpy.context.scene.objects:
                nam = 'Sv_' + self.name
                if nam in obj.name:
                    bpy.context.scene.objects[obj.name].select = True
                    bpy.ops.object.delete(use_global=False)
            global sverchok_bakery_cache
            sverchok_bakery_cache[self.name] = []
Beispiel #7
0
    def get_input_or_default(self, name, this_val, fparams):
        ''' fill up the fparams list with found or default values '''
        socket = self.inputs[name]

        # this deals with incoming links only.
        if socket.links:
            if isinstance(this_val, list):
                try:
                    this_val = socket.sv_get()
                    this_val = dataCorrect(this_val)
                except:
                    pass
            elif isinstance(this_val, (int, float)):
                try:
                    k = str(socket.sv_get())
                    kfree = k[2:-2]
                    this_val = ast.literal_eval(kfree)
                    #this_val = socket.sv_get()[0][0]
                except:
                    pass

        # this catches movement on UI sliders.
        elif isinstance(this_val, (int, float)):
            # extra pussyfooting for the load sequence.
            t = socket.sv_get()
            if t and t[0] and t[0][0]:
                this_val = t[0][0]

        # either found input, or uses default.
        fparams.append(this_val)
Beispiel #8
0
    def update(self):
        if 'Vertices' not in self.outputs:
            return
        if not any((s.links for s in self.outputs)):
            return

        if self.inputs['Vertices'].links:
            verts = SvGetSocketAnyType(self, self.inputs['Vertices'])
            verts = dataCorrect(verts)
            t_ins = self.inputs['Interval'].sv_get()
            verts_out = []
            for v, t_in in zip(verts, repeat_last(t_ins)):
                pts = np.array(v).T
                tmp = np.apply_along_axis(np.linalg.norm, 0, pts[:, :-1]-pts[:, 1:])
                t = np.insert(tmp, 0, 0).cumsum()
                t = t/t[-1]
                t_corr = [min(1, max(t_c, 0)) for t_c in t_in]
                # this should also be numpy
                if self.mode == 'LIN':
                    out = [np.interp(t_corr, t, pts[i]) for i in range(3)]
                    verts_out.append(list(zip(*out)))
                else:  # SPL
                    spl = cubic_spline(v, t)
                    out = eval_spline(spl, t, t_corr)
                    verts_out.append(out)

            if 'Vertices' in self.outputs and self.outputs['Vertices'].links:
                SvSetSocketAnyType(self, 'Vertices', verts_out)
Beispiel #9
0
 def get_socket(x):
     r = None
     links = inputs[x].links
     if links:
         r = SvGetSocketAnyType(self, inputs[x])
         r = dataCorrect(r)
     return r
Beispiel #10
0
    def update(self):
        # inputs
        if 'Vectors' in self.outputs and len(
                self.outputs['Vectors'].links) > 0:
            if self.inputs['Vectors'].links and \
                    type(self.inputs['Vectors'].links[0].from_socket) == VerticesSocket \
                    and self.inputs['Matrixes'] and \
                    type(self.inputs['Matrixes'].links[0].from_socket) == MatrixSocket:

                vecs_ = SvGetSocketAnyType(self, self.inputs['Vectors'])

                vecs = Vector_generate(vecs_)
                #print (vecs)

                mats_ = dataCorrect(
                    SvGetSocketAnyType(self, self.inputs['Matrixes']))
                mats = Matrix_generate(mats_)
            else:
                vecs = [[]]
                mats = [Matrix()]

            # outputs

            vectors_ = self.vecscorrect(vecs, mats)
            vectors = Vector_degenerate(vectors_)
            SvSetSocketAnyType(self, 'Vectors', vectors)
Beispiel #11
0
    def get_input_or_default(self, name, this_val, fparams):
        ''' fill up the fparams list with found or default values '''
        socket = self.inputs[name]

        # this deals with incoming links only.
        if socket.links:
            if isinstance(this_val, list):
                try:
                    this_val = socket.sv_get()
                    this_val = dataCorrect(this_val)
                except:
                    pass
            elif isinstance(this_val, (int, float)):
                try:
                    k = str(socket.sv_get())
                    kfree = k[2:-2]
                    this_val = ast.literal_eval(kfree)
                    #this_val = socket.sv_get()[0][0]
                except:
                    pass

        # this catches movement on UI sliders.
        elif isinstance(this_val, (int, float)):
            # extra pussyfooting for the load sequence.
            t = socket.sv_get()
            if t and t[0] and t[0][0]:
                this_val = t[0][0]

        # either found input, or uses default.
        fparams.append(this_val)
Beispiel #12
0
 def get_socket(x):
     r = None
     links = inputs[x].links
     if links:
         r = SvGetSocketAnyType(self, inputs[x])
         r = dataCorrect(r)
     return r
Beispiel #13
0
    def update(self):
        if 'Vertices' not in self.outputs:
            return
        if not any((s.links for s in self.outputs)):
            return

        if self.inputs['Vertices'].links:
            verts = SvGetSocketAnyType(self, self.inputs['Vertices'])
            verts = dataCorrect(verts)
            t_ins = self.inputs['Interval'].sv_get()
            verts_out = []
            for v, t_in in zip(verts, repeat_last(t_ins)):
                pts = np.array(v).T
                tmp = np.apply_along_axis(np.linalg.norm, 0,
                                          pts[:, :-1] - pts[:, 1:])
                t = np.insert(tmp, 0, 0).cumsum()
                t = t / t[-1]
                t_corr = [min(1, max(t_c, 0)) for t_c in t_in]
                # this should also be numpy
                if self.mode == 'LIN':
                    out = [np.interp(t_corr, t, pts[i]) for i in range(3)]
                    verts_out.append(list(zip(*out)))
                else:  # SPL
                    spl = cubic_spline(v, t)
                    out = eval_spline(spl, t, t_corr)
                    verts_out.append(out)

            if 'Vertices' in self.outputs and self.outputs['Vertices'].links:
                SvSetSocketAnyType(self, 'Vertices', verts_out)
Beispiel #14
0
    def update(self):
        # inputs
        multi_socket(self, min=2, start=-1, breck=True)

        if 'X' in self.inputs and len(self.inputs['X'].links) > 0:
            # адаптивный сокет
            inputsocketname = 'X'
            outputsocketname = ['Result']
            changable_sockets(self, inputsocketname, outputsocketname)
            vecs = SvGetSocketAnyType(self, self.inputs['X'])
        else:
            vecs = [[0.0]]

        # outputs
        if 'Result' in self.outputs and len(self.outputs['Result'].links) > 0:
            list_mult = []
            if 'n[0]' in self.inputs and len(self.inputs['n[0]'].links) > 0:
                i = 0
                for socket in self.inputs:
                    if socket.links and i != 0:
                        list_mult.append(SvGetSocketAnyType(self, socket))
                    else:
                        i = 1
                #print(list_mult)
            code_formula = parser.expr(self.formula).compile()
            # finding nasty levels, make equal nastyness (canonical 0,1,2,3)
            levels = [levelsOflist(vecs)]
            for n in list_mult:
                levels.append(levelsOflist(n))
            maxlevel = max(max(levels), 3)
            diflevel = maxlevel - levels[0]

            if diflevel:
                vecs_ = dataSpoil([vecs], diflevel - 1)
                vecs = dataCorrect(vecs_, nominal_dept=2)
            for i, lev in enumerate(levels):
                if i == 0:
                    continue
                diflevel = maxlevel - lev
                if diflevel:
                    list_temp = dataSpoil([list_mult[i - 1]], diflevel - 1)
                    list_mult[i - 1] = dataCorrect(list_temp, nominal_dept=2)
            #print(list_mult)
            r = self.inte(vecs, code_formula, list_mult, 3)
            result = dataCorrect(r, nominal_dept=min((levels[0] - 1), 2))

            SvSetSocketAnyType(self, 'Result', result)
Beispiel #15
0
    def update(self):
        # inputs
        multi_socket(self, min=2, start=-1, breck=True)

        if 'X' in self.inputs and len(self.inputs['X'].links) > 0:
            # адаптивный сокет
            inputsocketname = 'X'
            outputsocketname = ['Result']
            changable_sockets(self, inputsocketname, outputsocketname)
            vecs = SvGetSocketAnyType(self, self.inputs['X'])
        else:
            vecs = [[0.0]]

        # outputs
        if 'Result' in self.outputs and len(self.outputs['Result'].links) > 0:
            list_mult = []
            if 'n[0]' in self.inputs and len(self.inputs['n[0]'].links) > 0:
                i = 0
                for socket in self.inputs:
                    if socket.links and i != 0:
                        list_mult.append(SvGetSocketAnyType(self, socket))
                    else:
                        i = 1
                #print(list_mult)
            code_formula = parser.expr(self.formula).compile()
            # finding nasty levels, make equal nastyness (canonical 0,1,2,3)
            levels = [levelsOflist(vecs)]
            for n in list_mult:
                levels.append(levelsOflist(n))
            maxlevel = max(max(levels), 3)
            diflevel = maxlevel - levels[0]

            if diflevel:
                vecs_ = dataSpoil([vecs], diflevel-1)
                vecs = dataCorrect(vecs_, nominal_dept=2)
            for i, lev in enumerate(levels):
                if i == 0:
                    continue
                diflevel = maxlevel-lev
                if diflevel:
                    list_temp = dataSpoil([list_mult[i-1]], diflevel-1)
                    list_mult[i-1] = dataCorrect(list_temp, nominal_dept=2)
            #print(list_mult)
            r = self.inte(vecs, code_formula, list_mult, 3)
            result = dataCorrect(r, nominal_dept=min((levels[0]-1), 2))

            SvSetSocketAnyType(self, 'Result', result)
Beispiel #16
0
 def get_corrected_data(self, socket_name, socket_type):
     inputs = self.inputs
     socket = inputs[socket_name].links[0].from_socket
     if isinstance(socket, socket_type):
         socket_in = SvGetSocketAnyType(self, inputs[socket_name])
         return dataCorrect(socket_in)
     else:
         return []
Beispiel #17
0
 def get_corrected_data(self, socket_name, socket_type):
     inputs = self.inputs
     socket = inputs[socket_name].links[0].from_socket
     if isinstance(socket, socket_type):
         socket_in = SvGetSocketAnyType(self, inputs[socket_name])
         return dataCorrect(socket_in)
     else:
         return []
Beispiel #18
0
 def update(self):
     if 'edgs' in self.outputs and len(self.outputs['edgs'].links) > 0:
         if 'pols' in self.inputs and len(self.inputs['pols'].links) > 0:
             X_ = SvGetSocketAnyType(self, self.inputs['pols'])
             X = dataCorrect(X_)
             #print('p2e-X',str(X))
             result = self.pols_edges(X)
             SvSetSocketAnyType(self, 'edgs', result)
Beispiel #19
0
    def process(self):
        n_id = node_id(self)

        global cache_viewer_baker
        vertex_ref = n_id + 'v'
        poledg_ref = n_id + 'ep'
        matrix_ref = n_id + 'm'
        cache_viewer_baker[vertex_ref] = []
        cache_viewer_baker[poledg_ref] = []
        cache_viewer_baker[matrix_ref] = []

        callback_disable(n_id)

        # every time you hit a dot, you pay a price, so alias and benefit
        inputs = self.inputs
        vertex_links = inputs['vertices'].links
        matrix_links = inputs['matrix'].links
        edgepol_links = inputs['edg_pol'].links

        if (vertex_links or matrix_links):

            if vertex_links:
                if isinstance(vertex_links[0].from_socket, VerticesSocket):
                    propv = inputs['vertices'].sv_get()
                    if propv:
                        cache_viewer_baker[vertex_ref] = dataCorrect(propv)

            if edgepol_links:
                if isinstance(edgepol_links[0].from_socket, StringsSocket):
                    prope = inputs['edg_pol'].sv_get()
                    if prope:
                        cache_viewer_baker[poledg_ref] = dataCorrect(prope)

            if matrix_links:
                if isinstance(matrix_links[0].from_socket, MatrixSocket):
                    propm = inputs['matrix'].sv_get()
                    if propm:
                        cache_viewer_baker[matrix_ref] = dataCorrect(propm)

        if cache_viewer_baker[vertex_ref] or cache_viewer_baker[matrix_ref]:
            config_options = self.get_options().copy()
            callback_enable(n_id, cache_viewer_baker, config_options)
            self.color = (1, 1, 1)
        else:
            self.color = (0.7, 0.7, 0.7)
Beispiel #20
0
    def process(self):
        n_id = node_id(self)

        global cache_viewer_baker
        vertex_ref = n_id + 'v'
        poledg_ref = n_id + 'ep'
        matrix_ref = n_id + 'm'
        cache_viewer_baker[vertex_ref] = []
        cache_viewer_baker[poledg_ref] = []
        cache_viewer_baker[matrix_ref] = []

        callback_disable(n_id)

        # every time you hit a dot, you pay a price, so alias and benefit
        inputs = self.inputs
        vertex_links = inputs['vertices'].links
        matrix_links = inputs['matrix'].links
        edgepol_links = inputs['edg_pol'].links

        if (vertex_links or matrix_links):

            if vertex_links:
                if isinstance(vertex_links[0].from_socket, VerticesSocket):
                    propv = inputs['vertices'].sv_get()
                    if propv:
                        cache_viewer_baker[vertex_ref] = dataCorrect(propv)

            if edgepol_links:
                if isinstance(edgepol_links[0].from_socket, StringsSocket):
                    prope = inputs['edg_pol'].sv_get()
                    if prope:
                        cache_viewer_baker[poledg_ref] = dataCorrect(prope)

            if matrix_links:
                if isinstance(matrix_links[0].from_socket, MatrixSocket):
                    propm = inputs['matrix'].sv_get()
                    if propm:
                        cache_viewer_baker[matrix_ref] = dataCorrect(propm)

        if cache_viewer_baker[vertex_ref] or cache_viewer_baker[matrix_ref]:
            config_options = self.get_options().copy()
            callback_enable(n_id, cache_viewer_baker, config_options)
            self.color = (1, 1, 1)
        else:
            self.color = (0.7, 0.7, 0.7)
Beispiel #21
0
 def update(self):
     if 'edgs' in self.outputs and len(self.outputs['edgs'].links) > 0:
         if 'pols' in self.inputs and len(self.inputs['pols'].links) > 0:
             X_ = SvGetSocketAnyType(self, self.inputs['pols'])
             X = dataCorrect(X_)
             #print('p2e-X',str(X))
             result = self.pols_edges(X)
             #result = self.polstoedgs(X)
             SvSetSocketAnyType(self, 'edgs', result)
Beispiel #22
0
 def meta_get(self, s_name, fallback, level):
     '''
     private function for the get_input function, accepts level 0..2
     - if socket has no links, then return fallback value
     - s_name can be an index instead of socket name
     '''
     inputs = self.inputs
     if inputs[s_name].links:
         socket_in = SvGetSocketAnyType(self, inputs[s_name])
         if level == 1:
             data = dataCorrect(socket_in)[0]
         elif level == 2:
             data = dataCorrect(socket_in)[0][0]
         else:
             data = dataCorrect(socket_in)
         return data
     else:
         return fallback
Beispiel #23
0
 def get_data(name, fallback=[]):
     TypeSocket = get_socket_type(name)
     if has_good_link(name, TypeSocket):
         d = dataCorrect(SvGetSocketAnyType(node, inputs[name]))
         if name == 'matrix':
             d = Matrix_generate(d) if d else []
         elif name == 'vertices':
             d = Vector_generate(d) if d else []
         return d
     return fallback
Beispiel #24
0
    def update(self):
        if 'data' in self.inputs and len(self.inputs['data'].links) > 0:
            # адаптивный сокет
            inputsocketname = 'data'
            outputsocketname = ['data']
            changable_sockets(self, inputsocketname, outputsocketname)

        # достаём два слота - вершины и полики
        if 'data' in self.outputs and len(self.outputs['data'].links) > 0 \
                and 'data' in self.inputs and len(self.inputs['data'].links) > 0:
            data_ = SvGetSocketAnyType(self, self.inputs['data'])

            # init_level = levelsOflist(data)
            data = dataCorrect(data_, nominal_dept=self.level)
            out_ = []
            for obj in data:
                out_.append(svQsort(obj))
            out = dataCorrect(out_)
            SvSetSocketAnyType(self, 'data', out)
Beispiel #25
0
 def get_data(name, fallback=[]):
     TypeSocket = get_socket_type(name)
     if has_good_link(name, TypeSocket):
         d = dataCorrect(SvGetSocketAnyType(node, inputs[name]))
         if name == 'matrix':
             d = Matrix_generate(d) if d else []
         elif name == 'vertices':
             d = Vector_generate(d) if d else []
         return d
     return fallback
Beispiel #26
0
    def update(self):
        if 'data' in self.inputs and len(self.inputs['data'].links) > 0:
            # адаптивный сокет
            inputsocketname = 'data'
            outputsocketname = ['data']
            changable_sockets(self, inputsocketname, outputsocketname)

        # достаём два слота - вершины и полики
        if 'data' in self.outputs and len(self.outputs['data'].links) > 0 \
                and 'data' in self.inputs and len(self.inputs['data'].links) > 0:
            data_ = SvGetSocketAnyType(self, self.inputs['data'])

            # init_level = levelsOflist(data)
            data = dataCorrect(data_, nominal_dept=self.level)
            out_ = []
            for obj in data:
                out_.append(svQsort(obj))
            out = dataCorrect(out_)
            SvSetSocketAnyType(self, 'data', out)
Beispiel #27
0
    def update(self):

        if self.outputs['Volume'].links and self.inputs['Vers'].links:
            vertices = Vector_generate(
                dataCorrect(SvGetSocketAnyType(self, self.inputs['Vers'])))
            faces = dataCorrect(SvGetSocketAnyType(self, self.inputs['Pols']))
            out = []
            for verts_obj, faces_obj in zip(vertices, faces):
                # this is for one object
                bme = bmesh_from_pydata(verts_obj, [], faces_obj)
                geom_in = bme.verts[:] + bme.edges[:] + bme.faces[:]
                bmesh.ops.recalc_face_normals(bme, faces=bme.faces[:])
                # calculation itself
                out.append(bme.calc_volume())
                bme.clear()
                bme.free()

            if self.outputs['Volume'].links:
                SvSetSocketAnyType(self, 'Volume', out)
Beispiel #28
0
    def update(self):
        # multisocket - from util(formula node)
        multi_socket(self, min=2)

        if 'x0' in self.inputs and len(self.inputs['x0'].links) > 0:
            # adaptive socket - from util(mask list node)
            inputsocketname = self.inputs[
                0].name  # is you need x0 to define socket type - set 0 to 1
            outputsocketname = [
                'data',
            ]
            changable_sockets(self, inputsocketname, outputsocketname)

        if 'data' in self.outputs and len(self.outputs['data'].links) > 0:
            if 'x0' in self.inputs and len(self.inputs['x0'].links) > 0:
                # get any type socket from input:
                X = SvGetSocketAnyType(self, self.inputs['data'])
                slots = []
                for socket in self.inputs:
                    if socket.links:
                        slots.append(SvGetSocketAnyType(self, socket))

                # determine if you have enough inputs for make output
                # if not return
                # examples: all but last (last is never connected)
                # len(slots) == len(self.inputs)-1
                # if more than 2 etc.

                if len(slots) < 2:
                    return

                # Process data
                X_ = dataCorrect(X)
                result = []
                for socket in slots:
                    result.extend(self.f(X_, dataCorrect(socket)))

                # how to assign correct property to adaptive output:
                # in nearest future with socket's data' dictionary we will send
                # only node_name+layout_name+socket_name in str() format
                # and will make separate definition to easyly assign and
                # get and recognise data from dictionary
                SvSetSocketAnyType(self, 'data', result)
Beispiel #29
0
    def process(self, n_id, IV):
        inputs = self.inputs
        iv_links = inputs['vertices'].links
        im_links = inputs['matrix'].links

        draw_verts, draw_matrix = [], []
        text = ''

        # gather vertices from input
        if isinstance(iv_links[0].from_socket, VerticesSocket):
            propv = SvGetSocketAnyType(self, inputs['vertices'])
            draw_verts = dataCorrect(propv)

        # idea to make text in 3d
        if inputs['text'].links:
            text_so = SvGetSocketAnyType(self, inputs['text'])
            text = dataCorrect(text_so)
            fullList(text, len(draw_verts))
            for i, t in enumerate(text):
                fullList(text[i], len(draw_verts[i]))

        if im_links and isinstance(im_links[0].from_socket, MatrixSocket):
            propm = SvGetSocketAnyType(self, inputs['matrix'])
            draw_matrix = dataCorrect(propm)

        data_feind = []
        for socket in ['edges', 'faces']:
            try:
                propm = SvGetSocketAnyType(self, inputs[socket])
                input_stream = dataCorrect(propm)
            except:
                input_stream = []
            finally:
                data_feind.append(input_stream)

        draw_edges, draw_faces = data_feind

        bg = self.draw_bg
        settings = self.get_settings()
        IV.callback_enable(
            n_id, draw_verts, draw_edges, draw_faces,
            draw_matrix, bg, settings.copy(), text)
Beispiel #30
0
    def update(self):
        if 'Poly Egde' not in self.outputs:
            return
        if not any((s.links for s in self.outputs)):
            return
        if self.inputs['Vertices'].links and self.inputs['Poly Egde'].links:
            verts = SvGetSocketAnyType(self, self.inputs['Vertices'])
            poly = SvGetSocketAnyType(self, self.inputs['Poly Egde'])
            verts = dataCorrect(verts)
            poly = dataCorrect(poly)
            if self.inputs['Mask'].links:
                mask = SvGetSocketAnyType(self, self.inputs['Mask'])
            else:
                mask = [[1, 0]]
            has_true_out = True
            has_false_out = False
            verts_out = []
            poly_edge_out = []
            for ve, pe, ma in zip(verts, poly, repeat_last(mask)):
                current_mask = islice(cycle(ma), len(ve))
                vert_index = [i for i, m in enumerate(current_mask) if m]
                if len(vert_index) < len(ve):
                    index_set = set(vert_index)
                    if has_true_out:
                        vert_dict = {j: i for i, j in enumerate(vert_index)}
                        new_vert = [ve[i] for i in vert_index]
                        is_ss = index_set.issuperset
                        new_pe = [[vert_dict[n] for n in fe] for fe in pe
                                  if is_ss(fe)]
                        verts_out.append(new_vert)
                        poly_edge_out.append(new_pe)

                else:  # no reprocessing needed
                    verts_out.append(ve)
                    poly_edge_out.append(pe)

            if 'Vertices' in self.outputs and self.outputs['Vertices'].links:
                SvSetSocketAnyType(self, 'Vertices', verts_out)

            if 'Poly Egde' in self.outputs and self.outputs['Poly Egde'].links:
                if poly_edge_out:
                    SvSetSocketAnyType(self, 'Poly Egde', poly_edge_out)
Beispiel #31
0
    def process(self, n_id, IV):
        inputs = self.inputs
        iv_links = inputs['vertices'].links
        im_links = inputs['matrix'].links

        draw_verts, draw_matrix = [], []
        text = ''

        # gather vertices from input
        if isinstance(iv_links[0].from_socket, VerticesSocket):
            propv = SvGetSocketAnyType(self, inputs['vertices'])
            draw_verts = dataCorrect(propv)

        # idea to make text in 3d
        if inputs['text'].links:
            text_so = SvGetSocketAnyType(self, inputs['text'])
            text = dataCorrect(text_so)
            fullList(text, len(draw_verts))
            for i, t in enumerate(text):
                fullList(text[i], len(draw_verts[i]))

        if im_links and isinstance(im_links[0].from_socket, MatrixSocket):
            propm = SvGetSocketAnyType(self, inputs['matrix'])
            draw_matrix = dataCorrect(propm)

        data_feind = []
        for socket in ['edges', 'faces']:
            try:
                propm = SvGetSocketAnyType(self, inputs[socket])
                input_stream = dataCorrect(propm)
            except:
                input_stream = []
            finally:
                data_feind.append(input_stream)

        draw_edges, draw_faces = data_feind

        bg = self.draw_bg
        settings = self.get_settings()
        IV.callback_enable(n_id, draw_verts, draw_edges, draw_faces,
                           draw_matrix, bg, settings.copy(), text)
Beispiel #32
0
    def update(self):
        # адаптивный сокет
        inputsocketname = 'data'
        outputsocketname = ['data']
        changable_sockets(self, inputsocketname, outputsocketname)

        if 'data' in self.outputs and self.outputs['data'].links:
            outEval = SvGetSocketAnyType(self, self.inputs['data'])
            outCorr = dataCorrect(outEval)  # this is bullshit, as max 3 in levels
            levels = self.level-1
            out = self.flip(outCorr, levels)
            SvSetSocketAnyType(self, 'data', out)
Beispiel #33
0
    def update(self):
        if 'Center' not in self.outputs:
            return
        if not self.inputs['Vertices'].links:
            return
        if not any([s.links for s in self.outputs]):
            return
        has_mat_out = bool(self.outputs['Center'].links)
        has_mean = bool(self.outputs['Mean'].links)
        has_vert_out = bool(self.outputs['Vertices'].links)
        vert = SvGetSocketAnyType(self, self.inputs['Vertices'])
        vert = dataCorrect(vert, nominal_dept=2)

        if vert:
            verts_out = []
            edges_out = []
            edges = [
                (0, 1), (1, 3), (3, 2), (2, 0),  # bottom edges
                (4, 5), (5, 7), (7, 6), (6, 4),  # top edges
                (0, 4), (1, 5), (2, 6), (3, 7)  # sides
            ]
            mat_out = []
            mean_out = []

            for v in vert:
                if has_mat_out or has_vert_out:
                    maxmin = list(zip(map(max, *v), map(min, *v)))
                    out = list(product(*reversed(maxmin)))
                    verts_out.append([l[::-1] for l in out[::-1]])
                edges_out.append(edges)
                if has_mat_out:
                    center = [(u+v)*.5 for u, v in maxmin]
                    mat = Matrix.Translation(center)
                    scale = [(u-v)*.5 for u, v in maxmin]
                    for i, s in enumerate(scale):
                        mat[i][i] = s
                    mat_out.append(mat)
                if has_mean:
                    avr = list(map(sum, zip(*v)))
                    avr = [n/len(v) for n in avr]
                    mean_out.append([avr])

            if self.outputs['Vertices'].links:
                SvSetSocketAnyType(self, 'Vertices', verts_out)

            if self.outputs['Edges'].links:
                SvSetSocketAnyType(self, 'Edges', edges_out)

            if self.outputs['Mean'].links:
                SvSetSocketAnyType(self, 'Mean', mean_out)

            if self.outputs['Center'].links:
                SvSetSocketAnyType(self, 'Center', Matrix_listing(mat_out))
Beispiel #34
0
    def update(self):
        # multisocket - from util(formula node)
        multi_socket(self, min=2)

        if 'x0' in self.inputs and len(self.inputs['x0'].links) > 0:
            # adaptive socket - from util(mask list node)
            inputsocketname = self.inputs[0].name  # is you need x0 to define socket type - set 0 to 1
            outputsocketname = ['data', ]
            changable_sockets(self, inputsocketname, outputsocketname)

        if 'data' in self.outputs and len(self.outputs['data'].links) > 0:
            if 'x0' in self.inputs and len(self.inputs['x0'].links) > 0:
                # get any type socket from input:
                X = SvGetSocketAnyType(self, self.inputs['data'])
                slots = []
                for socket in self.inputs:
                    if socket.links:
                        slots.append(SvGetSocketAnyType(self, socket))

                # determine if you have enough inputs for make output
                # if not return
                # examples: all but last (last is never connected)
                # len(slots) == len(self.inputs)-1
                # if more than 2 etc.

                if len(slots) < 2:
                    return

                # Process data
                X_ = dataCorrect(X)
                result = []
                for socket in slots:
                    result.extend(self.f(X_, dataCorrect(socket)))

                # how to assign correct property to adaptive output:
                # in nearest future with socket's data' dictionary we will send
                # only node_name+layout_name+socket_name in str() format
                # and will make separate definition to easyly assign and
                # get and recognise data from dictionary
                SvSetSocketAnyType(self, 'data', result)
Beispiel #35
0
    def update(self):
        # адаптивный сокет
        inputsocketname = 'data'
        outputsocketname = ['data']
        changable_sockets(self, inputsocketname, outputsocketname)

        if 'data' in self.outputs and self.outputs['data'].links:
            outEval = SvGetSocketAnyType(self, self.inputs['data'])
            outCorr = dataCorrect(
                outEval)  # this is bullshit, as max 3 in levels
            levels = self.level - 1
            out = self.flip(outCorr, levels)
            SvSetSocketAnyType(self, 'data', out)
Beispiel #36
0
        def get_data(name, fallback=[]):
            if name in {'edges', 'faces', 'text'}:
                TypeSocket = StringsSocket
            else:
                TypeSocket = MatrixSocket if name == 'matrix' else VerticesSocket

            if has_good_link(name, TypeSocket):
                d = dataCorrect(SvGetSocketAnyType(node, inputs[name]))
                if name == 'matrix':
                    d = Matrix_generate(d) if d else []
                elif name == 'vertices':
                    d = Vector_generate(d) if d else []
                return d
            return fallback
Beispiel #37
0
    def update(self):
        multi_socket(self, min=2)

        if 'x0' in self.inputs and len(self.inputs['x0'].links) > 0:
            inputsocketname = self.inputs[0].name
            outputsocketname = ['data', ]
            changable_sockets(self, inputsocketname, outputsocketname)

        if 'data' in self.outputs and len(self.outputs['data'].links) > 0:
            if 'x0' in self.inputs and len(self.inputs['x0'].links) > 0:
                X = SvGetSocketAnyType(self, self.inputs['data'])
                slots = []
                for socket in self.inputs:
                    if socket.links:
                        slots.append(SvGetSocketAnyType(self, socket))
                if len(slots) < 2:
                    return

                X_ = dataCorrect(X)
                result = []
                for socket in slots:
                    result.extend(self.f(X_, dataCorrect(socket)))

                SvSetSocketAnyType(self, 'data', result)
Beispiel #38
0
    def update(self):
        # inputs
        if 'Vectors' in self.inputs and self.inputs['Vectors'].links:
            xyz = SvGetSocketAnyType(self, self.inputs['Vectors'])

            data = dataCorrect(xyz)
            #print (data)
            X, Y, Z = [], [], []
            for obj in data:
                x_, y_, z_ = (list(x) for x in zip(*obj))
                X.append(x_)
                Y.append(y_)
                Z.append(z_)
            for i, name in enumerate(['X', 'Y', 'Z']):
                if self.outputs[name].links:
                    SvSetSocketAnyType(self, name, [X, Y, Z][i])
Beispiel #39
0
    def execute(self, context):
        global cache_viewer_baker

        node_group = bpy.data.node_groups[self.idtree]
        node = node_group.nodes[self.idname]
        nid = node_id(node)

        matrix_cache = cache_viewer_baker[nid + 'm']
        vertex_cache = cache_viewer_baker[nid + 'v']
        edgpol_cache = cache_viewer_baker[nid + 'ep']

        if matrix_cache and not vertex_cache:
            return {'CANCELLED'}

        v = dataCorrect(vertex_cache)
        e = self.dataCorrect3(edgpol_cache)
        m = self.dataCorrect2(matrix_cache, v)
        self.makeobjects(v, e, m)
        return {'FINISHED'}
Beispiel #40
0
    def execute(self, context):
        global cache_viewer_baker

        node_group = bpy.data.node_groups[self.idtree]
        node = node_group.nodes[self.idname]
        nid = node_id(node)

        matrix_cache = cache_viewer_baker[nid+'m']
        vertex_cache = cache_viewer_baker[nid+'v']
        edgpol_cache = cache_viewer_baker[nid+'ep']

        if matrix_cache and not vertex_cache:
            return {'CANCELLED'}

        v = dataCorrect(vertex_cache)
        e = self.dataCorrect3(edgpol_cache)
        m = self.dataCorrect2(matrix_cache, v)
        self.makeobjects(v, e, m)
        return {'FINISHED'}
Beispiel #41
0
    def update_py(self):

        node_function = self.node_dict[hash(self)].get('node_function', None)
        if not node_function:
            return

        defaults = node_function.__defaults__
        input_names = [i.name for i in self.inputs]

        fparams = []
        for param_idx, name in enumerate(input_names):
            links = self.inputs[name].links
            this_val = defaults[param_idx]

            if links:
                if isinstance(this_val, list):
                    try:
                        this_val = SvGetSocketAnyType(self, self.inputs[param_idx])
                        this_val = dataCorrect(this_val)
                    except:
                        this_val = defaults[param_idx]
                elif isinstance(this_val, (int, float)):
                    try:
                        k = str(SvGetSocketAnyType(self, self.inputs[name]))
                        kfree = k[2:-2]
                        this_val = ast.literal_eval(kfree)
                    except:
                        this_val = defaults[param_idx]

            fparams.append(this_val)

        if node_function and (len(fparams) == len(input_names)):

            fn_return_values = node_function(*fparams)
            out_sockets = fn_return_values[1]

            for socket_type, name, data in out_sockets:
                SvSetSocketAnyType(self, name, data)
Beispiel #42
0
    def update(self):
        # inputs
        if 'Vectors' in self.outputs and len(self.outputs['Vectors'].links) > 0:
            if self.inputs['Vectors'].links and \
                    type(self.inputs['Vectors'].links[0].from_socket) == VerticesSocket \
                    and self.inputs['Matrixes'] and \
                    type(self.inputs['Matrixes'].links[0].from_socket) == MatrixSocket:

                vecs_ = SvGetSocketAnyType(self, self.inputs['Vectors'])

                vecs = Vector_generate(vecs_)
                #print (vecs)

                mats_ = dataCorrect(SvGetSocketAnyType(self, self.inputs['Matrixes']))
                mats = Matrix_generate(mats_)
            else:
                vecs = [[]]
                mats = [Matrix()]

            # outputs

            vectors_ = self.vecscorrect(vecs, mats)
            vectors = Vector_degenerate(vectors_)
            SvSetSocketAnyType(self, 'Vectors', vectors)
Beispiel #43
0
    def update(self):
        if 'vec' in self.inputs and 'edg' in self.inputs:
            print(self.name, 'is starting')
            if self.inputs['vec'].links and self.inputs['edg'].links:

                
                vec = self.inputs['vec'].sv_get()
                edg = self.inputs['edg'].sv_get()
                vecplan = self.inputs['vecplan'].sv_get()
                edgplan = self.inputs['edgplan'].sv_get()
                loc = self.inputs['loc'].sv_get()
                norm = self.inputs['norm'].sv_get()
                thick = self.inputs['thick'].sv_get()[0][0]
                sinuso60 = 0.8660254037844386
                sinuso60_minus = 0.133974596
                sinuso30 = 0.5
                sinuso45 = 0.7071067811865475
                if 'loccont' in self.inputs and self.inputs['loccont'].links and \
                       'normcont' in self.inputs and self.inputs['normcont'].links:
                    vecont = self.inputs['vecont'].sv_get()
                    loccont = self.inputs['loccont'].sv_get()
                    normcont = self.inputs['normcont'].sv_get()
                    vec_cont = Vector_generate(vecont)
                    loc_cont = Vector_generate(loccont)
                    norm_cont = Vector_generate(normcont)
                else:
                    norm_cont = [[Vector((0,0,1)) for i in range(len(norm[0]))]]
                    loc_cont = [[Vector((0,0,10000)) for i in range(len(norm[0]))]]
                    vec_cont = [[Vector((1000,0,1))] for i in range(len(norm[0]))]
                outeup = []
                outelo = []
                vupper = []
                vlower = []
                vec_ = Vector_generate(vec)
                loc_ = Vector_generate(loc)
                norm_ = Vector_generate(norm)
                vecplan_ = Vector_generate(vecplan)
                #print(self.name, 'veriables: \n', \
                #      vec_,'\n',
                #      vecplan_,'\n',
                #      loc_,'\n',
                #      loc_cont)
                for l,n,vecp, edgp in zip(loc_[0],norm_[0],vecplan_,edgplan):
                    newinds1 = edgp.copy()
                    newinds2 = edgp.copy()
                    vupperob = vecp.copy()
                    vlowerob = vecp.copy()
                    deledges1 = []
                    deledges2 = []
                    k = 0
                    lenvep = len(vecp)
                    # KDtree collections closest to join edges to sockets
                    tree = KDT.KDTree(lenvep)
                    for i,v in enumerate(vecp):
                        tree.insert(v,i)
                    tree.balance()
                    # to define bounds
                    x = [i[0] for i in vecp]
                    y = [i[1] for i in vecp]
                    m1x,m2x,m1y,m2y = max(x), min(x), max(y), min(y)
                    # vertical edges iterations
                    # every edge is object - two points, one edge
                    for v in vec_:
                        # sort vertices by Z value
                        # find two vertices - one lower, two upper
                        vlist = [v[0],v[1]]
                        vlist.sort(key=lambda x: x[2], reverse=False)
                        # flip if coplanar to enemy plane
                        # flip plane coplanar
                        fliped = self.get_coplanar(v[0], loc_cont,norm_cont, vec_cont)
                        if fliped:
                            two, one = vlist
                        else:
                            one, two = vlist
                        # coplanar to owner
                        cop = abs(D2P(one,l,n))
                        # defining bounds
                        inside = one[0]<m1x and one[0]>m2x and one[1]<m1y and one[1]>m2y
                        # if in bounds and coplanar do:
                        #print(self.name,l, cop, inside)
                        if cop < 0.001 and inside:
                            '''
                            huge calculations. if we can reduce...
                            '''
                            # find shift for thickness in sockets
                            angle = radians(degrees(atan(n.y/n.x))+90)
                            thick_2 = thick/2
                            direction = Vector((cos(angle),sin(angle),0))*thick_2
                            #matr = Euler((0,0,angle),'YZX').to_matrix().to_4x4()
                            #matr.translation = 
                            #direction = matr
                            # вектор, индекс, расстояние
                            # запоминаем порядок
                            # находим какие удалить рёбра
                            # делаем выборку левая-правая точка
                            nearv_1, near_1 = tree.find(one)[:2]
                            nearv_2, near_2 = tree.find(two)[:2]
                            # indexes of two nearest points
                            # удалить рёбра что мешают спать заодно
                            en_0, en_1, de1 = self.calc_indexes(edgp, near_1)
                            deledges1.extend(de1)
                            en_2, en_3, de2 = self.calc_indexes(edgp, near_2)
                            deledges2.extend(de2)
                            # old delete
                            # en_0,en_1 = [[t for t in i if t != near_1] for i in edgp if near_1 in i]
                            # en_2,en_3 = [[t for t in i if t != near_2] for i in edgp if near_2 in i]
                            # print(vecp, one, direction, en_0, en_1)
                            # left-right indexes and vectors
                            # с учётом интерполяций по высоте
                            left1, right1, l1, r1, lz1, rz1 = \
                                    self.calc_leftright(vecp, one, direction, en_0, en_1, thick_2)
                            left2, right2, l2, r2, lz2, rz2 = \
                                    self.calc_leftright(vecp, two, direction, en_2, en_3, thick_2)

                            # средняя точка и её смещение по толщине материала
                            three = (one-two)/2 + two
                            if self.rounded:
                                '''рёбра'''
                                if fliped:
                                    doflip = -1
                                else:
                                    doflip = 1
                                # пазы формируем независимо от верх низ

                                outeob1 = [[lenvep+k+8,lenvep+k],[lenvep+k+1,lenvep+k+2],
                                          [lenvep+k+2,lenvep+k+3],[lenvep+k+3,lenvep+k+4],
                                          [lenvep+k+4,lenvep+k+5],[lenvep+k+5,lenvep+k+6],
                                          [lenvep+k+6,lenvep+k+7],[lenvep+k+7,lenvep+k+8],
                                          [lenvep+k+9,lenvep+k+1]]

                                outeob2 = [[lenvep+k,lenvep+k+1],[lenvep+k+1,lenvep+k+2],
                                          [lenvep+k+2,lenvep+k+3],[lenvep+k+3,lenvep+k+4],
                                          [lenvep+k+4,lenvep+k+5],[lenvep+k+5,lenvep+k+6],
                                          [lenvep+k+6,lenvep+k+7],[lenvep+k+7,lenvep+k+8],
                                          [lenvep+k+8,lenvep+k+9]]
                                # наполнение списков lenvep = length(vecp)
                                newinds1.extend([[l1, lenvep+k], [lenvep+k+9, r1]])
                                newinds2.extend([[l2, lenvep+k+9], [lenvep+k, r2]])
                                '''Вектора'''
                                thick_3 = thick/3
                                thick_6 = thick/6
                                round1 = Vector((0,0,doflip*thick_3))
                                round2 = Vector((0,0,doflip*thick_3*sinuso30))
                                round2_= direction/3 + direction*(2*sinuso60/3)
                                round3 = Vector((0,0,doflip*thick_3*sinuso60_minus))
                                round3_= direction/3 + direction*(2*sinuso30/3)
                                round4 = direction/3
                                vupperob.extend([two-direction-Vector((0,0,lz2)),
                                                 three+round1-direction, three+round2-round2_,
                                                 three+round3-round3_, three-round4,
                                                 three+round4, three+round3+round3_,
                                                 three+round2+round2_, three+round1+direction,
                                                 two+direction-Vector((0,0,rz2))])
                                vlowerob.extend([one+direction-Vector((0,0,rz1)),
                                                 three-round1-direction, three-round2-round2_,
                                                 three-round3-round3_, three-round4,
                                                 three+round4, three-round3+round3_,
                                                 three-round2+round2_, three-round1+direction,
                                                 one-direction-Vector((0,0,lz1))])
                                k += 10
                            else:
                                '''рёбра'''
                                # пазы формируем независимо от верх низ
                                outeob1 = [[lenvep+k,lenvep+k+1],[lenvep+k+1,lenvep+k+2],[lenvep+k+2,lenvep+k+3]]
                                outeob2 = [[lenvep+k,lenvep+k+1],[lenvep+k+1,lenvep+k+2],[lenvep+k+2,lenvep+k+3]]
                                # наполнение списков lenvep = length(vecp)
                                newinds1.extend([[l1, lenvep+k], [lenvep+k+3, r1]])
                                newinds2.extend([[l2, lenvep+k+3], [lenvep+k, r2]])
                                '''Вектора'''
                                vupperob.extend([two-direction-Vector((0,0,lz2)), three-direction, 
                                                 three+direction, two+direction-Vector((0,0,rz2))])
                                vlowerob.extend([one+direction-Vector((0,0,rz1)), three+direction,
                                                 three-direction, one-direction-Vector((0,0,lz1))])
                                k += 4
                            newinds1.extend(outeob1)
                            newinds2.extend(outeob2)
                    del tree
                    for e in deledges1:
                        if e in newinds1:
                            newinds1.remove(e)
                    for e in deledges2:
                        if e in newinds2:
                            newinds2.remove(e)
                    if vupperob or vlowerob:
                        outeup.append(newinds2)
                        outelo.append(newinds1)
                        vupper.append(vupperob)
                        vlower.append(vlowerob)
                vupper = Vector_degenerate(vupper)
                vlower = Vector_degenerate(vlower)
                
                if 'vupper' in self.outputs and self.outputs['vupper'].links:
                    out = dataCorrect(vupper)
                    SvSetSocketAnyType(self, 'vupper', out)
                if 'outeup' in self.outputs and self.outputs['outeup'].links:
                    SvSetSocketAnyType(self, 'outeup', outeup)
                if 'vlower' in self.outputs and self.outputs['vlower'].links:
                    SvSetSocketAnyType(self, 'vlower', vlower)
                if 'outelo' in self.outputs and self.outputs['outelo'].links:
                    SvSetSocketAnyType(self, 'outelo', outelo)
                print(self.name, 'is finishing')
Beispiel #44
0
 def dataCorrect3(self, destination, fallback=[]):
     if destination:
         return dataCorrect(destination)
     return fallback
Beispiel #45
0
 def dataCorrect2(self, destination, obj):
     if destination:
         return dataCorrect(destination)
     return [Matrix() for v in obj]
Beispiel #46
0
    def update(self):
        if 'Center' not in self.outputs:
            return
        if not self.inputs['Vertices'].links:
            return
        if not any([s.links for s in self.outputs]):
            return
        has_mat_out = bool(self.outputs['Center'].links)
        has_mean = bool(self.outputs['Mean'].links)
        has_vert_out = bool(self.outputs['Vertices'].links)
        vert = SvGetSocketAnyType(self, self.inputs['Vertices'])
        vert = dataCorrect(vert, nominal_dept=2)

        if vert:
            verts_out = []
            edges_out = []
            edges = [
                (0, 1),
                (1, 3),
                (3, 2),
                (2, 0),  # bottom edges
                (4, 5),
                (5, 7),
                (7, 6),
                (6, 4),  # top edges
                (0, 4),
                (1, 5),
                (2, 6),
                (3, 7)  # sides
            ]
            mat_out = []
            mean_out = []

            for v in vert:
                if has_mat_out or has_vert_out:
                    maxmin = list(zip(map(max, *v), map(min, *v)))
                    out = list(product(*reversed(maxmin)))
                    verts_out.append([l[::-1] for l in out[::-1]])
                edges_out.append(edges)
                if has_mat_out:
                    center = [(u + v) * .5 for u, v in maxmin]
                    mat = Matrix.Translation(center)
                    scale = [(u - v) * .5 for u, v in maxmin]
                    for i, s in enumerate(scale):
                        mat[i][i] = s
                    mat_out.append(mat)
                if has_mean:
                    avr = list(map(sum, zip(*v)))
                    avr = [n / len(v) for n in avr]
                    mean_out.append([avr])

            if self.outputs['Vertices'].links:
                SvSetSocketAnyType(self, 'Vertices', verts_out)

            if self.outputs['Edges'].links:
                SvSetSocketAnyType(self, 'Edges', edges_out)

            if self.outputs['Mean'].links:
                SvSetSocketAnyType(self, 'Mean', mean_out)

            if self.outputs['Center'].links:
                SvSetSocketAnyType(self, 'Center', Matrix_listing(mat_out))
Beispiel #47
0
    def update(self):
        inputs = self.inputs
        text=''

        # if you change this change in free() also
        n_id = node_id(self)
        # end early
        if not ('vertices' in inputs) and not ('matrix' in inputs):
            IV.callback_disable(n_id)
            return
        # end if tree status is set to not show
        if not self.id_data.sv_show:
            IV.callback_disable(n_id)
            return

        # alias in case it is present
        iv_links = inputs['vertices'].links

        if self.activate and iv_links:
            IV.callback_disable(n_id)
            draw_verts, draw_matrix = [], []

            # gather vertices from input
            if isinstance(iv_links[0].from_socket, VerticesSocket):
                propv = SvGetSocketAnyType(self, inputs['vertices'])
                draw_verts = dataCorrect(propv)
            
            # idea to make text in 3d
            if 'text' in inputs and inputs['text'].links:
                text_so = SvGetSocketAnyType(self, inputs['text'])
                text = dataCorrect(text_so)
                fullList(text, len(draw_verts))
                for i, t in enumerate(text):
                    fullList(text[i], len(draw_verts[i]))
                
            # matrix might be operating on vertices, check and act on.
            if 'matrix' in inputs:
                im_links = inputs['matrix'].links

                # end early, skips to drwa vertex indices without matrix
                if im_links and isinstance(im_links[0].from_socket, MatrixSocket):
                    propm = SvGetSocketAnyType(self, inputs['matrix'])
                    draw_matrix = dataCorrect(propm)

            data_feind = []
            for socket in ['edges', 'faces']:
                try:
                    propm = SvGetSocketAnyType(self, inputs[socket])
                    input_stream = dataCorrect(propm)
                except:
                    input_stream = []
                finally:
                    data_feind.append(input_stream)

            draw_edges, draw_faces = data_feind

            bg = self.draw_bg
            settings = self.get_settings()
            IV.callback_enable(
                n_id, draw_verts, draw_edges, draw_faces, draw_matrix, bg, settings.copy(), text)
            self.use_custom_color = True
            self.color = READY_COLOR
        else:
            IV.callback_disable(n_id)
            self.use_custom_color = True
            self.color = FAIL_COLOR
Beispiel #48
0
 def dataCorrect3(self, destination, fallback=[]):
     if destination:
         return dataCorrect(destination)
     return fallback
Beispiel #49
0
 def dataCorrect2(self, destination, obj):
     if destination:
         return dataCorrect(destination)
     return [Matrix() for v in obj]
Beispiel #50
0
    def update(self):
        if not 'centers' in self.outputs or \
                not self.inputs['vecLine'].links or \
                not self.outputs['vert'].links:
            return
        self.ext_draw_checking()
            
        if 'vecLine' in self.inputs and \
                'vecPlane' in self.inputs and \
                'edgPlane' in self.inputs:
            print(self.name, 'is starting')
            if self.inputs['vecLine'].links and \
                    self.inputs['vecPlane'].links and \
                    self.inputs['edgPlane'].links:
                if self.bindCircle:
                    circle = [ (Vector((sin(radians(i)),cos(radians(i)),0))*self.circle_rad)/4 \
                              for i in range(0,360,30) ]
                vec = self.inputs['vecLine'].sv_get()
                vecplan = self.inputs['vecPlane'].sv_get()
                edgplan = self.inputs['edgPlane'].sv_get()
                thick = self.inputs['thick'].sv_get()[0][0]
                threshold_coplanar = 0.005
                sinuso60 = 0.8660254037844386
                sinuso60_minus = 0.133974596
                sinuso30 = 0.5
                sinuso45 = 0.7071067811865475
                thick_2 = thick/2
                thick_3 = thick/3
                thick_6 = thick/6
                threshold = self.threshold
                if 'vecContr' in self.inputs and self.inputs['vecContr'].links:
                    vecont = self.inputs['vecContr'].sv_get()
                    #edgcont = self.inputs['edgContr'].sv_get()
                    vec_cont = Vector_generate(vecont)
                    loc_cont = [ [ i[0] ] for i in vec_cont ]
                    norm_cont = [ [ NM(i[0],i[len(i)//2], i[-1]) ] for i in vec_cont ] # довести до ума
                else:
                    vec_cont = []
                if 'vecTube' in self.inputs and self.inputs['vecTube'].links:
                    vectube = self.inputs['vecTube'].sv_get()
                    vec_tube = Vector_generate(vectube)
                    tube_radius = self.inputs['radTube'].sv_get()[0][0]
                    circle_tube = [ (Vector((sin(radians(i)),cos(radians(i)),0))*tube_radius) \
                              for i in range(0,360,15) ]
                else:
                    vec_tube = []
                outeup = []
                outelo = []
                vupper = []
                vlower = []
                centers = []
                vec_ = Vector_generate(vec)
                vecplan_ = Vector_generate(vecplan)
                for centersver, vecp, edgp in zip(vecplan,vecplan_,edgplan):
                    tubes_flag_bed_solution_i_know = False
                    newinds1 = edgp.copy()
                    newinds2 = edgp.copy()
                    vupperob = vecp.copy()
                    vlowerob = vecp.copy()
                    deledges1 = []
                    deledges2 = []
                    # to define bounds
                    x = [i[0] for i in vecp]
                    y = [i[1] for i in vecp]
                    z = [i[2] for i in vecp]
                    m1x,m2x,m1y,m2y,m1z,m2z = max(x), min(x), max(y), min(y), max(z), min(z)
                    l = Vector((sum(x)/len(x),sum(y)/len(y),sum(z)/len(z)))
                    n_select = [vecp[0],vecp[len(vecp)//2], vecp[-1]] # довести до ума
                    n_select.sort(key=lambda x: sum(x[:]), reverse=False)
                    n_ = NM(n_select[0],n_select[1],n_select[2])
                    n_.normalize()
                    # а виновта ли нормаль?
                    if n_[0] < 0:
                        n = n_ * -1
                    else:
                        n = n_
                    cen = [sum(i) for i in zip(*centersver)]
                    centers.append(Vector(cen)/len(centersver))
                    k = 0
                    lenvep = len(vecp)
                    # KDtree collections closest to join edges to sockets
                    tree = KDT.KDTree(lenvep)
                    for i,v in enumerate(vecp):
                        tree.insert(v,i)
                    tree.balance()
                    # vertical edges iterations
                    # every edge is object - two points, one edge
                    for v in vec_:
                        if not v: continue
                        # sort vertices by Z value
                        # find two vertices - one lower, two upper
                        vlist = [v[0],v[1]]
                        vlist.sort(key=lambda x: x[2], reverse=False)
                        # flip if coplanar to enemy plane
                        # flip plane coplanar
                        if vec_cont:
                            fliped = self.get_coplanar(v[0], loc_cont,norm_cont, vec_cont)
                        else:
                            fliped = False
                        shortedge = (vlist[1]-vlist[0]).length
                        if fliped:
                            two, one = vlist
                        else:
                            one, two = vlist
                        # coplanar to owner
                        cop = abs(D2P(one,l,n))
                        # defining bounds
                        inside = one[0]<m1x and one[0]>m2x and one[1]<m1y and one[1]>m2y \
                                 and one[2]<=m1z and one[2]>=m2z
                        # if in bounds and coplanar do:
                        #print(self.name,l, cop, inside)
                        if cop < threshold_coplanar and inside and shortedge > thick*threshold:
                            '''
                            huge calculations. if we can reduce...
                            '''
                            # find shift for thickness in sockets
                            diry = two - one
                            diry.normalize()
                            # solution for vertical wafel - cool but not in diagonal case
                            # angle = radians(degrees(atan(n.y/n.x))+90)
                            dirx_ = self.rotation_on_axis(diry, n, radians(90))
                            dirx = dirx_*thick_2
                            # вектор, индекс, расстояние
                            # запоминаем порядок находим какие удалить рёбра
                            # делаем выборку левая-правая точка
                            nearv_1, near_1 = tree.find(one)[:2]
                            nearv_2, near_2 = tree.find(two)[:2]
                            # indexes of two nearest points
                            # удалить рёбра что мешают спать заодно
                            en_0, en_1, de1 = self.calc_indexes(edgp, near_1)
                            deledges1.extend(de1)
                            en_2, en_3, de2 = self.calc_indexes(edgp, near_2)
                            deledges2.extend(de2)
                            # print(vecp, one, dirx, en_0, en_1)
                            # left-right indexes and vectors
                            # с учётом интерполяций по высоте
                            l1, r1, lz1, rz1 = \
                                    self.calc_leftright(vecp, one, dirx, en_0, en_1, thick_2, diry)
                            l2, r2, lz2, rz2 = \
                                    self.calc_leftright(vecp, two, dirx, en_2, en_3, thick_2, diry)
                            # print(left2, right2, l2, r2, lz2, rz2)
                            # средняя точка и её смещение по толщине материала
                            three = (one-two)/2 + two
                            
                            # rounded section
                            if self.rounded:
                                '''рёбра'''
                                # пазы формируем независимо от верх низ

                                outeob1 = [[lenvep+k+8,lenvep+k],[lenvep+k+1,lenvep+k+2],
                                          [lenvep+k+2,lenvep+k+3],[lenvep+k+3,lenvep+k+4],
                                          [lenvep+k+4,lenvep+k+5],[lenvep+k+5,lenvep+k+6],
                                          [lenvep+k+6,lenvep+k+7],[lenvep+k+7,lenvep+k+8],
                                          [lenvep+k+9,lenvep+k+1]]

                                outeob2 = [[lenvep+k,lenvep+k+1],[lenvep+k+1,lenvep+k+2],
                                          [lenvep+k+2,lenvep+k+3],[lenvep+k+3,lenvep+k+4],
                                          [lenvep+k+4,lenvep+k+5],[lenvep+k+5,lenvep+k+6],
                                          [lenvep+k+6,lenvep+k+7],[lenvep+k+7,lenvep+k+8],
                                          [lenvep+k+8,lenvep+k+9]]
                                # наполнение списков lenvep = length(vecp)
                                newinds1.extend([[l1, lenvep+k], [lenvep+k+9, r1]])
                                newinds2.extend([[l2, lenvep+k+9], [lenvep+k, r2]])
                                '''Вектора'''
                                round1 = diry*thick_3
                                round2 = diry*thick_3*sinuso30
                                round2_= dirx/3 + dirx*(2*sinuso60/3)
                                round3 = diry*thick_3*sinuso60_minus
                                round3_= dirx/3 + dirx*(2*sinuso30/3)
                                round4 = dirx/3
                                vupperob.extend([lz2,
                                                 three+round1-dirx, three+round2-round2_,
                                                 three+round3-round3_, three-round4,
                                                 three+round4, three+round3+round3_,
                                                 three+round2+round2_, three+round1+dirx,
                                                 rz2])
                                vlowerob.extend([rz1,
                                                 three-round1-dirx, three-round2-round2_,
                                                 three-round3-round3_, three-round4,
                                                 three+round4, three-round3+round3_,
                                                 three-round2+round2_, three-round1+dirx,
                                                 lz1])
                                k += 10
                            
                            # streight section
                            else:
                                '''рёбра'''
                                # пазы формируем независимо от верх низ
                                outeob1 = [[lenvep+k,lenvep+k+1],[lenvep+k+1,lenvep+k+2],[lenvep+k+2,lenvep+k+3]]
                                outeob2 = [[lenvep+k,lenvep+k+1],[lenvep+k+1,lenvep+k+2],[lenvep+k+2,lenvep+k+3]]
                                # наполнение списков lenvep = length(vecp)
                                newinds1.extend([[l1, lenvep+k], [lenvep+k+3, r1]])
                                newinds2.extend([[l2, lenvep+k+3], [lenvep+k, r2]])
                                '''Вектора'''
                                vupperob.extend([lz2, three-dirx, 
                                                 three+dirx, rz2])
                                vlowerob.extend([rz1, three+dirx,
                                                 three-dirx, lz1])
                                k += 4
                            newinds1.extend(outeob1)
                            newinds2.extend(outeob2)
                            
                            # circles to bing panels section
                            if self.bindCircle:
                                CP = self.circl_place
                                if CP == 'Midl':
                                    crcl_cntr = IL2P(one, two, Vector((0,0,0)), Vector((0,0,-1)))
                                elif CP == 'Up' and not fliped:
                                    crcl_cntr = two - diry*self.circle_rad*2
                                elif CP == 'Down' and not fliped:
                                    crcl_cntr = one + diry*self.circle_rad*2
                                elif CP == 'Up' and fliped:
                                    crcl_cntr = one + diry*self.circle_rad*2
                                elif CP == 'Down' and fliped:
                                    crcl_cntr = two - diry*self.circle_rad*2
                                # forgot howto 'else' in line iteration?
                                outeob1 = [ [lenvep+k+i,lenvep+k+i+1] for i in range(0,11) ]
                                outeob1.append([lenvep+k,lenvep+k+11])
                                outeob2 = [ [lenvep+k+i,lenvep+k+i+1] for i in range(12,23) ]
                                outeob2.append([lenvep+k+12,lenvep+k+23])
                                newinds1.extend(outeob1+outeob2)
                                newinds2.extend(outeob1+outeob2)
                                mat_rot_cir = n.rotation_difference(Vector((0,0,1))).to_matrix().to_4x4()
                                circle_to_add_1 = [vecir*mat_rot_cir+crcl_cntr+ \
                                        dirx_*self.circle_rad for vecir in circle ]
                                circle_to_add_2 = [vecir*mat_rot_cir+crcl_cntr- \
                                        dirx_*self.circle_rad for vecir in circle ]
                                vupperob.extend(circle_to_add_1+circle_to_add_2)
                                vlowerob.extend(circle_to_add_1+circle_to_add_2)
                                k += 24
                                
                            # TUBE section
                            if vec_tube and not tubes_flag_bed_solution_i_know:
                                for v in vec_tube:
                                    tubeverlength = len(v)
                                    if tubeverlength == 2:
                                        crcl_cntr = IL2P(v[0], v[1], l, n)
                                        if crcl_cntr:
                                            inside = crcl_cntr[0]<m1x and crcl_cntr[0]>m2x and crcl_cntr[1]<m1y \
                                                 and crcl_cntr[1]>m2y and crcl_cntr[2]<=m1z and crcl_cntr[2]>=m2z
                                            if inside:
                                                outeob = [ [lenvep+k+i,lenvep+k+i+1] for i in range(0,23) ]
                                                outeob.append([lenvep+k,lenvep+k+23])
                                                newinds1.extend(outeob)
                                                newinds2.extend(outeob)
                                                mat_rot_cir = n.rotation_difference(Vector((0,0,1))).to_matrix().to_4x4()
                                                circle_to_add = [ vecir*mat_rot_cir+crcl_cntr for vecir in circle_tube ]
                                                vupperob.extend(circle_to_add)
                                                vlowerob.extend(circle_to_add)
                                                k += 24
                                    else:
                                        tubeshift = tubeverlength//2
                                        crcl_cntr = IL2P(v[0], v[tubeshift], l, n)
                                        if crcl_cntr:
                                            inside = crcl_cntr[0]<m1x and crcl_cntr[0]>m2x and crcl_cntr[1]<m1y \
                                                 and crcl_cntr[1]>m2y and crcl_cntr[2]<=m1z and crcl_cntr[2]>=m2z
                                            if inside:
                                                outeob = [ [lenvep+k+i,lenvep+k+i+1] for i in range(tubeshift-1) ]
                                                outeob.append([lenvep+k,lenvep+k+tubeshift-1])
                                                newinds1.extend(outeob)
                                                newinds2.extend(outeob)
                                                for tubevert in range(tubeshift):
                                                    tubevert_out = IL2P(v[tubevert], v[tubevert+tubeshift], l, n)
                                                    vupperob.append(tubevert_out)
                                                    vlowerob.append(tubevert_out)
                                                k += tubeshift
                                            
                                tubes_flag_bed_solution_i_know = True
                        elif cop < threshold_coplanar and inside and shortedge <= thick*threshold:
                            vupperob.extend([one,two])
                            vlowerob.extend([one,two])
                            newinds1.append([lenvep+k,lenvep+k+1])
                            newinds2.append([lenvep+k,lenvep+k+1])
                            k += 2
                    del tree
                    for e in deledges1:
                        if e in newinds1:
                            newinds1.remove(e)
                    for e in deledges2:
                        if e in newinds2:
                            newinds2.remove(e)
                    if vupperob or vlowerob:
                        outeup.append(newinds2)
                        outelo.append(newinds1)
                        vupper.append(vupperob)
                        vlower.append(vlowerob)
                vupper = Vector_degenerate(vupper)
                vlower = Vector_degenerate(vlower)
                centers = Vector_degenerate([centers])
                
                if 'vert' in self.outputs:
                    if self.out_up_down == 'Up':
                        out = dataCorrect(vupper)
                    else:
                        out = dataCorrect(vlower)
                    SvSetSocketAnyType(self, 'vert', out)
                if 'edge' in self.outputs and self.outputs['edge'].links:
                    if self.out_up_down == 'Up':
                        SvSetSocketAnyType(self, 'edge', outeup)
                    else:
                        SvSetSocketAnyType(self, 'edge', outelo)
                if 'centers' in self.outputs and self.outputs['centers'].links:
                    SvSetSocketAnyType(self, 'centers', centers)
                print(self.name, 'is finishing')
Beispiel #51
0
    def update(self):
        if not 'centers' in self.outputs:
            return
        if 'vecLine' in self.inputs and 'vecPlane' in self.inputs \
                and 'edgPlane' in self.inputs:
            print(self.name, 'is starting')
            if self.inputs['vecLine'].links and self.inputs['vecPlane'].links \
                    and self.inputs['edgPlane'].links:
                if self.bindCircle:
                    circle = [ (Vector((sin(radians(i)),cos(radians(i)),0))*self.circle_rad)/4 \
                              for i in range(0,360,30) ]
                vec = self.inputs['vecLine'].sv_get()
                vecplan = self.inputs['vecPlane'].sv_get()
                edgplan = self.inputs['edgPlane'].sv_get()
                thick = self.inputs['thick'].sv_get()[0][0]
                sinuso60 = 0.8660254037844386
                sinuso60_minus = 0.133974596
                sinuso30 = 0.5
                sinuso45 = 0.7071067811865475
                thick_2 = thick / 2
                thick_3 = thick / 3
                thick_6 = thick / 6
                threshold = self.threshold
                if 'vecContr' in self.inputs and self.inputs['vecContr'].links:
                    vecont = self.inputs['vecContr'].sv_get()
                    edgcont = self.inputs['edgContr'].sv_get()
                    vec_cont = Vector_generate(vecont)
                    loc_cont = [[i[0]] for i in vec_cont]
                    norm_cont = [[NM(i[0], i[len(i) // 2], i[-1])]
                                 for i in vec_cont]  # довести до ума
                else:
                    vec_cont = []
                if 'vecTube' in self.inputs and self.inputs['vecTube'].links:
                    vectube = self.inputs['vecTube'].sv_get()
                    vec_tube = Vector_generate(vectube)
                    tube_radius = self.inputs['radTube'].sv_get()[0][0]
                    circle_tube = [ (Vector((sin(radians(i)),cos(radians(i)),0))*tube_radius) \
                              for i in range(0,360,15) ]
                else:
                    vec_tube = []
                outeup = []
                outelo = []
                vupper = []
                vlower = []
                centers = []
                vec_ = Vector_generate(vec)
                vecplan_ = Vector_generate(vecplan)
                for centersver, vecp, edgp in zip(vecplan, vecplan_, edgplan):
                    tubes_flag_bed_solution_i_know = False
                    newinds1 = edgp.copy()
                    newinds2 = edgp.copy()
                    vupperob = vecp.copy()
                    vlowerob = vecp.copy()
                    deledges1 = []
                    deledges2 = []
                    # to define bounds
                    x = [i[0] for i in vecp]
                    y = [i[1] for i in vecp]
                    z = [i[2] for i in vecp]
                    m1x, m2x, m1y, m2y, m1z, m2z = max(x), min(x), max(y), min(
                        y), max(z), min(z)
                    l = Vector(
                        (sum(x) / len(x), sum(y) / len(y), sum(z) / len(z)))
                    n_select = [vecp[0], vecp[len(vecp) // 2],
                                vecp[-1]]  # довести до ума
                    n_select.sort(key=lambda x: sum(x[:]), reverse=False)
                    n_ = NM(n_select[0], n_select[1], n_select[2])
                    n_.normalize()
                    # а виновта ли нормаль?
                    if n_[0] < 0:
                        n = n_ * -1
                    else:
                        n = n_
                    cen = [sum(i) for i in zip(*centersver)]
                    centers.append(Vector(cen) / len(centersver))
                    k = 0
                    lenvep = len(vecp)
                    # KDtree collections closest to join edges to sockets
                    tree = KDT.KDTree(lenvep)
                    for i, v in enumerate(vecp):
                        tree.insert(v, i)
                    tree.balance()
                    # vertical edges iterations
                    # every edge is object - two points, one edge
                    for v in vec_:
                        # sort vertices by Z value
                        # find two vertices - one lower, two upper
                        vlist = [v[0], v[1]]
                        vlist.sort(key=lambda x: x[2], reverse=False)
                        # flip if coplanar to enemy plane
                        # flip plane coplanar
                        if vec_cont:
                            fliped = self.get_coplanar(v[0], loc_cont,
                                                       norm_cont, vec_cont)
                        else:
                            fliped = False
                        shortedge = (vlist[1] - vlist[0]).length
                        if fliped:
                            two, one = vlist
                        else:
                            one, two = vlist
                        # coplanar to owner
                        cop = abs(D2P(one, l, n))
                        # defining bounds
                        inside = one[0]<m1x and one[0]>m2x and one[1]<m1y and one[1]>m2y \
                                 and one[2]<=m1z and one[2]>=m2z
                        # if in bounds and coplanar do:
                        #print(self.name,l, cop, inside)
                        if cop < 0.001 and inside and shortedge > thick * threshold:
                            '''
                            huge calculations. if we can reduce...
                            '''
                            # find shift for thickness in sockets
                            diry = two - one
                            diry.normalize()
                            # solution for vertical wafel - cool but not in diagonal case
                            # angle = radians(degrees(atan(n.y/n.x))+90)
                            dirx_ = self.rotation_on_axis(diry, n, radians(90))
                            dirx = dirx_ * thick_2
                            # вектор, индекс, расстояние
                            # запоминаем порядок находим какие удалить рёбра
                            # делаем выборку левая-правая точка
                            nearv_1, near_1 = tree.find(one)[:2]
                            nearv_2, near_2 = tree.find(two)[:2]
                            # indexes of two nearest points
                            # удалить рёбра что мешают спать заодно
                            en_0, en_1, de1 = self.calc_indexes(edgp, near_1)
                            deledges1.extend(de1)
                            en_2, en_3, de2 = self.calc_indexes(edgp, near_2)
                            deledges2.extend(de2)
                            # print(vecp, one, dirx, en_0, en_1)
                            # left-right indexes and vectors
                            # с учётом интерполяций по высоте
                            l1, r1, lz1, rz1 = \
                                    self.calc_leftright(vecp, one, dirx, en_0, en_1, thick_2, diry)
                            l2, r2, lz2, rz2 = \
                                    self.calc_leftright(vecp, two, dirx, en_2, en_3, thick_2, diry)
                            # print(left2, right2, l2, r2, lz2, rz2)
                            # средняя точка и её смещение по толщине материала
                            three = (one - two) / 2 + two
                            if self.rounded:
                                '''рёбра'''
                                # пазы формируем независимо от верх низ

                                outeob1 = [[lenvep + k + 8, lenvep + k],
                                           [lenvep + k + 1, lenvep + k + 2],
                                           [lenvep + k + 2, lenvep + k + 3],
                                           [lenvep + k + 3, lenvep + k + 4],
                                           [lenvep + k + 4, lenvep + k + 5],
                                           [lenvep + k + 5, lenvep + k + 6],
                                           [lenvep + k + 6, lenvep + k + 7],
                                           [lenvep + k + 7, lenvep + k + 8],
                                           [lenvep + k + 9, lenvep + k + 1]]

                                outeob2 = [[lenvep + k, lenvep + k + 1],
                                           [lenvep + k + 1, lenvep + k + 2],
                                           [lenvep + k + 2, lenvep + k + 3],
                                           [lenvep + k + 3, lenvep + k + 4],
                                           [lenvep + k + 4, lenvep + k + 5],
                                           [lenvep + k + 5, lenvep + k + 6],
                                           [lenvep + k + 6, lenvep + k + 7],
                                           [lenvep + k + 7, lenvep + k + 8],
                                           [lenvep + k + 8, lenvep + k + 9]]
                                # наполнение списков lenvep = length(vecp)
                                newinds1.extend([[l1, lenvep + k],
                                                 [lenvep + k + 9, r1]])
                                newinds2.extend([[l2, lenvep + k + 9],
                                                 [lenvep + k, r2]])
                                '''Вектора'''
                                round1 = diry * thick_3
                                round2 = diry * thick_3 * sinuso30
                                round2_ = dirx / 3 + dirx * (2 * sinuso60 / 3)
                                round3 = diry * thick_3 * sinuso60_minus
                                round3_ = dirx / 3 + dirx * (2 * sinuso30 / 3)
                                round4 = dirx / 3
                                vupperob.extend([
                                    lz2, three + round1 - dirx,
                                    three + round2 - round2_,
                                    three + round3 - round3_, three - round4,
                                    three + round4, three + round3 + round3_,
                                    three + round2 + round2_,
                                    three + round1 + dirx, rz2
                                ])
                                vlowerob.extend([
                                    rz1, three - round1 - dirx,
                                    three - round2 - round2_,
                                    three - round3 - round3_, three - round4,
                                    three + round4, three - round3 + round3_,
                                    three - round2 + round2_,
                                    three - round1 + dirx, lz1
                                ])
                                k += 10
                            else:
                                '''рёбра'''
                                # пазы формируем независимо от верх низ
                                outeob1 = [[lenvep + k, lenvep + k + 1],
                                           [lenvep + k + 1, lenvep + k + 2],
                                           [lenvep + k + 2, lenvep + k + 3]]
                                outeob2 = [[lenvep + k, lenvep + k + 1],
                                           [lenvep + k + 1, lenvep + k + 2],
                                           [lenvep + k + 2, lenvep + k + 3]]
                                # наполнение списков lenvep = length(vecp)
                                newinds1.extend([[l1, lenvep + k],
                                                 [lenvep + k + 3, r1]])
                                newinds2.extend([[l2, lenvep + k + 3],
                                                 [lenvep + k, r2]])
                                '''Вектора'''
                                vupperob.extend(
                                    [lz2, three - dirx, three + dirx, rz2])
                                vlowerob.extend(
                                    [rz1, three + dirx, three - dirx, lz1])
                                k += 4
                            newinds1.extend(outeob1)
                            newinds2.extend(outeob2)
                            if self.bindCircle:
                                CP = self.circl_place
                                if CP == 'Midl':
                                    crcl_cntr = IL2P(one, two, Vector(
                                        (0, 0, 0)), Vector((0, 0, -1)))
                                elif CP == 'Up' and not fliped:
                                    crcl_cntr = two - diry * self.circle_rad * 2
                                elif CP == 'Down' and not fliped:
                                    crcl_cntr = one + diry * self.circle_rad * 2
                                elif CP == 'Up' and fliped:
                                    crcl_cntr = one + diry * self.circle_rad * 2
                                elif CP == 'Down' and fliped:
                                    crcl_cntr = two - diry * self.circle_rad * 2
                                # forgot howto 'else' in line iteration?
                                outeob1 = [[
                                    lenvep + k + i, lenvep + k + i + 1
                                ] for i in range(0, 11)]
                                outeob1.append([lenvep + k, lenvep + k + 11])
                                outeob2 = [[
                                    lenvep + k + i, lenvep + k + i + 1
                                ] for i in range(12, 23)]
                                outeob2.append(
                                    [lenvep + k + 12, lenvep + k + 23])
                                newinds1.extend(outeob1 + outeob2)
                                newinds2.extend(outeob1 + outeob2)
                                mat_rot_cir = n.rotation_difference(
                                    Vector((0, 0, 1))).to_matrix().to_4x4()
                                circle_to_add_1 = [vecir*mat_rot_cir+crcl_cntr+ \
                                        dirx_*self.circle_rad for vecir in circle ]
                                circle_to_add_2 = [vecir*mat_rot_cir+crcl_cntr- \
                                        dirx_*self.circle_rad for vecir in circle ]
                                vupperob.extend(circle_to_add_1 +
                                                circle_to_add_2)
                                vlowerob.extend(circle_to_add_1 +
                                                circle_to_add_2)
                                k += 24
                            if vec_tube and not tubes_flag_bed_solution_i_know:
                                for v in vec_tube:
                                    crcl_cntr = IL2P(v[0], v[1], l, n)
                                    if crcl_cntr:
                                        inside = crcl_cntr[0]<m1x and crcl_cntr[0]>m2x and crcl_cntr[1]<m1y \
                                             and crcl_cntr[1]>m2y and crcl_cntr[2]<=m1z and crcl_cntr[2]>=m2z
                                        if inside:
                                            outeob = [[
                                                lenvep + k + i,
                                                lenvep + k + i + 1
                                            ] for i in range(0, 23)]
                                            outeob.append(
                                                [lenvep + k, lenvep + k + 23])
                                            newinds1.extend(outeob)
                                            newinds2.extend(outeob)
                                            mat_rot_cir = n.rotation_difference(
                                                Vector(
                                                    (0, 0,
                                                     1))).to_matrix().to_4x4()
                                            circle_to_add = [
                                                vecir * mat_rot_cir + crcl_cntr
                                                for vecir in circle_tube
                                            ]
                                            vupperob.extend(circle_to_add)
                                            vlowerob.extend(circle_to_add)
                                            k += 24
                                tubes_flag_bed_solution_i_know = True
                        elif cop < 0.001 and inside and shortedge <= thick * threshold:
                            vupperob.extend([one, two])
                            vlowerob.extend([one, two])
                            newinds1.append([lenvep + k, lenvep + k + 1])
                            newinds2.append([lenvep + k, lenvep + k + 1])
                            k += 2
                    del tree
                    for e in deledges1:
                        if e in newinds1:
                            newinds1.remove(e)
                    for e in deledges2:
                        if e in newinds2:
                            newinds2.remove(e)
                    if vupperob or vlowerob:
                        outeup.append(newinds2)
                        outelo.append(newinds1)
                        vupper.append(vupperob)
                        vlower.append(vlowerob)
                vupper = Vector_degenerate(vupper)
                vlower = Vector_degenerate(vlower)
                centers = Vector_degenerate([centers])

                if 'vertUp' in self.outputs and self.outputs['vertUp'].links:
                    out = dataCorrect(vupper)
                    SvSetSocketAnyType(self, 'vertUp', out)
                if 'edgeUp' in self.outputs and self.outputs['edgeUp'].links:
                    SvSetSocketAnyType(self, 'edgeUp', outeup)
                if 'vertLo' in self.outputs and self.outputs['vertLo'].links:
                    SvSetSocketAnyType(self, 'vertLo', vlower)
                if 'edgeLo' in self.outputs and self.outputs['edgeLo'].links:
                    SvSetSocketAnyType(self, 'edgeLo', outelo)
                if 'centers' in self.outputs and self.outputs['centers'].links:
                    SvSetSocketAnyType(self, 'centers', centers)
                print(self.name, 'is finishing')