Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
hrntsm committed Sep 24, 2021
1 parent 272d6a3 commit 64717cf
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 141 deletions.
145 changes: 4 additions & 141 deletions HoaryFox/Component/Utils/Geometry/BrepMaker/Girder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,18 @@ private List<Curve> SecSteelBeamToCurves(IReadOnlyList<object> figures, IReadOnl
{
var curveList = new List<Curve>();
Vector3d[] localAxis = Utils.CreateLocalAxis(sectionPoints);
var toCurveList = new GirderFigureToCurveList(_sections);

switch (figures.Count)
{
case 1:
SingleFigureCurveList(figures, sectionPoints, curveList, localAxis);
toCurveList.SingleFigure(figures, sectionPoints, curveList, localAxis);
break;
case 2:
TwoFigureCurveList(figures, sectionPoints, curveList, localAxis);
toCurveList.TwoFigure(figures, sectionPoints, curveList, localAxis);
break;
case 3:
ThreeFigureCurveList(figures, sectionPoints, curveList, localAxis);
toCurveList.ThreeFigure(figures, sectionPoints, curveList, localAxis);
break;
case 5:
throw new ArgumentException("5 section steel is not supported");
Expand All @@ -143,143 +144,5 @@ private List<Curve> SecSteelBeamToCurves(IReadOnlyList<object> figures, IReadOnl

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)
{
switch (figures[0])
{
case StbSecSteelBeam_S_Taper _:
{
TwoFigureTaper(figures, sectionPoints, curveList, localAxis);
break;
}
case StbSecSteelBeam_S_Joint _:
{
TwoFigureJoint(figures, sectionPoints, curveList, localAxis);
break;
}
case StbSecSteelBeam_S_Haunch _:
{
TwoFigureHaunch(figures, sectionPoints, curveList, localAxis);
break;
}
default:
{
throw new ArgumentException("Unmatched StbSecSteelBeam_S");
}
}
}

private void TwoFigureTaper(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints, ICollection<Curve> curveList, Vector3d[] localAxis)
{
var tapers = new[] { figures[0] as StbSecSteelBeam_S_Taper, figures[1] as StbSecSteelBeam_S_Taper };
string start = tapers.First(sec => sec.pos == StbSecSteelBeam_S_TaperPos.START).shape;
string 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, start, sectionPoints[1], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[2], Utils.SectionType.Beam, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[3], Utils.SectionType.Beam, localAxis));
}

private void TwoFigureJoint(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints, ICollection<Curve> curveList, Vector3d[] localAxis)
{
var joint = new[] { figures[0] as StbSecSteelBeam_S_Joint, figures[1] as StbSecSteelBeam_S_Joint };
string center = joint.First(sec => sec.pos == StbSecSteelBeam_S_JointPos.CENTER).shape;

if (joint.FirstOrDefault(sec => sec.pos == StbSecSteelBeam_S_JointPos.START) != null)
{
string start = joint.First(sec => sec.pos == StbSecSteelBeam_S_JointPos.START).shape;
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, center, sectionPoints[3], Utils.SectionType.Beam, localAxis));
}
else
{
string end = joint.First(sec => sec.pos == StbSecSteelBeam_S_JointPos.END).shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, 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));
}
}

private void TwoFigureHaunch(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints, ICollection<Curve> curveList, Vector3d[] localAxis)
{
var joint = new[] { figures[0] as StbSecSteelBeam_S_Haunch, figures[1] as StbSecSteelBeam_S_Haunch };
string center;

if (joint.FirstOrDefault(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.START) != null)
{
string start = joint.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.START).shape;
center = joint.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.CENTER).shape;
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, center, sectionPoints[3], Utils.SectionType.Beam, localAxis));
}
else
{
center = joint.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.CENTER).shape;
string end = joint.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.END).shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, 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));
}
}

private void ThreeFigureCurveList(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints, ICollection<Curve> curveList, Vector3d[] localAxis)
{
switch (figures[0])
{
case StbSecSteelBeam_S_Haunch _:
{
ThreeFigureHaunch(figures, sectionPoints, curveList, localAxis);
break;
}
case StbSecSteelBeam_S_Joint _:
{
ThreeFigureJoint(figures, sectionPoints, curveList, localAxis);
break;
}
default:
{
throw new ArgumentException("Unmatched StbSecSteelBeam_S");
}
}
}

private void ThreeFigureHaunch(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints, ICollection<Curve> curveList, Vector3d[] localAxis)
{
var haunch = new[] { figures[0] as StbSecSteelBeam_S_Haunch, figures[1] as StbSecSteelBeam_S_Haunch, figures[2] as StbSecSteelBeam_S_Haunch };
string start = haunch.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.START).shape;
string center = haunch.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.CENTER).shape;
string end = haunch.First(sec => sec.pos == StbSecSteelBeam_S_HaunchPos.END).shape;
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));
}

private void ThreeFigureJoint(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints, ICollection<Curve> curveList, Vector3d[] localAxis)
{
var joint = new[] { figures[0] as StbSecSteelBeam_S_Joint, figures[1] as StbSecSteelBeam_S_Joint, figures[2] as StbSecSteelBeam_S_Joint };
string start = joint.First(sec => sec.pos == StbSecSteelBeam_S_JointPos.START).shape;
string center = joint.First(sec => sec.pos == StbSecSteelBeam_S_JointPos.CENTER).shape;
string end = joint.First(sec => sec.pos == StbSecSteelBeam_S_JointPos.END).shape;
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));
}
}
}
Loading

0 comments on commit 64717cf

Please sign in to comment.