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

Add Brep display in CFT column #253

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
54 changes: 54 additions & 0 deletions HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Column.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ private SectionCurve[] CreateCurveList(string idSection, StbColumnKind_structure
curveList = SecRcColumnToCurves(srcSec.StbSecFigureColumn_SRC.Item, sectionPoints);
break;
case StbColumnKind_structure.CFT:
StbSecColumn_CFT cftSec = _sections.StbSecColumn_CFT.First(sec => sec.id == idSection);
curveList = SecCftColumnToCurves(cftSec.StbSecSteelFigureColumn_CFT.Items, sectionPoints);
break;
case StbColumnKind_structure.UNDEFINED:
throw new ArgumentException("Unsupported StbColumnKind");
default:
Expand All @@ -67,6 +70,57 @@ private SectionCurve[] CreateCurveList(string idSection, StbColumnKind_structure
return curveList;
}

private SectionCurve[] SecCftColumnToCurves(IReadOnlyList<object> figures, IReadOnlyList<Point3d> sectionPoints)
Copy link

Choose a reason for hiding this comment

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

Method SecCftColumnToCurves has 44 lines of code (exceeds 25 allowed). Consider refactoring.

Copy link

Choose a reason for hiding this comment

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

Method SecCftColumnToCurves has 48 lines of code (exceeds 25 allowed). Consider refactoring.

{
var curveList = new List<SectionCurve>();
Vector3d[] localAxis = Utils.CreateLocalAxis(sectionPoints);

string bottom, center, top;
switch (figures.Count)
{
case 1:
var same = figures[0] as StbSecSteelColumn_CFT_Same;
center = same.shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[0], Utils.SectionType.Column, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[3], Utils.SectionType.Column, localAxis));
break;
case 2:
var notSames = new[] { figures[0] as StbSecSteelColumn_CFT_NotSame, figures[1] as StbSecSteelColumn_CFT_NotSame };
bottom = notSames.First(item => item.pos == StbSecSteelColumn_CFT_NotSamePos.BOTTOM).shape;
top = notSames.First(item => item.pos == StbSecSteelColumn_CFT_NotSamePos.TOP).shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, bottom, sectionPoints[0], Utils.SectionType.Column, localAxis));
if (sectionPoints[1].Z > sectionPoints[0].Z)
{
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, bottom, sectionPoints[1], Utils.SectionType.Column, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, top, sectionPoints[1], Utils.SectionType.Column, localAxis));
}
else
{
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, bottom, sectionPoints[2], Utils.SectionType.Column, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, top, sectionPoints[2], Utils.SectionType.Column, localAxis));
}
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, top, sectionPoints[3], Utils.SectionType.Column, localAxis));
break;
case 3:
var three = new[] { figures[0] as StbSecSteelColumn_CFT_ThreeTypes, figures[1] as StbSecSteelColumn_CFT_ThreeTypes, figures[2] as StbSecSteelColumn_CFT_ThreeTypes };
bottom = three.First(item => item.pos == StbSecSteelColumn_CFT_ThreeTypesPos.BOTTOM).shape;
center = three.First(item => item.pos == StbSecSteelColumn_CFT_ThreeTypesPos.CENTER).shape;
top = three.First(item => item.pos == StbSecSteelColumn_CFT_ThreeTypesPos.TOP).shape;
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, bottom, sectionPoints[0], Utils.SectionType.Column, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[1], Utils.SectionType.Column, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[2], Utils.SectionType.Column, localAxis));
curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, top, sectionPoints[3], Utils.SectionType.Column, localAxis));
break;
default:
throw new ArgumentException("Unmatched StbSecSteelColumn_CFT");
}
foreach (var curve in curveList)
{
curve.IsCft = true;
}
return curveList.ToArray();
}

private static SectionCurve[] SecRcColumnToCurves(object figure, IReadOnlyList<Point3d> sectionPoints)
{
var curveList = new List<SectionCurve>();
Expand Down
3 changes: 1 addition & 2 deletions HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,13 @@ public static void RotateCurveList(Vector3d rotateAxis, IReadOnlyList<SectionCur

public static Brep CreateCapedBrepFromLoft(SectionCurve[] sectionCurve, double tolerance)
{

Brep brep = Brep.CreateFromLoft(sectionCurve.Select(c => c.OuterCurve), Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0]
.CapPlanarHoles(tolerance);
if (brep == null)
{
return null;
}
if (sectionCurve[0].InnerCurve != null)
if (sectionCurve[0].InnerCurve != null && !sectionCurve[0].IsCft)
{
Brep innerBrep = Brep.CreateFromLoft(sectionCurve.Select(c => c.InnerCurve), Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0]
.CapPlanarHoles(tolerance);
Expand Down
6 changes: 2 additions & 4 deletions HoaryFox/RH7/Component/Utils/Geometry/SectionCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ public class SectionCurve
public SectionShape Shape { get; set; }
public SectionType Type { get; set; }
public Vector3d XAxis { get; set; }
public bool IsCft { get; set; }

public void RotateSection(double inPlaneAngle, Vector3d rotateAxis, Point3d sectionPoint)
{
OuterCurve.Rotate(inPlaneAngle, rotateAxis, sectionPoint);
if (InnerCurve != null)
{
InnerCurve.Rotate(inPlaneAngle, rotateAxis, sectionPoint);
}
InnerCurve?.Rotate(inPlaneAngle, rotateAxis, sectionPoint);
}

public static SectionCurve CreateSolidColumnRect(Point3d sectionPoint, double widthX, double widthY, Vector3d[] localAxis)
Expand Down