feat: 添加自由锻圆头毛坯件的参数化绘图逻辑

This commit is contained in:
sladro 2026-02-12 11:38:19 +08:00
parent 2236372f05
commit e759b0d267

View File

@ -100,10 +100,6 @@ namespace CadParamPluging.Cad
? innerFilletParam.Value
: 0;
// 1. 绘制完整锻件外轮廓(方体有圆头 - 白色,大圆弧)
// 修正:圆弧弦线需向内缩进 headFilletR (原 logic 使用 innerFilletR),以与锻件外侧圆角起点对齐
DrawBlockRoundHeadOutline(ctx, ox, oy, visualTotalW, H, arcHeight, headFilletR);
// 2. 绘制分段式内框(左、中、右三段)以支持中间剖面区域的独立圆角
// 中间区域(剖面)作为主体,如果设置了圆角,四个角都应为圆角
@ -139,15 +135,27 @@ namespace CadParamPluging.Cad
// 使用 sectionFilletR
DrawBoxSectionContourWithFillet(ctx, xSectionLeft, xSectionRight, oy, H, sectionFilletR);
// Calculate effective head fillet R (clamped by side frame width) to ensure Outline matches SideFrame
double sideFrameWidth = xSectionLeft - xInnerLeft;
double maxR = Math.Min(sideFrameWidth * 0.5, H * 0.5);
double effectiveHeadR = Math.Min(headFilletR, maxR);
// 绘制左侧框线(连接左端圆弧和中间剖面框)
// 左端: xInnerLeft (需处理左上下角的圆角 - 使用 headFilletR)
// 右端: xSectionLeft (连接到中间框的直边)
DrawBoxSideFrame(ctx, xInnerLeft, xSectionLeft, oy, H, headFilletR, isLeft: true);
// Note: Extend horizontally by sectionFilletR to achieve "Horizontal Closure" with the section fillet
DrawBoxSideFrame(ctx, xInnerLeft, xSectionLeft + sectionFilletR, oy, H, headFilletR, isLeft: true);
// 绘制右侧框线
// 左端: xSectionRight (连接到中间框的直边)
// 右端: xInnerRight (需处理右上下角的圆角 - 使用 headFilletR)
DrawBoxSideFrame(ctx, xSectionRight, xInnerRight, oy, H, headFilletR, isLeft: false);
// Note: Extend horizontally inwards by sectionFilletR
DrawBoxSideFrame(ctx, xSectionRight - sectionFilletR, xInnerRight, oy, H, headFilletR, isLeft: false);
// 1. 绘制完整锻件外轮廓(方体有圆头 - 白色,大圆弧)
// 修正:圆弧弦线需向内缩进 effectiveHeadR (Clamped),以与锻件外侧圆角起点对齐
// This ensures the Big Arc starts curving exactly where the Side Frame vertical edge ends.
DrawBlockRoundHeadOutline(ctx, ox, oy, visualTotalW, H, arcHeight, effectiveHeadR);
// 3. 剖面填充 - 只在中间区域
// 使用 sectionFilletR
@ -315,10 +323,13 @@ namespace CadParamPluging.Cad
double xInnerLeft = ox + arcHeight;
double xInnerRight = ox + totalWidth - arcHeight;
double yBottomStraight = oy + r;
double yTopStraight = oy + H - r;
// 修正:为了确保视觉上与圆角完全闭合,稍微向圆角区域延伸一点 (0.8 * r)
// 用户的需求是“再高一点和低一点”,这意味着需要一定的重叠量来消除缝隙
double overlapFactor = 0.8;
double yBottomStraight = oy + r * overlapFactor;
double yTopStraight = oy + H - r * overlapFactor;
double chordLength = H - 2.0 * r;
double chordLength = yTopStraight - yBottomStraight;
if (chordLength < 0.1) return; // Should not happen for reasonable params
double sagitta = arcHeight;
@ -421,12 +432,6 @@ namespace CadParamPluging.Cad
poly.AddVertexAt(4, new Point2d(xStart + r, yTop), 0, 0, 0);
poly.AddVertexAt(5, new Point2d(xEnd, yTop), 0, 0, 0);
}
else
{
poly.AddVertexAt(1, new Point2d(xStart, yBottom), 0, 0, 0);
poly.AddVertexAt(2, new Point2d(xStart, yTop), 0, 0, 0);
poly.AddVertexAt(3, new Point2d(xEnd, yTop), 0, 0, 0);
}
poly.Closed = false;
}
else