本文整理汇总了Python中sverchok.data_structure.match_long_repeat函数的典型用法代码示例。如果您正苦于以下问题:Python match_long_repeat函数的具体用法?Python match_long_repeat怎么用?Python match_long_repeat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了match_long_repeat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
def process(self):
if not self.outputs['Vertices'].is_linked:
return
Vertices = self.inputs['Vertices'].sv_get(default=[])
if 'Vert A' in self.inputs:
Vert_A = self.inputs['Vert A'].sv_get(default=[[[0.0, 0.0, 0.0]]])[0]
if 'Vert B' in self.inputs:
Vert_B = self.inputs['Vert B'].sv_get(default=[[[1.0, 0.0, 0.0]]])[0]
if 'Plane' in self.inputs:
Plane = self.inputs['Plane'].sv_get(default=[Matrix()])
# outputs
if self.mode == 'VERTEX':
parameters = match_long_repeat([Vertices, Vert_A])
points = [mirrorPoint(v, a) for v, a in zip(*parameters)]
self.outputs['Vertices'].sv_set(points)
elif self.mode == 'AXIS':
parameters = match_long_repeat([Vertices, Vert_A, Vert_B])
points = [mirrorAxis(v, a, b) for v, a, b in zip(*parameters)]
self.outputs['Vertices'].sv_set(points)
elif self.mode == 'PLANE':
parameters = match_long_repeat([Vertices, Plane])
points = [mirrorPlane(v, p) for v, p in zip(*parameters)]
self.outputs['Vertices'].sv_set(points)
示例2: process
def process(self):
# inputs
if self.mode == 'AXIS':
Vertices = self.inputs['Vertices'].sv_get()
Angle = self.inputs['Angle'].sv_get()
Center = self.inputs['Center'].sv_get(default=[[[0.0, 0.0, 0.0]]])
Axis = self.inputs['Axis'].sv_get(default=[[[0.0, 0.0, 1.0]]])
parameters = match_long_repeat([Vertices, Center, Axis, Angle])
elif self.mode == 'EULER' or self.mode == 'QUAT':
Vertices = self.inputs['Vertices'].sv_get()
X = self.inputs['X'].sv_get()[0]
Y = self.inputs['Y'].sv_get()[0]
Z = self.inputs['Z'].sv_get()[0]
parameters = match_long_repeat([Vertices, X, Y, Z, [self.order]])
if self.mode == 'QUAT':
if 'W' in self.inputs:
W = self.inputs['W'].sv_get()[0]
else:
W = [self.w_]
parameters = match_long_repeat([Vertices, X, Y, Z, W])
# outputs
if self.mode == 'AXIS':
points = [axis_rotation(v, c, d, a) for v, c, d, a in zip(*parameters)]
self.outputs['Vertices'].sv_set(points)
elif self.mode == 'EULER':
points = [euler_rotation(v, x, y, z, o) for v, x, y, z, o in zip(*parameters)]
self.outputs['Vertices'].sv_set(points)
elif self.mode == 'QUAT':
points = [quat_rotation(m, x, y, z, w) for m, x, y, z, w in zip(*parameters)]
self.outputs['Vertices'].sv_set(points)
示例3: unit_generator
def unit_generator(self, idx, geometry):
verts, _, _, radiix, radiiy = geometry
ntimes = len(verts)
radiix, _ = match_long_repeat([radiix, verts])
radiiy, _ = match_long_repeat([radiiy, verts])
# assign radii after creation
obj, data_layers = make_bmesh_geometry(self, bpy.context, geometry, idx, [radiix, radiiy])
if data_layers and self.distance_doubles > 0.0:
# This sets the modified geometry with radius x and radius y.
f_r = list(itertools.chain(*zip(data_layers[0], data_layers[1])))
f_r = [abs(f) for f in f_r]
obj.data.skin_vertices[0].data.foreach_set('radius', f_r)
all_yes = list(itertools.repeat(True, len(obj.data.vertices)))
obj.data.skin_vertices[0].data.foreach_set('use_root', all_yes)
elif len(radiix) == len(verts):
f_r = list(itertools.chain(*zip(radiix, radiiy)))
f_r = [abs(f) for f in f_r]
obj.data.skin_vertices[0].data.foreach_set('radius', f_r)
if self.use_root:
# set all to root
all_yes = list(itertools.repeat(True, ntimes))
obj.data.skin_vertices[0].data.foreach_set('use_root', all_yes)
elif self.use_slow_root:
process_mesh_into_features(obj.data.skin_vertices[0].data, obj.data.edge_keys)
# truthy if self.material is in .materials
if bpy.data.materials.get(self.material):
self.set_corresponding_materials([obj])
示例4: process
def process(self):
outputs = self.outputs
# return if no outputs are connected
if not any(s.is_linked for s in outputs):
return
inputs = self.inputs
all_AZ_sockets = list(filter(lambda s: s.name in ABC, inputs))
connected_AZ_sockets = list(filter(lambda s: s.is_linked, all_AZ_sockets))
# collect the data inputs from all connected AZ sockets
I = [s.sv_get()[0] for s in connected_AZ_sockets]
if self.operation == "PRODUCT":
R = inputs["Repeat"].sv_get()[0]
R = list(map(lambda x: max(1, int(x)), R))
parameters = match_long_repeat([[I], R])
else: # PERMUTATIONS / COMBINATIONS
L = inputs["Length"].sv_get()[0]
L = list(map(lambda x: max(0, int(x)), L))
parameters = match_long_repeat([I, L])
function = operations[self.operation][1]
resultList = []
for sequence, v in zip(*parameters):
if self.operation in {"PERMUTATIONS", "COMBINATIONS"}:
if v == 0 or v > len(sequence):
v = len(sequence)
result = [list(a) for a in function(sequence, v)]
resultList.append(result)
outputs["Result"].sv_set(resultList)
示例5: process
def process(self):
# inputs
if 'Vertices' in self.inputs and self.inputs['Vertices'].is_linked:
Vertices = SvGetSocketAnyType(self, self.inputs['Vertices'])
else:
Vertices = []
if 'Vert A' in self.inputs and self.inputs['Vert A'].is_linked:
Vert_A = SvGetSocketAnyType(self, self.inputs['Vert A'])[0]
else:
Vert_A = [[0.0, 0.0, 0.0]]
if 'Vert B' in self.inputs and self.inputs['Vert B'].is_linked:
Vert_B = SvGetSocketAnyType(self, self.inputs['Vert B'])[0]
else:
Vert_B = [[1.0, 0.0, 0.0]]
if 'Plane' in self.inputs and self.inputs['Plane'].is_linked:
Plane = SvGetSocketAnyType(self, self.inputs['Plane'])
else:
Plane = [Matrix()]
# outputs
if 'Vertices' in self.outputs and self.outputs['Vertices'].is_linked:
if self.mode == 'VERTEX':
parameters = match_long_repeat([Vertices, Vert_A])
points = [mirrorPoint(v, a) for v, a in zip(*parameters)]
SvSetSocketAnyType(self, 'Vertices', points)
elif self.mode == 'AXIS':
parameters = match_long_repeat([Vertices, Vert_A, Vert_B])
points = [mirrorAxis(v, a, b) for v, a, b in zip(*parameters)]
SvSetSocketAnyType(self, 'Vertices', points)
elif self.mode == 'PLANE':
parameters = match_long_repeat([Vertices, Plane])
points = [mirrorPlane(v, p) for v, p in zip(*parameters)]
SvSetSocketAnyType(self, 'Vertices', points)
示例6: process
def process(self):
outputs = self.outputs
if not any(s.is_linked for s in outputs):
return
inputs = self.inputs
all_AZ_sockets = list(filter(lambda s: s.name in ABC, inputs))
connected_AZ_sockets = list(filter(lambda s: s.is_linked, all_AZ_sockets))
if len(connected_AZ_sockets) == 0:
return
# collect the quaternion inputs from all connected AZ sockets
I = [s.sv_get(default=id_quat)[0] for s in connected_AZ_sockets]
if self.operation in prepost_operations:
if self.prePost == "POST": # A op B : keep input order
I = I[::-1]
other_sockets = list(filter(lambda s: s.name not in ABC and not s.hide, inputs))
# collect the remaning visible inputs
for socket in other_sockets:
values = socket.sv_get()[0]
if socket.name == "Scale":
qs = []
for s in values:
swxyz = [s if self.scales[i] else 1.0 for i in range(4)]
qs.append(Quaternion(swxyz))
values = qs
I.append(values)
operation = self.get_operation()
if self.operation in NQ_operations:
parameters = match_long_repeat(I)
quaternionList = [operation(params) for params in zip(*parameters)]
elif self.operation in QQ_operations:
parameters = match_long_repeat(I)
quaternionList = [operation(*params) for params in zip(*parameters)]
elif self.operation == "SCALE":
parameters = match_long_repeat(I)
quaternionList = [operation(*params) for params in zip(*parameters)]
else: # single input operations
parameters = I[0] # just quaternion values
quaternionList = [operation(a) for a in parameters]
if self.operation in output_S_operations:
if outputs['Value'].is_linked:
outputs['Value'].sv_set([quaternionList])
else: # output quaternions
if outputs['Quaternion'].is_linked:
outputs['Quaternion'].sv_set([quaternionList])
示例7: process
def process(self):
if not self.outputs['Quaternions'].is_linked:
return
inputs = self.inputs
quaternionList = []
if self.mode == "WXYZ":
I = [inputs[n].sv_get()[0] for n in "WXYZ"]
params = match_long_repeat(I)
for wxyz in zip(*params):
q = Quaternion(wxyz)
if self.normalize:
q.normalize()
quaternionList.append(q)
elif self.mode == "SCALARVECTOR":
I = [inputs[n].sv_get()[0] for n in ["Scalar", "Vector"]]
params = match_long_repeat(I)
for scalar, vector in zip(*params):
q = Quaternion([scalar, *vector])
if self.normalize:
q.normalize()
quaternionList.append(q)
elif self.mode == "EULER":
I = [inputs["Angle " + n].sv_get()[0] for n in "XYZ"]
params = match_long_repeat(I)
au = angleConversion[self.angleUnits]
for angleX, angleY, angleZ in zip(*params):
euler = Euler((angleX * au, angleY * au, angleZ * au), self.eulerOrder)
q = euler.to_quaternion()
if self.normalize:
q.normalize()
quaternionList.append(q)
elif self.mode == "AXISANGLE":
I = [inputs[n].sv_get()[0] for n in ["Axis", "Angle"]]
params = match_long_repeat(I)
au = angleConversion[self.angleUnits]
for axis, angle in zip(*params):
q = Quaternion(axis, angle * au)
if self.normalize:
q.normalize()
quaternionList.append(q)
elif self.mode == "MATRIX":
input_M = inputs["Matrix"].sv_get(default=idMat)
for m in input_M:
q = Matrix(m).to_quaternion()
if self.normalize:
q.normalize()
quaternionList.append(q)
self.outputs['Quaternions'].sv_set([quaternionList])
示例8: process
def process(self):
# return if no outputs are connected
if not any(s.is_linked for s in self.outputs):
return
# input values lists (single or multi value)
input_RR = self.inputs["R"].sv_get()[0] # list of MAJOR or EXTERIOR radii
input_rr = self.inputs["r"].sv_get()[0] # list of MINOR or INTERIOR radii
input_n1 = self.inputs["n1"].sv_get()[0] # list of number of MAJOR sections
input_n2 = self.inputs["n2"].sv_get()[0] # list of number of MINOR sections
input_rP = self.inputs["rP"].sv_get()[0] # list of REVOLUTION phases
input_sP = self.inputs["sP"].sv_get()[0] # list of SPIN phases
input_sT = self.inputs["sT"].sv_get()[0] # list of SPIN twists
# bound check the list values
input_RR = list(map(lambda x: max(0, x), input_RR))
input_rr = list(map(lambda x: max(0, x), input_rr))
input_n1 = list(map(lambda x: max(3, int(x)), input_n1))
input_n2 = list(map(lambda x: max(3, int(x)), input_n2))
# convert input radii values to MAJOR/MINOR, based on selected mode
if self.mode == 'EXT_INT':
# convert radii from EXTERIOR/INTERIOR to MAJOR/MINOR
# (extend radii lists to a matching length before conversion)
input_RR, input_rr = match_long_repeat([input_RR, input_rr])
input_R = list(map(lambda x, y: (x + y) * 0.5, input_RR, input_rr))
input_r = list(map(lambda x, y: (x - y) * 0.5, input_RR, input_rr))
else: # values already given as MAJOR/MINOR radii
input_R = input_RR
input_r = input_rr
parameters = match_long_repeat([input_R, input_r, input_n1, input_n2, input_rP, input_sP, input_sT])
if self.outputs['Vertices'].is_linked or self.outputs['Normals'].is_linked:
vertList = []
normList = []
for R, r, n1, n2, rP, sP, sT in zip(*parameters):
verts, norms = torus_verts(R, r, n1, n2, rP, sP, sT, self.Separate)
vertList.append(verts)
normList.append(norms)
self.outputs['Vertices'].sv_set(vertList)
self.outputs['Normals'].sv_set(normList)
if self.outputs['Edges'].is_linked:
edgeList = []
for R, r, n1, n2, rP, sP, sT in zip(*parameters):
edges = torus_edges(n1, n2, sT)
edgeList.append(edges)
self.outputs['Edges'].sv_set(edgeList)
if self.outputs['Polygons'].is_linked:
polyList = []
for R, r, n1, n2, rP, sP, sT in zip(*parameters):
polys = torus_polygons(n1, n2, sT)
polyList.append(polys)
self.outputs['Polygons'].sv_set(polyList)
示例9: process
def process(self):
# return if no outputs are connected
if not any(s.is_linked for s in self.outputs):
return
# input values lists
inputs = self.inputs
input_level = inputs["Level"].sv_get()[0] if "Level" in inputs else [0]
input_numx = inputs["NumX"].sv_get()[0] if "NumX" in inputs else [1]
input_numy = inputs["NumY"].sv_get()[0] if "NumY" in inputs else [1]
input_radius = inputs["Radius"].sv_get()[0]
input_angle = inputs["Angle"].sv_get()[0]
input_scale = inputs["Scale"].sv_get()[0]
# sanitize the input values
input_level = list(map(lambda x: max(1, x), input_level))
input_numx = list(map(lambda x: max(1, x), input_numx))
input_numy = list(map(lambda x: max(1, x), input_numy))
input_radius = list(map(lambda x: max(0, x), input_radius))
input_scale = list(map(lambda x: max(0, x), input_scale))
# generate the vectorized grids
paramLists = []
if self.gridLayout == 'RECTANGLE':
paramLists.extend([input_radius, input_angle, input_numx, input_numy])
else: # TRIANGLE, DIAMOND HEXAGON layouts
paramLists.extend([input_radius, input_angle, input_level])
params = match_long_repeat(paramLists)
gridList = [generate_grid(self.center, self.gridLayout, args) for args in zip(*params)]
self.outputs['Centers'].sv_set(gridList)
# generate the vectorized tiles only if any of VEP outputs are linked
_, V, E, P = self.outputs[:]
if not any(s.is_linked for s in [V, E, P]):
return
params = match_long_repeat([input_radius, input_angle, input_scale, gridList])
vertList, edgeList, polyList = [[], [], []]
for r, a, s, grid in zip(*params):
verts, edges, polys = generate_tiles(r * s, a, self.separate, [grid])
vertList.extend(verts)
edgeList.extend(edges)
polyList.extend(polys)
self.outputs['Vertices'].sv_set(vertList)
self.outputs['Edges'].sv_set(edgeList)
self.outputs['Polygons'].sv_set(polyList)
示例10: process
def process(self):
# inputs
inputs = self.inputs
RadiusTop = inputs['RadTop'].sv_get()[0]
RadiusBot = inputs['RadBot'].sv_get()[0]
Vertices = [max(int(v), 3) for v in inputs['Vertices'].sv_get()[0]]
Height = inputs['Height'].sv_get()[0]
Sub = [max(int(s), 0) for s in inputs['Subdivisions'].sv_get()[0]]
params = match_long_repeat([Sub, Vertices, Height, RadiusBot, RadiusTop])
# outputs
if self.outputs['Vertices'].is_linked:
points = [cylinder_vertices(s, v, h, rb, rt, self.Separate)
for s, v, h, rb, rt in zip(*params)]
self.outputs['Vertices'].sv_set(points)
if self.outputs['Edges'].is_linked:
edges = [cylinder_edges(s, v)
for s, v, h, rb, rt in zip(*params)]
self.outputs['Edges'].sv_set(edges)
if self.outputs['Polygons'].is_linked:
faces = [cylinder_faces(s, v, self.cap_)
for s, v, h, rb, rt in zip(*params)]
self.outputs['Polygons'].sv_set(faces)
示例11: process
def process(self):
o,s,e = self.inputs
S,P,N,I = self.outputs
outfin,OutLoc,obj,sm1,sm2 = [],[],o.sv_get(),self.mode,self.mode2
st, en = match_long_repeat([s.sv_get()[0], e.sv_get()[0]])
for OB in obj:
if sm1:
obm = OB.matrix_local.inverted()
outfin.append([OB.ray_cast(obm*Vector(i), obm*Vector(i2)) for i,i2 in zip(st,en)])
else:
outfin.append([OB.ray_cast(i,i2) for i,i2 in zip(st,en)])
if sm2:
if P.is_linked:
for i,i2 in zip(obj,outfin):
omw = i.matrix_world
OutLoc.append([(omw*i[1])[:] for i in i2])
P.sv_set(OutLoc)
else:
if P.is_linked:
P.sv_set([[i[1][:] for i in i2] for i2 in outfin])
if S.is_linked:
S.sv_set([[i[0] for i in i2] for i2 in outfin])
if N.is_linked:
N.sv_set([[i[2][:] for i in i2] for i2 in outfin])
if I.is_linked:
I.sv_set([[i[3] for i in i2] for i2 in outfin])
示例12: process
def process(self):
if not self.outputs[0].is_linked:
return
var_names = self.get_variables()
inputs = self.get_input()
results = []
if var_names:
input_values = [inputs.get(name, []) for name in var_names]
parameters = match_long_repeat(input_values)
else:
parameters = [[[]]]
for values in zip(*parameters):
variables = dict(zip(var_names, values))
vector = []
for formula in self.formulas():
if formula:
value = safe_eval(formula, variables)
vector.append(value)
if self.separate:
results.append(vector)
else:
results.extend(vector)
if self.wrap:
results = [results]
self.outputs['Result'].sv_set(results)
示例13: process
def process(self):
inputs, outputs = self.inputs, self.outputs
# inputs
if inputs["Radius"].is_linked:
Radius = inputs["Radius"].sv_get(deepcopy=False)[0]
else:
Radius = [self.rad_]
if inputs["Nº Vertices"].is_linked:
Vertices = inputs["Nº Vertices"].sv_get(deepcopy=False)[0]
Vertices = list(map(lambda x: max(3, int(x)), Vertices))
else:
Vertices = [self.vert_]
Angle = inputs["Degrees"].sv_get(deepcopy=False)[0]
if inputs["Degrees"].is_linked:
Angle = list(map(lambda x: min(360, max(0, x)), Angle))
parameters = match_long_repeat([Angle, Vertices, Radius])
# outputs
if outputs["Vertices"].is_linked:
points = [self.make_verts(a, v, r) for a, v, r in zip(*parameters)]
outputs["Vertices"].sv_set(points)
if outputs["Edges"].is_linked:
edg = [self.make_edges(v, a) for a, v, r in zip(*parameters)]
outputs["Edges"].sv_set(edg)
if outputs["Polygons"].is_linked:
plg = [self.make_faces(a, v) for a, v, r in zip(*parameters)]
outputs["Polygons"].sv_set(plg)
示例14: process
def process(self):
if not self.activate:
return
# only interested in the first
geometry = self.get_geometry_from_sockets()
make_bmesh_geometry(self, bpy.context, geometry)
if not self.live_updates:
return
# assign radii after creation
obj = bpy.data.objects[self.basemesh_name]
i = self.inputs
ntimes = len(geometry[0])
if i['radii'].is_linked:
radii = i['radii'].sv_get()[0]
radii, delete = match_long_repeat([radii,geometry[0]])
# perhaps extend to fullList if given list length doesn't match.
# maybe also indicate this failure somehow in the UI?
else:
radii = list(itertools.repeat(self.general_radius, ntimes))
# for now don't update unless
if len(radii) == len(geometry[0]):
f_r = list(itertools.chain(*zip(radii, radii)))
obj.data.skin_vertices[0].data.foreach_set('radius', f_r)
# set all to root
all_yes = list(itertools.repeat(True, ntimes))
obj.data.skin_vertices[0].data.foreach_set('use_root', all_yes)
# truthy if self.material is in .materials
if bpy.data.materials.get(self.material):
self.set_corresponding_materials([obj])
示例15: process
def process(self):
so = self.outputs
OutLoc = []
OutNorm = []
Succ = []
ObjectID = []
OutMatrix = []
st = self.inputs['start'].sv_get()[0]
en = self.inputs['end'].sv_get()[0]
st, en = match_long_repeat([st, en])
for i, last in enumerate(en):
rc = bpy.context.scene.ray_cast(st[i], last)
OutLoc.append(rc[3][:])
OutNorm.append(rc[4][:])
Succ.append(rc[0])
ObjectID.append(rc[1])
if so['hited object matrix'].is_linked:
OutMatrix.append([[a[:], b[:], c[:], d[:]] for a, b, c, d in [rc[2][:]]])
so['HitP'].sv_set([OutLoc])
so['HitNorm'].sv_set([OutNorm])
so['Succes'].sv_set([Succ])
so['Objects'].sv_set(ObjectID)
so['hited object matrix'].sv_set(OutMatrix)