Skip to content

Commit

Permalink
Merge pull request #165 from hrntsm/feature/add-slab-n-wall-tag-output
Browse files Browse the repository at this point in the history
Feature/add slab n wall tag output
  • Loading branch information
hrntsm committed Aug 29, 2021
2 parents aab1c37 + 7aa4351 commit d6e6583
Show file tree
Hide file tree
Showing 27 changed files with 1,059 additions and 20 deletions.
2 changes: 2 additions & 0 deletions HoaryFox/Component/Geometry/Axes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class Axis : GH_Component
private readonly List<string> _storyStr = new List<string>();

public override bool IsPreviewCapable => true;
public override GH_Exposure Exposure => GH_Exposure.secondary;

public Axis()
: base("Axis", "Axis",
"Description",
Expand Down
2 changes: 2 additions & 0 deletions HoaryFox/Component/Geometry/Stb2Brep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class Stb2Brep : GH_Component
private ST_BRIDGE _stBridge;
private readonly List<List<Brep>> _brepList = new List<List<Brep>>();

public override GH_Exposure Exposure => GH_Exposure.primary;

public Stb2Brep()
: base("Stb to Brep", "S2B",
"Display ST-Bridge model in Brep",
Expand Down
2 changes: 2 additions & 0 deletions HoaryFox/Component/Geometry/Stb2Line.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class Stb2Line : GH_Component
private List<Point3d> _nodes = new List<Point3d>();
private readonly List<List<Line>> _lineList = new List<List<Line>>();

public override GH_Exposure Exposure => GH_Exposure.primary;

public Stb2Line()
: base("Stb to Line", "S2L",
"Display ST-Bridge model in line",
Expand Down
4 changes: 3 additions & 1 deletion HoaryFox/Component/Tag/Name/BeamNameTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class BeamNameTag : GH_Component
private readonly List<Point3d> _framePos = new List<Point3d>();

public override bool IsPreviewCapable => true;
public override GH_Exposure Exposure => GH_Exposure.secondary;

public BeamNameTag()
: base("Beam Name Tag", "BeamTag",
"Display Beam Name Tag",
Expand Down Expand Up @@ -55,7 +57,7 @@ protected override void SolveInstance(IGH_DataAccess dataAccess)

string idNodeStart = beam.id_node_start;
string idNodeEnd = beam.id_node_end;
_framePos.Add(TagUtils.GetTagPosition(idNodeStart, idNodeEnd, nodes));
_framePos.Add(TagUtils.GetFrameTagPosition(idNodeStart, idNodeEnd, nodes));
}
dataAccess.SetDataList(0, _frameName);
}
Expand Down
4 changes: 3 additions & 1 deletion HoaryFox/Component/Tag/Name/BraceNameTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class BraceNameTag : GH_Component
private readonly List<Point3d> _framePos = new List<Point3d>();

public override bool IsPreviewCapable => true;
public override GH_Exposure Exposure => GH_Exposure.tertiary;

public BraceNameTag()
: base("Brace Name Tag", "BraceTag",
"Display Brace Name Tag",
Expand Down Expand Up @@ -55,7 +57,7 @@ protected override void SolveInstance(IGH_DataAccess dataAccess)

string idNodeStart = brace.id_node_start;
string idNodeEnd = brace.id_node_end;
_framePos.Add(TagUtils.GetTagPosition(idNodeStart, idNodeEnd, nodes));
_framePos.Add(TagUtils.GetFrameTagPosition(idNodeStart, idNodeEnd, nodes));
}
dataAccess.SetDataList(0, _frameName);
}
Expand Down
4 changes: 3 additions & 1 deletion HoaryFox/Component/Tag/Name/ColumnNameTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class ColumnNameTag : GH_Component
private readonly List<Point3d> _framePos = new List<Point3d>();

public override bool IsPreviewCapable => true;
public override GH_Exposure Exposure => GH_Exposure.primary;

public ColumnNameTag()
: base("Column Name Tag", "ColumnTag",
"Display Column Name Tag",
Expand Down Expand Up @@ -55,7 +57,7 @@ protected override void SolveInstance(IGH_DataAccess dataAccess)

string idNodeStart = column.id_node_bottom;
string idNodeEnd = column.id_node_top;
_framePos.Add(TagUtils.GetTagPosition(idNodeStart, idNodeEnd, nodes));
_framePos.Add(TagUtils.GetFrameTagPosition(idNodeStart, idNodeEnd, nodes));
}
dataAccess.SetDataList(0, _frameName);
}
Expand Down
4 changes: 3 additions & 1 deletion HoaryFox/Component/Tag/Name/GirderNameTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class GirderNameTag : GH_Component
private readonly List<Point3d> _framePos = new List<Point3d>();

public override bool IsPreviewCapable => true;
public override GH_Exposure Exposure => GH_Exposure.secondary;

public GirderNameTag()
: base("Girder Name Tag", "GirderTag",
"Display Girder Name Tag",
Expand Down Expand Up @@ -55,7 +57,7 @@ protected override void SolveInstance(IGH_DataAccess dataAccess)

string idNodeStart = girder.id_node_start;
string idNodeEnd = girder.id_node_end;
_framePos.Add(TagUtils.GetTagPosition(idNodeStart, idNodeEnd, nodes));
_framePos.Add(TagUtils.GetFrameTagPosition(idNodeStart, idNodeEnd, nodes));
}
dataAccess.SetDataList(0, _frameName);
}
Expand Down
4 changes: 3 additions & 1 deletion HoaryFox/Component/Tag/Name/PostNameTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class PostNameTag : GH_Component
private readonly List<Point3d> _framePos = new List<Point3d>();

public override bool IsPreviewCapable => true;
public override GH_Exposure Exposure => GH_Exposure.primary;

public PostNameTag()
: base("Post Name Tag", "PostTag",
"Display Post Name Tag",
Expand Down Expand Up @@ -55,7 +57,7 @@ protected override void SolveInstance(IGH_DataAccess dataAccess)

string idNodeStart = post.id_node_bottom;
string idNodeEnd = post.id_node_top;
_framePos.Add(TagUtils.GetTagPosition(idNodeStart, idNodeEnd, nodes));
_framePos.Add(TagUtils.GetFrameTagPosition(idNodeStart, idNodeEnd, nodes));
}
dataAccess.SetDataList(0, _frameName);
}
Expand Down
100 changes: 100 additions & 0 deletions HoaryFox/Component/Tag/Name/SlabNameTag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Grasshopper.Kernel;
using HoaryFox.Properties;
using Rhino.Geometry;
using STBDotNet.v202;

namespace HoaryFox.Component.Tag.Name
{
public class SlabNameTag : GH_Component
{
private ST_BRIDGE _stBridge;
private int _size;

private readonly List<string> _plateName = new List<string>();
private readonly List<Point3d> _platePos = new List<Point3d>();

public override bool IsPreviewCapable => true;
public override GH_Exposure Exposure => GH_Exposure.quarternary;

public SlabNameTag()
: base("Slab Name Tag", "SlabTag",
"Display Slab Name Tag",
"HoaryFox", "NameTag")
{
}

public override void ClearData()
{
base.ClearData();
_plateName.Clear();
_platePos.Clear();
}

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGenericParameter("Data", "D", "input ST-Bridge file data", GH_ParamAccess.item);
pManager.AddIntegerParameter("Size", "S", "Tag size", GH_ParamAccess.item, 12);
}

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddTextParameter("NameTag", "NTag", "output name tag", GH_ParamAccess.list);
}

protected override void SolveInstance(IGH_DataAccess dataAccess)
{
if (!dataAccess.GetData("Data", ref _stBridge)) { return; }
if (!dataAccess.GetData("Size", ref _size)) { return; }

StbNode[] nodes = _stBridge.StbModel.StbNodes;
StbSlab[] slabs = _stBridge.StbModel.StbMembers.StbSlabs;
foreach (StbSlab slab in slabs)
{
_plateName.Add(slab.name);
StbSlabOffset[] offsets = slab.StbSlabOffsetList;
string[] nodeIds = slab.StbNodeIdOrder.Split(' ');
Point3d[] pts = SlabNodeToPoint3ds(nodeIds, nodes, offsets);
_platePos.Add(new Point3d(pts.Average(n => n.X), pts.Average(n => n.Y), pts.Average(n => n.Z)));
}
dataAccess.SetDataList(0, _plateName);
}

private static Point3d[] SlabNodeToPoint3ds(IReadOnlyList<string> nodeIds, StbNode[] nodes, StbSlabOffset[] offsets)
{
var pts = new Point3d[nodeIds.Count];
for (var i = 0; i < nodeIds.Count; i++)
{
string nodeId = nodeIds[i];
StbNode node = nodes.First(n => n.id == nodeId);
var offsetVec = new Vector3d();
if (offsets != null)
{
foreach (StbSlabOffset offset in offsets.Where(offset => nodeId == offset.id_node))
{
offsetVec = new Vector3d(offset.offset_X, offset.offset_Y, offset.offset_Z);
}
}

pts[i] = new Point3d(node.X, node.Y, node.Z) + offsetVec;
}

return pts;
}

public override void DrawViewportWires(IGH_PreviewArgs args)
{
for (var i = 0; i < _plateName.Count; i++)
{
args.Display.Draw2dText(_plateName[i], Color.Black, _platePos[i], true, _size);
}
}

protected override Bitmap Icon => Resource.SlabName;

public override Guid ComponentGuid => new Guid("9ee6efbb-20b5-49bb-aae9-02ca6031c09d");
}
}
84 changes: 84 additions & 0 deletions HoaryFox/Component/Tag/Name/WallNameTag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Grasshopper.Kernel;
using HoaryFox.Properties;
using Rhino.Geometry;
using STBDotNet.v202;

namespace HoaryFox.Component.Tag.Name
{
public class WallNameTag : GH_Component
{
private ST_BRIDGE _stBridge;
private int _size;

private readonly List<string> _plateName = new List<string>();
private readonly List<Point3d> _platePos = new List<Point3d>();

public override bool IsPreviewCapable => true;
public override GH_Exposure Exposure => GH_Exposure.quarternary;

public WallNameTag()
: base("Wall Name Tag", "WallTag",
"Display Wall Name Tag",
"HoaryFox", "NameTag")
{
}

public override void ClearData()
{
base.ClearData();
_plateName.Clear();
_platePos.Clear();
}

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGenericParameter("Data", "D", "input ST-Bridge file data", GH_ParamAccess.item);
pManager.AddIntegerParameter("Size", "S", "Tag size", GH_ParamAccess.item, 12);
}

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddTextParameter("NameTag", "NTag", "output name tag", GH_ParamAccess.list);
}

protected override void SolveInstance(IGH_DataAccess dataAccess)
{
if (!dataAccess.GetData("Data", ref _stBridge)) { return; }
if (!dataAccess.GetData("Size", ref _size)) { return; }

StbNode[] nodes = _stBridge.StbModel.StbNodes;
StbWall[] walls = _stBridge.StbModel.StbMembers.StbWalls;
foreach (StbWall wall in walls)
{
_plateName.Add(wall.name);

string[] nodeIds = wall.StbNodeIdOrder.Split(' ');
var pts = new Point3d[nodeIds.Length];
for (int i = 0; i < nodeIds.Length; i++)
{
string nodeId = nodeIds[i];
StbNode node = nodes.First(n => n.id == nodeId);
pts[i] = new Point3d(node.X, node.Y, node.Z);
}
_platePos.Add(new Point3d(pts.Average(n => n.X), pts.Average(n => n.Y), pts.Average(n => n.Z)));
}
dataAccess.SetDataList(0, _plateName);
}

public override void DrawViewportWires(IGH_PreviewArgs args)
{
for (var i = 0; i < _plateName.Count; i++)
{
args.Display.Draw2dText(_plateName[i], Color.Black, _platePos[i], true, _size);
}
}

protected override Bitmap Icon => Resource.WallName;

public override Guid ComponentGuid => new Guid("713d1503-eebd-4504-83f0-ddd072a11188");
}
}
3 changes: 2 additions & 1 deletion HoaryFox/Component/Tag/Section/BeamSecTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class BeamSecTag : GH_Component
private int _size;
private GH_Structure<GH_String> _frameTags = new GH_Structure<GH_String>();
private List<Point3d> _tagPos = new List<Point3d>();
public override GH_Exposure Exposure => GH_Exposure.secondary;

public BeamSecTag()
: base("Beam Section Tag", "BeamSec",
Expand Down Expand Up @@ -105,7 +106,7 @@ private static GH_Structure<GH_String> GetTagStrings(IEnumerable<StbBeam> beams,

private static List<Point3d> GetTagPosition(IEnumerable<StbBeam> beams, IEnumerable<StbNode> nodes)
{
return beams.Select(beam => TagUtils.GetTagPosition(beam.id_node_start, beam.id_node_end, nodes)).ToList();
return beams.Select(beam => TagUtils.GetFrameTagPosition(beam.id_node_start, beam.id_node_end, nodes)).ToList();
}

public override void DrawViewportWires(IGH_PreviewArgs args)
Expand Down
3 changes: 2 additions & 1 deletion HoaryFox/Component/Tag/Section/BraceSecTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class BraceSecTag : GH_Component
private int _size;
private GH_Structure<GH_String> _frameTags = new GH_Structure<GH_String>();
private List<Point3d> _tagPos = new List<Point3d>();
public override GH_Exposure Exposure => GH_Exposure.tertiary;

public BraceSecTag()
: base("Brace Section Tag", "BraceSec",
Expand Down Expand Up @@ -95,7 +96,7 @@ private static List<Point3d> GetTagPosition(IEnumerable<StbBrace> braces, IEnume
{
return braces == null
? new List<Point3d>()
: braces.Select(beam => TagUtils.GetTagPosition(beam.id_node_start, beam.id_node_end, nodes)).ToList();
: braces.Select(beam => TagUtils.GetFrameTagPosition(beam.id_node_start, beam.id_node_end, nodes)).ToList();
}

public override void DrawViewportWires(IGH_PreviewArgs args)
Expand Down
4 changes: 3 additions & 1 deletion HoaryFox/Component/Tag/Section/ColumnSecTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class ColumnSecTag : GH_Component
private int _size;
private GH_Structure<GH_String> _frameTags = new GH_Structure<GH_String>();
private List<Point3d> _tagPos = new List<Point3d>();
public override GH_Exposure Exposure => GH_Exposure.primary;


public ColumnSecTag()
: base("Column Section Tag", "ColumnSec",
Expand Down Expand Up @@ -100,7 +102,7 @@ private static GH_Structure<GH_String> GetTagStrings(IEnumerable<StbColumn> colu

private static List<Point3d> GetTagPosition(IEnumerable<StbColumn> columns, IEnumerable<StbNode> nodes)
{
return columns.Select(beam => TagUtils.GetTagPosition(beam.id_node_bottom, beam.id_node_top, nodes)).ToList();
return columns.Select(beam => TagUtils.GetFrameTagPosition(beam.id_node_bottom, beam.id_node_top, nodes)).ToList();
}

public override void DrawViewportWires(IGH_PreviewArgs args)
Expand Down
3 changes: 2 additions & 1 deletion HoaryFox/Component/Tag/Section/GirderSecTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class GirderSecTag : GH_Component
private int _size;
private GH_Structure<GH_String> _frameTags = new GH_Structure<GH_String>();
private List<Point3d> _tagPos = new List<Point3d>();
public override GH_Exposure Exposure => GH_Exposure.secondary;

public GirderSecTag()
: base("Girder Section Tag", "GirderSec",
Expand Down Expand Up @@ -105,7 +106,7 @@ private static GH_Structure<GH_String> GetTagStrings(IEnumerable<StbGirder> beam

private static List<Point3d> GetTagPosition(IEnumerable<StbGirder> girders, IEnumerable<StbNode> nodes)
{
return girders.Select(girder => TagUtils.GetTagPosition(girder.id_node_start, girder.id_node_end, nodes)).ToList();
return girders.Select(girder => TagUtils.GetFrameTagPosition(girder.id_node_start, girder.id_node_end, nodes)).ToList();
}

public override void DrawViewportWires(IGH_PreviewArgs args)
Expand Down
3 changes: 2 additions & 1 deletion HoaryFox/Component/Tag/Section/PostSecTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class PostSecTag : GH_Component
private int _size;
private GH_Structure<GH_String> _frameTags = new GH_Structure<GH_String>();
private List<Point3d> _tagPos = new List<Point3d>();
public override GH_Exposure Exposure => GH_Exposure.primary;

public PostSecTag()
: base("Post Section Tag", "PostSec",
Expand Down Expand Up @@ -100,7 +101,7 @@ private static GH_Structure<GH_String> GetTagStrings(IEnumerable<StbPost> column

private static List<Point3d> GetTagPosition(IEnumerable<StbPost> columns, IEnumerable<StbNode> nodes)
{
return columns.Select(beam => TagUtils.GetTagPosition(beam.id_node_bottom, beam.id_node_top, nodes)).ToList();
return columns.Select(beam => TagUtils.GetFrameTagPosition(beam.id_node_bottom, beam.id_node_top, nodes)).ToList();
}

public override void DrawViewportWires(IGH_PreviewArgs args)
Expand Down
Loading

0 comments on commit d6e6583

Please sign in to comment.