-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tom Svilans
committed
Aug 7, 2020
1 parent
2badd7d
commit 925cd62
Showing
67 changed files
with
9,237 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Grasshopper; | ||
using Grasshopper.Kernel; | ||
using Grasshopper.Kernel.Types; | ||
using Rhino.Geometry; | ||
|
||
namespace GluLamb.GH.Components | ||
{ | ||
public class Cmpt_AnalyzeLamellaBending2 : GH_Component | ||
{ | ||
public Cmpt_AnalyzeLamellaBending2() | ||
: base("Analyze Lamella Bending", "LamK", | ||
"Compares the ratio between the glulam curvature and lamella size to a specified tolerance (i.e. Eurocode 5 1/200 ratio between " | ||
+ "lamella thickness and radius of curvature).", | ||
"GluLamb", "Analyze") | ||
{ | ||
} | ||
|
||
protected override void RegisterInputParams(GH_InputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("Glulam", "G", "Glulam blank.", GH_ParamAccess.item); | ||
pManager.AddNumberParameter("Ratio", "R", "Override for the ratio (1 / input value). Default is 200 according to " + | ||
"Eurocode 5 specifications (lamella thickness:radius of curvature = 1:200).", GH_ParamAccess.item, 200.0); | ||
} | ||
|
||
protected override void RegisterOutputParams(GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddMeshParameter("Mesh", "M", "Glulam mesh.", GH_ParamAccess.item); | ||
pManager.AddNumberParameter("Factor", "F", "Resultant factor at each Glulam mesh vertex. Values over 1.0 exceed the allowed ratio between lamella thickness "+ | ||
"and curvature.", GH_ParamAccess.list); | ||
} | ||
|
||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
Glulam m_glulam = null; | ||
|
||
if (!DA.GetData("Glulam", ref m_glulam)) | ||
{ | ||
this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No glulam input."); | ||
return; | ||
} | ||
|
||
Mesh m = m_glulam.ToMesh(); | ||
|
||
double m_ratio = 200.0; | ||
DA.GetData("Ratio", ref m_ratio); | ||
|
||
if (m_ratio <= 0.0) | ||
{ | ||
this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Ratio values must be greater than 0."); | ||
return; | ||
} | ||
|
||
double min_rx = m_glulam.Data.LamWidth * m_ratio; | ||
double min_ry = m_glulam.Data.LamHeight * m_ratio; | ||
|
||
double max_kx = 1 / min_rx; | ||
double max_ky = 1 / min_ry; | ||
|
||
List<double> f_values = new List<double>(); | ||
double t; | ||
|
||
for (int i = 0; i < m.Vertices.Count; ++i) | ||
{ | ||
m_glulam.Centreline.ClosestPoint(m.Vertices[i], out t); | ||
Plane frame = m_glulam.GetPlane(t); | ||
|
||
Vector3d offset = m.Vertices[i] - frame.Origin; | ||
|
||
double offset_x = offset * frame.XAxis; | ||
double offset_y = offset * frame.YAxis; | ||
|
||
Vector3d kv = m_glulam.Centreline.CurvatureAt(t); | ||
double k = kv.Length; | ||
|
||
kv.Unitize(); | ||
|
||
double r = (1 / k) - offset * kv; | ||
|
||
k = 1 / r; | ||
|
||
double kx = k * (kv * frame.XAxis); | ||
double ky = k * (kv * frame.YAxis); | ||
|
||
f_values.Add(Math.Max(Math.Abs(kx / max_kx), Math.Abs(ky / max_ky))); | ||
} | ||
|
||
DA.SetData("Mesh", m); | ||
DA.SetDataList("Factor", f_values); | ||
} | ||
|
||
protected override System.Drawing.Bitmap Icon | ||
{ | ||
get | ||
{ | ||
return Properties.Resources.glulamb_CurvatureAnalysis_24x24; | ||
} | ||
} | ||
|
||
public override Guid ComponentGuid | ||
{ | ||
get { return new Guid("62BBB1D6-F714-4462-A21C-5305114BE561"); } | ||
} | ||
} | ||
} |
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,157 @@ | ||
/* | ||
* GluLamb | ||
* A constrained glulam modelling toolkit. | ||
* Copyright 2020 Tom Svilans | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Grasshopper.Kernel; | ||
using Grasshopper; | ||
using Grasshopper.Kernel.Data; | ||
using Rhino.DocObjects; | ||
|
||
namespace GluLamb.GH.Components | ||
{ | ||
public class Cmpt_DeLaminate : GH_Component | ||
{ | ||
public Cmpt_DeLaminate() | ||
: base("Delaminate", "DeLam", | ||
"Gets individual lamellas from Glulam.", | ||
"GluLamb", "Analyze") | ||
{ | ||
} | ||
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("Glulam", "G", "Input glulam blank to deconstruct.", GH_ParamAccess.list); | ||
pManager.AddIntegerParameter("Type", "T", "Type of output: 0 = centreline curves, 1 = Mesh, 2 = Brep.", GH_ParamAccess.item, 0); | ||
|
||
pManager[1].Optional = true; | ||
} | ||
|
||
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("Lamellae", "L", "Lamellae objects from Glulam.", GH_ParamAccess.tree); | ||
pManager.AddGenericParameter("Species", "S", "Lamellae species.", GH_ParamAccess.tree); | ||
pManager.AddGenericParameter("Reference", "R", "Lamellae IDs.", GH_ParamAccess.tree); | ||
} | ||
|
||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
List<GH_Glulam> inputs = new List<GH_Glulam>(); | ||
|
||
if (!DA.GetDataList<GH_Glulam>("Glulam", inputs)) | ||
{ | ||
this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No glulam blank connected."); | ||
return; | ||
} | ||
|
||
int type = 0; | ||
DA.GetData("Type", ref type); | ||
|
||
DataTree<object> output = new DataTree<object>(); | ||
DataTree<string> species = new DataTree<string>(); | ||
DataTree<Guid> ids = new DataTree<Guid>(); | ||
|
||
for (int i = 0; i < inputs.Count; ++i) | ||
{ | ||
|
||
Glulam g = inputs[i].Value; | ||
|
||
GH_Path path; | ||
int j = 0; | ||
switch (type) | ||
{ | ||
case (1): | ||
var meshes = g.GetLamellaeMeshes(); | ||
|
||
if (meshes.Count < 1) | ||
throw new NotImplementedException(); | ||
|
||
for (int x = 0; x < g.Data.NumWidth; ++x) | ||
{ | ||
path = new GH_Path(i, x); | ||
for (int y = 0; y < g.Data.NumHeight; ++y) | ||
{ | ||
output.Add(meshes[j], path); | ||
if (g.Data.Lamellae[x, y] != null) | ||
{ | ||
species.Add(g.Data.Lamellae[x, y].Species, path); | ||
ids.Add(g.Data.Lamellae[x, y].Reference, path); | ||
} | ||
j++; | ||
} | ||
} | ||
break; | ||
case (2): | ||
var breps = g.GetLamellaeBreps(); | ||
|
||
for (int x = 0; x < g.Data.NumWidth; ++x) | ||
{ | ||
path = new GH_Path(i, x); | ||
for (int y = 0; y < g.Data.NumHeight; ++y) | ||
{ | ||
output.Add(breps[j], path); | ||
if (g.Data.Lamellae[x, y] != null) | ||
{ | ||
species.Add(g.Data.Lamellae[x, y].Species, path); | ||
ids.Add(g.Data.Lamellae[x, y].Reference, path); | ||
} | ||
j++; | ||
} | ||
} | ||
break; | ||
default: | ||
var crvs = g.GetLamellaeCurves(); | ||
|
||
for (int x = 0; x < g.Data.NumWidth; ++x) | ||
{ | ||
path = new GH_Path(i, x); | ||
for (int y = 0; y < g.Data.NumHeight; ++y) | ||
{ | ||
output.Add(crvs[j], path); | ||
if (g.Data.Lamellae[x, y] != null) | ||
{ | ||
species.Add(g.Data.Lamellae[x, y].Species, path); | ||
ids.Add(g.Data.Lamellae[x, y].Reference, path); | ||
} | ||
j++; | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
|
||
DA.SetDataTree(0, output); | ||
DA.SetDataTree(1, species); | ||
DA.SetDataTree(2, ids); | ||
} | ||
|
||
protected override System.Drawing.Bitmap Icon | ||
{ | ||
get | ||
{ | ||
return Properties.Resources.glulamb_Delaminate_24x24; | ||
} | ||
} | ||
|
||
public override Guid ComponentGuid | ||
{ | ||
get { return new Guid("E4487BDA-9F44-491C-8EEB-5A0BF6D4330F"); } | ||
} | ||
} | ||
} |
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,104 @@ | ||
/* | ||
* GluLamb | ||
* A constrained glulam modelling toolkit. | ||
* Copyright 2020 Tom Svilans | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
using System; | ||
|
||
using Grasshopper.Kernel; | ||
using Rhino.Geometry; | ||
|
||
namespace GluLamb.GH.Components | ||
{ | ||
public class Cmpt_EstimateK : GH_Component | ||
{ | ||
public Cmpt_EstimateK() | ||
: base("Estimate Curvature", "GetK", | ||
"Estimate the maximum curvature for the width and height of a glulam cross-section, using the RMF of the input curve.", | ||
"GluLamb", "Analyze") | ||
{ | ||
} | ||
|
||
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("Curve", "C", "Glulam to offset.", GH_ParamAccess.item); | ||
pManager.AddIntegerParameter("Num samples", "N", "Number of times to sample the curve. Higher is more accurate.", GH_ParamAccess.item, 100); | ||
} | ||
|
||
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddNumberParameter("MaxK X", "kX", "The maximum curvature in the RMF's X-axis.", GH_ParamAccess.item); | ||
pManager.AddNumberParameter("MaxK Y", "kY", "The maximum curvature in the RMF's Y-axis.", GH_ParamAccess.item); | ||
} | ||
|
||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
Curve m_curve = null; | ||
if (!DA.GetData("Curve", ref m_curve) || m_curve == null) | ||
{ | ||
return; | ||
} | ||
|
||
int N = 100; | ||
|
||
DA.GetData("Num samples", ref N); | ||
N = Math.Max(2, N); | ||
|
||
double[] t = m_curve.DivideByCount(N, false); | ||
Plane[] frames = m_curve.GetPerpendicularFrames(t); | ||
|
||
Plane RMF; | ||
Vector3d vK; | ||
|
||
double kx = 0, ky = 0; | ||
|
||
for (int i = 0; i < frames.Length; ++i) | ||
{ | ||
RMF = frames[i]; | ||
//m_curve.PerpendicularFrameAt(t[i], out RMF); | ||
vK = m_curve.CurvatureAt(t[i]); | ||
|
||
kx = Math.Max(kx, Math.Abs(vK * RMF.XAxis)); | ||
ky = Math.Max(ky, Math.Abs(vK * RMF.YAxis)); | ||
} | ||
|
||
if (m_curve.IsPlanar()) | ||
{ | ||
DA.SetData("MaxK X", ky); | ||
DA.SetData("MaxK Y", kx); | ||
} | ||
else | ||
{ | ||
DA.SetData("MaxK X", kx); | ||
DA.SetData("MaxK Y", ky); | ||
} | ||
} | ||
|
||
protected override System.Drawing.Bitmap Icon | ||
{ | ||
get | ||
{ | ||
return Properties.Resources.glulamb_CurvatureAnalysis_24x24; | ||
} | ||
} | ||
|
||
public override Guid ComponentGuid | ||
{ | ||
get { return new Guid("35580DD3-977C-47BE-B569-A445632B7CCF"); } | ||
} | ||
} | ||
} |
Oops, something went wrong.