x
This commit is contained in:
@@ -113,6 +113,7 @@ class MultiSchemeMoldPlanner:
|
||||
undercut_regions = generator._build_undercut_regions(
|
||||
side_action_result.get("undercut_analysis", {})
|
||||
)
|
||||
mold_structure = self._determine_mold_structure(analysis, undercut_regions)
|
||||
|
||||
scaled_shape = generator._apply_shrinkage_compensation(shape)
|
||||
drafted_shape = generator._apply_draft_angles(scaled_shape, parting_surface)
|
||||
@@ -150,6 +151,9 @@ class MultiSchemeMoldPlanner:
|
||||
cavity_data["metadata"]["scheme_reason"] = candidate["reason"]
|
||||
cavity_data["metadata"]["scheme_offset_ratio"] = candidate.get("offset_ratio", 0.0)
|
||||
cavity_data["metadata"]["scheme_offset_label"] = candidate.get("offset_label", "中面")
|
||||
cavity_data["metadata"]["mold_structure_type"] = mold_structure["mold_structure_type"]
|
||||
cavity_data["metadata"]["core_required"] = mold_structure["core_required"]
|
||||
cavity_data["metadata"]["structure_decision_reason"] = mold_structure["decision_reason"]
|
||||
|
||||
return {
|
||||
"scheme_id": candidate["scheme_id"],
|
||||
@@ -161,6 +165,9 @@ class MultiSchemeMoldPlanner:
|
||||
"normal_alignment_score": candidate.get("normal_alignment_score"),
|
||||
"offset_ratio": candidate.get("offset_ratio", 0.0),
|
||||
"offset_label": candidate.get("offset_label", "中面"),
|
||||
"mold_structure_type": mold_structure["mold_structure_type"],
|
||||
"core_required": mold_structure["core_required"],
|
||||
"decision_reason": mold_structure["decision_reason"],
|
||||
"parting": {
|
||||
"axis": candidate["axis"],
|
||||
"direction": parting_direction,
|
||||
@@ -273,3 +280,40 @@ class MultiSchemeMoldPlanner:
|
||||
axis: round(value / total * 100, 2)
|
||||
for axis, value in stats.items()
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _determine_mold_structure(analysis: Dict[str, Any], undercut_regions: List[Dict[str, Any]]) -> Dict[str, Any]:
|
||||
"""
|
||||
判定是否需要独立模芯。
|
||||
规则为工程启发式:
|
||||
- 实心度高 + 平均厚度占比高 + 无明显倒扣:倾向两板半腔(无独立凸芯)
|
||||
- 否则:采用型腔+模芯结构
|
||||
"""
|
||||
dims = analysis.get("bounding_box", {}).get("dimensions", [0.0, 0.0, 0.0])
|
||||
valid_dims = [float(d) for d in dims if float(d) > 1e-6]
|
||||
min_dim = min(valid_dims) if valid_dims else 1.0
|
||||
bbox_volume = 1.0
|
||||
for dim in valid_dims[:3]:
|
||||
bbox_volume *= dim
|
||||
if bbox_volume <= 0:
|
||||
bbox_volume = 1.0
|
||||
|
||||
volume = float(analysis.get("volume", 0.0))
|
||||
surface_area = float(analysis.get("surface_area", 0.0))
|
||||
solid_ratio = max(0.0, min(volume / bbox_volume, 1.0))
|
||||
avg_wall = (2.0 * volume / surface_area) if surface_area > 1e-6 else min_dim
|
||||
wall_ratio = max(0.0, min(avg_wall / max(min_dim, 1e-6), 1.0))
|
||||
undercut_count = len(undercut_regions or [])
|
||||
|
||||
core_required = not (solid_ratio > 0.62 and wall_ratio > 0.38 and undercut_count == 0)
|
||||
mold_structure_type = "cavity_core" if core_required else "two_half_cavity"
|
||||
decision_reason = (
|
||||
f"solid_ratio={solid_ratio:.2f}, wall_ratio={wall_ratio:.2f}, "
|
||||
f"undercut_count={undercut_count}"
|
||||
)
|
||||
|
||||
return {
|
||||
"core_required": core_required,
|
||||
"mold_structure_type": mold_structure_type,
|
||||
"decision_reason": decision_reason,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user