-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from hrntsm/feature/add-slab-n-wall-tag-output
Feature/add slab n wall tag output
- Loading branch information
Showing
27 changed files
with
1,059 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.