Skip to content

Commit

Permalink
Merge pull request #85 from arup-group/bugfix/ADSECGH-43-Perimeter-pr…
Browse files Browse the repository at this point in the history
…ofiles-not-displayed-correctly

ADSECGH-43-Perimeter-profiles-not-displayed-correctly
  • Loading branch information
tlmnrnhrdt authored Oct 17, 2023
2 parents 5c8b4b1 + 55565fa commit 18c5ffc
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 20 deletions.
2 changes: 1 addition & 1 deletion AdSecGH/AdSecGH.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Platforms>x64</Platforms>
<Title>AdSecGH</Title>
<Company>Oasys</Company>
<Copyright>Copyright © Oasys 1985 - 2022</Copyright>
<Copyright>Copyright © Oasys 1985 - 2023</Copyright>
<PackageProjectUrl>https://github.com/arup-group/AdSec-Grasshopper</PackageProjectUrl>
<RepositoryUrl>https://github.com/arup-group/AdSec-Grasshopper</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
2 changes: 2 additions & 0 deletions AdSecGH/Components/2_Rebar/CreateRebarGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ protected override void InitialiseDropdowns() {

_dropDownItems.Add(Enum.GetNames(typeof(FoldMode)).ToList());
_selectedItems.Add(_dropDownItems[0][0]);

_dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length));
_selectedItems.Add(Length.GetAbbreviation(_lengthUnit));

_isInitialised = true;
Expand Down
79 changes: 79 additions & 0 deletions AdSecGH/Components/3_Section/CreateSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
using AdSecGH.Parameters;
using Grasshopper.Kernel;
using Oasys.AdSec;
using Oasys.AdSec.Reinforcement;
using Oasys.AdSec.Reinforcement.Groups;
using Oasys.Profiles;
using OasysGH;
using OasysGH.Components;
using OasysUnits;
using OasysUnits.Units;

namespace AdSecGH.Components {
public class CreateSection : GH_OasysComponent {
Expand Down Expand Up @@ -63,6 +68,80 @@ protected override void SolveInstance(IGH_DataAccess DA) {
// create section
var section = new AdSecSection(profile.Profile, profile.LocalPlane, material, reinforcements, subComponents);

if (section.Section.Profile is IPerimeterProfile) {
var adSec = IAdSec.Create(material.DesignCode.DesignCode);
ISection flattened = adSec.Flatten(section.Section);

string foo1 = profile.Profile.Description();
string foo2 = flattened.Profile.Description();

string[] coordinates1 = profile.Profile.Description().Remove(0, 11).Split(new[] { ") L(" }, StringSplitOptions.None);
double maxY1 = double.MinValue;
double maxZ1 = double.MinValue;
foreach(string c in coordinates1) {
string[] value = c.Split('|');
double y1 = double.Parse(value[0]);
double z1 = double.Parse(value[1].Remove(value[1].Length - 2));

if (y1 > maxY1) {
maxY1 = y1;
}
if (z1 > maxZ1) {
maxZ1 = z1;
}
}

string[] coordinates2 = flattened.Profile.Description().Remove(0, 11).Split(new[] { ") L(" }, StringSplitOptions.None);
double maxY2 = double.MinValue;
double maxZ2 = double.MinValue;
foreach (string c in coordinates2) {
string[] value = c.Split('|');
double y2 = double.Parse(value[0]);
double z2 = double.Parse(value[1].Remove(value[1].Length - 2));

if (y2 > maxY2) {
maxY2 = y2;
}
if (z2 > maxZ2) {
maxZ2 = z2;
}
}

double deltaY = maxY2 - maxY1;
double deltaZ = maxZ2 - maxZ1;

var updatedReinforcement = new List<AdSecRebarGroup>();
foreach (AdSecRebarGroup group in reinforcements) {
var duplicate = new AdSecRebarGroup();
if(group.Cover != null) {
duplicate.Cover = ICover.Create(group.Cover.UniformCover);
}

updatedReinforcement.Add(duplicate);

switch (group.Group) {
case ISingleBars bars:
var bundle = IBarBundle.Create(bars.BarBundle.Material, bars.BarBundle.Diameter, bars.BarBundle.CountPerBundle);
var singleBars = ISingleBars.Create(bundle);

foreach (IPoint point in bars.Positions) {
var p = IPoint.Create(new Length(point.Y.As(LengthUnit.Meter) - deltaY, LengthUnit.Meter),
new Length(point.Z.As(LengthUnit.Meter) - deltaZ, LengthUnit.Meter));
singleBars.Positions.Add(p);
}

duplicate.Group = singleBars;
break;

default:
duplicate.Group = group.Group;
break;
}
}

section = new AdSecSection(profile.Profile, profile.LocalPlane, material, updatedReinforcement, subComponents);
}

DA.SetData(0, new AdSecSectionGoo(section));
}
}
Expand Down
8 changes: 2 additions & 6 deletions AdSecGH/Components/3_Section/FlattenRebar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace AdSecGH.Components {
public class FlattenRebar : GH_OasysComponent {
// This region handles how the component in displayed on the ribbon including name, exposure level and icon
public override Guid ComponentGuid => new Guid("879ecac6-464d-4286-9113-c15fcf03e4e6");
public override GH_Exposure Exposure => GH_Exposure.tertiary | GH_Exposure.obscure;
public override OasysPluginInfo PluginInfo => AdSecGH.PluginInfo.Instance;
Expand All @@ -29,10 +28,9 @@ public FlattenRebar() : base(
"Flatten all rebars in a section into single bars.",
CategoryName.Name(),
SubCategoryName.Cat4()) {
Hidden = true; // sets the initial state of the component to hidden
Hidden = true;
}

//This region overrides the typical component layout

protected override void RegisterInputParams(GH_InputParamManager pManager) {
pManager.AddGenericParameter("Section", "Sec", "AdSec Section to get single rebars from", GH_ParamAccess.item);
Expand Down Expand Up @@ -61,7 +59,7 @@ protected override void SolveInstance(IGH_DataAccess DA) {

// create flattened section
ISection flat = null;
if (section.DesignCode != null) //{ code = Oasys.AdSec.DesignCode.EN1992.Part1_1.Edition_2004.NationalAnnex.NoNationalAnnex; }
if (section.DesignCode != null)
{
var adSec = IAdSec.Create(section.DesignCode);
flat = adSec.Flatten(section.Section);
Expand Down Expand Up @@ -118,8 +116,6 @@ protected override void SolveInstance(IGH_DataAccess DA) {
}
}

// ### output ###

DA.SetDataList(0, pointGoos);
DA.SetDataList(1, diameters);
DA.SetDataList(2, counts);
Expand Down
2 changes: 1 addition & 1 deletion AdSecGH/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 Oasys
Copyright (c) 2021-2023 Oasys

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 1 addition & 2 deletions AdSecGH/Parameters/AdSecSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public override string ToString() {

internal void CreatePreview(ref Brep profile, ref Polyline profileEdge, ref List<Polyline> profileVoidEdges, ref DisplayMaterial profileColour, ref List<Brep> rebars, ref List<Circle> rebarEdges, ref List<Curve> linkEdges, ref List<DisplayMaterial> rebarColours, ref List<Brep> subProfiles, ref List<Polyline> subEdges, ref List<List<Polyline>> subVoidEdges, ref List<DisplayMaterial> subColours, IPoint offset = null) {
ISection flat = null;
if (DesignCode != null) //{ code = Oasys.AdSec.DesignCode.EN1992.Part1_1.Edition_2004.NationalAnnex.NoNationalAnnex; }
{
if (DesignCode != null) {
var adSec = IAdSec.Create(DesignCode);
flat = adSec.Flatten(Section);
} else {
Expand Down
2 changes: 1 addition & 1 deletion AdSecGH/UI/AboutBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace AdSecGH.UI {
internal partial class AboutBox : Form {
public string AssemblyCompany {
get {
return "Copyright © Oasys 1985 - 2022";
return "Copyright © Oasys 1985 - 2023";
}
}

Expand Down
4 changes: 2 additions & 2 deletions AdSecGHConverterTests/AdSecGHConverterTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion AdSecGHConverters/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 Oasys
Copyright (c) 2021-2023 Oasys

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions AdSecGHTests/AdSecGHTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.3" />
<PackageReference Include="Rhino.Inside" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
3 changes: 2 additions & 1 deletion AdSecGHTests/GrasshopperFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using OasysGH.Units;
using Xunit;

namespace AdSecGHTests {
Expand Down Expand Up @@ -49,7 +50,7 @@ public GrasshopperFixture() {
InitializeCore();

// setup headless units
OasysGH.Units.Utility.SetupUnitsDuringLoad();
Utility.SetupUnitsDuringLoad();
}

public void AddPluginToGH() {
Expand Down
85 changes: 85 additions & 0 deletions AdSecGHTests/Parameters/AdSecSectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

using System.Collections.Generic;
using Oasys.AdSec;
using Oasys.AdSec.DesignCode;
using Oasys.AdSec.Materials;
using Oasys.AdSec.Materials.StressStrainCurves;
using Oasys.Interop;
using Oasys.Taxonomy.Geometry;
using Oasys.Taxonomy.Profiles;
using OasysUnits;
using OasysUnits.Units;
using Xunit;

namespace AdSecGHTests.Parameters {
[Collection("GrasshopperFixture collection")]
public class AdSecSectionTests {
[Fact]
public void FlattenSectionTest() {

var failurePoint = IStressStrainPoint.Create(new Pressure(1, PressureUnit.DynePerSquareCentimeter), new Strain(1, StrainUnit.MicroStrain));
IStressStrainCurve tension = ILinearStressStrainCurve.Create(failurePoint);
IStressStrainCurve compression = ILinearStressStrainCurve.Create(failurePoint);
var strength = ITensionCompressionCurve.Create(tension, compression);
var serviceability = ITensionCompressionCurve.Create(tension, compression);
var concreteCrackCalculationParameters = IConcreteCrackCalculationParameters.Create(new Pressure(1, PressureUnit.DynePerSquareCentimeter), new Pressure(-1, PressureUnit.DynePerSquareCentimeter), new Pressure(1, PressureUnit.DynePerSquareCentimeter));
IMaterial material = IConcrete.Create(strength, serviceability, concreteCrackCalculationParameters);

IDesignCode designCode = EN1992.Part1_1.Edition_2004.NationalAnnex.DE.Edition_2013;

var points = new List<IPoint2d>() {
new Point2d(new Length(3.1464410643837, LengthUnit.Meter), new Length(2.9552083887352, LengthUnit.Meter)),
new Point2d(new Length(-0.6535618090254, LengthUnit.Meter), new Length(2.9552083887352, LengthUnit.Meter)),
new Point2d(new Length(-0.6535618090254, LengthUnit.Meter), new Length(-1.2447891504457, LengthUnit.Meter)),
new Point2d(new Length(5.1964353178991, LengthUnit.Meter), new Length(-1.2447891504457, LengthUnit.Meter)),
new Point2d(new Length(5.1964353178991, LengthUnit.Meter), new Length(2.9552083911969, LengthUnit.Meter)),
new Point2d(new Length(5.1964410643837, LengthUnit.Meter), new Length(3.2552083887352, LengthUnit.Meter)),
new Point2d(new Length(6.2464410643837, LengthUnit.Meter), new Length(3.2551587793664, LengthUnit.Meter)),
new Point2d(new Length(6.2464410643837, LengthUnit.Meter), new Length(-2.9947891504454, LengthUnit.Meter)),
new Point2d(new Length(5.1964410643837, LengthUnit.Meter), new Length(-2.9947891504454, LengthUnit.Meter)),
new Point2d(new Length(5.1964410643837, LengthUnit.Meter), new Length(-2.1447891504457, LengthUnit.Meter)),
new Point2d(new Length(-0.60355893561307, LengthUnit.Meter), new Length(-2.1447891504457, LengthUnit.Meter)),
new Point2d(new Length(-3.8535589356163, LengthUnit.Meter), new Length(-2.1447891504456, LengthUnit.Meter)),
new Point2d(new Length(-3.8535589356163, LengthUnit.Meter), new Length(-2.9947938617324, LengthUnit.Meter)),
new Point2d(new Length(-4.4535589356163, LengthUnit.Meter), new Length(-2.9947938617324, LengthUnit.Meter)),
new Point2d(new Length(-4.4535589356163, LengthUnit.Meter), new Length(-2.1447891504456, LengthUnit.Meter)),
new Point2d(new Length(-7.5035618086918, LengthUnit.Meter), new Length(-2.1447891504456, LengthUnit.Meter)),
new Point2d(new Length(-7.5035093262381, LengthUnit.Meter), new Length(-1.2447891504456, LengthUnit.Meter)),
new Point2d(new Length(-4.4535589356162, LengthUnit.Meter), new Length(-1.2447891504457, LengthUnit.Meter)),
new Point2d(new Length(-4.4535589356163, LengthUnit.Meter), new Length(1.8052083886678, LengthUnit.Meter)),
new Point2d(new Length(-4.9785589356162, LengthUnit.Meter), new Length(1.8052083886678, LengthUnit.Meter)),
new Point2d(new Length(-4.9785589356162, LengthUnit.Meter), new Length(2.1052083886678, LengthUnit.Meter)),
new Point2d(new Length(-3.2285589356162, LengthUnit.Meter), new Length(2.1052083886678, LengthUnit.Meter)),
new Point2d(new Length(-3.2285589356162, LengthUnit.Meter), new Length(1.8052083886678, LengthUnit.Meter)),
new Point2d(new Length(-3.8535589356163, LengthUnit.Meter), new Length(1.8052083886678, LengthUnit.Meter)),
new Point2d(new Length(-3.8535589356163, LengthUnit.Meter), new Length(-1.2447891504457, LengthUnit.Meter)),
new Point2d(new Length(-0.95356180902542, LengthUnit.Meter), new Length(-1.2447891504457, LengthUnit.Meter)),
new Point2d(new Length(-0.95355893561614, LengthUnit.Meter), new Length(1.8052056355333, LengthUnit.Meter)),
new Point2d(new Length(-1.6285589356162, LengthUnit.Meter), new Length(1.8052083886678, LengthUnit.Meter)),
new Point2d(new Length(-1.6285589356162, LengthUnit.Meter), new Length(2.1052083886678, LengthUnit.Meter)),
new Point2d(new Length(-0.95356180902541, LengthUnit.Meter), new Length(2.1052083886678, LengthUnit.Meter)),
new Point2d(new Length(-0.9535618090254, LengthUnit.Meter), new Length(3.2552083887352, LengthUnit.Meter)),
new Point2d(new Length(3.1464410643837, LengthUnit.Meter), new Length(3.2552083887352, LengthUnit.Meter)),
};

var polygon = new Polygon(points);
var profile = new PerimeterProfile(polygon, new List<IPolygon>());
Oasys.Profiles.IPerimeterProfile adsecProfile = AdSecProfiles.CreatePerimeterProfile(profile);
var section = ISection.Create(adsecProfile, material);

var adSec = IAdSec.Create(designCode);
ISection flattened = adSec.Flatten(section);

string foo = flattened.Profile.Description();

Assert.Equal(section.Profile.ElasticModulus().Y.Value, flattened.Profile.ElasticModulus().Y.Value, 10);
Assert.Equal(section.Profile.ElasticModulus().Z.Value, flattened.Profile.ElasticModulus().Z.Value, 10);
Assert.Equal(section.Profile.SurfaceAreaPerUnitLength().Value, flattened.Profile.SurfaceAreaPerUnitLength().Value, 10);
Assert.Equal(section.Profile.LocalAxisSecondMomentOfArea().YY.Value, flattened.Profile.LocalAxisSecondMomentOfArea().YY.Value, 10);
Assert.Equal(section.Profile.LocalAxisSecondMomentOfArea().ZZ.Value, flattened.Profile.LocalAxisSecondMomentOfArea().ZZ.Value, 10);
Assert.Equal(section.Profile.LocalAxisSecondMomentOfArea().YZ.Value, flattened.Profile.LocalAxisSecondMomentOfArea().YZ.Value, 10);
Assert.Equal(section.Profile.PrincipalAxisSecondMomentOfArea().UU.Value, flattened.Profile.PrincipalAxisSecondMomentOfArea().UU.Value, 10);
Assert.Equal(section.Profile.PrincipalAxisSecondMomentOfArea().VV.Value, flattened.Profile.PrincipalAxisSecondMomentOfArea().VV.Value, 10);
}
}
}
3 changes: 2 additions & 1 deletion IntegrationTests/GrasshopperFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using OasysGH.Units;
using Xunit;

namespace IntegrationTests {
Expand Down Expand Up @@ -49,7 +50,7 @@ public GrasshopperFixture() {
InitializeCore();

// setup headless units
OasysGH.Units.Utility.SetupUnitsDuringLoad();
Utility.SetupUnitsDuringLoad();
}

public void AddPluginToGH() {
Expand Down
4 changes: 2 additions & 2 deletions IntegrationTests/IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.3" />
<PackageReference Include="Rhino.Inside" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 18c5ffc

Please sign in to comment.