feat: add juicer mechanism with continuous pressing animation
Add the Minex-inspired juicer model with synchronized rotary pressing, peel discharge, generation scripts, validation reports, previews, and reference materials. Status: work in progress. The juicer model is not complete yet and still needs further geometric and motion refinements.
This commit is contained in:
@@ -0,0 +1,365 @@
|
||||
import bpy
|
||||
import bmesh
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
from mathutils import Vector
|
||||
from mathutils.bvhtree import BVHTree
|
||||
|
||||
OUT = Path(__file__).resolve().parent
|
||||
DOC = OUT.parents[1]/'HOW_ZMUEX_juicer_work.md'
|
||||
scene = bpy.context.scene
|
||||
report = json.loads((OUT/'mechanism_validation.json').read_text(encoding='utf-8'))
|
||||
report['revision_notes'] = [
|
||||
'Reference ZMUEX_working_video.mp4 01:59-02:06 was inspected from both supplied viewpoints before rebuilding the motion',
|
||||
'Disc and pressing carrier rotate clockwise continuously with a four-pocket/three-head angular speed ratio; neither has a dwell during pressing',
|
||||
'Each half follows its rotating pocket through the rolling nip; cut flesh becomes a concave layer around the ball instead of translating upward as a flattened orange',
|
||||
'Squeezed hollow peels leave the moving pocket after engagement, follow a short discharge guide and then fall into the residue box',
|
||||
'Recursive visibility keys hide every fruit and residue child mesh; blue-gray machinery contrasts with orange ingredients',
|
||||
'Pressing carrier has a fixed Y axis and no Z translation; balls engage pockets only by coordinated rotation',
|
||||
'Drum and pressing carrier use parallel Y axes; their circular faces lie in XOZ and face machine front +Y',
|
||||
'One-piece hemispherical pockets remain centered across the 74 mm drum thickness',
|
||||
'External tangential blade meets fruit at the projected tangent and never enters the drum or pocket rims; its cutting plane matches fruit separation',
|
||||
'Incorrect wire filter and all drum blade-clearance slots are removed; a solid juice guide is used',
|
||||
'Residue and its collection box use synchronized world-space extraction',
|
||||
]
|
||||
report['saved_file_reopened'] = Path(bpy.data.filepath).name == 'PerfectCoffee_Minex_Mechanism.blend'
|
||||
report['source_document_matches'] = hashlib.sha256(DOC.read_bytes()).hexdigest() == report['source_sha256']
|
||||
report['missing_external_assets'] = [im.filepath for im in bpy.data.images if im.source=='FILE' and not im.packed_file and not Path(bpy.path.abspath(im.filepath)).exists()]
|
||||
report['linked_library_count'] = len(bpy.data.libraries)
|
||||
scene.frame_set(1)
|
||||
bpy.context.view_layer.update()
|
||||
disc = bpy.data.objects['Four_Pocket_Disc_Y_Axis']
|
||||
male = bpy.data.objects['Three_Ball_Press_Y_Axis']
|
||||
blade = bpy.data.objects['Fixed_Tangential_Cutting_Blade']
|
||||
report['disc_thickness_m'] = disc['thickness_m']
|
||||
report['thick_disc_passed'] = report['disc_thickness_m'] >= 0.070
|
||||
report['actual_pocket_count'] = len([o for o in bpy.data.objects if o.name.startswith('Hemispherical_Pocket_')])
|
||||
report['actual_spherical_head_count'] = len([o for o in bpy.data.objects if o.name.startswith('Spherical_Pressing_Head_')])
|
||||
report['solid_front_cover_present'] = 'Disc_Solid_Front_Cover' in bpy.data.objects
|
||||
report['vertical_press_parts_absent'] = not any(o.name.startswith('Press_Z_') or o.name.startswith('Press_Sliding_') for o in bpy.data.objects)
|
||||
report['rotational_relief_grooves_present'] = disc.get('rotational_relief_track_count',0)>0 and all(bpy.data.objects['Hemispherical_Pocket_'+str(i)].get('rotational_relief_grooves',0)>0 for i in range(1,5))
|
||||
report['press_axis_positions'] = {}
|
||||
reference_axis = None
|
||||
report['press_axis_max_deviation_m'] = 0.0
|
||||
for frame in range(1,361):
|
||||
scene.frame_set(frame)
|
||||
bpy.context.view_layer.update()
|
||||
position = male.matrix_world.translation.copy()
|
||||
if reference_axis is None:
|
||||
reference_axis = position.copy()
|
||||
report['press_axis_max_deviation_m'] = max(report['press_axis_max_deviation_m'],(position-reference_axis).length)
|
||||
if frame in [1,64,128,172,192,214,236,256,278,360]:
|
||||
report['press_axis_positions'][str(frame)] = list(position)
|
||||
report['press_axis_fixed_throughout_animation'] = report['press_axis_max_deviation_m']<0.000001
|
||||
report['short_neck_heads_present'] = all('Press_Head_Short_Neck_'+str(i) in bpy.data.objects for i in [1,2,3])
|
||||
report['fixed_blade_has_no_animation'] = blade.animation_data is None
|
||||
report['filter_mesh_absent'] = not any(o.name.startswith('Filter_') or o.name == 'Juice_Only_Inclined_Filter' for o in bpy.data.objects)
|
||||
report['solid_juice_guide_present'] = 'Juice_Guide_Solid_Tray_No_Mesh' in bpy.data.objects
|
||||
report['drum_blade_slots_absent'] = not any('Blade_Clearance' in o.name for o in bpy.data.objects)
|
||||
|
||||
report['front_facing_checks'] = {}
|
||||
for obj in [disc,male,bpy.data.objects['Press_Equilateral_Triangle_Carrier']]:
|
||||
normal = obj.matrix_world.to_quaternion() @ Vector((1,0,0))
|
||||
report['front_facing_checks'][obj.name] = {
|
||||
'face_normal':list(normal),
|
||||
'expected':[0,1,0],
|
||||
'error':(normal-Vector((0,1,0))).length,
|
||||
}
|
||||
report['front_faces_xoz_passed'] = all(v['error']<0.0001 for v in report['front_facing_checks'].values())
|
||||
report['blade_minimum_edge_radius_m'] = abs(blade.location.y-blade.dimensions.y/2-disc.location.y)
|
||||
report['blade_outside_drum'] = report['blade_minimum_edge_radius_m'] > 0.091
|
||||
report['blade_outside_pocket_rims'] = report['blade_minimum_edge_radius_m'] > 0.103
|
||||
report['blade_penetration_disabled_by_geometry'] = not blade['penetrates_drum'] and report['blade_outside_pocket_rims']
|
||||
report['l_hopper_parts_present'] = all(name in bpy.data.objects for name in ['L_Hopper_Long_Arm_Floor','L_Hopper_Short_Arm_Floor','Fixed_Entrance_Sliding_Ramp','Entrance_Periodic_Gate_Pivot'])
|
||||
report['long_arm_has_four_fruit_positions'] = all(name in bpy.data.objects for name in ['Process_Whole_Orange','Hopper_Queued_Orange_1','Hopper_Queued_Orange_2','Hopper_Queued_Orange_3'])
|
||||
report['separate_half_and_residue_meshes'] = all(name in bpy.data.objects for name in ['Process_Retained_Half_Peel','Process_Blade_Half_Peel','Residue_A_Pressed_Half_Peel_Empty_Peel','Residue_B_Pressed_Half_Peel_Empty_Peel'])
|
||||
report['visibility_checks'] = {}
|
||||
assembly_names = ['Process_Whole_Orange','Process_Retained_Half','Process_Blade_Half','Residue_A_Pressed_Half_Peel','Residue_B_Pressed_Half_Peel']
|
||||
visibility_expectations = {
|
||||
1:{'Process_Whole_Orange'},
|
||||
127:{'Process_Whole_Orange'},
|
||||
128:{'Process_Retained_Half','Process_Blade_Half'},
|
||||
192:{'Process_Retained_Half','Process_Blade_Half'},
|
||||
213:{'Process_Retained_Half','Process_Blade_Half'},
|
||||
214:{'Process_Blade_Half','Residue_A_Pressed_Half_Peel'},
|
||||
256:{'Process_Blade_Half','Residue_A_Pressed_Half_Peel'},
|
||||
278:{'Residue_A_Pressed_Half_Peel','Residue_B_Pressed_Half_Peel'},
|
||||
360:{'Residue_A_Pressed_Half_Peel','Residue_B_Pressed_Half_Peel'},
|
||||
}
|
||||
for frame,visible in visibility_expectations.items():
|
||||
scene.frame_set(frame)
|
||||
bpy.context.view_layer.update()
|
||||
unexpected = []
|
||||
for name in assembly_names:
|
||||
assembly = bpy.data.objects[name]
|
||||
should_hide = name not in visible
|
||||
for child in [assembly,*assembly.children_recursive]:
|
||||
if child.hide_render != should_hide or child.hide_viewport != should_hide:
|
||||
unexpected.append(child.name)
|
||||
report['visibility_checks'][str(frame)] = {'unexpected_objects':unexpected,'passed':not unexpected}
|
||||
report['recursive_visibility_passed'] = all(v['passed'] for v in report['visibility_checks'].values())
|
||||
mechanism_color = bpy.data.materials['Mechanism_Light_Blue_Gray_Polymer'].diffuse_color
|
||||
fruit_color = bpy.data.materials['Orange_Peel_Procedural'].diffuse_color
|
||||
report['mechanism_fruit_color_distance'] = (Vector(mechanism_color[:3])-Vector(fruit_color[:3])).length
|
||||
report['mechanism_fruit_colors_differ'] = report['mechanism_fruit_color_distance']>0.4
|
||||
report['collector_flags'] = {
|
||||
'juice_no_spout':not bpy.data.objects['Juice_Collection_Box_No_Spout_No_Handle']['has_spout'],
|
||||
'juice_no_handle':not bpy.data.objects['Juice_Collection_Box_No_Spout_No_Handle']['has_handle'],
|
||||
'residue_no_juice':not bpy.data.objects['Residue_Collection_Box']['contains_juice'],
|
||||
}
|
||||
|
||||
report['pocket_orientation_checks'] = {}
|
||||
report['pocket_axial_center_errors_m'] = {}
|
||||
for frame,index,expected in [(64,1,(0,0,1)),(128,1,(-1,0,0)),(192,1,(0,0,-1)),(256,2,(0,0,-1))]:
|
||||
scene.frame_set(frame)
|
||||
bpy.context.view_layer.update()
|
||||
pocket = bpy.data.objects['Hemispherical_Pocket_'+str(index+1)]
|
||||
normal = disc.matrix_world.to_quaternion() @ Vector(pocket['radial_opening_local'])
|
||||
pp = pocket.matrix_world.translation
|
||||
axial_error = abs(pp.y-disc.matrix_world.translation.y)
|
||||
report['pocket_axial_center_errors_m'][f'{frame}_pocket_{index}'] = axial_error
|
||||
report['pocket_orientation_checks'][f'{frame}_pocket_{index}'] = {
|
||||
'normal':list(normal),
|
||||
'expected':expected,
|
||||
'error':(normal-Vector(expected)).length,
|
||||
'opening_plane_contains_y_axis':abs(normal.y)<0.000001,
|
||||
}
|
||||
report['pocket_orientation_passed'] = all(v['error']<0.0001 and v['opening_plane_contains_y_axis'] for v in report['pocket_orientation_checks'].values())
|
||||
report['pockets_centered_across_drum_thickness'] = all(v<0.000001 for v in report['pocket_axial_center_errors_m'].values())
|
||||
report['pocket_dimensions'] = {name:{key:bpy.data.objects[name][key] for key in ['inner_radius_m','outer_radius_m','depth_m']} for name in ['Hemispherical_Pocket_1','Hemispherical_Pocket_2','Hemispherical_Pocket_3','Hemispherical_Pocket_4']}
|
||||
report['hemispherical_pockets_passed'] = all(v['inner_radius_m']>0.030 and v['outer_radius_m']>v['inner_radius_m'] and v['depth_m']==v['outer_radius_m'] for v in report['pocket_dimensions'].values())
|
||||
|
||||
scene.frame_set(128)
|
||||
bpy.context.view_layer.update()
|
||||
report['disc_top_moves_to_negative_x'] = (disc.matrix_world.to_quaternion() @ Vector((0,0,1))-Vector((-1,0,0))).length < 0.0001
|
||||
report['disc_rotation_is_clockwise_from_positive_y'] = report['disc_top_moves_to_negative_x'] and disc.rotation_euler.x<0 and abs(disc.rotation_euler.y)<1e-6 and abs(disc.rotation_euler.z)<1e-6
|
||||
male_angle_at_cut = male.rotation_euler.x
|
||||
scene.frame_set(145)
|
||||
report['press_rotation_is_clockwise_from_positive_y'] = male.rotation_euler.x<male_angle_at_cut and abs(male.rotation_euler.y)<1e-6 and abs(male.rotation_euler.z)<1e-6
|
||||
previous_rotations = None
|
||||
report['both_mechanisms_clockwise_throughout'] = True
|
||||
report['rotor_step_ranges_degrees'] = {'disc':[float('inf'),float('-inf')],'press':[float('inf'),float('-inf')]}
|
||||
report['rotor_zero_speed_frames'] = []
|
||||
report['rotor_frame_deltas'] = {}
|
||||
for frame in range(1,361):
|
||||
scene.frame_set(frame)
|
||||
rotations = (disc.rotation_euler.x,male.rotation_euler.x)
|
||||
if previous_rotations is not None:
|
||||
deltas = tuple(math.degrees(rotations[i]-previous_rotations[i]) for i in range(2))
|
||||
report['rotor_frame_deltas'][str(frame)] = deltas
|
||||
if deltas[0]>=-0.00001 or deltas[1]>=-0.00001:
|
||||
report['both_mechanisms_clockwise_throughout'] = False
|
||||
report['rotor_zero_speed_frames'].append(frame)
|
||||
for name,delta in zip(['disc','press'],deltas):
|
||||
bounds = report['rotor_step_ranges_degrees'][name]
|
||||
bounds[0] = min(bounds[0],delta)
|
||||
bounds[1] = max(bounds[1],delta)
|
||||
previous_rotations = rotations
|
||||
report['both_rotors_continuous_throughout'] = report['both_mechanisms_clockwise_throughout'] and not report['rotor_zero_speed_frames']
|
||||
report['press_to_disc_angular_speed_ratio'] = report['rotor_step_ranges_degrees']['press'][0]/report['rotor_step_ranges_degrees']['disc'][0]
|
||||
report['constant_speed_ratio_passed'] = abs(report['press_to_disc_angular_speed_ratio']-4/3)<0.0001
|
||||
scene.frame_set(128)
|
||||
bpy.context.view_layer.update()
|
||||
pocket_normal = disc.matrix_world.to_quaternion() @ Vector(bpy.data.objects['Hemispherical_Pocket_2']['radial_opening_local'])
|
||||
blade_tangent = blade.matrix_world.to_quaternion() @ Vector((0,0,1))
|
||||
blade_plane_normal = blade.matrix_world.to_quaternion() @ Vector((0,1,0))
|
||||
report['blade_tangent_at_cutting_station'] = abs(blade_tangent.dot(pocket_normal))<0.0001
|
||||
report['blade_cut_plane_matches_fruit_split'] = (blade_plane_normal-pocket_normal).length<0.0001
|
||||
fruit_center = bpy.data.objects['Process_Whole_Orange'].matrix_world.translation
|
||||
disc_center = disc.matrix_world.translation
|
||||
report['cutting_fruit_radius_m'] = math.hypot(fruit_center.x-disc_center.x,fruit_center.z-disc_center.z)
|
||||
report['fruit_centered_on_external_cutting_edge'] = abs(report['cutting_fruit_radius_m']-blade['cutting_edge_radius_m'])<0.00001
|
||||
scene.frame_set(182)
|
||||
ejector = bpy.data.objects['Blade_Discharge_Spring_Pivot']
|
||||
report['spring_ejector_moves_in_xoz'] = abs(ejector.rotation_euler.x)>0.1 and (ejector.matrix_world.to_quaternion() @ Vector((1,0,0))-Vector((0,1,0))).length<0.0001
|
||||
|
||||
report['fruit_rolling_nip_checks'] = {}
|
||||
for half_name,pocket_index,frames in [('Process_Retained_Half',2,[176,184,192,200,208]),('Process_Blade_Half',3,[240,248,256,264,270])]:
|
||||
positions = []
|
||||
errors = []
|
||||
orientation_errors = []
|
||||
scales = []
|
||||
for frame in frames:
|
||||
scene.frame_set(frame)
|
||||
bpy.context.view_layer.update()
|
||||
half = bpy.data.objects[half_name]
|
||||
pocket = bpy.data.objects['Hemispherical_Pocket_'+str(pocket_index)]
|
||||
expected = pocket.matrix_world.translation
|
||||
positions.append(half.matrix_world.translation.copy())
|
||||
errors.append((expected-half.matrix_world.translation).length)
|
||||
inward = disc.matrix_world.to_quaternion() @ -Vector(pocket['radial_opening_local'])
|
||||
dome = half.matrix_world.to_quaternion() @ Vector((0,0,1))
|
||||
orientation_errors.append((inward-dome).length)
|
||||
scales.append(list(half.scale))
|
||||
report['fruit_rolling_nip_checks'][half_name] = {
|
||||
'frames':frames,
|
||||
'pocket_tracking_errors_m':errors,
|
||||
'dome_orientation_errors':orientation_errors,
|
||||
'arc_travel_m':(positions[-1]-positions[0]).length,
|
||||
'root_scales':scales,
|
||||
}
|
||||
report['fruit_follows_pocket_through_press'] = all(max(v['pocket_tracking_errors_m'])<0.00001 and max(v['dome_orientation_errors'])<0.0001 and v['arc_travel_m']>0.040 for v in report['fruit_rolling_nip_checks'].values())
|
||||
report['no_fake_z_squash_or_ram'] = all(abs(scale[2]-1)<0.000001 for v in report['fruit_rolling_nip_checks'].values() for scale in v['root_scales'])
|
||||
|
||||
report['pressing_alignment'] = {}
|
||||
for frame,half_name,pocket_index,ball_index in [(192,'Process_Retained_Half',1,1),(256,'Process_Blade_Half',2,2)]:
|
||||
scene.frame_set(frame)
|
||||
bpy.context.view_layer.update()
|
||||
pocket = bpy.data.objects['Hemispherical_Pocket_'+str(pocket_index+1)]
|
||||
ball = bpy.data.objects['Spherical_Pressing_Head_'+str(ball_index+1)]
|
||||
pp = pocket.matrix_world.translation
|
||||
bp = ball.matrix_world.translation
|
||||
pocket_normal = disc.matrix_world.to_quaternion() @ Vector(pocket['radial_opening_local'])
|
||||
ball_normal = (male.matrix_world.to_quaternion() @ Vector((0,ball.location.y,ball.location.z))).normalized()
|
||||
half = bpy.data.objects[half_name]
|
||||
dome_normal = half.matrix_world.to_quaternion() @ Vector((0,0,1))
|
||||
cup = bpy.data.objects[half_name+'_Cut_Flesh'].data.shape_keys.key_blocks['Pressed_Around_Spherical_Head']
|
||||
report['pressing_alignment'][str(frame)] = {
|
||||
'pocket_center_m':list(pp),
|
||||
'ball_center_m':list(bp),
|
||||
'ball_pocket_center_error_m':(pp-bp).length,
|
||||
'half_cut_plane_origin_m':list(half.matrix_world.translation),
|
||||
'ball_half_origin_error_m':(bp-half.matrix_world.translation).length,
|
||||
'ball_inward_apex_m':list(bp+ball_normal*0.028),
|
||||
'flesh_cup_apex_m':list(half.matrix_world @ Vector((0,0,0.0289))),
|
||||
'half_dome_matches_inward_normal':dome_normal.dot(-pocket_normal)>0.999,
|
||||
'flesh_conforms_to_ball':cup.value>0.999,
|
||||
'root_scale':list(half.scale),
|
||||
'disc_step_degrees':report['rotor_frame_deltas'][str(frame)][0],
|
||||
'press_step_degrees':report['rotor_frame_deltas'][str(frame)][1],
|
||||
}
|
||||
report['pressing_alignment_passed'] = all(v['ball_pocket_center_error_m']<0.00001 and v['ball_half_origin_error_m']<0.00001 and v['half_dome_matches_inward_normal'] and v['flesh_conforms_to_ball'] and v['disc_step_degrees']<-0.01 and v['press_step_degrees']<-0.01 for v in report['pressing_alignment'].values())
|
||||
|
||||
report['residue_contact_and_motion'] = {}
|
||||
for name,half_name,ball_name,pocket_name,show_frame,end in [('Residue_A_Pressed_Half_Peel','Process_Retained_Half','Spherical_Pressing_Head_2','Hemispherical_Pocket_2',214,242),('Residue_B_Pressed_Half_Peel','Process_Blade_Half','Spherical_Pressing_Head_3','Hemispherical_Pocket_3',278,306)]:
|
||||
obj = bpy.data.objects[name]
|
||||
scene.frame_set(show_frame)
|
||||
bpy.context.view_layer.update()
|
||||
actual_at_show = obj.matrix_world.translation.copy()
|
||||
scene.frame_set(show_frame)
|
||||
bpy.context.view_layer.update()
|
||||
expected = bpy.data.objects[pocket_name].matrix_world.translation.copy()
|
||||
contact_error = (actual_at_show-expected).length
|
||||
scene.frame_set(show_frame)
|
||||
bpy.context.view_layer.update()
|
||||
start_position = obj.matrix_world.translation.copy()
|
||||
start_rotation = obj.matrix_world.to_quaternion()
|
||||
scene.frame_set(end)
|
||||
bpy.context.view_layer.update()
|
||||
position = obj.matrix_world.translation.copy()
|
||||
end_rotation = obj.matrix_world.to_quaternion()
|
||||
ball_position = bpy.data.objects[ball_name].matrix_world.translation
|
||||
center = bpy.data.objects['Residue_Collection_Box_Slide'].matrix_world @ Vector((0.045,0.003,0))
|
||||
report['residue_contact_and_motion'][name] = {
|
||||
'initial_pressed_half_position_error_m':contact_error,
|
||||
'actual_at_show':list(actual_at_show),
|
||||
'expected_at_show':list(expected),
|
||||
'guided_lateral_travel_m':math.hypot(position.x-start_position.x,position.y-start_position.y),
|
||||
'release_rotation_change_radians':start_rotation.rotation_difference(end_rotation).angle,
|
||||
'z_at_release_m':start_position.z,
|
||||
'z_in_bin_m':position.z,
|
||||
'falls_downward':position.z<start_position.z,
|
||||
'distance_from_rotating_ball_at_rest_m':(position-ball_position).length,
|
||||
'inside_residue_box_world_coordinates':abs(position.x-center.x)<0.065 and abs(position.y-center.y)<0.063 and 0.058<position.z<0.233,
|
||||
}
|
||||
report['residue_motion_passed'] = all(v['initial_pressed_half_position_error_m']<0.00001 and abs(v['release_rotation_change_radians'])<0.0001 and v['falls_downward'] and v['distance_from_rotating_ball_at_rest_m']>0.12 and v['inside_residue_box_world_coordinates'] for v in report['residue_contact_and_motion'].values())
|
||||
scene.frame_set(350)
|
||||
report['residue_and_box_slide_error_m'] = (bpy.data.objects['Residue_Animation_Slide'].matrix_world.translation-bpy.data.objects['Residue_Collection_Box_Slide'].matrix_world.translation).length
|
||||
report['collector_slide_synchronized'] = report['residue_and_box_slide_error_m']<0.000001
|
||||
|
||||
report['non_manifold_edges'] = {}
|
||||
report['positive_part_volumes_m3'] = {}
|
||||
for name in ['Four_Pocket_Disc_Thick_Body','Fixed_Tangential_Cutting_Blade','Spherical_Pressing_Head_1','Press_Equilateral_Triangle_Carrier','Process_Retained_Half_Peel','Residue_A_Pressed_Half_Peel_Empty_Peel','Juice_Collection_Box_No_Spout_No_Handle','Residue_Collection_Box','Juice_Guide_Solid_Tray_No_Mesh','Transparent_Hood_With_Curved_Sides']+['Hemispherical_Pocket_'+str(i) for i in range(1,5)]+['Pocket_Rim_'+str(i) for i in range(1,5)]:
|
||||
scene.frame_set(1)
|
||||
obj = bpy.data.objects[name]
|
||||
ev = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
|
||||
mesh = ev.to_mesh()
|
||||
bm = bmesh.new()
|
||||
bm.from_mesh(mesh)
|
||||
report['non_manifold_edges'][name] = sum(not e.is_manifold for e in bm.edges)
|
||||
report['positive_part_volumes_m3'][name] = bm.calc_volume(signed=True)
|
||||
bm.free()
|
||||
ev.to_mesh_clear()
|
||||
|
||||
|
||||
def tree(obj):
|
||||
ev = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
|
||||
mesh = ev.to_mesh()
|
||||
result = BVHTree.FromPolygons([ev.matrix_world@v.co for v in mesh.vertices],[list(p.vertices) for p in mesh.polygons])
|
||||
ev.to_mesh_clear()
|
||||
return result
|
||||
|
||||
|
||||
report['ball_disc_surface_intersection_frames'] = []
|
||||
report['ball_disc_collision_details'] = []
|
||||
report['seated_fruit_pocket_intersection_frames'] = []
|
||||
report['blade_pocket_intersection_frames'] = []
|
||||
report['blade_disc_surface_intersection_frames'] = []
|
||||
report['ejector_pocket_intersection_frames'] = []
|
||||
report['ejector_disc_surface_intersection_frames'] = []
|
||||
blade_names = ['Fixed_Tangential_Cutting_Blade','Blade_Holder_Crossbar','Blade_Fixed_Mount','Blade_External_Cross_Bracket'] + [o.name for o in bpy.data.objects if o.name.startswith('Blade_Holder_Side_Cheek') or o.name.startswith('Blade_Mounting_Tang')]
|
||||
ejector_names = ['Blade_Spring_Discharge_Plate']
|
||||
for frame in sorted(set(range(1,361,2)) | {64,128,148,172,178,184,192,202,214,236,248,256,266,278,322}):
|
||||
scene.frame_set(frame)
|
||||
bpy.context.view_layer.update()
|
||||
part_names = ['Four_Pocket_Disc_Thick_Body','Disc_Solid_Front_Cover']+['Pocket_Rim_'+str(i) for i in range(1,5)]
|
||||
drum_parts = [tree(bpy.data.objects[name]) for name in part_names]
|
||||
pockets = [tree(bpy.data.objects['Hemispherical_Pocket_'+str(i)]) for i in range(1,5)]
|
||||
ball_names = ['Spherical_Pressing_Head_'+str(i) for i in range(1,4)]
|
||||
moving_press_names = ball_names+['Press_Head_Short_Neck_'+str(i) for i in range(1,4)]+['Press_Equilateral_Triangle_Carrier']
|
||||
balls = [tree(bpy.data.objects[name]) for name in moving_press_names]
|
||||
details = [{'frame':frame,'ball':ball_name,'part':part_name} for ball_name,ball in zip(moving_press_names,balls) for part_name,part in zip(part_names,drum_parts) if part.overlap(ball)]
|
||||
details += [{'frame':frame,'ball':ball_name,'part':'Hemispherical_Pocket_'+str(i)} for ball_name,ball in zip(moving_press_names,balls) for i,pocket in enumerate(pockets,1) if pocket.overlap(ball)]
|
||||
report['ball_disc_collision_details'].extend(details)
|
||||
if details:
|
||||
report['ball_disc_surface_intersection_frames'].append(frame)
|
||||
blades = [tree(bpy.data.objects[name]) for name in blade_names]
|
||||
if any(blade.overlap(pocket) for blade in blades for pocket in pockets):
|
||||
report['blade_pocket_intersection_frames'].append(frame)
|
||||
if any(blade.overlap(part) for blade in blades for part in drum_parts):
|
||||
report['blade_disc_surface_intersection_frames'].append(frame)
|
||||
ejectors = [tree(bpy.data.objects[name]) for name in ejector_names]
|
||||
if any(ejector.overlap(pocket) for ejector in ejectors for pocket in pockets):
|
||||
report['ejector_pocket_intersection_frames'].append(frame)
|
||||
if any(ejector.overlap(part) for ejector in ejectors for part in drum_parts):
|
||||
report['ejector_disc_surface_intersection_frames'].append(frame)
|
||||
if 64<=frame<=92:
|
||||
fruit = tree(bpy.data.objects['Process_Whole_Orange_Peel'])
|
||||
if any(fruit.overlap(pocket) for pocket in pockets):
|
||||
report['seated_fruit_pocket_intersection_frames'].append({'frame':frame,'fruit':'whole'})
|
||||
if 148<=frame<214:
|
||||
fruit = tree(bpy.data.objects['Process_Retained_Half_Peel'])
|
||||
if any(fruit.overlap(pocket) for pocket in pockets):
|
||||
report['seated_fruit_pocket_intersection_frames'].append({'frame':frame,'fruit':'retained_half'})
|
||||
if 192<=frame<278:
|
||||
fruit = tree(bpy.data.objects['Process_Blade_Half_Peel'])
|
||||
if any(fruit.overlap(pocket) for pocket in pockets):
|
||||
report['seated_fruit_pocket_intersection_frames'].append({'frame':frame,'fruit':'blade_half'})
|
||||
|
||||
report['geometry_checks_passed'] = all(v==0 for v in report['non_manifold_edges'].values()) and all(v>0 for v in report['positive_part_volumes_m3'].values())
|
||||
report['structure_checks_passed'] = (
|
||||
report['source_document_matches'] and report['thick_disc_passed'] and report['actual_pocket_count']==4
|
||||
and report['actual_spherical_head_count']==3 and report['solid_front_cover_present'] and report['short_neck_heads_present']
|
||||
and report['vertical_press_parts_absent'] and report['press_axis_fixed_throughout_animation'] and report['rotational_relief_grooves_present']
|
||||
and report['fixed_blade_has_no_animation'] and report['filter_mesh_absent'] and report['solid_juice_guide_present'] and report['drum_blade_slots_absent']
|
||||
and report['front_faces_xoz_passed'] and report['blade_outside_drum'] and report['blade_outside_pocket_rims'] and report['blade_penetration_disabled_by_geometry']
|
||||
and report['pockets_centered_across_drum_thickness'] and report['pocket_orientation_passed'] and report['hemispherical_pockets_passed']
|
||||
and report['disc_rotation_is_clockwise_from_positive_y'] and report['press_rotation_is_clockwise_from_positive_y'] and report['both_mechanisms_clockwise_throughout'] and report['both_rotors_continuous_throughout'] and report['constant_speed_ratio_passed']
|
||||
and report['fruit_follows_pocket_through_press'] and report['no_fake_z_squash_or_ram']
|
||||
and report['blade_tangent_at_cutting_station'] and report['blade_cut_plane_matches_fruit_split'] and report['fruit_centered_on_external_cutting_edge'] and report['spring_ejector_moves_in_xoz']
|
||||
and report['l_hopper_parts_present'] and report['long_arm_has_four_fruit_positions']
|
||||
and report['separate_half_and_residue_meshes'] and report['recursive_visibility_passed'] and report['mechanism_fruit_colors_differ'] and all(report['collector_flags'].values())
|
||||
and report['pressing_alignment_passed'] and report['residue_motion_passed'] and report['collector_slide_synchronized']
|
||||
)
|
||||
report['contact_checks_passed'] = all(not report[key] for key in ['ball_disc_surface_intersection_frames','seated_fruit_pocket_intersection_frames','blade_pocket_intersection_frames','blade_disc_surface_intersection_frames','ejector_pocket_intersection_frames','ejector_disc_surface_intersection_frames'])
|
||||
report['contact_check_scope'] = 'Every frame: both rotor angle increments and fixed press axis. Every second frame plus exact process keyframes: balls, short necks and carrier versus drum, cover and one-piece pockets; seated fruit versus pockets; external blade, holder, supports and moving ejector versus rotating geometry. Intentional fruit cutting and pressing contact are excluded; this is sampled geometric validation, not a manufacturing physics simulation.'
|
||||
report['data_checks_passed'] = report['saved_file_reopened'] and not report['missing_external_assets'] and report['linked_library_count']==0
|
||||
report['passed'] = report['geometry_checks_passed'] and report['structure_checks_passed'] and report['contact_checks_passed'] and report['data_checks_passed']
|
||||
report['visual_review'] = 'Final stills and rendered video are reviewed separately.'
|
||||
(OUT/'mechanism_validation.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
|
||||
keys = ['passed','structure_checks_passed','geometry_checks_passed','contact_checks_passed','data_checks_passed','front_faces_xoz_passed','filter_mesh_absent','blade_minimum_edge_radius_m','cutting_fruit_radius_m','ball_disc_surface_intersection_frames','ball_disc_collision_details','seated_fruit_pocket_intersection_frames','blade_pocket_intersection_frames','blade_disc_surface_intersection_frames','ejector_pocket_intersection_frames','ejector_disc_surface_intersection_frames','pocket_axial_center_errors_m','pocket_orientation_checks','pressing_alignment','residue_contact_and_motion','collector_slide_synchronized','recursive_visibility_passed','visibility_checks','both_mechanisms_clockwise_throughout','both_rotors_continuous_throughout','rotor_step_ranges_degrees','rotor_zero_speed_frames','press_to_disc_angular_speed_ratio','fruit_follows_pocket_through_press','no_fake_z_squash_or_ram','fruit_rolling_nip_checks','non_manifold_edges']
|
||||
print(json.dumps({k:report[k] for k in keys},ensure_ascii=False,indent=2),flush=True)
|
||||
if not report['passed']:
|
||||
raise RuntimeError('Front-facing external-blade mechanism validation failed')
|
||||
Reference in New Issue
Block a user