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

Feature/pile and foundation #255

Merged
merged 13 commits into from
Jun 5, 2023
19 changes: 12 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
]
}
27 changes: 1 addition & 26 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
12 changes: 8 additions & 4 deletions HoaryFox/RH7/Component/Geometry/Stb2Brep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace HoaryFox.Component.Geometry
public class Stb2Brep : GH_Component
{
private ST_BRIDGE _stBridge;
private readonly GH_Structure<GH_Brep>[] _brepList = new GH_Structure<GH_Brep>[7];
private readonly GH_Structure<GH_Brep>[] _brepList = new GH_Structure<GH_Brep>[9];

public override GH_Exposure Exposure => GH_Exposure.primary;

Expand All @@ -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)
Expand All @@ -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]);
}
Expand All @@ -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<string, string>[][] infoArray = Utils.TagUtils.GetAllSectionInfoArray(_stBridge.StbModel.StbMembers, _stBridge.StbModel.StbSections);
Expand Down
65 changes: 39 additions & 26 deletions HoaryFox/RH7/Component/Geometry/Stb2Line.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Stb2Line : GH_Component
{
private ST_BRIDGE _stBridge;
private List<Point3d> _nodes = new List<Point3d>();
private readonly GH_Structure<GH_Line>[] _lineList = new GH_Structure<GH_Line>[5];
private readonly GH_Structure<GH_Line>[] _lineList = new GH_Structure<GH_Line>[8];

public override GH_Exposure Exposure => GH_Exposure.primary;

Expand All @@ -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);
}

Expand All @@ -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();
Expand All @@ -65,66 +69,75 @@ protected override void SolveInstance(IGH_DataAccess dataAccess)
dataAccess.SetDataList(0, _nodes);
foreach ((GH_Structure<GH_Line> 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<string, string>[][] infoArray = Utils.TagUtils.GetAllSectionInfoArray(_stBridge.StbModel.StbMembers, _stBridge.StbModel.StbSections);

foreach ((GH_Structure<GH_Line> 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;
foreach ((Line line, int bIndex) in lines.Select((geometry, bIndex) => (geometry.Value, bIndex)))
{
var objAttr = new ObjectAttributes();

if (i < 5)
Dictionary<string, string>[] infos = infoArray[i];
Dictionary<string, string> info = infos[bIndex];

foreach (KeyValuePair<string, string> pair in info)
{
Dictionary<string, string>[] infos = infoArray[i];
Dictionary<string, string> info = infos[bIndex];

foreach (KeyValuePair<string, string> 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;
Expand Down
6 changes: 4 additions & 2 deletions HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Brace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ public class Brace
{
private readonly IReadOnlyList<double> _tolerance;
private readonly StbSections _sections;
private readonly string _guid;

public Brace(StbSections sections, IReadOnlyList<double> tolerance)
public Brace(StbSections sections, IReadOnlyList<double> tolerance, string guid)
{
_tolerance = tolerance;
_sections = sections;
_guid = guid;
}

public Brep CreateBraceBrep(string idSection, double rotate, StbBraceKind_structure kind, IReadOnlyList<Point3d> sectionPoints, Vector3d memberAxis)
Expand Down Expand Up @@ -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.");
}
}

Expand Down
7 changes: 5 additions & 2 deletions HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Column.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ public class Column
{
private readonly IReadOnlyList<double> _tolerance;
private readonly StbSections _sections;
public Column(StbSections sections, IReadOnlyList<double> tolerance)
private readonly string _guid;

public Column(StbSections sections, IReadOnlyList<double> tolerance, string guid)
{
_tolerance = tolerance;
_sections = sections;
_guid = guid;
}

public Brep CreateColumnBrep(string idSection, double rotate, StbColumnKind_structure kind, IReadOnlyList<Point3d> sectionPoints, Vector3d memberAxis)
Expand All @@ -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;
Expand Down
66 changes: 66 additions & 0 deletions HoaryFox/RH7/Component/Utils/Geometry/BrepMaker/Footing.cs
Original file line number Diff line number Diff line change
@@ -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<double> _tolerance;
private readonly StbSections _sections;
private readonly string _guid;

public Footing(StbSections sections, IReadOnlyList<double> tolerance, string guid)
{
_tolerance = tolerance;
_sections = sections;
_guid = guid;
}

public Brep CreateFootingBrep(string idSection, double rotate, IReadOnlyList<Point3d> 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<Point3d> 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<Point3d> sectionPoints, Vector3d axis)
{
var curveList = new List<SectionCurve>();
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();
}
}
}
Loading