diff --git a/HoaryFox/Component/Geometry/Axes.cs b/HoaryFox/Component/Geometry/Axes.cs index 4e3da5fe..d94556c9 100644 --- a/HoaryFox/Component/Geometry/Axes.cs +++ b/HoaryFox/Component/Geometry/Axes.cs @@ -21,6 +21,8 @@ public class Axis : GH_Component private readonly List _storyStr = new List(); public override bool IsPreviewCapable => true; + public override GH_Exposure Exposure => GH_Exposure.secondary; + public Axis() : base("Axis", "Axis", "Description", diff --git a/HoaryFox/Component/Geometry/Stb2Brep.cs b/HoaryFox/Component/Geometry/Stb2Brep.cs index c2343813..9da02140 100644 --- a/HoaryFox/Component/Geometry/Stb2Brep.cs +++ b/HoaryFox/Component/Geometry/Stb2Brep.cs @@ -17,6 +17,8 @@ public class Stb2Brep : GH_Component private ST_BRIDGE _stBridge; private readonly List> _brepList = new List>(); + public override GH_Exposure Exposure => GH_Exposure.primary; + public Stb2Brep() : base("Stb to Brep", "S2B", "Display ST-Bridge model in Brep", diff --git a/HoaryFox/Component/Geometry/Stb2Line.cs b/HoaryFox/Component/Geometry/Stb2Line.cs index 44cc4c7a..2c60d1d1 100644 --- a/HoaryFox/Component/Geometry/Stb2Line.cs +++ b/HoaryFox/Component/Geometry/Stb2Line.cs @@ -18,6 +18,8 @@ public class Stb2Line : GH_Component private List _nodes = new List(); private readonly List> _lineList = new List>(); + public override GH_Exposure Exposure => GH_Exposure.primary; + public Stb2Line() : base("Stb to Line", "S2L", "Display ST-Bridge model in line", diff --git a/HoaryFox/Component/Tag/Name/BeamNameTag.cs b/HoaryFox/Component/Tag/Name/BeamNameTag.cs index aa6ed27e..b98fbe8e 100644 --- a/HoaryFox/Component/Tag/Name/BeamNameTag.cs +++ b/HoaryFox/Component/Tag/Name/BeamNameTag.cs @@ -17,6 +17,8 @@ public class BeamNameTag : GH_Component private readonly List _framePos = new List(); public override bool IsPreviewCapable => true; + public override GH_Exposure Exposure => GH_Exposure.secondary; + public BeamNameTag() : base("Beam Name Tag", "BeamTag", "Display Beam Name Tag", @@ -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); } diff --git a/HoaryFox/Component/Tag/Name/BraceNameTag.cs b/HoaryFox/Component/Tag/Name/BraceNameTag.cs index 9b27cc9f..da857bbb 100644 --- a/HoaryFox/Component/Tag/Name/BraceNameTag.cs +++ b/HoaryFox/Component/Tag/Name/BraceNameTag.cs @@ -17,6 +17,8 @@ public class BraceNameTag : GH_Component private readonly List _framePos = new List(); public override bool IsPreviewCapable => true; + public override GH_Exposure Exposure => GH_Exposure.tertiary; + public BraceNameTag() : base("Brace Name Tag", "BraceTag", "Display Brace Name Tag", @@ -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); } diff --git a/HoaryFox/Component/Tag/Name/ColumnNameTag.cs b/HoaryFox/Component/Tag/Name/ColumnNameTag.cs index 92df7a97..b138a79d 100644 --- a/HoaryFox/Component/Tag/Name/ColumnNameTag.cs +++ b/HoaryFox/Component/Tag/Name/ColumnNameTag.cs @@ -17,6 +17,8 @@ public class ColumnNameTag : GH_Component private readonly List _framePos = new List(); public override bool IsPreviewCapable => true; + public override GH_Exposure Exposure => GH_Exposure.primary; + public ColumnNameTag() : base("Column Name Tag", "ColumnTag", "Display Column Name Tag", @@ -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); } diff --git a/HoaryFox/Component/Tag/Name/GirderNameTag.cs b/HoaryFox/Component/Tag/Name/GirderNameTag.cs index e193ebcf..1e4d7130 100644 --- a/HoaryFox/Component/Tag/Name/GirderNameTag.cs +++ b/HoaryFox/Component/Tag/Name/GirderNameTag.cs @@ -17,6 +17,8 @@ public class GirderNameTag : GH_Component private readonly List _framePos = new List(); public override bool IsPreviewCapable => true; + public override GH_Exposure Exposure => GH_Exposure.secondary; + public GirderNameTag() : base("Girder Name Tag", "GirderTag", "Display Girder Name Tag", @@ -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); } diff --git a/HoaryFox/Component/Tag/Name/PostNameTag.cs b/HoaryFox/Component/Tag/Name/PostNameTag.cs index 90403466..fdd117b6 100644 --- a/HoaryFox/Component/Tag/Name/PostNameTag.cs +++ b/HoaryFox/Component/Tag/Name/PostNameTag.cs @@ -17,6 +17,8 @@ public class PostNameTag : GH_Component private readonly List _framePos = new List(); public override bool IsPreviewCapable => true; + public override GH_Exposure Exposure => GH_Exposure.primary; + public PostNameTag() : base("Post Name Tag", "PostTag", "Display Post Name Tag", @@ -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); } diff --git a/HoaryFox/Component/Tag/Name/SlabNameTag.cs b/HoaryFox/Component/Tag/Name/SlabNameTag.cs new file mode 100644 index 00000000..c8804370 --- /dev/null +++ b/HoaryFox/Component/Tag/Name/SlabNameTag.cs @@ -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 _plateName = new List(); + private readonly List _platePos = new List(); + + 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 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"); + } +} diff --git a/HoaryFox/Component/Tag/Name/WallNameTag.cs b/HoaryFox/Component/Tag/Name/WallNameTag.cs new file mode 100644 index 00000000..10c25769 --- /dev/null +++ b/HoaryFox/Component/Tag/Name/WallNameTag.cs @@ -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 _plateName = new List(); + private readonly List _platePos = new List(); + + 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"); + } +} diff --git a/HoaryFox/Component/Tag/Section/BeamSecTag.cs b/HoaryFox/Component/Tag/Section/BeamSecTag.cs index 8865b96b..3acd383a 100644 --- a/HoaryFox/Component/Tag/Section/BeamSecTag.cs +++ b/HoaryFox/Component/Tag/Section/BeamSecTag.cs @@ -18,6 +18,7 @@ public class BeamSecTag : GH_Component private int _size; private GH_Structure _frameTags = new GH_Structure(); private List _tagPos = new List(); + public override GH_Exposure Exposure => GH_Exposure.secondary; public BeamSecTag() : base("Beam Section Tag", "BeamSec", @@ -105,7 +106,7 @@ private static GH_Structure GetTagStrings(IEnumerable beams, private static List GetTagPosition(IEnumerable beams, IEnumerable 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) diff --git a/HoaryFox/Component/Tag/Section/BraceSecTag.cs b/HoaryFox/Component/Tag/Section/BraceSecTag.cs index 01ec62cf..88333ac1 100644 --- a/HoaryFox/Component/Tag/Section/BraceSecTag.cs +++ b/HoaryFox/Component/Tag/Section/BraceSecTag.cs @@ -18,6 +18,7 @@ public class BraceSecTag : GH_Component private int _size; private GH_Structure _frameTags = new GH_Structure(); private List _tagPos = new List(); + public override GH_Exposure Exposure => GH_Exposure.tertiary; public BraceSecTag() : base("Brace Section Tag", "BraceSec", @@ -95,7 +96,7 @@ private static List GetTagPosition(IEnumerable braces, IEnume { return braces == null ? new List() - : 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) diff --git a/HoaryFox/Component/Tag/Section/ColumnSecTag.cs b/HoaryFox/Component/Tag/Section/ColumnSecTag.cs index 0f5a7fad..7f21153d 100644 --- a/HoaryFox/Component/Tag/Section/ColumnSecTag.cs +++ b/HoaryFox/Component/Tag/Section/ColumnSecTag.cs @@ -18,6 +18,8 @@ public class ColumnSecTag : GH_Component private int _size; private GH_Structure _frameTags = new GH_Structure(); private List _tagPos = new List(); + public override GH_Exposure Exposure => GH_Exposure.primary; + public ColumnSecTag() : base("Column Section Tag", "ColumnSec", @@ -100,7 +102,7 @@ private static GH_Structure GetTagStrings(IEnumerable colu private static List GetTagPosition(IEnumerable columns, IEnumerable 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) diff --git a/HoaryFox/Component/Tag/Section/GirderSecTag.cs b/HoaryFox/Component/Tag/Section/GirderSecTag.cs index 1a3e75e3..a77e88ba 100644 --- a/HoaryFox/Component/Tag/Section/GirderSecTag.cs +++ b/HoaryFox/Component/Tag/Section/GirderSecTag.cs @@ -18,6 +18,7 @@ public class GirderSecTag : GH_Component private int _size; private GH_Structure _frameTags = new GH_Structure(); private List _tagPos = new List(); + public override GH_Exposure Exposure => GH_Exposure.secondary; public GirderSecTag() : base("Girder Section Tag", "GirderSec", @@ -105,7 +106,7 @@ private static GH_Structure GetTagStrings(IEnumerable beam private static List GetTagPosition(IEnumerable girders, IEnumerable 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) diff --git a/HoaryFox/Component/Tag/Section/PostSecTag.cs b/HoaryFox/Component/Tag/Section/PostSecTag.cs index e449b485..e306e0e1 100644 --- a/HoaryFox/Component/Tag/Section/PostSecTag.cs +++ b/HoaryFox/Component/Tag/Section/PostSecTag.cs @@ -18,6 +18,7 @@ public class PostSecTag : GH_Component private int _size; private GH_Structure _frameTags = new GH_Structure(); private List _tagPos = new List(); + public override GH_Exposure Exposure => GH_Exposure.primary; public PostSecTag() : base("Post Section Tag", "PostSec", @@ -100,7 +101,7 @@ private static GH_Structure GetTagStrings(IEnumerable column private static List GetTagPosition(IEnumerable columns, IEnumerable 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) diff --git a/HoaryFox/Component/Tag/Section/SlabSecTag.cs b/HoaryFox/Component/Tag/Section/SlabSecTag.cs new file mode 100644 index 00000000..43827818 --- /dev/null +++ b/HoaryFox/Component/Tag/Section/SlabSecTag.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using Grasshopper.Kernel; +using Grasshopper.Kernel.Data; +using Grasshopper.Kernel.Types; +using HoaryFox.Component.Utils; +using HoaryFox.Properties; +using Rhino.Geometry; +using STBDotNet.v202; + +namespace HoaryFox.Component.Tag.Section +{ + public class SlabSecTag : GH_Component + { + private ST_BRIDGE _stBridge; + private int _size; + private GH_Structure _plateTags = new GH_Structure(); + private List _tagPos = new List(); + + public override GH_Exposure Exposure => GH_Exposure.quarternary; + + public SlabSecTag() + : base("Slab Section Tag", "SlabSec", + "Display Slab Section Tag", + "HoaryFox", "SectionTag") + { + } + + public override void ClearData() + { + base.ClearData(); + _plateTags.Clear(); + _tagPos.Clear(); + } + + public override bool IsPreviewCapable => true; + + 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("SecTag", "STag", "output section tag", GH_ParamAccess.tree); + } + + protected override void SolveInstance(IGH_DataAccess dataAccess) + { + if (!dataAccess.GetData("Data", ref _stBridge)) { return; } + if (!dataAccess.GetData("Size", ref _size)) { return; } + + _plateTags = GetTagStrings(_stBridge.StbModel.StbMembers.StbSlabs, _stBridge.StbModel.StbSections); + _tagPos = GetTagPosition(_stBridge.StbModel.StbMembers.StbSlabs, _stBridge.StbModel.StbNodes); + + dataAccess.SetDataTree(0, _plateTags); + } + private static GH_Structure GetTagStrings(IEnumerable slabs, StbSections sections) + { + var ghSecStrings = new GH_Structure(); + + foreach (var item in slabs.Select((slab, index) => new { slab, index })) + { + SetSectionInfo(sections, ghSecStrings, item.slab, item.index); + } + + return ghSecStrings; + } + + private static void SetSectionInfo(StbSections sections, GH_Structure ghSecStrings, StbSlab slab, int index) + { + string secId = slab.id_section; + var ghPath = new GH_Path(0, index); + StbSlabKind_structure kindStruct = slab.kind_structure; + switch (kindStruct) + { + case StbSlabKind_structure.RC: + StbSecSlab_RC secRc = sections.StbSecSlab_RC.First(i => i.id == secId); + foreach (object figure in secRc.StbSecFigureSlab_RC.Items) + { + ghSecStrings.AppendRange(TagUtils.GetSlabRcSection(figure, secRc.strength_concrete), ghPath); + } + break; + case StbSlabKind_structure.DECK: + StbSecSlabDeck secDeck = sections.StbSecSlabDeck.First(i => i.id == secId); + ghSecStrings.AppendRange(TagUtils.GetSlabDeckSection(secDeck.StbSecFigureSlabDeck.StbSecSlabDeckStraight, secDeck.strength_concrete), ghPath); + break; + case StbSlabKind_structure.PRECAST: + StbSecSlabPrecast secPrecast = sections.StbSecSlabPrecast.First(i => i.id == secId); + ghSecStrings.AppendRange(TagUtils.GetSlabPrecastSection(secPrecast.precast_type, secPrecast.StbSecProductSlabPrecast, secPrecast.strength_concrete), ghPath); + break; + default: + throw new ArgumentOutOfRangeException(nameof(kindStruct), kindStruct, null); + } + } + + private static List GetTagPosition(IEnumerable slabs, IEnumerable nodes) + { + return slabs.Select(slab => TagUtils.GetSlabTagPosition(slab.StbNodeIdOrder, slab.StbSlabOffsetList, nodes)).ToList(); + } + + public override void DrawViewportWires(IGH_PreviewArgs args) + { + if (_plateTags.DataCount == 0) + { + return; + } + + for (var i = 0; i < _plateTags.PathCount; i++) + { + List tags = _plateTags.Branches[i]; + string tag = tags.Aggregate(string.Empty, (current, tagString) => current + tagString + "\n"); + args.Display.Draw2dText(tag, Color.Black, _tagPos[i], true, _size); + } + } + + protected override Bitmap Icon => Resource.SlabSection; + public override Guid ComponentGuid => new Guid("90b847fd-4bac-4ea1-bab9-6ed6cc7541ed"); + + } +} diff --git a/HoaryFox/Component/Tag/Section/WallSecTag.cs b/HoaryFox/Component/Tag/Section/WallSecTag.cs new file mode 100644 index 00000000..3c22c802 --- /dev/null +++ b/HoaryFox/Component/Tag/Section/WallSecTag.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using Grasshopper.Kernel; +using Grasshopper.Kernel.Data; +using Grasshopper.Kernel.Types; +using HoaryFox.Component.Utils; +using HoaryFox.Properties; +using Rhino.Geometry; +using STBDotNet.v202; + +namespace HoaryFox.Component.Tag.Section +{ + public class WallSecTag : GH_Component + { + private ST_BRIDGE _stBridge; + private int _size; + private GH_Structure _plateTags = new GH_Structure(); + private List _tagPos = new List(); + + public override GH_Exposure Exposure => GH_Exposure.quarternary; + + public WallSecTag() + : base("Wall Section Tag", "WallSec", + "Display Wall Section Tag", + "HoaryFox", "SectionTag") + { + } + + public override void ClearData() + { + base.ClearData(); + _plateTags.Clear(); + _tagPos.Clear(); + } + + public override bool IsPreviewCapable => true; + + 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("SecTag", "STag", "output section tag", GH_ParamAccess.tree); + } + + protected override void SolveInstance(IGH_DataAccess dataAccess) + { + if (!dataAccess.GetData("Data", ref _stBridge)) { return; } + if (!dataAccess.GetData("Size", ref _size)) { return; } + + _plateTags = GetTagStrings(_stBridge.StbModel.StbMembers.StbWalls, _stBridge.StbModel.StbSections); + _tagPos = GetTagPosition(_stBridge.StbModel.StbMembers.StbWalls, _stBridge.StbModel.StbNodes); + + dataAccess.SetDataTree(0, _plateTags); + } + private static GH_Structure GetTagStrings(IEnumerable walls, StbSections sections) + { + var ghSecStrings = new GH_Structure(); + + foreach (var item in walls.Select((wall, index) => new { wall, index })) + { + string secId = item.wall.id_section; + var ghPath = new GH_Path(0, item.index); + + StbSecWall_RC secRc = sections.StbSecWall_RC.First(i => i.id == secId); + StbSecWall_RC_Straight figure = secRc.StbSecFigureWall_RC.StbSecWall_RC_Straight; + ghSecStrings.AppendRange(TagUtils.GetWallRcSection(figure, secRc.strength_concrete), ghPath); + } + + return ghSecStrings; + } + + private static List GetTagPosition(IEnumerable walls, IEnumerable nodes) + { + return walls.Select(wall => TagUtils.GetWallTagPosition(wall.StbNodeIdOrder, wall.StbWallOffsetList, nodes)).ToList(); + } + + public override void DrawViewportWires(IGH_PreviewArgs args) + { + if (_plateTags.DataCount == 0) + { + return; + } + + for (var i = 0; i < _plateTags.PathCount; i++) + { + List tags = _plateTags.Branches[i]; + string tag = tags.Aggregate(string.Empty, (current, tagString) => current + tagString + "\n"); + args.Display.Draw2dText(tag, Color.Black, _tagPos[i], true, _size); + } + } + + protected override Bitmap Icon => Resource.WallSection; + public override Guid ComponentGuid => new Guid("fcb8d572-732a-473f-a807-7c2e8bc6f64f"); + + } +} diff --git a/HoaryFox/Component/Utils/Geometry/CreateMemberBrepListFromStb.cs b/HoaryFox/Component/Utils/Geometry/CreateMemberBrepListFromStb.cs index 30175dc8..bd540abf 100644 --- a/HoaryFox/Component/Utils/Geometry/CreateMemberBrepListFromStb.cs +++ b/HoaryFox/Component/Utils/Geometry/CreateMemberBrepListFromStb.cs @@ -253,13 +253,53 @@ public List Slab(IEnumerable slabs) topPts.Add(topPts[0]); curveList[0] = new PolylineCurve(topPts); + CreateSlabBrep(depth, curveList, topPts, brepList); + } + + return brepList; + } + + private void CreateSlabBrep(double depth, IList curveList, IEnumerable topPts, ICollection brepList) + { + if (depth > 0) + { Vector3d normal = Vector3d.CrossProduct(curveList[0].TangentAtEnd, curveList[0].TangentAtStart); curveList[1] = new PolylineCurve(topPts.Select(pt => pt - normal * depth)); - brepList.Add(Brep.CreateFromLoft(curveList, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0] - .CapPlanarHoles(_tolerance[0])); + Brep loftBrep = Brep.CreateFromLoft(curveList, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0]; + Brep capedBrep = loftBrep.CapPlanarHoles(_tolerance[0]); + + brepList.Add(capedBrep ?? NonPlanarBrep(depth, curveList)); } + else + { + Brep[] planarBrep = Brep.CreatePlanarBreps(new[] { curveList[0] }, _tolerance[0]); + brepList.Add(planarBrep != null + ? planarBrep[0] + : Brep.CreatePatch(new[] { curveList[0] }, 5, 5, _tolerance[0])); + } + } - return brepList; + private Brep NonPlanarBrep(double depth, IList curveList) + { + var nonPlanarBrep = new List(); + var topBrep = Brep.CreatePatch(new[] { curveList[0] }, 5, 5, _tolerance[0]); + nonPlanarBrep.Add(topBrep); + + BrepFace face = topBrep.Faces[0]; + Vector3d faceNormal = face.NormalAt(face.Domain(0).Mid, face.Domain(1).Mid); + if (Vector3d.VectorAngle(faceNormal, Vector3d.ZAxis) < Vector3d.VectorAngle(faceNormal, -Vector3d.ZAxis)) + { + faceNormal = -faceNormal; + } + + Brep bottomBrep = topBrep.DuplicateBrep(); + bottomBrep.Translate(faceNormal * depth); + nonPlanarBrep.Add(bottomBrep); + + IEnumerable edgeCurveList = topBrep.Edges.Select(edge => edge.DuplicateCurve()); + nonPlanarBrep.AddRange(edgeCurveList.Select(edgeCurve => + Surface.CreateExtrusion(edgeCurve, faceNormal * depth).ToBrep())); + return Brep.JoinBreps(nonPlanarBrep, _tolerance[0])[0] ?? topBrep; } public List Wall(IEnumerable walls) diff --git a/HoaryFox/Component/Utils/TagUtils.cs b/HoaryFox/Component/Utils/TagUtils.cs index f91eb1c2..4f2a1ffa 100644 --- a/HoaryFox/Component/Utils/TagUtils.cs +++ b/HoaryFox/Component/Utils/TagUtils.cs @@ -12,18 +12,59 @@ namespace HoaryFox.Component.Utils { internal static class TagUtils { - internal static Point3d GetTagPosition(string idStart, string idEnd, IEnumerable nodes) + internal static Point3d GetFrameTagPosition(string idStart, string idEnd, IEnumerable nodes) { StbNode startNode = nodes.First(node => node.id == idStart); StbNode endNode = nodes.First(node => node.id == idEnd); - return new Point3d( - (startNode.X + endNode.X) / 2.0, - (startNode.Y + endNode.Y) / 2.0, - (startNode.Z + endNode.Z) / 2.0 + return new Point3d((startNode.X + endNode.X) / 2.0, (startNode.Y + endNode.Y) / 2.0, (startNode.Z + endNode.Z) / 2.0 ); } + internal static Point3d GetSlabTagPosition(string idOrder, StbSlabOffset[] offsets, IEnumerable nodes) + { + string[] nodeIds = idOrder.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); + var offsetVec = new Vector3d(); + if (offsets != null) + { + foreach (var 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 new Point3d(pts.Average(n => n.X), pts.Average(n => n.Y), pts.Average(n => n.Z)); + } + + internal static Point3d GetWallTagPosition(string idOrder, StbWallOffset[] offsets, IEnumerable nodes) + { + string[] nodeIds = idOrder.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); + var offsetVec = new Vector3d(); + if (offsets != null) + { + foreach (var 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 new Point3d(pts.Average(n => n.X), pts.Average(n => n.Y), pts.Average(n => n.Z)); + } + internal static IEnumerable GetBeamRcSection(object rcFigure, string strength) { var ghSecStrings = new GH_Structure(); @@ -218,7 +259,23 @@ internal static IEnumerable GetSlabRcSection(object slabFigure, strin return ghSecString; } - internal static IEnumerable GetWallSection(StbSecWall_RC_Straight figure, string strength) + internal static IEnumerable GetSlabDeckSection(StbSecSlabDeckStraight figure, string strength) + { + var ghSecString = new GH_Structure(); + ghSecString.Append(new GH_String("t=" + figure.depth + "(" + strength + ")")); + + return ghSecString; + } + + internal static IEnumerable GetSlabPrecastSection(StbSecSlabPrecastPrecast_type type, StbSecProductSlabPrecast figure, string strength) + { + var ghSecString = new GH_Structure(); + ghSecString.Append(new GH_String("t=" + figure.depth + "(" + strength + ", type:" + type + ")")); + + return ghSecString; + } + + internal static IEnumerable GetWallRcSection(StbSecWall_RC_Straight figure, string strength) { var ghSecString = new GH_Structure(); ghSecString.Append(new GH_String("t=" + figure.t + "(" + strength + ")")); @@ -369,7 +426,7 @@ private static void AppendSectionInfos(IDictionary pDict, StbSec break; case "StbWall": // RC しかない StbSecWall_RC wallRc = sections.StbSecWall_RC.First(sec => sec.id == pDict["id_section"]); - sectionInfo = GetWallSection(wallRc.StbSecFigureWall_RC.StbSecWall_RC_Straight, wallRc.strength_concrete).ToList(); + sectionInfo = GetWallRcSection(wallRc.StbSecFigureWall_RC.StbSecWall_RC_Straight, wallRc.strength_concrete).ToList(); break; } diff --git a/HoaryFox/Properties/Resource.Designer.cs b/HoaryFox/Properties/Resource.Designer.cs index 549f9d1e..cd44ba29 100644 --- a/HoaryFox/Properties/Resource.Designer.cs +++ b/HoaryFox/Properties/Resource.Designer.cs @@ -209,5 +209,45 @@ internal static System.Drawing.Bitmap PostSection { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// 型 System.Drawing.Bitmap のローカライズされたリソースを検索します。 + /// + internal static System.Drawing.Bitmap SlabName { + get { + object obj = ResourceManager.GetObject("SlabName", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 型 System.Drawing.Bitmap のローカライズされたリソースを検索します。 + /// + internal static System.Drawing.Bitmap SlabSection { + get { + object obj = ResourceManager.GetObject("SlabSection", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 型 System.Drawing.Bitmap のローカライズされたリソースを検索します。 + /// + internal static System.Drawing.Bitmap WallName { + get { + object obj = ResourceManager.GetObject("WallName", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 型 System.Drawing.Bitmap のローカライズされたリソースを検索します。 + /// + internal static System.Drawing.Bitmap WallSection { + get { + object obj = ResourceManager.GetObject("WallSection", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/HoaryFox/Properties/Resource.resx b/HoaryFox/Properties/Resource.resx index 19717845..82592480 100644 --- a/HoaryFox/Properties/Resource.resx +++ b/HoaryFox/Properties/Resource.resx @@ -163,4 +163,16 @@ ..\Resources\PostSection.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\SlabName.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\SlabSection.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\WallName.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\WallSection.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/HoaryFox/Resources/Slab - Copy.svg b/HoaryFox/Resources/Slab - Copy.svg new file mode 100644 index 00000000..bbabce39 --- /dev/null +++ b/HoaryFox/Resources/Slab - Copy.svg @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/HoaryFox/Resources/SlabName.png b/HoaryFox/Resources/SlabName.png new file mode 100644 index 00000000..ef669dfd Binary files /dev/null and b/HoaryFox/Resources/SlabName.png differ diff --git a/HoaryFox/Resources/SlabSection.png b/HoaryFox/Resources/SlabSection.png new file mode 100644 index 00000000..951a1967 Binary files /dev/null and b/HoaryFox/Resources/SlabSection.png differ diff --git a/HoaryFox/Resources/Wall.svg b/HoaryFox/Resources/Wall.svg new file mode 100644 index 00000000..29d8bef8 --- /dev/null +++ b/HoaryFox/Resources/Wall.svg @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/HoaryFox/Resources/WallName.png b/HoaryFox/Resources/WallName.png new file mode 100644 index 00000000..83c7284b Binary files /dev/null and b/HoaryFox/Resources/WallName.png differ diff --git a/HoaryFox/Resources/WallSection.png b/HoaryFox/Resources/WallSection.png new file mode 100644 index 00000000..c50960bc Binary files /dev/null and b/HoaryFox/Resources/WallSection.png differ