Skip to content

Commit

Permalink
Merge pull request #253 from hrntsm/Feature/Support-CFT-section
Browse files Browse the repository at this point in the history
Add Brep display in CFT column
  • Loading branch information
hrntsm authored May 18, 2023
2 parents a3833d9 + 3cea44e commit 288126d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
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)
{
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

0 comments on commit 288126d

Please sign in to comment.