Skip to content

Commit

Permalink
Merge pull request #59 from MagmaWorks/feature/profile-description
Browse files Browse the repository at this point in the history
Profile description
  • Loading branch information
kpne authored Dec 11, 2024
2 parents efe19ca + 190d052 commit 40a82b3
Show file tree
Hide file tree
Showing 26 changed files with 241 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public abstract class SingletonAmericanBase<T> : SingletonCatalogueBase<T>, IAme
public Catalogue Catalogue => Catalogue.AmericanAISC;
public abstract AmericanShape Shape { get; }
public abstract string Label { get; }
public virtual string Description => Label.Replace(" ", "\u2009");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public abstract class SingletonEuropeanBase<T> : SingletonCatalogueBase<T>, IEur
public Catalogue Catalogue => Catalogue.EuropeanEN10365;
public abstract EuropeanShape Shape { get; }
public abstract string Label { get; }
public virtual string Description => Label.Replace(" ", "\u2009");
}
}
5 changes: 4 additions & 1 deletion Profiles/IProfiles/IProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

namespace MagmaWorks.Taxonomy.Profiles
{
public interface IProfile : ITaxonomySerializable { }
public interface IProfile : ITaxonomySerializable
{
string Description { get; }
}
}
12 changes: 12 additions & 0 deletions Profiles/Perimeter/Perimeter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public IList<ILocalPolyline2d> VoidEdges
}
}

public string Description => GetDescription();

private ILocalPolyline2d _outerEdge;
private IList<ILocalPolyline2d> _voidEdges;

Expand Down Expand Up @@ -84,5 +86,15 @@ private static ILocalPolyline2d EnsureClosedPolygon(ILocalPolyline2d polygon)
closed.Points.Add(closed.Points[0]);
return closed;
}

private string GetDescription()
{
if (VoidEdges != null && VoidEdges.Count > 0)
{
return $"Outer Edge with {OuterEdge.Points.Count} Vertices and {VoidEdges.Count} void(s)";
}

return $"{OuterEdge.Points.Count} Vertices";
}
}
}
2 changes: 2 additions & 0 deletions Profiles/ProfileTests/IParallelFlangeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ public class MockHEB500 : IIParallelFlange
public Length FlangeThickness => new Length(28, LengthUnit.Millimeter);
public Length WebThickness => new Length(14.5, LengthUnit.Millimeter);

public string Description => "HE 500 B";

public MockHEB500() { }
}
}
118 changes: 118 additions & 0 deletions Profiles/ProfileTests/Utility/DescriptionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using MagmaWorks.Taxonomy.Profiles;
using OasysUnits;
using OasysUnits.Units;

namespace ProfileTests
{
public class DescriptionTests
{
[Fact]
public void RectangleProfileDescriptionTest()
{
// Assemble
var h = new Length(20, LengthUnit.Centimeter);
var w = new Length(500.4, LengthUnit.Millimeter);
var prfl = new Rectangle(w, h);

// Act
string description = prfl.Description;

// Assert
Assert.Equal("500 × 200 mm", description);
}

[Fact]
public void CircleProfileDescriptionTest()
{
// Assemble
var dia = new Length(2.3, LengthUnit.Centimeter);
ICircle prfl = new Circle(dia);

// Act
string description = prfl.Description;

// Assert
Assert.Equal("Ø 2.3 cm", description);
}

[Fact]
public void CircularHollowProfileDescriptionTest()
{
// Assemble
var dia = new Length(2.3, LengthUnit.Centimeter);
var thk = new Length(10.9, LengthUnit.Millimeter);
ICircularHollow prfl = new CircularHollow(dia, thk);

// Act
string description = prfl.Description;

// Assert
Assert.Equal("Ø 2.3 × 1.1 cm", description);
}

[Fact]
public void BackToBackAngleProfileDescriptionTest()
{
// Assemble
var h = new Length(2.3, LengthUnit.Centimeter);
var w = new Length(5.4, LengthUnit.Centimeter);
var webThk = new Length(10.9, LengthUnit.Millimeter);
var flangeThk = new Length(15, LengthUnit.Millimeter);
var dist = new Length(2.5, LengthUnit.Millimeter);
IDoubleAngle prfl = new DoubleAngle(h, w, webThk, flangeThk, dist);

// Act
string description = prfl.Description;

// Assert
Assert.Equal("2.3 × 5.4 × 1.1 × 1.5 cm B2B 2.5 mm", description);
}

[Fact]
public void BackToBackChannelProfileDescriptionTest()
{
// Assemble
var h = new Length(2.3, LengthUnit.Centimeter);
var w = new Length(5.4, LengthUnit.Centimeter);
var webThk = new Length(10.9, LengthUnit.Millimeter);
var flangeThk = new Length(15, LengthUnit.Millimeter);
var dist = new Length(2.5, LengthUnit.Millimeter);
IDoubleChannel prfl = new DoubleChannel(h, w, webThk, flangeThk, dist);

// Act
string description = prfl.Description;

// Assert
Assert.Equal("2.3 × 5.4 × 1.1 × 1.5 cm B2B 2.5 mm", description);
}

[Fact]
public void TrapezoidProfileDescriptionTest()
{
// Assemble
var h = new Length(2.3, LengthUnit.Centimeter);
var wTop = new Length(5.4, LengthUnit.Centimeter);
var wBottom = new Length(0.5, LengthUnit.Meter);
ITrapezoid prfl = new Trapezoid(wTop, wBottom, h);

// Act
string description = prfl.Description;

// Assert
Assert.Equal("5.4 / 50.0 × 2.3 cm", description);
}

[Fact]
public void HE300BProfileDescriptionTest()
{
// Assemble
var prfl = new HE300B();

// Act
string description = prfl.Description;

// Assert
Assert.Equal("HE 300 B", description);
}
}
}
2 changes: 2 additions & 0 deletions Profiles/Profiles/Angle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class Angle : IAngle
public Length Width { get; set; }
public Length WebThickness { get; set; }
public Length FlangeThickness { get; set; }
public string Description
=> Utility.Describe(Height, Width, WebThickness, FlangeThickness);

public Angle(Length height, Length width, Length webThickness, Length flangeThickness)
{
Expand Down
2 changes: 2 additions & 0 deletions Profiles/Profiles/C.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class C : IC
public Length WebThickness { get; set; }
public Length FlangeThickness { get; set; }
public Length Lip { get; set; }
public string Description
=> Utility.Describe(Height, Width, WebThickness, FlangeThickness, Lip);

public C(Length height, Length width, Length webThickness, Length flangeThickness, Length lip)
{
Expand Down
2 changes: 2 additions & 0 deletions Profiles/Profiles/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class Channel : IChannel
public Length Width { get; set; }
public Length WebThickness { get; set; }
public Length FlangeThickness { get; set; }
public string Description
=> Utility.Describe(Height, Width, WebThickness, FlangeThickness);

public Channel(Length height, Length width, Length webThickness, Length flangeThickness)
{
Expand Down
1 change: 1 addition & 0 deletions Profiles/Profiles/Circle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace MagmaWorks.Taxonomy.Profiles
public class Circle : ICircle
{
public Length Diameter { get; set; }
public string Description => $\u2009{Utility.Describe(Diameter)}";

public Circle(Length diameter)
{
Expand Down
3 changes: 2 additions & 1 deletion Profiles/Profiles/CircularHollow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ namespace MagmaWorks.Taxonomy.Profiles
public class CircularHollow : ICircularHollow
{
public Length Diameter { get; set; }

public Length Thickness { get; set; }
public string Description
=> $\u2009{Utility.Describe(Diameter, Thickness)}";

public CircularHollow(Length diameter, Length thickness)
{
Expand Down
2 changes: 2 additions & 0 deletions Profiles/Profiles/Cruciform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class Cruciform : ICruciform
public Length Width { get; set; }
public Length FlangeThickness { get; set; }
public Length WebThickness { get; set; }
public string Description
=> Utility.Describe(Height, Width, FlangeThickness, WebThickness);

public Cruciform(Length height, Length width, Length flangeThickness, Length webThickness)
{
Expand Down
3 changes: 3 additions & 0 deletions Profiles/Profiles/CustomI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class CustomI : ICustomI
public Length TopFlangeThickness { get; set; }
public Length BottomFlangeThickness { get; set; }
public Length WebThickness { get; set; }
public string Description
=> Utility.Describe(Height, TopFlangeWidth, BottomFlangeWidth,
BottomFlangeThickness, TopFlangeThickness, WebThickness);

public CustomI(Length height, Length topFlangeWidth, Length bottomFlangeWidth, Length topFlangeThickness, Length bottomFlangeThickness, Length webThickness)
{
Expand Down
12 changes: 12 additions & 0 deletions Profiles/Profiles/DoubleAngle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class DoubleAngle : IDoubleAngle
public Length WebThickness { get; set; }
public Length FlangeThickness { get; set; }
public Length BackToBackDistance { get; set; }
public string Description => GetDescription();

public DoubleAngle(Length height, Length width, Length webThickness, Length flangeThickness, Length backToBackDistance)
{
Expand All @@ -18,5 +19,16 @@ public DoubleAngle(Length height, Length width, Length webThickness, Length flan
FlangeThickness = flangeThickness;
BackToBackDistance = backToBackDistance;
}

private string GetDescription()
{
string description = $"{Utility.Describe(Height, Width, WebThickness, FlangeThickness)} B2B\u2009";
if (BackToBackDistance.Value != 0)
{
description += $"{BackToBackDistance.ToString().Replace(" ", "\u2009")}";
}

return description;
}
}
}
12 changes: 12 additions & 0 deletions Profiles/Profiles/DoubleChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class DoubleChannel : IDoubleChannel
public Length WebThickness { get; set; }
public Length FlangeThickness { get; set; }
public Length BackToBackDistance { get; set; }
public string Description => GetDescription();

public DoubleChannel(Length height, Length width, Length webThickness, Length flangeThickness, Length backToBackDistance)
{
Expand All @@ -18,5 +19,16 @@ public DoubleChannel(Length height, Length width, Length webThickness, Length fl
FlangeThickness = flangeThickness;
BackToBackDistance = backToBackDistance;
}

private string GetDescription()
{
string description = $"{Utility.Describe(Height, Width, WebThickness, FlangeThickness)} B2B\u2009";
if (BackToBackDistance.Value != 0)
{
description += $"{BackToBackDistance.ToString().Replace(" ", "\u2009")}";
}

return description;
}
}
}
1 change: 1 addition & 0 deletions Profiles/Profiles/Ellipse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class Ellipse : IEllipse
{
public Length Height { get; set; }
public Length Width { get; set; }
public string Description => Utility.Describe(Height, Width);

public Ellipse(Length width, Length height)
{
Expand Down
1 change: 1 addition & 0 deletions Profiles/Profiles/EllipseHollow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class EllipseHollow : IEllipseHollow
public Length Height { get; set; }
public Length Width { get; set; }
public Length Thickness { get; set; }
public string Description => Utility.Describe(Height, Width, Thickness);

public EllipseHollow(Length width, Length height, Length thickness)
{
Expand Down
1 change: 1 addition & 0 deletions Profiles/Profiles/I.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class I : II
public Length Width { get; set; }
public Length FlangeThickness { get; set; }
public Length WebThickness { get; set; }
public string Description => Utility.Describe(Height, Width, FlangeThickness, WebThickness);

public I(Length height, Length width, Length flangeThickness, Length webThickness)
{
Expand Down
1 change: 1 addition & 0 deletions Profiles/Profiles/Rectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class Rectangle : IRectangle
{
public Length Height { get; set; }
public Length Width { get; set; }
public string Description => Utility.Describe(Width, Height);

public Rectangle(Length width, Length height)
{
Expand Down
1 change: 1 addition & 0 deletions Profiles/Profiles/RectangularHollow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class RectangularHollow : IRectangularHollow
public Length Height { get; set; }
public Length Width { get; set; }
public Length Thickness { get; set; }
public string Description => Utility.Describe(Width, Height, Thickness);

public RectangularHollow(Length width, Length height, Length thickness)
{
Expand Down
1 change: 1 addition & 0 deletions Profiles/Profiles/RoundedRectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class RoundedRectangle : IRoundedRectangle
public Length Width { get; set; }
public Length FlatHeight { get; set; }
public Length FlatWidth { get; set; }
public string Description => Utility.Describe(Width, Height, FlatHeight, FlatWidth);

public RoundedRectangle(Length width, Length height, Length flatWidth, Length flatHeight)
{
Expand Down
2 changes: 2 additions & 0 deletions Profiles/Profiles/RoundedRectangularHollow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class RoundedRectangularHollow : IRoundedRectangularHollow
public Length FlatHeight { get; set; }
public Length FlatWidth { get; set; }
public Length Thickness { get; set; }
public string Description
=> Utility.Describe(Width, Height, FlatHeight, FlatWidth, Thickness);

public RoundedRectangularHollow(Length width, Length height, Length flatWidth, Length flatHeight, Length thickness)
{
Expand Down
2 changes: 2 additions & 0 deletions Profiles/Profiles/Tee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class Tee : ITee
public Length Width { get; set; }
public Length FlangeThickness { get; set; }
public Length WebThickness { get; set; }
public string Description
=> Utility.Describe(Height, Width, FlangeThickness, WebThickness);

public Tee(Length height, Length width, Length flangeThickness, Length webThickness)
{
Expand Down
11 changes: 11 additions & 0 deletions Profiles/Profiles/Trapezoid.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OasysUnits;
using OasysUnits.Units;

namespace MagmaWorks.Taxonomy.Profiles
{
Expand All @@ -7,12 +8,22 @@ public class Trapezoid : ITrapezoid
public Length Height { get; set; }
public Length TopWidth { get; set; }
public Length BottomWidth { get; set; }
public string Description => GetDescription();

public Trapezoid(Length topWidth, Length bottomWidth, Length height)
{
Height = height;
TopWidth = topWidth;
BottomWidth = bottomWidth;
}

private string GetDescription()
{
LengthUnit u = Height.Unit;
string topAndBottom = Utility.Describe("/", TopWidth.ToUnit(u), BottomWidth);
topAndBottom = topAndBottom.Replace(Length.GetAbbreviation(u), string.Empty);
string height = Utility.Describe(Height);
return $"{topAndBottom}× {height}";
}
}
}
Loading

0 comments on commit 40a82b3

Please sign in to comment.