feat: Add BlockRawFreeForgeRoundHeadDrawer class to implement drawing logic for free forge round head CAD blocks.
This commit is contained in:
parent
50a8e275dd
commit
2236372f05
@ -311,29 +311,45 @@ namespace CadParamPluging.Cad
|
||||
double H = height;
|
||||
double r = innerFilletR;
|
||||
|
||||
double xCurrentLeft = ox + arcHeight + r;
|
||||
double xCurrentRight = ox + totalWidth - arcHeight - r;
|
||||
|
||||
double sagitta = arcHeight + r;
|
||||
double halfChord = H / 2.0;
|
||||
// Calculate geometric bounds
|
||||
double xInnerLeft = ox + arcHeight;
|
||||
double xInnerRight = ox + totalWidth - arcHeight;
|
||||
|
||||
double bulge = 0;
|
||||
if (halfChord > 1e-3)
|
||||
{
|
||||
bulge = -(sagitta / halfChord);
|
||||
}
|
||||
double yBottomStraight = oy + r;
|
||||
double yTopStraight = oy + H - r;
|
||||
|
||||
double chordLength = H - 2.0 * r;
|
||||
if (chordLength < 0.1) return; // Should not happen for reasonable params
|
||||
|
||||
var poly = new Polyline();
|
||||
double sagitta = arcHeight;
|
||||
|
||||
// Bulge calculation: bulge = 2 * sagitta / chord
|
||||
// For a CCW arc, bulge is positive.
|
||||
double bulge = (2.0 * sagitta) / chordLength;
|
||||
|
||||
poly.AddVertexAt(0, new Point2d(xCurrentRight, oy), 0, 0, 0);
|
||||
poly.AddVertexAt(1, new Point2d(xCurrentLeft, oy), bulge, 0, 0);
|
||||
poly.AddVertexAt(2, new Point2d(xCurrentLeft, oy + H), 0, 0, 0);
|
||||
poly.AddVertexAt(3, new Point2d(xCurrentRight, oy + H), bulge, 0, 0);
|
||||
poly.Closed = true;
|
||||
// Left Arc: From Top to Bottom, bulging Left (CCW)
|
||||
// Start: (xInnerLeft, yTopStraight)
|
||||
// End: (xInnerLeft, yBottomStraight)
|
||||
// Path: 12 o'clock -> 9 o'clock -> 6 o'clock direction is CCW.
|
||||
var leftPoly = new Polyline();
|
||||
leftPoly.AddVertexAt(0, new Point2d(xInnerLeft, yTopStraight), bulge, 0, 0);
|
||||
leftPoly.AddVertexAt(1, new Point2d(xInnerLeft, yBottomStraight), 0, 0, 0);
|
||||
|
||||
ctx.Style?.Apply(leftPoly, DrawingStyleManager.Role.OutlineBold);
|
||||
ctx.Btr.AppendEntity(leftPoly);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(leftPoly, true);
|
||||
|
||||
ctx.Style?.Apply(poly, DrawingStyleManager.Role.OutlineBold);
|
||||
ctx.Btr.AppendEntity(poly);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(poly, true);
|
||||
// Right Arc: From Bottom to Top, bulging Right (CCW)
|
||||
// Start: (xInnerRight, yBottomStraight)
|
||||
// End: (xInnerRight, yTopStraight)
|
||||
// Path: 6 o'clock -> 3 o'clock -> 12 o'clock direction is CCW.
|
||||
var rightPoly = new Polyline();
|
||||
rightPoly.AddVertexAt(0, new Point2d(xInnerRight, yBottomStraight), bulge, 0, 0);
|
||||
rightPoly.AddVertexAt(1, new Point2d(xInnerRight, yTopStraight), 0, 0, 0);
|
||||
|
||||
ctx.Style?.Apply(rightPoly, DrawingStyleManager.Role.OutlineBold);
|
||||
ctx.Btr.AppendEntity(rightPoly);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(rightPoly, true);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user