diff --git a/.vscode/launch.json b/.vscode/launch.json index bf07d24f..60958a3c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,21 +5,26 @@ "version": "0.2.0", "configurations": [ { - "name": ".NET Core Launch (console)", + "name": "Run Rhino8 WIP", "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "C:/Program Files/Rhino 6/System/Rhino.exe", - "args": [], + "program": "C:/Program Files/Rhino 8 WIP/System/Rhino.exe", + "args": ["/nosplash"], "cwd": "${workspaceFolder}", "console": "internalConsole", "stopAtEntry": true }, { - "name": ".NET Core Attach", + "name": "Run Rhino7", "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" - } + "request": "launch", + "preLaunchTask": "build", + "program": "C:/Program Files/Rhino 7/System/Rhino.exe", + "args": ["/nosplash"], + "cwd": "${workspaceFolder}", + "console": "internalConsole", + "stopAtEntry": true + }, ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d96f354e..0e4358c6 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,36 +7,11 @@ "type": "process", "args": [ "build", - "${workspaceFolder}/HoaryFox/HoaryFox.csproj", + "${workspaceFolder}/HoaryFox/RH7/HoaryFoxRH7.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], "problemMatcher": "$msCompile" }, - { - "label": "publish", - "command": "dotnet", - "type": "process", - "args": [ - "publish", - "${workspaceFolder}/HoaryFox/HoaryFox.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "watch", - "command": "dotnet", - "type": "process", - "args": [ - "watch", - "run", - "${workspaceFolder}/HoaryFox/HoaryFox.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - } ] } \ No newline at end of file diff --git a/HoaryFox/RH7/Component/Geometry/Stb2Brep.cs b/HoaryFox/RH7/Component/Geometry/Stb2Brep.cs index d70e875c..18429709 100644 --- a/HoaryFox/RH7/Component/Geometry/Stb2Brep.cs +++ b/HoaryFox/RH7/Component/Geometry/Stb2Brep.cs @@ -22,7 +22,7 @@ namespace HoaryFox.Component.Geometry public class Stb2Brep : GH_Component { private ST_BRIDGE _stBridge; - private readonly GH_Structure[] _brepList = new GH_Structure[7]; + private readonly GH_Structure[] _brepList = new GH_Structure[9]; public override GH_Exposure Exposure => GH_Exposure.primary; @@ -48,6 +48,8 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) pManager.AddBrepParameter("Braces", "Brc", "output StbBraces to Brep", GH_ParamAccess.tree); pManager.AddBrepParameter("Slabs", "Slb", "output StbSlabs to Brep", GH_ParamAccess.tree); pManager.AddBrepParameter("Walls", "Wl", "output StbWalls to Brep", GH_ParamAccess.tree); + pManager.AddBrepParameter("Piles", "Pil", "output StbPiles to Brep", GH_ParamAccess.tree); + pManager.AddBrepParameter("Footings", "Ftg", "output StbFootings to Brep", GH_ParamAccess.tree); } protected override void SolveInstance(IGH_DataAccess dataAccess) @@ -62,7 +64,7 @@ protected override void SolveInstance(IGH_DataAccess dataAccess) BakeBrep(); } - for (var i = 0; i < 7; i++) + for (var i = 0; i < 9; i++) { dataAccess.SetDataTree(i, _brepList[i]); } @@ -82,13 +84,15 @@ private void CreateBrep() _brepList[4] = brepFromStb.Brace(member.StbBraces); _brepList[5] = brepFromStb.Slab(member.StbSlabs); _brepList[6] = brepFromStb.Wall(member.StbWalls, member.StbOpens); + _brepList[7] = brepFromStb.Pile(member.StbPiles); + _brepList[8] = brepFromStb.Footing(member.StbFootings); } private void BakeBrep() { RhinoDoc activeDoc = RhinoDoc.ActiveDoc; - var parentLayerNames = new[] { "Column", "Girder", "Post", "Beam", "Brace", "Slab", "Wall" }; - Color[] layerColors = { Color.Red, Color.Green, Color.Aquamarine, Color.LightCoral, Color.MediumPurple, Color.DarkGray, Color.CornflowerBlue }; + var parentLayerNames = new[] { "Column", "Girder", "Post", "Beam", "Brace", "Slab", "Wall", "Pile", "Footing" }; + Color[] layerColors = new[] { Color.Red, Color.Green, Color.Aquamarine, Color.LightCoral, Color.MediumPurple, Color.DarkGray, Color.CornflowerBlue, Color.DarkOrange, Color.DarkKhaki }; GeometryBaker.MakeParentLayers(activeDoc, parentLayerNames, layerColors); Dictionary[][] infoArray = Utils.TagUtils.GetAllSectionInfoArray(_stBridge.StbModel.StbMembers, _stBridge.StbModel.StbSections); diff --git a/HoaryFox/RH7/Component/Geometry/Stb2Line.cs b/HoaryFox/RH7/Component/Geometry/Stb2Line.cs index 51a8784b..d0815efa 100644 --- a/HoaryFox/RH7/Component/Geometry/Stb2Line.cs +++ b/HoaryFox/RH7/Component/Geometry/Stb2Line.cs @@ -23,7 +23,7 @@ public class Stb2Line : GH_Component { private ST_BRIDGE _stBridge; private List _nodes = new List(); - private readonly GH_Structure[] _lineList = new GH_Structure[5]; + private readonly GH_Structure[] _lineList = new GH_Structure[8]; public override GH_Exposure Exposure => GH_Exposure.primary; @@ -37,6 +37,7 @@ public Stb2Line() protected override void RegisterInputParams(GH_InputParamManager pManager) { pManager.AddGenericParameter("Data", "D", "input ST-Bridge Data", GH_ParamAccess.item); + pManager.AddBooleanParameter("OffsetNode", "OfNd", "If it true, offset geometry.", GH_ParamAccess.item, false); pManager.AddBooleanParameter("Bake", "Bake", "If it true, bake geometry.", GH_ParamAccess.item, false); } @@ -48,15 +49,18 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) pManager.AddLineParameter("Posts", "Pst", "output StbPosts to Line", GH_ParamAccess.tree); pManager.AddLineParameter("Beams", "Beam", "output StbBeams to Line", GH_ParamAccess.tree); pManager.AddLineParameter("Braces", "Brc", "output StbBraces to Line", GH_ParamAccess.tree); + pManager.AddLineParameter("Piles", "Pil", "output StbPiles to Line", GH_ParamAccess.tree); } protected override void SolveInstance(IGH_DataAccess dataAccess) { var isBake = false; + var isOffset = false; if (!dataAccess.GetData("Data", ref _stBridge)) { return; } + if (!dataAccess.GetData("OffsetNode", ref isOffset)) { return; } if (!dataAccess.GetData("Bake", ref isBake)) { return; } - CreateLine(); + CreateLine(isOffset); if (isBake) { BakeLine(); @@ -65,21 +69,36 @@ protected override void SolveInstance(IGH_DataAccess dataAccess) dataAccess.SetDataList(0, _nodes); foreach ((GH_Structure geometry, int i) in _lineList.Select((geo, index) => (geo, index + 1))) { - dataAccess.SetDataTree(i, geometry); + if (i == 8) + { + dataAccess.SetDataTree(6, geometry); + } + else if (i == 6 || i == 7) + { + continue; + } + else + { + dataAccess.SetDataTree(i, geometry); + } } } private void BakeLine() { RhinoDoc activeDoc = RhinoDoc.ActiveDoc; - var parentLayerNames = new[] { "Column", "Girder", "Post", "Beam", "Brace", "Slab", "Wall" }; - Color[] layerColors = { Color.Red, Color.Green, Color.Aquamarine, Color.LightCoral, Color.MediumPurple, Color.DarkGray, Color.CornflowerBlue }; + var parentLayerNames = new[] { "Column", "Girder", "Post", "Beam", "Brace", "Slab", "Wall", "Pile" }; + Color[] layerColors = { Color.Red, Color.Green, Color.Aquamarine, Color.LightCoral, Color.MediumPurple, Color.DarkGray, Color.CornflowerBlue, Color.DarkOrange }; GeometryBaker.MakeParentLayers(activeDoc, parentLayerNames, layerColors); Dictionary[][] infoArray = Utils.TagUtils.GetAllSectionInfoArray(_stBridge.StbModel.StbMembers, _stBridge.StbModel.StbSections); foreach ((GH_Structure lines, int i) in _lineList.Select((frameBrep, index) => (frameBrep, index))) { + if (lines == null) + { + continue; + } Layer parentLayer = activeDoc.Layers.FindName(parentLayerNames[i]); int parentIndex = parentLayer.Index; Guid parentId = parentLayer.Id; @@ -87,44 +106,38 @@ private void BakeLine() { var objAttr = new ObjectAttributes(); - if (i < 5) + Dictionary[] infos = infoArray[i]; + Dictionary info = infos[bIndex]; + + foreach (KeyValuePair pair in info) { - Dictionary[] infos = infoArray[i]; - Dictionary info = infos[bIndex]; - - foreach (KeyValuePair pair in info) - { - objAttr.SetUserString(pair.Key, pair.Value); - } - - var layer = new Layer { Name = info["name"], ParentLayerId = parentId, Color = layerColors[i] }; - int layerIndex = activeDoc.Layers.Add(layer); - if (layerIndex == -1) - { - layer = activeDoc.Layers.FindName(info["name"]); - layerIndex = layer.Index; - } - objAttr.LayerIndex = layerIndex; + objAttr.SetUserString(pair.Key, pair.Value); } - else + + var layer = new Layer { Name = info["name"], ParentLayerId = parentId, Color = layerColors[i] }; + int layerIndex = activeDoc.Layers.Add(layer); + if (layerIndex == -1) { - objAttr.LayerIndex = parentIndex; + layer = activeDoc.Layers.FindName(info["name"]); + layerIndex = layer.Index; } + objAttr.LayerIndex = layerIndex; activeDoc.Objects.AddLine(line, objAttr); } } } - private void CreateLine() + private void CreateLine(bool isOffset) { - var createLines = new CreateLineFromStb(_stBridge); + var createLines = new CreateLineFromStb(_stBridge, isOffset); _nodes = createLines.Nodes(); _lineList[0] = createLines.Columns(); _lineList[1] = createLines.Girders(); _lineList[2] = createLines.Posts(); _lineList[3] = createLines.Beams(); _lineList[4] = createLines.Braces(); + _lineList[7] = createLines.Piles(); } protected override Bitmap Icon => Resource.Line; diff --git a/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Brace.cs b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Brace.cs index 221bd1a2..b732f3d1 100644 --- a/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Brace.cs +++ b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Brace.cs @@ -12,11 +12,13 @@ public class Brace { private readonly IReadOnlyList _tolerance; private readonly StbSections _sections; + private readonly string _guid; - public Brace(StbSections sections, IReadOnlyList tolerance) + public Brace(StbSections sections, IReadOnlyList tolerance, string guid) { _tolerance = tolerance; _sections = sections; + _guid = guid; } public Brep CreateBraceBrep(string idSection, double rotate, StbBraceKind_structure kind, IReadOnlyList sectionPoints, Vector3d memberAxis) @@ -45,7 +47,7 @@ private SectionCurve[] CreateFromEachBraceKind(string idSection, StbBraceKind_st } catch (Exception) { - throw new ArgumentException("The cross-sectional shape of the brace seems to be wrong. Please check."); + throw new ArgumentException($"Error converting guid: {_guid}\nThe cross-sectional shape of the brace seems to be wrong. Please check."); } } diff --git a/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Column.cs b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Column.cs index e99af064..246e6ed4 100644 --- a/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Column.cs +++ b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Column.cs @@ -12,10 +12,13 @@ public class Column { private readonly IReadOnlyList _tolerance; private readonly StbSections _sections; - public Column(StbSections sections, IReadOnlyList tolerance) + private readonly string _guid; + + public Column(StbSections sections, IReadOnlyList tolerance, string guid) { _tolerance = tolerance; _sections = sections; + _guid = guid; } public Brep CreateColumnBrep(string idSection, double rotate, StbColumnKind_structure kind, IReadOnlyList sectionPoints, Vector3d memberAxis) @@ -34,7 +37,7 @@ private SectionCurve[] CreateFromEachColumnKind(string idSection, StbColumnKind_ } catch (Exception) { - throw new ArgumentException("The cross-sectional shape of the column or post seems to be wrong. Please check."); + throw new ArgumentException($"Error converting guid: {_guid}\nThe cross-sectional shape of the column or post seems to be wrong. Please check."); } return curveList; diff --git a/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Footing.cs b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Footing.cs new file mode 100644 index 00000000..c36929be --- /dev/null +++ b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Footing.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using Rhino.Geometry; + +using STBDotNet.v202; + +namespace HoaryFox.Component.Utils.Geometry.BrepMaker +{ + public class Footing + { + private readonly IReadOnlyList _tolerance; + private readonly StbSections _sections; + private readonly string _guid; + + public Footing(StbSections sections, IReadOnlyList tolerance, string guid) + { + _tolerance = tolerance; + _sections = sections; + _guid = guid; + } + + public Brep CreateFootingBrep(string idSection, double rotate, IReadOnlyList sectionPoints, Vector3d axis) + { + SectionCurve[] curveList = CreateCurveList(idSection, sectionPoints, axis); + Utils.RotateCurveList(axis, curveList, rotate, sectionPoints); + return Utils.CreateCapedBrepFromLoft(curveList, _tolerance[0]); + } + + private SectionCurve[] CreateCurveList(string idSection, IReadOnlyList sectionPoints, Vector3d axis) + { + SectionCurve[] curveList; + try + { + StbSecFoundation_RC rcSec = _sections.StbSecFoundation_RC.First(sec => sec.id == idSection); + curveList = SecRcFootingToCurves(rcSec.StbSecFigureFoundation_RC.Item, sectionPoints, axis); + } + catch (Exception) + { + throw new ArgumentException($"Error converting guid: {_guid}\nThe cross-sectional shape of the footing seems to be wrong. Please check."); + } + + return curveList; + } + + private static SectionCurve[] SecRcFootingToCurves(object figure, IReadOnlyList sectionPoints, Vector3d axis) + { + var curveList = new List(); + Vector3d[] localAxis = Utils.CreateLocalAxis(sectionPoints); + + switch (figure) + { + case StbSecFoundation_RC_Rect rect: + var topPt = sectionPoints[3] - axis * rect.depth; + curveList.Add(SectionCurve.CreateSolidColumnRect(topPt, rect.width_X, rect.width_Y, localAxis)); + curveList.Add(SectionCurve.CreateSolidColumnRect(sectionPoints[3], rect.width_X, rect.width_Y, localAxis)); + break; + default: + throw new ArgumentException("Unsupported StbSecFoundation_RC type."); + } + + return curveList.ToArray(); + } + } +} diff --git a/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Girder.cs b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Girder.cs index 309cba44..82620f9e 100644 --- a/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Girder.cs +++ b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Girder.cs @@ -12,11 +12,15 @@ public class Girder { private readonly IReadOnlyList _tolerance; private readonly StbSections _sections; - public Girder(StbSections sections, IReadOnlyList tolerance) + private readonly string _guid; + + public Girder(StbSections sections, IReadOnlyList tolerance, string guid) { _tolerance = tolerance; _sections = sections; + _guid = guid; } + public Brep CreateGirderBrep(string idSection, double rotate, StbGirderKind_structure kind, IReadOnlyList sectionPoints, Vector3d memberAxis) { SectionCurve[] curveList = CreateFromEachGirderKind(idSection, kind, sectionPoints); @@ -33,7 +37,7 @@ private SectionCurve[] CreateFromEachGirderKind(string idSection, StbGirderKind_ } catch (Exception) { - throw new ArgumentException("The cross-sectional shape of the girder or beam seems to be wrong. Please check."); + throw new ArgumentException($"Error converting guid: {_guid}\nThe cross-sectional shape of the girder or beam seems to be wrong. Please check."); } return curveList; @@ -77,14 +81,14 @@ private static SectionCurve[] SecRcBeamCurves(IReadOnlyList figures, IRe case 1: var straight = figures[0] as StbSecBeam_RC_Straight; curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[0], straight.depth, straight.width, localAxis)); - curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[3], straight.depth, straight.width, localAxis)); + curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[5], straight.depth, straight.width, localAxis)); break; case 2: var taper = new[] { figures[0] as StbSecBeam_RC_Taper, figures[1] as StbSecBeam_RC_Taper }; curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[0], taper[0].depth, taper[0].width, localAxis)); curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[1], taper[0].depth, taper[0].width, localAxis)); - curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[2], taper[1].depth, taper[1].width, localAxis)); - curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[3], taper[1].depth, taper[1].width, localAxis)); + curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[4], taper[1].depth, taper[1].width, localAxis)); + curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[5], taper[1].depth, taper[1].width, localAxis)); break; case 3: var haunch = new[] { figures[0] as StbSecBeam_RC_Haunch, figures[1] as StbSecBeam_RC_Haunch, figures[2] as StbSecBeam_RC_Haunch }; @@ -93,8 +97,8 @@ private static SectionCurve[] SecRcBeamCurves(IReadOnlyList figures, IRe StbSecBeam_RC_Haunch end = haunch.First(fig => fig.pos == StbSecBeam_RC_HaunchPos.END); curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[0], start.depth, start.width, localAxis)); curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[1], center.depth, center.width, localAxis)); - curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[2], center.depth, center.width, localAxis)); - curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[3], end.depth, end.width, localAxis)); + curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[4], center.depth, center.width, localAxis)); + curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[5], end.depth, end.width, localAxis)); break; default: throw new Exception(); @@ -113,14 +117,14 @@ private static SectionCurve[] SecSrcBeamCurves(IReadOnlyList figures, IR case 1: var straight = figures[0] as StbSecBeam_SRC_Straight; curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[0], straight.depth, straight.width, localAxis)); - curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[3], straight.depth, straight.width, localAxis)); + curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[5], straight.depth, straight.width, localAxis)); break; case 2: var taper = new[] { figures[0] as StbSecBeam_SRC_Taper, figures[1] as StbSecBeam_SRC_Taper }; curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[0], taper[0].depth, taper[0].width, localAxis)); curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[1], taper[0].depth, taper[0].width, localAxis)); - curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[2], taper[1].depth, taper[1].width, localAxis)); - curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[3], taper[1].depth, taper[1].width, localAxis)); + curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[4], taper[1].depth, taper[1].width, localAxis)); + curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[5], taper[1].depth, taper[1].width, localAxis)); break; case 3: var haunch = new[] { figures[0] as StbSecBeam_SRC_Haunch, figures[1] as StbSecBeam_SRC_Haunch, figures[2] as StbSecBeam_SRC_Haunch }; @@ -129,8 +133,8 @@ private static SectionCurve[] SecSrcBeamCurves(IReadOnlyList figures, IR StbSecBeam_SRC_Haunch end = haunch.First(fig => fig.pos == StbSecBeam_RC_HaunchPos.END); curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[0], start.depth, start.width, localAxis)); curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[1], center.depth, center.width, localAxis)); - curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[2], center.depth, center.width, localAxis)); - curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[3], end.depth, end.width, localAxis)); + curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[4], center.depth, center.width, localAxis)); + curveList.Add(SectionCurve.CreateSolidBeamRect(sectionPoints[5], end.depth, end.width, localAxis)); break; default: throw new Exception(); diff --git a/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/GirderFigureToCurveList.cs b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/GirderFigureToCurveList.cs index fd00fb9f..1ccf257e 100644 --- a/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/GirderFigureToCurveList.cs +++ b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/GirderFigureToCurveList.cs @@ -22,7 +22,7 @@ public void SingleFigure(IReadOnlyList figures, IReadOnlyList s 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)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[5], Utils.SectionType.Beam, localAxis)); } public void TwoFigure(IReadOnlyList figures, IReadOnlyList sectionPoints, ICollection curveList, Vector3d[] localAxis) @@ -78,8 +78,8 @@ private void TwoFigureTaper(IReadOnlyList figures, IReadOnlyList 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)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[4], Utils.SectionType.Beam, localAxis)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[5], Utils.SectionType.Beam, localAxis)); } private void TwoFigureJoint(IReadOnlyList figures, IReadOnlyList sectionPoints, ICollection curveList, Vector3d[] localAxis) @@ -91,17 +91,17 @@ private void TwoFigureJoint(IReadOnlyList figures, IReadOnlyList 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)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[5], 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)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[3], Utils.SectionType.Beam, localAxis)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[5], Utils.SectionType.Beam, localAxis)); } } @@ -116,8 +116,8 @@ private void TwoFigureHaunch(IReadOnlyList figures, IReadOnlyList 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)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[4], Utils.SectionType.Beam, localAxis)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[5], Utils.SectionType.Beam, localAxis)); } else { @@ -125,8 +125,8 @@ private void TwoFigureHaunch(IReadOnlyList figures, IReadOnlyList 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)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[4], Utils.SectionType.Beam, localAxis)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[5], Utils.SectionType.Beam, localAxis)); } } @@ -138,8 +138,8 @@ private void ThreeFigureHaunch(IReadOnlyList figures, IReadOnlyList 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)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[4], Utils.SectionType.Beam, localAxis)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[5], Utils.SectionType.Beam, localAxis)); } private void ThreeFigureJoint(IReadOnlyList figures, IReadOnlyList sectionPoints, ICollection curveList, Vector3d[] localAxis) @@ -149,9 +149,9 @@ private void ThreeFigureJoint(IReadOnlyList figures, IReadOnlyList 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)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, center, sectionPoints[3], Utils.SectionType.Beam, localAxis)); + curveList.Add(SteelSections.GetCurve(_sections.StbSecSteel, end, sectionPoints[5], Utils.SectionType.Beam, localAxis)); } } } diff --git a/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Pile.cs b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Pile.cs new file mode 100644 index 00000000..ccbb1346 --- /dev/null +++ b/HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Pile.cs @@ -0,0 +1,178 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using Rhino.Geometry; + +using STBDotNet.v202; + +namespace HoaryFox.Component.Utils.Geometry.BrepMaker +{ + public class Pile + { + private readonly IReadOnlyList _tolerance; + private readonly StbSections _sections; + private readonly string _guid; + + public Pile(StbSections sections, IReadOnlyList tolerance, string guid) + { + _tolerance = tolerance; + _sections = sections; + _guid = guid; + } + + public Brep CreatePileBrep(string idSection, StbPileKind_structure kind, IReadOnlyList sectionPoints, Vector3d axis) + { + SectionCurve[] curveList = CreateFromEachColumnKind(idSection, kind, sectionPoints, axis); + return Utils.CreateCapedBrepFromLoft(curveList, _tolerance[0]); + } + + private SectionCurve[] CreateFromEachColumnKind(string idSection, StbPileKind_structure kind, IReadOnlyList sectionPoints, Vector3d axis) + { + SectionCurve[] curveList; + try + { + curveList = CreateCurveList(idSection, kind, sectionPoints, axis); + } + catch (Exception) + { + throw new ArgumentException($"Error converting guid: {_guid}\nThe cross-sectional shape of the pile seems to be wrong. Please check."); + } + + return curveList; + } + + private SectionCurve[] CreateCurveList(string idSection, StbPileKind_structure kind, IReadOnlyList sectionPoints, Vector3d axis) + { + SectionCurve[] curveList; + switch (kind) + { + case StbPileKind_structure.RC: + StbSecPile_RC rcSec = _sections.StbSecPile_RC.First(sec => sec.id == idSection); + curveList = SecRcPileToCurves(rcSec.StbSecFigurePile_RC.Item, sectionPoints, axis); + break; + case StbPileKind_structure.PC: + StbSecPileProduct productSec = _sections.StbSecPileProduct.First(sec => sec.id == idSection); + curveList = SecProductPileToCurves(productSec, sectionPoints, axis); + break; + case StbPileKind_structure.S: + default: + throw new ArgumentException("Unsupported StbPileKind"); + } + + return curveList; + } + + private SectionCurve[] SecProductPileToCurves(StbSecPileProduct stbSecPileProduct, IReadOnlyList sectionPoints, Vector3d axis) + { + var curveList = new List(); + Vector3d[] localAxis = Utils.CreateLocalAxis(sectionPoints); + var figures = PCPileFigure.GetFigureList(stbSecPileProduct); + foreach ((PCPileFigure fig, int index) in figures.Select((fig, index) => (fig, index))) + { + curveList.Add(SectionCurve.CreateSolidColumnPipe( + sectionPoints[index], fig.Diameter, fig.Diameter - 2 * fig.Thickness, localAxis[0]) + ); + curveList.Add(SectionCurve.CreateSolidColumnPipe( + sectionPoints[index + 1] + 10 * Vector3d.ZAxis, fig.Diameter, fig.Diameter - 2 * fig.Thickness, localAxis[0]) + ); + } + curveList.Add(SectionCurve.CreateSolidColumnPipe( + sectionPoints.Last(), figures.Last().Diameter, figures.Last().Diameter - 2 * figures.Last().Thickness, localAxis[0]) + ); + return curveList.ToArray(); + } + + private static SectionCurve[] SecRcPileToCurves(object figure, IReadOnlyList sectionPoints, Vector3d axis) + { + var curveList = new List(); + Vector3d[] localAxis = Utils.CreateLocalAxis(sectionPoints); + switch (figure) + { + case StbSecPile_RC_Straight straight: + PileStraight(sectionPoints, curveList, localAxis, straight.D); + break; + case StbSecPile_RC_ExtendedFoot foot: + if (foot.D_axial == foot.D_extended_foot) + { + PileStraight(sectionPoints, curveList, localAxis, foot.D_axial); + } + else + { + PileExtendedFoot(sectionPoints, axis, curveList, localAxis, foot.D_axial, foot.D_extended_foot, foot.length_extended_foot, foot.angle_extended_foot_taper); + } + break; + case StbSecPile_RC_ExtendedTop top: + if (top.D_axial == top.D_extended_top) + { + PileStraight(sectionPoints, curveList, localAxis, top.D_axial); + } + else + { + PileExtendedTop(sectionPoints, axis, curveList, localAxis, top.D_extended_top, top.D_axial, top.angle_extended_top_taper); + } + break; + case StbSecPile_RC_ExtendedTopFoot both: + if (both.D_axial == both.D_extended_foot && both.D_axial == both.D_extended_top) + { + PileStraight(sectionPoints, curveList, localAxis, both.D_axial); + } + else if (both.D_axial == both.D_extended_foot) + { + PileExtendedTop(sectionPoints, axis, curveList, localAxis, both.D_extended_top, both.D_axial, both.angle_extended_top_taper); + } + else if (both.D_axial == both.D_extended_top) + { + PileExtendedFoot(sectionPoints, axis, curveList, localAxis, both.D_axial, both.D_extended_foot, both.length_extended_foot, both.angle_extended_foot_taper); + } + else + { + PileExtendedTopFoot(sectionPoints, axis, curveList, localAxis, both); + } + break; + default: + throw new ArgumentException(); + } + + return curveList.ToArray(); + } + + private static void PileExtendedTopFoot(IReadOnlyList sectionPoints, Vector3d axis, List curveList, Vector3d[] localAxis, StbSecPile_RC_ExtendedTopFoot both) + { + var bothPos1 = sectionPoints[1] + axis * (both.D_extended_top - both.D_axial) / 2d / Math.Tan(Math.PI / 180 * both.angle_extended_top_taper); + var bothPos2 = sectionPoints[3] - axis * both.length_extended_foot; + var bothPos3 = bothPos2 - axis * (both.D_extended_foot - both.D_axial) / 2d / Math.Tan(Math.PI / 180 * both.angle_extended_foot_taper); + curveList.Add(SectionCurve.CreateSolidColumnCircle(sectionPoints[0], both.D_extended_top, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(sectionPoints[1], both.D_extended_top, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(bothPos1, both.D_axial, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(bothPos3, both.D_axial, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(bothPos2, both.D_extended_foot, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(sectionPoints[3], both.D_extended_foot, localAxis[0])); + } + + private static void PileExtendedTop(IReadOnlyList sectionPoints, Vector3d axis, List curveList, Vector3d[] localAxis, double dExtend, double d, double angle) + { + var topPos1 = sectionPoints[1] + axis * (dExtend - d) / 2d / Math.Tan(Math.PI / 180 * angle); + curveList.Add(SectionCurve.CreateSolidColumnCircle(sectionPoints[0], dExtend, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(sectionPoints[1], dExtend, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(topPos1, d, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(sectionPoints[3], d, localAxis[0])); + } + + private static void PileExtendedFoot(IReadOnlyList sectionPoints, Vector3d axis, List curveList, Vector3d[] localAxis, double d, double dExtend, double length, double angle) + { + var footPos1 = sectionPoints[3] - axis * length; + var footPos2 = footPos1 - axis * (dExtend - d) / 2d / Math.Tan(Math.PI / 180 * angle); + curveList.Add(SectionCurve.CreateSolidColumnCircle(sectionPoints[0], d, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(footPos2, d, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(footPos1, dExtend, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(sectionPoints[3], dExtend, localAxis[0])); + } + + private static void PileStraight(IReadOnlyList sectionPoints, List curveList, Vector3d[] localAxis, double d) + { + curveList.Add(SectionCurve.CreateSolidColumnCircle(sectionPoints[0], d, localAxis[0])); + curveList.Add(SectionCurve.CreateSolidColumnCircle(sectionPoints[3], d, localAxis[0])); + } + } +} diff --git a/HoaryFox/RH7/Component/Utils/Geometry/CreateLineFromStb.cs b/HoaryFox/RH7/Component/Utils/Geometry/CreateLineFromStb.cs index 25ca8d7f..d539d74e 100644 --- a/HoaryFox/RH7/Component/Utils/Geometry/CreateLineFromStb.cs +++ b/HoaryFox/RH7/Component/Utils/Geometry/CreateLineFromStb.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using Grasshopper.Kernel.Data; @@ -13,12 +14,16 @@ namespace HoaryFox.Component.Utils.Geometry public class CreateLineFromStb { private readonly StbMembers _members; + private readonly StbSections _sections; private readonly StbNode[] _nodes; + private readonly bool _isOffset; - public CreateLineFromStb(ST_BRIDGE stBridge) + public CreateLineFromStb(ST_BRIDGE stBridge, bool isOffset) { _members = stBridge.StbModel.StbMembers; + _sections = stBridge.StbModel.StbSections; _nodes = stBridge.StbModel.StbNodes; + _isOffset = isOffset; } public List Nodes() @@ -36,8 +41,32 @@ public GH_Structure Columns() foreach ((StbColumn member, int i) in _members.StbColumns.Select((member, index) => (member, index))) { - StbNode nodeBottom = _nodes.First(node => node.id == member.id_node_bottom); - StbNode nodeTop = _nodes.First(node => node.id == member.id_node_top); + StbNode nodeBottom = new StbNode(); + StbNode nodeTop = new StbNode(); + + StbNode nodeBottomBase = _nodes.First(node => node.id == member.id_node_bottom); + StbNode nodeTopBase = _nodes.First(node => node.id == member.id_node_top); + + if (_isOffset) + { + nodeBottom = new StbNode + { + X = nodeBottomBase.X + member.offset_bottom_X, + Y = nodeBottomBase.Y + member.offset_bottom_Y, + Z = nodeBottomBase.Z + member.offset_bottom_Z + }; + nodeTop = new StbNode + { + X = nodeTopBase.X + member.offset_top_X, + Y = nodeTopBase.Y + member.offset_top_Y, + Z = nodeTopBase.Z + member.offset_top_Z + }; + } + else + { + nodeBottom = nodeBottomBase; + nodeTop = nodeTopBase; + } lines.Append(GH_LineFromStbNode(nodeBottom, nodeTop), new GH_Path(0, i)); } @@ -55,9 +84,32 @@ public GH_Structure Girders() foreach ((StbGirder member, int i) in _members.StbGirders.Select((member, index) => (member, index))) { - StbNode nodeStart = _nodes.First(node => node.id == member.id_node_start); - StbNode nodeEnd = _nodes.First(node => node.id == member.id_node_end); + var nodeStart = new StbNode(); + var nodeEnd = new StbNode(); + + StbNode nodeStartBase = _nodes.First(node => node.id == member.id_node_start); + StbNode nodeEndBase = _nodes.First(node => node.id == member.id_node_end); + if (_isOffset) + { + nodeStart = new StbNode + { + X = nodeStartBase.X + member.offset_start_X, + Y = nodeStartBase.Y + member.offset_start_Y, + Z = nodeStartBase.Z + member.offset_start_Z + }; + nodeEnd = new StbNode + { + X = nodeEndBase.X + member.offset_end_X, + Y = nodeEndBase.Y + member.offset_end_Y, + Z = nodeEndBase.Z + member.offset_end_Z + }; + } + else + { + nodeStart = nodeStartBase; + nodeEnd = nodeEndBase; + } lines.Append(GH_LineFromStbNode(nodeStart, nodeEnd), new GH_Path(0, i)); } @@ -74,8 +126,32 @@ public GH_Structure Posts() foreach ((StbPost member, int i) in _members.StbPosts.Select((member, index) => (member, index))) { - StbNode nodeBottom = _nodes.First(node => node.id == member.id_node_bottom); - StbNode nodeTop = _nodes.First(node => node.id == member.id_node_top); + var nodeBottom = new StbNode(); + var nodeTop = new StbNode(); + + StbNode nodeBottomBase = _nodes.First(node => node.id == member.id_node_bottom); + StbNode nodeTopBase = _nodes.First(node => node.id == member.id_node_top); + + if (_isOffset) + { + nodeBottom = new StbNode + { + X = nodeBottomBase.X + member.offset_bottom_X, + Y = nodeBottomBase.Y + member.offset_bottom_Y, + Z = nodeBottomBase.Z + member.offset_bottom_Z + }; + nodeTop = new StbNode + { + X = nodeTopBase.X + member.offset_top_X, + Y = nodeTopBase.Y + member.offset_top_Y, + Z = nodeTopBase.Z + member.offset_top_Z + }; + } + else + { + nodeBottom = nodeBottomBase; + nodeTop = nodeTopBase; + } lines.Append(GH_LineFromStbNode(nodeBottom, nodeTop), new GH_Path(0, i)); } @@ -93,8 +169,32 @@ public GH_Structure Beams() foreach ((StbBeam member, int i) in _members.StbBeams.Select((member, index) => (member, index))) { - StbNode nodeStart = _nodes.First(node => node.id == member.id_node_start); - StbNode nodeEnd = _nodes.First(node => node.id == member.id_node_end); + var nodeStart = new StbNode(); + var nodeEnd = new StbNode(); + + StbNode nodeStartBase = _nodes.First(node => node.id == member.id_node_start); + StbNode nodeEndBase = _nodes.First(node => node.id == member.id_node_end); + + if (_isOffset) + { + nodeStart = new StbNode + { + X = nodeStartBase.X + member.offset_start_X, + Y = nodeStartBase.Y + member.offset_start_Y, + Z = nodeStartBase.Z + member.offset_start_Z + }; + nodeEnd = new StbNode + { + X = nodeEndBase.X + member.offset_end_X, + Y = nodeEndBase.Y + member.offset_end_Y, + Z = nodeEndBase.Z + member.offset_end_Z + }; + } + else + { + nodeStart = nodeStartBase; + nodeEnd = nodeEndBase; + } lines.Append(GH_LineFromStbNode(nodeStart, nodeEnd), new GH_Path(0, i)); } @@ -112,8 +212,32 @@ public GH_Structure Braces() foreach ((StbBrace member, int i) in _members.StbBraces.Select((member, index) => (member, index))) { - StbNode nodeStart = _nodes.First(node => node.id == member.id_node_start); - StbNode nodeEnd = _nodes.First(node => node.id == member.id_node_end); + var nodeStart = new StbNode(); + var nodeEnd = new StbNode(); + + StbNode nodeStartBase = _nodes.First(node => node.id == member.id_node_start); + StbNode nodeEndBase = _nodes.First(node => node.id == member.id_node_end); + + if (_isOffset) + { + nodeStart = new StbNode + { + X = nodeStartBase.X + member.offset_start_X, + Y = nodeStartBase.Y + member.offset_start_Y, + Z = nodeStartBase.Z + member.offset_start_Z + }; + nodeEnd = new StbNode + { + X = nodeEndBase.X + member.offset_end_X, + Y = nodeEndBase.Y + member.offset_end_Y, + Z = nodeEndBase.Z + member.offset_end_Z + }; + } + else + { + nodeStart = nodeStartBase; + nodeEnd = nodeEndBase; + } lines.Append(GH_LineFromStbNode(nodeStart, nodeEnd), new GH_Path(0, i)); } @@ -121,6 +245,109 @@ public GH_Structure Braces() return lines; } + internal GH_Structure Piles() + { + var lines = new GH_Structure(); + if (_members.StbPiles == null) + { + return lines; + } + + foreach ((StbPile member, int i) in _members.StbPiles.Select((member, index) => (member, index))) + { + switch (member.kind_structure) + { + case StbPileKind_structure.RC: + GetRcPileLines(lines, member, i); + break; + case StbPileKind_structure.PC: + GetPcPileLines(lines, member, i); + break; + case StbPileKind_structure.S: + throw new NotImplementedException(); + } + } + + return lines; + } + + private void GetPcPileLines(GH_Structure lines, StbPile member, int i) + { + var figures = PCPileFigure.GetFigureList(_sections, member); + + var nodes = new List(); + StbNode node = _nodes.First(n => n.id == member.id_node); + if (_isOffset) + { + nodes.Add(new StbNode + { + X = node.X + member.offset_X, + Y = node.Y + member.offset_Y, + Z = node.Z + member.level_top + }); + } + else + { + nodes.Add(new StbNode + { + X = node.X, + Y = node.Y, + Z = node.Z + }); + } + + foreach ((PCPileFigure figure, int index) in figures.Select((figure, index) => (figure, index))) + { + nodes.Add(new StbNode + { + X = nodes[index].X, + Y = nodes[index].Y, + Z = nodes[index].Z - figure.Length + }); + lines.Append(GH_LineFromStbNode(nodes[index], nodes[index + 1]), new GH_Path(0, i)); + } + } + + private void GetRcPileLines(GH_Structure lines, StbPile member, int i) + { + var nodeBottom = new StbNode(); + var nodeTop = new StbNode(); + + StbNode node = _nodes.First(n => n.id == member.id_node); + if (_isOffset) + { + nodeTop = new StbNode + { + X = node.X + member.offset_X, + Y = node.Y + member.offset_Y, + Z = node.Z + member.level_top + }; + nodeBottom = new StbNode + { + X = nodeTop.X, + Y = nodeTop.Y, + Z = nodeTop.Z - member.length_all + }; + + } + else + { + nodeTop = new StbNode + { + X = node.X, + Y = node.Y, + Z = node.Z + }; + nodeBottom = new StbNode + { + X = nodeTop.X, + Y = nodeTop.Y, + Z = nodeTop.Z - member.length_all + }; + } + lines.Append(GH_LineFromStbNode(nodeBottom, nodeTop), new GH_Path(0, i)); + } + private static GH_Line GH_LineFromStbNode(StbNode from, StbNode to) { var ptFrom = new Point3d(from.X, from.Y, from.Z); diff --git a/HoaryFox/RH7/Component/Utils/Geometry/CreateMemberBrepListFromStb.cs b/HoaryFox/RH7/Component/Utils/Geometry/CreateMemberBrepListFromStb.cs index 482621a3..b206e552 100644 --- a/HoaryFox/RH7/Component/Utils/Geometry/CreateMemberBrepListFromStb.cs +++ b/HoaryFox/RH7/Component/Utils/Geometry/CreateMemberBrepListFromStb.cs @@ -56,7 +56,7 @@ public GH_Structure Column(IEnumerable columns) sectionPoints[1] = sectionPoints[0] + memberAxis / memberAxis.Length * column.joint_bottom; sectionPoints[2] = sectionPoints[3] - memberAxis / memberAxis.Length * column.joint_top; - var brepMaker = new BrepMaker.Column(_sections, _tolerance); + var brepMaker = new BrepMaker.Column(_sections, _tolerance, column.guid); brepList.Append(new GH_Brep(brepMaker.CreateColumnBrep(column.id_section, column.rotate, kind, sectionPoints, memberAxis)), new GH_Path(0, i)); } @@ -96,7 +96,7 @@ public GH_Structure Post(IEnumerable posts) sectionPoints[1] = sectionPoints[0] + memberAxis / memberAxis.Length * post.joint_bottom; sectionPoints[2] = sectionPoints[3] - memberAxis / memberAxis.Length * post.joint_top; - var brepMaker = new BrepMaker.Column(_sections, _tolerance); + var brepMaker = new BrepMaker.Column(_sections, _tolerance, post.guid); brepList.Append(new GH_Brep(brepMaker.CreateColumnBrep(post.id_section, post.rotate, kind, sectionPoints, memberAxis)), new GH_Path(0, i)); } @@ -128,15 +128,19 @@ public GH_Structure Girder(IEnumerable girders) Point3d[] sectionPoints = { new Point3d(endNodes[0].X, endNodes[0].Y, endNodes[0].Z) + offset[0], - Point3d.Origin, - Point3d.Origin, + Point3d.Origin, // haunch_s + Point3d.Origin, // joint_s + Point3d.Origin, // joint_e + Point3d.Origin, // haunch_e new Point3d(endNodes[1].X, endNodes[1].Y, endNodes[1].Z) + offset[1] }; - Vector3d memberAxis = sectionPoints[3] - sectionPoints[0]; - sectionPoints[1] = sectionPoints[0] + memberAxis / memberAxis.Length * girder.joint_start; - sectionPoints[2] = sectionPoints[3] - memberAxis / memberAxis.Length * girder.joint_end; + Vector3d memberAxis = sectionPoints[5] - sectionPoints[0]; + sectionPoints[1] = sectionPoints[0] + memberAxis / memberAxis.Length * girder.haunch_start; + sectionPoints[2] = sectionPoints[0] + memberAxis / memberAxis.Length * girder.joint_start; + sectionPoints[3] = sectionPoints[5] - memberAxis / memberAxis.Length * girder.joint_end; + sectionPoints[4] = sectionPoints[5] - memberAxis / memberAxis.Length * girder.haunch_end; - var brepMaker = new BrepMaker.Girder(_sections, _tolerance); + var brepMaker = new BrepMaker.Girder(_sections, _tolerance, girder.guid); brepList.Append(new GH_Brep(brepMaker.CreateGirderBrep(girder.id_section, girder.rotate, kind, sectionPoints, memberAxis)), new GH_Path(0, i)); } @@ -168,15 +172,19 @@ public GH_Structure Beam(IEnumerable beams) Point3d[] sectionPoints = { new Point3d(endNodes[0].X, endNodes[0].Y, endNodes[0].Z) + offset[0], - Point3d.Origin, - Point3d.Origin, + Point3d.Origin, // haunch_s + Point3d.Origin, // joint_s + Point3d.Origin, // joint_e + Point3d.Origin, // haunch_e new Point3d(endNodes[1].X, endNodes[1].Y, endNodes[1].Z) + offset[1] }; - Vector3d memberAxis = sectionPoints[3] - sectionPoints[0]; - sectionPoints[1] = sectionPoints[0] + memberAxis / memberAxis.Length * beam.joint_start; - sectionPoints[2] = sectionPoints[3] - memberAxis / memberAxis.Length * beam.joint_end; + Vector3d memberAxis = sectionPoints[5] - sectionPoints[0]; + sectionPoints[1] = sectionPoints[0] + memberAxis / memberAxis.Length * beam.haunch_start; + sectionPoints[2] = sectionPoints[0] + memberAxis / memberAxis.Length * beam.joint_start; + sectionPoints[3] = sectionPoints[5] - memberAxis / memberAxis.Length * beam.joint_end; + sectionPoints[4] = sectionPoints[5] - memberAxis / memberAxis.Length * beam.haunch_end; - var brepMaker = new BrepMaker.Girder(_sections, _tolerance); + var brepMaker = new BrepMaker.Girder(_sections, _tolerance, beam.guid); brepList.Append(new GH_Brep(brepMaker.CreateGirderBrep(beam.id_section, beam.rotate, kind, sectionPoints, memberAxis)), new GH_Path(0, i)); } @@ -216,7 +224,7 @@ public GH_Structure Brace(IEnumerable braces) sectionPoints[1] = sectionPoints[0] + memberAxis / memberAxis.Length * brace.joint_start; sectionPoints[2] = sectionPoints[3] - memberAxis / memberAxis.Length * brace.joint_end; - var brepMaker = new BrepMaker.Brace(_sections, _tolerance); + var brepMaker = new BrepMaker.Brace(_sections, _tolerance, brace.guid); brepList.Append(new GH_Brep(brepMaker.CreateBraceBrep(brace.id_section, brace.rotate, kind, sectionPoints, memberAxis)), new GH_Path(0, i)); } @@ -424,5 +432,105 @@ private static Point3d[] GetOpenCurvePts(IReadOnlyList wallPts, StbOpen return openCurvePts; } + + public GH_Structure Pile(IEnumerable piles) + { + var brepList = new GH_Structure(); + if (piles == null) + { + return brepList; + } + + foreach ((StbPile pile, int i) in piles.Select((pile, index) => (pile, index))) + { + StbPileKind_structure kind = pile.kind_structure; + StbNode node = _nodes.First(n => n.id == pile.id_node); + var sectionPoints = new List(); + + switch (kind) + { + case StbPileKind_structure.RC: + Point3d[] endNodes = + { + new Point3d(node.X, node.Y, node.Z), + new Point3d(node.X, node.Y, node.Z - pile.length_all) + }; + Point3d[] offset = + { + new Point3d(pile.offset_X, pile.offset_Y, pile.level_top), + new Point3d(pile.offset_X, pile.offset_Y, pile.level_top), + }; + sectionPoints = new List + { + endNodes[0] + offset[0], + new Point3d(), + new Point3d(), + endNodes[1] + offset[1] + }; + sectionPoints[1] = sectionPoints[0] - Vector3d.ZAxis * pile.length_head; + break; + case StbPileKind_structure.PC: + var figures = PCPileFigure.GetFigureList(_sections, pile); + sectionPoints.Add(new Point3d + { + X = node.X + pile.offset_X, + Y = node.Y + pile.offset_Y, + Z = node.Z + pile.level_top + }); + foreach ((PCPileFigure figure, int index) in figures.Select((figure, index) => (figure, index))) + { + sectionPoints.Add(new Point3d + { + X = sectionPoints[index].X, + Y = sectionPoints[index].Y, + Z = sectionPoints[index].Z - figure.Length + }); + } + break; + } + + var brepMaker = new BrepMaker.Pile(_sections, _tolerance, pile.guid); + brepList.Append(new GH_Brep(brepMaker.CreatePileBrep(pile.id_section, kind, sectionPoints, -Vector3d.ZAxis)), new GH_Path(0, i)); + } + + return brepList; + } + + public GH_Structure Footing(IEnumerable footings) + { + var brepList = new GH_Structure(); + if (footings == null) + { + return brepList; + } + + foreach ((StbFooting footing, int i) in footings.Select((f, index) => (f, index))) + { + StbNode node = _nodes.First(n => n.id == footing.id_node); + Point3d[] endNodes = + { + new Point3d(node.X, node.Y, node.Z), + new Point3d(node.X, node.Y, node.Z + footing.level_bottom) + }; + Point3d[] offset = + { + new Point3d(footing.offset_X, footing.offset_Y, 0), + new Point3d(footing.offset_X, footing.offset_Y, 0), + }; + Point3d[] sectionPoints = + { + endNodes[0] + offset[0], + new Point3d(), + new Point3d(), + endNodes[1] + offset[1] + }; + Vector3d memberAxis = sectionPoints[3] - sectionPoints[0]; + + var brepMaker = new BrepMaker.Footing(_sections, _tolerance, footing.guid); + brepList.Append(new GH_Brep(brepMaker.CreateFootingBrep(footing.id_section, footing.rotate, sectionPoints, memberAxis / memberAxis.Length)), new GH_Path(0, i)); + } + + return brepList; + } } } diff --git a/HoaryFox/RH7/Component/Utils/Geometry/PCPileFigure.cs b/HoaryFox/RH7/Component/Utils/Geometry/PCPileFigure.cs new file mode 100644 index 00000000..5f2e8c36 --- /dev/null +++ b/HoaryFox/RH7/Component/Utils/Geometry/PCPileFigure.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using STBDotNet.v202; + +namespace HoaryFox.Component.Utils.Geometry +{ + public class PCPileFigure : IComparable + { + public int Order { get; private set; } + public double Diameter { get; private set; } + public double Thickness { get; private set; } + public double Length { get; private set; } + + public PCPileFigure(int order, double diameter, double thickness, double length) + { + Order = order; + Diameter = diameter; + Thickness = thickness; + Length = length; + } + + public PCPileFigure(StbSecPileProductNodular_CPRC figure) + { + Order = int.Parse(figure.id_order); + Diameter = figure.D1; + Thickness = figure.tc; + Length = figure.length_pile; + } + + public PCPileFigure(StbSecPileProductNodular_PRC figure) + { + Order = int.Parse(figure.id_order); + Diameter = figure.D1; + Thickness = figure.tc; + Length = figure.length_pile; + } + + public PCPileFigure(StbSecPileProductNodular_PHC figure) + { + Order = int.Parse(figure.id_order); + Diameter = figure.D1; + Thickness = figure.t; + Length = figure.length_pile; + } + + public PCPileFigure(StbSecPileProduct_CPRC figure) + { + Order = int.Parse(figure.id_order); + Diameter = figure.D; + Thickness = figure.tc; + Length = figure.length_pile; + } + + public PCPileFigure(StbSecPileProduct_PRC figure) + { + Order = int.Parse(figure.id_order); + Diameter = figure.D; + Thickness = figure.tc; + Length = figure.length_pile; + } + + public PCPileFigure(StbSecPileProduct_PHC figure) + { + Order = int.Parse(figure.id_order); + Diameter = figure.D; + Thickness = figure.t; + Length = figure.length_pile; + } + + public PCPileFigure(StbSecPileProduct_SC figure) + { + Order = int.Parse(figure.id_order); + Diameter = figure.D; + Thickness = figure.tc; + Length = figure.length_pile; + } + + public PCPileFigure(StbSecPileProduct_ST figure) + { + Order = int.Parse(figure.id_order); + Diameter = figure.D1; + Thickness = figure.t1; + Length = figure.length_pile; + } + + public int CompareTo(PCPileFigure other) + { + return Order.CompareTo(other.Order); + } + + public static IEnumerable GetFigureList(StbSections sections, StbPile member) + { + var figures = new List(); + var idSection = member.id_section; + + StbSecPileProduct secPileProduct = sections.StbSecPileProduct.First(sec => sec.id == idSection); + return GetFigureList(secPileProduct); + } + + public static List GetFigureList(StbSecPileProduct secPileProduct) + { + var figures = new List(); + var secNodularCPRC = secPileProduct.StbSecFigurePileProduct.StbSecPileProductNodular_CPRC; + if (secNodularCPRC != null) + { + figures.AddRange(secNodularCPRC.Select(figure => new PCPileFigure(figure))); + } + var secNodularPHC = secPileProduct.StbSecFigurePileProduct.StbSecPileProductNodular_PHC; + if (secNodularPHC != null) + { + figures.AddRange(secNodularPHC.Select(figure => new PCPileFigure(figure))); + } + var secNodularPRC = secPileProduct.StbSecFigurePileProduct.StbSecPileProductNodular_PRC; + if (secNodularPRC != null) + { + figures.AddRange(secNodularPRC.Select(figure => new PCPileFigure(figure))); + } + var secCPRC = secPileProduct.StbSecFigurePileProduct.StbSecPileProduct_CPRC; + if (secCPRC != null) + { + figures.AddRange(secCPRC.Select(figure => new PCPileFigure(figure))); + } + var secPHC = secPileProduct.StbSecFigurePileProduct.StbSecPileProduct_PHC; + if (secPHC != null) + { + figures.AddRange(secPHC.Select(figure => new PCPileFigure(figure))); + } + var secPRC = secPileProduct.StbSecFigurePileProduct.StbSecPileProduct_PRC; + if (secPRC != null) + { + figures.AddRange(secPRC.Select(figure => new PCPileFigure(figure))); + } + var secSC = secPileProduct.StbSecFigurePileProduct.StbSecPileProduct_SC; + if (secSC != null) + { + figures.AddRange(secSC.Select(figure => new PCPileFigure(figure))); + } + var secST = secPileProduct.StbSecFigurePileProduct.StbSecPileProduct_ST; + if (secST != null) + { + figures.AddRange(secST.Select(figure => new PCPileFigure(figure))); + } + + figures.Sort(); + return figures; + } + } +} diff --git a/HoaryFox/RH7/Component/Utils/Geometry/SectionCurve.cs b/HoaryFox/RH7/Component/Utils/Geometry/SectionCurve.cs index a201440d..0c2b6ef7 100644 --- a/HoaryFox/RH7/Component/Utils/Geometry/SectionCurve.cs +++ b/HoaryFox/RH7/Component/Utils/Geometry/SectionCurve.cs @@ -33,7 +33,7 @@ public static SectionCurve CreateSolidColumnCircle(Point3d sectionPoint, double { return new SectionCurve { - OuterCurve = SectionCornerPoints.ColumnPipe(sectionPoint, diameter, xAxis), + OuterCurve = SectionCornerPoints.ColumnPipe(sectionPoint, diameter / 2, xAxis), InnerCurve = null, Shape = SectionShape.Circle, Type = SectionType.Solid, @@ -41,6 +41,20 @@ public static SectionCurve CreateSolidColumnCircle(Point3d sectionPoint, double }; } + public static SectionCurve CreateSolidColumnPipe(Point3d sectionPoint, double outerDiameter, double innerDiameter, Vector3d xAxis) + { + return new SectionCurve + { + OuterCurve = SectionCornerPoints.ColumnPipe(sectionPoint, outerDiameter / 2, xAxis), + InnerCurve = outerDiameter != innerDiameter + ? SectionCornerPoints.ColumnPipe(sectionPoint, innerDiameter / 2, xAxis) + : null, + Shape = SectionShape.Circle, + Type = SectionType.Solid, + XAxis = xAxis, + }; + } + public static SectionCurve CreateSolidBeamRect(Point3d sectionPoint, double depth, double width, Vector3d[] localAxis) { return new SectionCurve() diff --git a/HoaryFox/RH7/Component/Utils/TagUtils.cs b/HoaryFox/RH7/Component/Utils/TagUtils.cs index 6546163a..8d237259 100644 --- a/HoaryFox/RH7/Component/Utils/TagUtils.cs +++ b/HoaryFox/RH7/Component/Utils/TagUtils.cs @@ -294,10 +294,10 @@ internal static IEnumerable GetWallRcSection(StbSecWall_RC_Straight f public static Dictionary[][] GetAllSectionInfoArray(StbMembers members, StbSections sections) { - var allTagList = new Dictionary[7][]; + var allTagList = new Dictionary[9][]; - var memberArray = new object[][] { members.StbColumns, members.StbGirders, members.StbPosts, members.StbBeams, members.StbBraces, members.StbSlabs, members.StbWalls }; - for (var i = 0; i < 7; i++) + var memberArray = new object[][] { members.StbColumns, members.StbGirders, members.StbPosts, members.StbBeams, members.StbBraces, members.StbSlabs, members.StbWalls, members.StbPiles, members.StbFootings }; + for (var i = 0; i < 9; i++) { allTagList[i] = memberArray[i] != null ? StbMembersToDictArray(memberArray[i], sections) : Array.Empty>(); }