有圆头的弧线修改

This commit is contained in:
sladro 2026-02-03 19:12:35 +08:00
parent 01b8f1930b
commit 253545e498

View File

@ -3018,20 +3018,27 @@ namespace CadParamPluging.Cad
double xInnerRight = ox + visualTotalW - arcHeight; double xInnerRight = ox + visualTotalW - arcHeight;
double innerWidth = xInnerRight - xInnerLeft; double innerWidth = xInnerRight - xInnerLeft;
// 获取内框圆角参数:优先取 UnspecifiedFilletRadiusMax如果没有则取 BoxFilletRadiusMax // 获取圆头处圆角半径 (BoxRoundHeadFilletRadiusMax) - 用于外侧圆角
// 依据用户需求:外侧圆角由“圆头处圆角半径”控制
var headFilletParam = bag.GetDoubleOrNull(KeyBoxRoundHeadFilletRadiusMax);
double headFilletR = headFilletParam.HasValue && headFilletParam.Value > 0
? headFilletParam.Value
: 0;
// 获取内框圆角参数:优先取 UnspecifiedFilletRadiusMax如果没有则取 BoxFilletRadiusMax - 用于内部剖面
var innerFilletParam = bag.GetDoubleOrNull(KeyUnspecifiedFilletRadiusMax); var innerFilletParam = bag.GetDoubleOrNull(KeyUnspecifiedFilletRadiusMax);
if (!innerFilletParam.HasValue || innerFilletParam.Value <= 0) if (!innerFilletParam.HasValue || innerFilletParam.Value <= 0)
{ {
innerFilletParam = bag.GetDoubleOrNull(KeyBoxFilletRadiusMax); innerFilletParam = bag.GetDoubleOrNull(KeyBoxFilletRadiusMax);
} }
double innerFilletR = innerFilletParam.HasValue && innerFilletParam.Value > 0 double sectionFilletR = innerFilletParam.HasValue && innerFilletParam.Value > 0
? innerFilletParam.Value ? innerFilletParam.Value
: 0; : 0;
// 1. 绘制完整锻件外轮廓(方体有圆头 - 白色,大圆弧) // 1. 绘制完整锻件外轮廓(方体有圆头 - 白色,大圆弧)
// 修正:圆弧弦线需向内缩进 innerFilletR以与锻件圆角起点对齐 // 修正:圆弧弦线需向内缩进 headFilletR (原 logic 使用 innerFilletR),以与锻件外侧圆角起点对齐
DrawBlockRoundHeadOutline(ctx, ox, oy, visualTotalW, H, arcHeight, innerFilletR); DrawBlockRoundHeadOutline(ctx, ox, oy, visualTotalW, H, arcHeight, headFilletR);
// 2. 绘制分段式内框(左、中、右三段)以支持中间剖面区域的独立圆角 // 2. 绘制分段式内框(左、中、右三段)以支持中间剖面区域的独立圆角
// 中间区域(剖面)作为主体,如果设置了圆角,四个角都应为圆角 // 中间区域(剖面)作为主体,如果设置了圆角,四个角都应为圆角
@ -3065,26 +3072,24 @@ namespace CadParamPluging.Cad
double xSectionRight = xSectionLeft + visualSectionWidth; double xSectionRight = xSectionLeft + visualSectionWidth;
// 绘制中间剖面框(带圆角) // 绘制中间剖面框(带圆角)
// 复用 Ring 模板的 SectionContourWithFillet 逻辑绘制中间闭合框 // 使用 sectionFilletR
// 注意:这里需要把 Ring 的 DrawRingSectionContourWithFillet 方法提取出来通用或者直接复制逻辑 DrawBoxSectionContourWithFillet(ctx, xSectionLeft, xSectionRight, oy, H, sectionFilletR);
// 为简单起见,这里直接使用类似的逻辑绘制
DrawBoxSectionContourWithFillet(ctx, xSectionLeft, xSectionRight, oy, H, innerFilletR);
// 绘制左侧框线(连接左端圆弧和中间剖面框) // 绘制左侧框线(连接左端圆弧和中间剖面框)
// 左端: xInnerLeft (需处理左上下角的圆角 - 修正为使用内框圆角 innerFilletR与方体参数一致) // 左端: xInnerLeft (需处理左上下角的圆角 - 使用 headFilletR)
// 右端: xSectionLeft (连接到中间框的直边) // 右端: xSectionLeft (连接到中间框的直边)
DrawBoxSideFrame(ctx, xInnerLeft, xSectionLeft, oy, H, innerFilletR, isLeft: true); DrawBoxSideFrame(ctx, xInnerLeft, xSectionLeft, oy, H, headFilletR, isLeft: true);
// 绘制右侧框线 // 绘制右侧框线
// 左端: xSectionRight (连接到中间框的直边) // 左端: xSectionRight (连接到中间框的直边)
// 右端: xInnerRight (需处理右上下角的圆角 - 修正为使用内框圆角 innerFilletR与方体参数一致) // 右端: xInnerRight (需处理右上下角的圆角 - 使用 headFilletR)
DrawBoxSideFrame(ctx, xSectionRight, xInnerRight, oy, H, innerFilletR, isLeft: false); DrawBoxSideFrame(ctx, xSectionRight, xInnerRight, oy, H, headFilletR, isLeft: false);
// 3. 剖面填充 - 只在中间区域 // 3. 剖面填充 - 只在中间区域
// 如果有圆角填充范围也应考虑圆角不过Hatch边界通常可以自动处理 // 使用 sectionFilletR
if (innerFilletR > 0.01) if (sectionFilletR > 0.01)
{ {
DrawRingSectionHatchWithFillet(ctx, xSectionLeft, xSectionRight, oy, H, innerFilletR); DrawRingSectionHatchWithFillet(ctx, xSectionLeft, xSectionRight, oy, H, sectionFilletR);
} }
else else
{ {
@ -3135,8 +3140,9 @@ namespace CadParamPluging.Cad
// 修正:标注需涵盖内框宽度 (矩形部分) // 修正:标注需涵盖内框宽度 (矩形部分)
// 修正:引线起点改为内框边界 (xInnerLeft/Right) 和高度底部上移圆角半径 (oy + innerFilletR),确保闭合到白色线框 // 修正:引线起点改为内框边界 (xInnerLeft/Right) 和高度底部上移圆角半径,确保闭合到白色线框
double dimOriginY = oy + innerFilletR; // 使用 headFilletR 作为 Offset因为这是侧边框的倒角
double dimOriginY = oy + headFilletR;
AddLinearDim( AddLinearDim(
ctx, ctx,
new Point3d(xInnerLeft, dimOriginY, 0), new Point3d(xInnerLeft, dimOriginY, 0),
@ -3167,8 +3173,8 @@ namespace CadParamPluging.Cad
// 标注从圆弧最外侧开始(避免与圆弧轮廓线重叠) // 标注从圆弧最外侧开始(避免与圆弧轮廓线重叠)
double xOuterRight = ox + visualTotalW; double xOuterRight = ox + visualTotalW;
// 修正:标注界线起点应从圆弧顶端开始,往内缩进一个圆弧高度 arcHeight + innerFilletR定位在弦线上 // 修正:标注界线起点应从圆弧顶端开始,往内缩进一个圆弧高度 arcHeight + headFilletR定位在弦线上
double xDimOrigin = xOuterRight - (arcHeight + innerFilletR); double xDimOrigin = xOuterRight - (arcHeight + headFilletR);
AddLinearDim( AddLinearDim(
ctx, ctx,