程序优化
This commit is contained in:
1 parent
2c036235a6
commit
3197efd6a3
3 files changed
+42
-3
No files matched your search
@@ -134,8 +134,20 @@ def get_obj_max_foot():
|
||||
obj.name = 'foot'
|
||||
print(f'最大脚底板面积: {max_area} cm²')
|
||||
if max_area < 5:
|
||||
print('最大脚底板面积太小,脚底模型可能有破损,异常退出')
|
||||
sys.exit(1)
|
||||
print('最大脚底板面积太小,脚底模型可能有破损,进行再次处理')
|
||||
numsTemp = 0
|
||||
#最多执行三次 重新处理
|
||||
while numsTemp < 3:
|
||||
#每次削的比例要加上去
|
||||
tempArea = 0.2+numsTemp*0.2
|
||||
max_area = check_and_deal_foot_area(tempArea)
|
||||
if max_area >= 5:
|
||||
break
|
||||
numsTemp += 1
|
||||
|
||||
if max_area < 5:
|
||||
print('最大脚底板面积处理多次还没有得到理想的面积,退出')
|
||||
sys.exit(1)
|
||||
# bpy.ops.wm.save_as_mainfile(filepath=os.path.join(workdir, f'{pid}_{order_id}', f'{pid}_{order_id}.blend'))
|
||||
active_object(bpy.data.objects['foot'])
|
||||
foot_points = get_plane_points(bpy.data.objects['foot'])
|
||||
@@ -159,6 +171,29 @@ def get_obj_max_foot():
|
||||
# plot(get_plane_points(bpy.data.objects['qr']), 'red')
|
||||
return foot_points
|
||||
|
||||
#检测到脚底板面积小于5cm²,重新调几次程序再次处理,如果还不行就退出
|
||||
def check_and_deal_foot_area(tempArea):
|
||||
bpy.ops.mesh.primitive_plane_add(size=200, enter_editmode=False, align='WORLD', location=(0, 0, tempArea), scale=(1, 1, 1))
|
||||
bpy.ops.object.modifier_add(type='BOOLEAN')
|
||||
bpy.context.object.modifiers["Boolean"].object = bpy.data.objects[pid_objname]
|
||||
bpy.context.object.modifiers["Boolean"].operation = 'INTERSECT'
|
||||
bpy.context.object.modifiers["Boolean"].solver = 'FAST'
|
||||
bpy.ops.object.modifier_apply(modifier="Boolean")
|
||||
|
||||
bpy.ops.mesh.separate(type='LOOSE')
|
||||
|
||||
max_area = 0
|
||||
for obj in bpy.data.objects:
|
||||
if obj.type == 'MESH' and obj.name.startswith('Plane'):
|
||||
if len(obj.data.polygons) == 0: continue
|
||||
area = obj.data.polygons[0].area
|
||||
if area > max_area:
|
||||
max_area = area
|
||||
obj.name = 'foot'
|
||||
print("再次处理脚底板得到的面积:" + str(max_area) + "cm²")
|
||||
return max_area
|
||||
|
||||
|
||||
def euclidean_distance(p1, p2):
|
||||
return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5
|
||||
|
||||
@@ -610,6 +645,7 @@ if __name__ == '__main__':
|
||||
get_qr_position_url = 'https://mp.api.suwa3d.com/api/printOrder/getFootCodePositionData'
|
||||
upload_qr_position_url = 'https://mp.api.suwa3d.com/api/printOrder/updateFootCodeStatus'
|
||||
get_pid_by_printid_url = 'https://mp.api.suwa3d.com/api/printOrder/getPidByPrintId'
|
||||
delete_form_foot_code_by_pid = 'https://mp.api.suwa3d.com/api/printOrder/deleteFormFootCodeByPid'
|
||||
# get_qr_position_url = 'http://172.31.1.254:8199/api/printOrder/getFootCodePositionData'
|
||||
# upload_qr_position_url = 'http://172.31.1.254:8199/api/printOrder/updateFootCodeStatus'
|
||||
# get_pid_by_printid_url = 'http://172.31.1.254:8199/api/printOrder/getPidByPrintId'
|
||||
|
||||
@@ -50,7 +50,7 @@ def get_task_distributed():
|
||||
#R11 R12的主机 可以执行step1 2 3 的任务
|
||||
#如果R11 R12的主机目前没有正在执行step2,则优先处理step2,
|
||||
# print("次数",is_run_stepx_nums("step2"))
|
||||
if is_run_stepx_nums("step2") < 2:
|
||||
if is_run_stepx_nums("step2") < 200000:
|
||||
resultData = need_run_step2()
|
||||
if resultData != "no":
|
||||
resultData["hostname"] = hostname
|
||||
|
||||
@@ -37,6 +37,9 @@ def readTask(key):
|
||||
|
||||
#默认走原来的数据表tasks,现在要切入一些数据过来走分布式建模系统
|
||||
taskData = {"task_type":key,"task_key":pid,"psid":psid,"priority":1}
|
||||
if int(psid) == 41 or int(psid) == 85:
|
||||
taskData["priority"] = 0
|
||||
|
||||
if libs_db.isStudioConfigDistribute(psid):
|
||||
print("走分布式建模系统插入",key,pid,psid)
|
||||
libs_db.add_task_distributed(taskData)
|
||||
|
||||
Reference in new issue
Block a user