Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 2figures beam convert error #191

Merged
merged 2 commits into from
Sep 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 68 additions & 23 deletions HoaryFox/Component/Utils/Geometry/BrepMaker/Girder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,51 +126,96 @@ private static List<Curve> SecSrcBeamCurves(IReadOnlyList<object> figures, IRead
private List<Curve> SecSteelBeamToCurves(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints)
{
var curveList = new List<Curve>();
string start, center, end;
Vector3d[] localAxis = Utils.CreateLocalAxis(sectionPoints);

switch (figures.Count)
{
case 1:
var straight = figures[0] as StbSecSteelBeam_S_Straight;
center = straight.shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[0], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[3], Utils.SectionType.Beam, localAxis));
SingleFigureCurveList(figures, sectionPoints, curveList, localAxis);
break;
case 2:
var tapers = new[] { figures[0] as StbSecSteelBeam_S_Taper, figures[1] as StbSecSteelBeam_S_Taper };
start = tapers.First(sec => sec.pos == StbSecSteelBeam_S_TaperPos.START).shape;
end = tapers.First(sec => sec.pos == StbSecSteelBeam_S_TaperPos.END).shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, start, sectionPoints[0], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[3], Utils.SectionType.Beam, localAxis));
TwoFigureCurveList(figures, sectionPoints, curveList, localAxis);
break;
case 3:
if (figures[0] is StbSecSteelBeam_S_Haunch)
ThreeFigureCurveList(figures, sectionPoints, curveList, localAxis);
break;
case 5:
throw new ArgumentException("5 section steel is not supported");
default:
throw new ArgumentException("Unmatched StbSecSteelBeam_S");
}

return curveList;
}

private void SingleFigureCurveList(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints, ICollection<Curve> curveList, Vector3d[] localAxis)
{
var straight = figures[0] as StbSecSteelBeam_S_Straight;
string center = straight.shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[0], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[3], Utils.SectionType.Beam, localAxis));
}

private void TwoFigureCurveList(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints, ICollection<Curve> curveList, Vector3d[] localAxis)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method TwoFigureCurveList has 31 lines of code (exceeds 25 allowed). Consider refactoring.

{
string start, center, end;
switch (figures[0])
{
case StbSecSteelBeam_S_Taper _:
{
var tapers = new[] { figures[0] as StbSecSteelBeam_S_Taper, figures[1] as StbSecSteelBeam_S_Taper };
start = tapers.First(sec => sec.pos == StbSecSteelBeam_S_TaperPos.START).shape;
end = tapers.First(sec => sec.pos == StbSecSteelBeam_S_TaperPos.END).shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, start, sectionPoints[0], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[3], Utils.SectionType.Beam, localAxis));
break;
}
case StbSecSteelBeam_S_Joint _:
{
var joint = new[] { figures[0] as StbSecSteelBeam_S_Joint, figures[1] as StbSecSteelBeam_S_Joint };
center = joint.First(sec => sec.pos == StbSecSteelBeam_S_JointPos.CENTER).shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[0], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[3], Utils.SectionType.Beam, localAxis));
break;
}
case StbSecSteelBeam_S_Haunch _:
{
var joint = new[] { figures[0] as StbSecSteelBeam_S_Haunch, figures[1] as StbSecSteelBeam_S_Haunch };
center = joint.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.CENTER).shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[0], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[3], Utils.SectionType.Beam, localAxis));
break;
}
}
}

private void ThreeFigureCurveList(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints, ICollection<Curve> curveList, Vector3d[] localAxis)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method ThreeFigureCurveList has 26 lines of code (exceeds 25 allowed). Consider refactoring.

{
string start, center, end;
switch (figures[0])
{
case StbSecSteelBeam_S_Haunch _:
{
var haunch = new[] { figures[0] as StbSecSteelBeam_S_Haunch, figures[1] as StbSecSteelBeam_S_Haunch, figures[2] as StbSecSteelBeam_S_Haunch };
start = haunch.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.START).shape;
center = haunch.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.CENTER).shape;
end = haunch.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.END).shape;
break;
}
else
default:
{
var joint = new[] { figures[0] as StbSecSteelBeam_S_Joint, figures[1] as StbSecSteelBeam_S_Joint, figures[2] as StbSecSteelBeam_S_Joint };
start = joint.First(sec => sec.pos == StbSecSteelBeam_S_JointPos.START).shape;
center = joint.First(sec => sec.pos == StbSecSteelBeam_S_JointPos.CENTER).shape;
end = joint.First(sec => sec.pos == StbSecSteelBeam_S_JointPos.END).shape;
break;
}
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, start, sectionPoints[0], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[1], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[2], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[3], Utils.SectionType.Beam, localAxis));
break;
case 5:
throw new ArgumentException("5 section steel is not supported");
default:
throw new ArgumentException("Unmatched StbSecSteelBeam_S");
}

return curveList;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, start, sectionPoints[0], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[1], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[2], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[3], Utils.SectionType.Beam, localAxis));
}

}
}