本文整理汇总了Python中sverchok.data_structure.dataCorrect函数的典型用法代码示例。如果您正苦于以下问题:Python dataCorrect函数的具体用法?Python dataCorrect怎么用?Python dataCorrect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dataCorrect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: generate_callback
def generate_callback(self, n_id, IV):
inputs = self.inputs
verts, matrices = [], []
text = ''
# gather vertices from input
propv = inputs['vertices'].sv_get()
verts = dataCorrect(propv)
# end early, no point doing anything else.
if not verts:
return
# draw text on locations instead of indices.
text_so = inputs['text'].sv_get(default=[])
text = dataCorrect(text_so)
if text:
fullList(text, len(verts))
for i, t in enumerate(text):
fullList(text[i], len(verts[i]))
# read non vertex inputs in a loop and assign to data_collected
data_collected = []
for socket in ['edges', 'faces', 'matrix']:
propm = inputs[socket].sv_get(default=[])
input_stream = dataCorrect(propm)
data_collected.append(input_stream)
edges, faces, matrices = data_collected
bg = self.draw_bg
settings = self.get_settings()
IV.callback_enable(
n_id, verts, edges, faces, matrices, bg, settings, text)
开发者ID:elfnor,项目名称:sverchok,代码行数:35,代码来源:viewer_indices.py
示例2: process
def process(self):
if not any(s.is_linked for s in self.outputs):
return
if self.inputs["Vertices"].is_linked and self.inputs["Poly Egde"].is_linked:
verts = self.inputs["Vertices"].sv_get()
poly = self.inputs["Poly Egde"].sv_get()
verts = dataCorrect(verts)
poly = dataCorrect(poly)
self.inputs["Mask"].sv_get(default=[[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)
self.outputs["Vertices"].sv_set(verts_out)
self.outputs["Poly Egde"].sv_set(poly_edge_out)
开发者ID:nortikin,项目名称:sverchok,代码行数:33,代码来源:vertices_mask.py
示例3: process
def process(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)
开发者ID:BitByte01,项目名称:myblendercontrib,代码行数:56,代码来源:viewer.py
示例4: process
def process(self):
if not (self.id_data.sv_show and self.activate):
callback_disable(node_id(self))
return
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
# this should catch accidental connections which otherwise will cause
# an unrecoverable crash. It might even be an idea to have step in between
# new connections and processing, it could auto rewire s->s v->v m->m.
def check_origin(to_socket, socket_type):
sock_string = sock_dict.get(socket_type)
return inputs[to_socket].links[0].from_socket.bl_idname == sock_string
vertex_links = inputs['vertices'].is_linked and check_origin('vertices', 'v')
matrix_links = inputs['matrix'].is_linked and check_origin('matrix', 'm')
edgepol_links = inputs['edg_pol'].is_linked and check_origin('edg_pol', 's')
if (vertex_links or matrix_links):
if vertex_links:
propv = inputs['vertices'].sv_get(deepcopy=False, default=[])
if propv:
verts = dataCorrect(propv)
for v in verts:
if any(l != 3 for l in map(len, v)):
raise ValueError
cache_viewer_baker[vertex_ref] = verts
if edgepol_links:
prope = inputs['edg_pol'].sv_get(deepcopy=False, default=[])
if prope:
cache_viewer_baker[poledg_ref] = dataCorrect(prope)
if matrix_links:
propm = inputs['matrix'].sv_get(deepcopy=False, default=[])
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()
callback_enable(n_id, cache_viewer_baker, config_options)
开发者ID:rangerBR,项目名称:sverchok,代码行数:55,代码来源:viewer_mk2.py
示例5: process
def process(self):
if not self.outputs["data"].is_linked:
return
data_ = self.inputs["data"].sv_get()
data = dataCorrect(data_, nominal_dept=self.level)
out_ = []
for obj in data:
out_.append(svQsort(obj))
out = dataCorrect(out_)
self.outputs["data"].sv_set(out)
开发者ID:gsp40213,项目名称:sverchok,代码行数:11,代码来源:sort.py
示例6: execute
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"}
开发者ID:nortikin,项目名称:sverchok,代码行数:15,代码来源:viewer.py
示例7: process
def process(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] = []
开发者ID:elfnor,项目名称:sverchok,代码行数:48,代码来源:bakery.py
示例8: get_input_or_default
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)
开发者ID:ma-ric,项目名称:sverchok,代码行数:30,代码来源:script.py
示例9: process
def process(self):
if self.inputs['data'].is_linked and self.outputs['data'].is_linked:
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)
开发者ID:BitByte01,项目名称:myblendercontrib,代码行数:7,代码来源:flip.py
示例10: process
def process(self):
"""
colorsys.rgb_to_yiq(r, g, b)
colorsys.yiq_to_rgb(y, i, q)
colorsys.rgb_to_hls(r, g, b)
colorsys.hls_to_rgb(h, l, s)
colorsys.rgb_to_hsv(r, g, b)
colorsys.hsv_to_rgb(h, s, v)
"""
color_input = self.inputs['Colors']
if color_input.is_linked:
abc = self.inputs['Colors'].sv_get()
data = dataCorrect(abc)
else:
data = [[self.unit_color[:]]]
A, B, C, D = [], [], [], []
if self.use_alpha:
for obj in data:
a_, b_, c_, d_ = (list(x) for x in zip(*obj))
A.append(a_)
B.append(b_)
C.append(c_)
D.append(d_)
for i, socket in enumerate(self.outputs):
self.outputs[socket.name].sv_set([A, B, C, D][i])
else:
for obj in data:
a_, b_, c_ = (list(x) for x in zip(*obj))
A.append(a_)
B.append(b_)
C.append(c_)
for i, socket in enumerate(self.outputs[:3]):
self.outputs[socket.name].sv_set([A, B, C][i])
开发者ID:nortikin,项目名称:sverchok,代码行数:35,代码来源:color_out_mk1.py
示例11: process
def process(self):
if not any(s.is_linked for s in self.outputs):
return
if self.inputs['Vertices'].is_linked:
verts = self.inputs['Vertices'].sv_get()
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)
self.outputs['Vertices'].sv_set(verts_out)
开发者ID:elfnor,项目名称:sverchok,代码行数:25,代码来源:interpolation.py
示例12: process
def process(self):
if not any(s.is_linked for s in self.outputs):
return
if self.inputs['Vertices'].is_linked:
verts = self.inputs['Vertices'].sv_get()
verts = dataCorrect(verts)
t_ins_x = self.inputs['IntervalX'].sv_get()
t_ins_y = self.inputs['IntervalY'].sv_get()
if self.regime == 'P' and self.direction == 'U':
self.direction = 'UV'
if self.defgrid:
t_ins_x = [[i/10 for i in range(11)]]
t_ins_y = [[i/10 for i in range(11)]]
if self.regime == 'G':
vertsX = self.interpol(verts, t_ins_x)
if self.direction == 'UV':
verts_T = np.swapaxes(np.array(vertsX),0,1).tolist()
verts_out = self.interpol(verts_T, t_ins_y)
else:
verts_out = vertsX
else:
verts_out_ = []
for x,y in zip(t_ins_x[0],t_ins_y[0]):
vertsX = self.interpol(verts, [[x]])
verts_T = np.swapaxes(np.array(vertsX),0,1).tolist()
vertsY = self.interpol(verts_T, [[y]])
verts_out_.extend(vertsY)
verts_out = [[i[0] for i in verts_out_]]
self.outputs['Vertices'].sv_set(verts_out)
开发者ID:elfnor,项目名称:sverchok,代码行数:33,代码来源:interpolation_mk2.py
示例13: get_corrected_data
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):
return dataCorrect(inputs[socket_name].sv_get())
else:
return []
开发者ID:elfnor,项目名称:sverchok,代码行数:7,代码来源:instancer.py
示例14: process
def process(self):
if not self.outputs[0].is_linked:
return
X_ = self.inputs['pols'].sv_get()
X = dataCorrect(X_)
result = pols_edges(X, self.unique_edges)
self.outputs['edgs'].sv_set(result)
开发者ID:elfnor,项目名称:sverchok,代码行数:7,代码来源:polygons_to_edges.py
示例15: process
def process(self):
verts_socket, polys_socket = self.inputs
vol_socket = self.outputs[0]
if vol_socket.is_linked and verts_socket.is_linked: # and polys_socket.is_linked ?
vertices = Vector_generate(dataCorrect(verts_socket.sv_get()))
faces = dataCorrect(polys_socket.sv_get())
out = []
for verts_obj, faces_obj in zip(vertices, faces):
bm = bmesh_from_pydata(verts_obj, [], faces_obj, normal_update=True)
out.append(bm.calc_volume())
bm.free()
vol_socket.sv_set(out)
开发者ID:elfnor,项目名称:sverchok,代码行数:16,代码来源:volume.py
示例16: get_corrected_data
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 []
开发者ID:BitByte01,项目名称:myblendercontrib,代码行数:8,代码来源:instancer.py
示例17: meta_get
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].is_linked:
socket_in = inputs[s_name].sv_get()
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
开发者ID:nortikin,项目名称:sverchok,代码行数:18,代码来源:profile.py
示例18: process
def process(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)
开发者ID:BitByte01,项目名称:myblendercontrib,代码行数:9,代码来源:polygons_to_edges.py
示例19: process
def process(self):
if self.outputs['Volume'].is_linked and self.inputs['Vers'].is_linked:
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'].is_linked:
SvSetSocketAnyType(self, 'Volume', out)
开发者ID:BitByte01,项目名称:myblendercontrib,代码行数:18,代码来源:volume.py
示例20: process
def process(self):
if not (self.id_data.sv_show and self.activate):
callback_disable(node_id(self))
return
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'].is_linked
matrix_links = inputs['matrix'].is_linked
edgepol_links = inputs['edg_pol'].is_linked
if vertex_links or matrix_links:
if vertex_links:
propv = inputs['vertices'].sv_get(deepcopy=False, default=[])
if propv:
cache_viewer_baker[vertex_ref] = dataCorrect(propv)
if edgepol_links:
prope = inputs['edg_pol'].sv_get(deepcopy=False, default=[])
if prope:
cache_viewer_baker[poledg_ref] = dataCorrect(prope)
if matrix_links:
propm = inputs['matrix'].sv_get(deepcopy=False, default=[])
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()
callback_enable(n_id, cache_viewer_baker, config_options)
开发者ID:johnyc90,项目名称:sverchok,代码行数:44,代码来源:viewer_mk2.py
注:本文中的sverchok.data_structure.dataCorrect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论