本文整理汇总了Python中component.Component.no_moving方法的典型用法代码示例。如果您正苦于以下问题:Python Component.no_moving方法的具体用法?Python Component.no_moving怎么用?Python Component.no_moving使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类component.Component
的用法示例。
在下文中一共展示了Component.no_moving方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deformShell
# 需要导入模块: from component import Component [as 别名]
# 或者: from component.Component import no_moving [as 别名]
def deformShell(components, full, shelled):
'''
If certain types of components intersect each other (e.g., non-input
components like processing boards), we can deform an object's shell
to make space for them. This function pushes the objects out along
their normals and creates a bounding box addition.
'''
oname = shelled
print 'your components intersect. now deforming shell...'
warn_user = False
# figure out how far FORWARD we need to set each component to make it
# not intersect with each other.
no_skipped_comps = 0
for comp in components:
curr_type = comp['type']
print "CURR COMP IS ", curr_type
if comp['type'] in Component.no_moving():
no_skipped_comps += 1
continue
if no_skipped_comps == len(components):
warn_user = True
print 'we skipped all the components!'
break
loc = comp['coords']
normal = comp['threed_normal']
ct = 0
while True:
mod_comp = dict(comp)
mod_comp['coords'] = [c_i + n_i for c_i, n_i in zip(loc, normal)]
print "new coords checking is ", mod_comp['coords']
print "currently we are on ", curr_type
mod_comp_list = [comp for comp in components if not (curr_type == comp.get('type'))]
#create a new list w/ the modified coordinates
mod_comp_list.append(mod_comp)
print "checking intersections!"
if not checkIntersections(mod_comp_list): #if there are no intersections
print "sweet, no intersections"
break
if ct > 30:
warn_user = True
break
loc = mod_comp['coords']
ct += 1
comp['coords'] = loc
print 'new:', loc, ' for ', comp['type']
if warn_user:
raise Exception("Components intersect beyond an aesthetically pleasing fix. Try a redesign?")
#just for the mainboard
for comp in components:
#add more objects here
if comp['type'] == Component.main_board:
global pushed_comp
pushed_comp.append(comp['type'])
print 'adding a bounding box to the main board...'
writeOpenSCAD(DEFORM_SHELL_SCRIPT, comp, object_body=shelled, full_body=full)
oname = shelled.replace('.stl','-deformed.stl')
callOpenSCAD(DEFORM_SHELL_SCRIPT, oname)
print 'done!'
return oname
return oname