File:Szilassi polyhedron.stl
此STL文件的PNG预览的大小:800 × 600像素。 其他分辨率:320 × 240像素 | 640 × 480像素 | 1,024 × 768像素 | 1,280 × 960像素 | 2,560 × 1,920像素 | 5,120 × 3,840像素。
原始文件 (5,120 × 2,880像素,文件大小:1 KB,MIME类型:application/sla)
View Szilassi polyhedron.stl on viewstl.com
摘要
描述Szilassi polyhedron.stl |
English: Szilassi polyhedron (polyhedron with complete face adjacency) by CMG Lee. |
日期 | |
来源 | 自己的作品 |
作者 | Cmglee |
Python source
#!/usr/bin/env python
header = 'Szilassi polyhedron (polyhedron with complete face adjacency) by CMG Lee.'
vertexsss = [ ## [i_vertex][property][x,y,z etc]
{'xyz':(-240, 0, 240), 'colour':'#f90', 'label':'G'},
{'xyz':( 240, 0, 240), 'colour':'#960', 'label':'H'},
{'xyz':( 0,-252,-240), 'colour':'#069', 'label':'B'},
{'xyz':( 0, 252,-240), 'colour':'#0cf', 'label':'M'},
{'xyz':( 40,-100,-160), 'colour':'#060', 'label':'C'},
{'xyz':( -40, 100,-160), 'colour':'#090', 'label':'L'},
{'xyz':( -75, -75, -60), 'colour':'#009', 'label':'D'},
{'xyz':( 75, 75, -60), 'colour':'#00f', 'label':'K'},
{'xyz':( 90, -50, 40), 'colour':'#909', 'label':'E'},
{'xyz':( -90, 50, 40), 'colour':'#f0f', 'label':'J'},
{'xyz':(-140, 0, 40), 'colour':'#000', 'label':'A'},
{'xyz':( 140, 0, 40), 'colour':'#666', 'label':'N'},
{'xyz':(-140, -50, 40), 'colour':'#900', 'label':'F'},
{'xyz':( 140, 50, 40), 'colour':'#f00', 'label':'I'}]
facesss = [ ## [i_face][property][i_vertex etc]
{'vertexss':[(11,13, 9,10,12, 8) ],'flip':False, 'colour':'#999'},
{'vertexss':[( 6, 4, 2,10, 9, 7) ],'flip':False, 'colour':'#f66'},
{'vertexss':[( 7, 5, 3,11, 8, 6) ],'flip':False, 'colour':'#66f'},
{'vertexss':[( 9,13, 1, 0, 5, 7) ],'flip':False, 'colour':'#0c0'},
{'vertexss':[( 8,12, 0, 1, 4, 6) ],'flip':False, 'colour':'#fc0'},
{'vertexss':[( 5,10, 2, 3),(0,12,10,5)],'flip':False, 'colour':'#c9f'},
{'vertexss':[( 4,11, 3, 2),(1,13,11,4)],'flip':False, 'colour':'#6cf'}]
import re, struct, math
def fmt(string): ## string.format(**vars()) using tags {expression!format} by CMG Lee
def f(tag): i_sep = tag.rfind('!'); return (re.sub('\.0+$', '', str(eval(tag[1:-1])))
if (i_sep < 0) else ('{:%s}' % tag[i_sep + 1:-1]).format(eval(tag[1:i_sep])))
return (re.sub(r'(?<!{){[^{}]+}', lambda m:f(m.group()), string)
.replace('{{', '{').replace('}}', '}'))
def append(obj, string): return obj.append(fmt(string))
def tabbify(cellss, separator='|'):
cellpadss = [list(rows) + [''] * (len(max(cellss, key=len)) - len(rows)) for rows in cellss]
fmts = ['%%%ds' % (max([len(str(cell)) for cell in cols])) for cols in zip(*cellpadss)]
return '\n'.join([separator.join(fmts) % tuple(rows) for rows in cellpadss])
def hex_rgb(colour): ## convert [#]RGB to #RRGGBB and [#]RRGGBB to #RRGGBB
return '#%s' % (colour if len(colour) > 4 else ''.join([c * 2 for c in colour])).lstrip('#')
def viscam_colour(colour):
colour_hex = hex_rgb(colour)
colour_top5bits = [int(colour_hex[i:i+2], 16) >> 3 for i in range(1,7,2)]
return (1 << 15) + (colour_top5bits[0] << 10) + (colour_top5bits[1] << 5) + colour_top5bits[2]
def roundm(x, multiple=1):
if (isinstance(x, tuple)): return tuple(roundm(list(x), multiple))
elif (isinstance(x, list )): return [roundm(x_i, multiple) for x_i in x]
else: return int(math.floor(float(x) / multiple + 0.5)) * multiple
def flatten(lss): return [l for ls in lss for l in ls]
def rotate(facetss, degs): ## around x then y then z axes
(deg_x,deg_y,deg_z) = degs
(sin_x,cos_x) = (math.sin(math.radians(deg_x)), math.cos(math.radians(deg_x)))
(sin_y,cos_y) = (math.sin(math.radians(deg_y)), math.cos(math.radians(deg_y)))
(sin_z,cos_z) = (math.sin(math.radians(deg_z)), math.cos(math.radians(deg_z)))
facet_rotatess = []
for facets in facetss:
facet_rotates = []
for i_point in range(4):
(x, y, z) = [facets[3 * i_point + i_xyz] for i_xyz in range(3)]
if (x is None or y is None or z is None):
facet_rotates += [x, y, z]
else:
(y, z) = (y * cos_x - z * sin_x, y * sin_x + z * cos_x) ## rotate about x
(x, z) = (x * cos_y + z * sin_y, -x * sin_y + z * cos_y) ## rotate about y
(x, y) = (x * cos_z - y * sin_z, x * sin_z + y * cos_z) ## rotate about z
facet_rotates += [round(value, 9) for value in [x, y, z]]
facet_rotatess.append(facet_rotates)
return facet_rotatess
def translate(facetss, ds): ## ds = (dx,dy,dz)
return [facets[:3] + [facets[3 * i_point + i_xyz] + ds[i_xyz]
for i_point in range(1,4) for i_xyz in range(3)]
for facets in facetss]
## Add facets
facetss = []
for facess in facesss:
for face_vertexs in facess['vertexss']:
face_vertexss = [list(vertexsss[i_vertex]['xyz'])
for i_vertex in (face_vertexs[::-1] if (facess['flip']) else face_vertexs)]
for i_face_vertex in range(len(face_vertexss) - 2):
facetss.append(flatten([(None,0,0), face_vertexss[0], face_vertexss[i_face_vertex + 1],
face_vertexss[i_face_vertex + 2], [facess['colour']]]))
facetss = [facets[:3] + facets[6:9] + facets[3:6] + facets[9:] for facets in facetss] ## flip facets
## Calculate normals
for facets in facetss:
if (facets[0] is None or facets[1] is None or facets[2] is None):
us = [facets[i_xyz + 9] - facets[i_xyz + 6] for i_xyz in range(3)]
vs = [facets[i_xyz + 6] - facets[i_xyz + 3] for i_xyz in range(3)]
normals = [us[1]*vs[2] - us[2]*vs[1], us[2]*vs[0] - us[0]*vs[2], us[0]*vs[1] - us[1]*vs[0]]
normal_length = sum([component * component for component in normals]) ** 0.5
facets[:3] = [-round(component / normal_length, 10) for component in normals]
print(tabbify([['N%s' % (xyz ) for xyz in list('xyz')] +
['%s%d' % (xyz, n) for n in range(3) for xyz in list('XYZ')] + ['RGB']] + facetss))
## Compile STL
outss = ([[('STL\n\n%-73s\n\n' % (header[:73])).encode('utf-8'), struct.pack('<L',len(facetss))]] +
[[struct.pack('<f',float(value)) for value in facets[:12]] +
[struct.pack('<H',0 if (len(facets) <= 12) else
viscam_colour(facets[12]))] for facets in facetss])
out = b''.join([bytes(out) for outs in outss for out in outs])
# out += ('\n\n## Python script to generate STL\n\n%s\n' % (open(__file__).read())).encode('utf-8')
print("# bytes:%d\t# facets:%d\ttitle:\"%-73s\"" % (len(out), len(facetss), header[:73]))
with open(__file__[:__file__.rfind('.')] + '.stl', 'wb') as f_out: f_out.write(out)
许可协议
我,本作品著作权人,特此采用以下许可协议发表本作品:
本文件采用知识共享署名-相同方式共享 4.0 国际许可协议授权。
- 您可以自由地:
- 共享 – 复制、发行并传播本作品
- 修改 – 改编作品
- 惟须遵守下列条件:
- 署名 – 您必须对作品进行署名,提供授权条款的链接,并说明是否对原始内容进行了更改。您可以用任何合理的方式来署名,但不得以任何方式表明许可人认可您或您的使用。
- 相同方式共享 – 如果您再混合、转换或者基于本作品进行创作,您必须以与原先许可协议相同或相兼容的许可协议分发您贡献的作品。
此文件的上传者已同意维基媒体基金会3D专利许可: 这个文件和文件中描述的任何3D对象都是我自己的作品。 我特此授予文件中描述的对象的每个用户、制造商或分销商,根据我现在拥有的任何专利或专利申请,在全球范围内、免版税、全额支付、非排他性、不可撤销和永久许可,无需额外费用 或在未来,制作、已经制作、使用、提议出售、出售、进口和分发此文件和文件中描述的任何3D对象,否则会侵犯我现在或将来持有的任何专利的任何权利要求。 请注意,如果本许可的英文原版与翻译版本之间在含义或解释上存在任何差异,则以英文原版为准。 |
此文件中描述的项目
描繪內容
29 3 2018
文件历史
点击某个日期/时间查看对应时刻的文件。
日期/时间 | 缩略图 | 大小 | 用户 | 备注 | |
---|---|---|---|---|---|
当前 | 2018年3月29日 (四) 19:10 | 5,120 × 2,880(1 KB) | Cmglee | Try to fix z-fighting. | |
2018年3月29日 (四) 18:57 | 5,120 × 2,880(1 KB) | Cmglee | Remove redundant facets. | ||
2018年3月29日 (四) 18:49 | 5,120 × 2,880(2 KB) | Cmglee | User created page with UploadWizard |
文件用途
以下页面使用本文件:
全域文件用途
以下其他wiki使用此文件:
- en.wikipedia.org上的用途
- es.wikipedia.org上的用途
- www.wikidata.org上的用途