-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADSECGH-92 coverage for AdSecProfiles.cs (#123)
* refactor: increasing coverage for AdSecProfiles.cs * refactor: updated catalogue test * refactor: extracted sample profiles into new class * refactor: clean up of adsecProfiles tests
- Loading branch information
1 parent
3eac3c7
commit e1b70ad
Showing
3 changed files
with
563 additions
and
104 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 |
---|---|---|
@@ -1,181 +1,224 @@ | ||
using Oasys.Taxonomy.Geometry; | ||
using System; | ||
using System.Linq; | ||
|
||
using Oasys.Profiles; | ||
using Oasys.Taxonomy.Profiles; | ||
|
||
using IAngleProfile = Oasys.Profiles.IAngleProfile; | ||
using ICatalogueProfile = Oasys.Profiles.ICatalogueProfile; | ||
using IChannelProfile = Oasys.Profiles.IChannelProfile; | ||
using ICircleHollowProfile = Oasys.Profiles.ICircleHollowProfile; | ||
using ICircleProfile = Oasys.Profiles.ICircleProfile; | ||
using ICruciformSymmetricalProfile = Oasys.Profiles.ICruciformSymmetricalProfile; | ||
using IEllipseHollowProfile = Oasys.Profiles.IEllipseHollowProfile; | ||
using IEllipseProfile = Oasys.Profiles.IEllipseProfile; | ||
using IFlange = Oasys.Profiles.IFlange; | ||
using IGeneralCProfile = Oasys.Profiles.IGeneralCProfile; | ||
using IGeneralZProfile = Oasys.Profiles.IGeneralZProfile; | ||
using IIBeamAsymmetricalProfile = Oasys.Profiles.IIBeamAsymmetricalProfile; | ||
using IIBeamCellularProfile = Oasys.Profiles.IIBeamCellularProfile; | ||
using IIBeamProfile = Oasys.Taxonomy.Profiles.IIBeamProfile; | ||
using IPerimeterProfile = Oasys.Profiles.IPerimeterProfile; | ||
using IProfile = Oasys.Profiles.IProfile; | ||
using IRectangleHollowProfile = Oasys.Profiles.IRectangleHollowProfile; | ||
using IRectangleProfile = Oasys.Profiles.IRectangleProfile; | ||
using IRectoEllipseProfile = Oasys.Profiles.IRectoEllipseProfile; | ||
using ISecantPileProfile = Oasys.Profiles.ISecantPileProfile; | ||
using ISheetPileProfile = Oasys.Profiles.ISheetPileProfile; | ||
using ITrapezoidProfile = Oasys.Profiles.ITrapezoidProfile; | ||
using ITSectionProfile = Oasys.Profiles.ITSectionProfile; | ||
using IWeb = Oasys.Profiles.IWeb; | ||
using IWebConstant = Oasys.Profiles.IWebConstant; | ||
using IWebTapered = Oasys.Profiles.IWebTapered; | ||
|
||
namespace AdSecGH.Helpers { | ||
public static class AdSecProfiles { | ||
public static Oasys.Profiles.IProfile CreateProfile(IProfile profile) { | ||
public static IProfile CreateProfile(Oasys.Taxonomy.Profiles.IProfile profile) { | ||
if (profile == null) { | ||
return null; | ||
} | ||
|
||
switch (profile.ProfileType) { | ||
case ProfileType.Angle: | ||
return CreateAngleProfile((IAngleProfile)profile); | ||
case ProfileType.Catalogue: | ||
return CreateCatalogueProfile((ICatalogueProfile)profile); | ||
case ProfileType.Channel: | ||
return CreateChannelProfile((IChannelProfile)profile); | ||
case ProfileType.Circle: | ||
return CreateCircleProfile((ICircleProfile)profile); | ||
case ProfileType.Angle: return CreateAngleProfile((Oasys.Taxonomy.Profiles.IAngleProfile)profile); | ||
case ProfileType.Catalogue: return CreateCatalogueProfile((Oasys.Taxonomy.Profiles.ICatalogueProfile)profile); | ||
case ProfileType.Channel: return CreateChannelProfile((Oasys.Taxonomy.Profiles.IChannelProfile)profile); | ||
case ProfileType.Circle: return CreateCircleProfile((Oasys.Taxonomy.Profiles.ICircleProfile)profile); | ||
case ProfileType.CircleHollow: | ||
return CreateCircleHollowProfile((ICircleHollowProfile)profile); | ||
return CreateCircleHollowProfile((Oasys.Taxonomy.Profiles.ICircleHollowProfile)profile); | ||
case ProfileType.CruciformSymmetrical: | ||
return CreateCruciformSymmetricalProfile((ICruciformSymmetricalProfile)profile); | ||
case ProfileType.Ellipse: | ||
return CreateEllipseProfile((IEllipseProfile)profile); | ||
return CreateCruciformSymmetricalProfile((Oasys.Taxonomy.Profiles.ICruciformSymmetricalProfile)profile); | ||
case ProfileType.Ellipse: return CreateEllipseProfile((Oasys.Taxonomy.Profiles.IEllipseProfile)profile); | ||
case ProfileType.EllipseHollow: | ||
return CreateEllipseHollowProfile((IEllipseHollowProfile)profile); | ||
case ProfileType.GeneralC: | ||
return CreateGeneralCProfile((IGeneralCProfile)profile); | ||
case ProfileType.GeneralZ: | ||
return CreateGeneralZProfile((IGeneralZProfile)profile); | ||
case ProfileType.IBeam: | ||
return CreateIBeamSymmetricalProfile((IBeamProfile)profile); | ||
case ProfileType.IBeamAssymetrical: | ||
return CreateIBeamAsymmetricalProfile((IBeamAsymmetricalProfile)profile); | ||
case ProfileType.IBeamCellular: | ||
return CreateIBeamCellularProfile((IBeamCellularProfile)profile); | ||
case ProfileType.Perimeter: | ||
return CreatePerimeterProfile((IPerimeterProfile)profile); | ||
case ProfileType.Rectangle: | ||
return CreateRectangleProfile((IRectangleProfile)profile); | ||
return CreateEllipseHollowProfile((Oasys.Taxonomy.Profiles.IEllipseHollowProfile)profile); | ||
case ProfileType.GeneralC: return CreateGeneralCProfile((Oasys.Taxonomy.Profiles.IGeneralCProfile)profile); | ||
case ProfileType.GeneralZ: return CreateGeneralZProfile((Oasys.Taxonomy.Profiles.IGeneralZProfile)profile); | ||
case ProfileType.IBeam: return CreateIBeamSymmetricalProfile((IBeamProfile)profile); | ||
case ProfileType.IBeamAssymetrical: return CreateIBeamAsymmetricalProfile((IBeamAsymmetricalProfile)profile); | ||
case ProfileType.IBeamCellular: return CreateIBeamCellularProfile((IBeamCellularProfile)profile); | ||
case ProfileType.Perimeter: return CreatePerimeterProfile((Oasys.Taxonomy.Profiles.IPerimeterProfile)profile); | ||
case ProfileType.Rectangle: return CreateRectangleProfile((Oasys.Taxonomy.Profiles.IRectangleProfile)profile); | ||
case ProfileType.RectangleHollow: | ||
return CreateRectangleHollowProfile((IRectangleHollowProfile)profile); | ||
case ProfileType.RectoCircle: | ||
return CreateStadiumProfile((IRectoCircleProfile)profile); | ||
return CreateRectangleHollowProfile((Oasys.Taxonomy.Profiles.IRectangleHollowProfile)profile); | ||
case ProfileType.RectoCircle: return CreateStadiumProfile((IRectoCircleProfile)profile); | ||
case ProfileType.RectoEllipse: | ||
return CreateRectoEllipseProfile((IRectoEllipseProfile)profile); | ||
return CreateRectoEllipseProfile((Oasys.Taxonomy.Profiles.IRectoEllipseProfile)profile); | ||
case ProfileType.SecantPile: | ||
return CreateSecantPileProfile((ISecantPileProfile)profile); | ||
case ProfileType.SheetPile: | ||
return CreateSheetPileProfile((ISheetPileProfile)profile); | ||
case ProfileType.Trapezoid: | ||
return CreateTrapezoidProfile((ITrapezoidProfile)profile); | ||
case ProfileType.TSection: | ||
return CreateTSectionProfile((ITSectionProfile)profile); | ||
return CreateSecantPileProfile((Oasys.Taxonomy.Profiles.ISecantPileProfile)profile); | ||
case ProfileType.SheetPile: return CreateSheetPileProfile((Oasys.Taxonomy.Profiles.ISheetPileProfile)profile); | ||
case ProfileType.Trapezoid: return CreateTrapezoidProfile((Oasys.Taxonomy.Profiles.ITrapezoidProfile)profile); | ||
case ProfileType.TSection: return CreateTSectionProfile((Oasys.Taxonomy.Profiles.ITSectionProfile)profile); | ||
case ProfileType.Undefined: | ||
default: | ||
throw new System.NotImplementedException(); | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public static Oasys.Profiles.IAngleProfile CreateAngleProfile(IAngleProfile profile) { | ||
return Oasys.Profiles.IAngleProfile.Create(profile.Depth, CreateFlange(profile.Flange), CreateWeb(profile.Web)); | ||
public static IAngleProfile CreateAngleProfile(Oasys.Taxonomy.Profiles.IAngleProfile profile) { | ||
return IAngleProfile.Create(profile.Depth, CreateFlange(profile.Flange), CreateWeb(profile.Web)); | ||
} | ||
|
||
public static Oasys.Profiles.ICatalogueProfile CreateCatalogueProfile(ICatalogueProfile profile) { | ||
return Oasys.Profiles.ICatalogueProfile.Create(profile.Description); | ||
public static ICatalogueProfile CreateCatalogueProfile(Oasys.Taxonomy.Profiles.ICatalogueProfile profile) { | ||
return ICatalogueProfile.Create(profile.Description); | ||
} | ||
|
||
public static Oasys.Profiles.IChannelProfile CreateChannelProfile(IChannelProfile profile) { | ||
return Oasys.Profiles.IChannelProfile.Create(profile.Depth, CreateFlange(profile.Flanges), CreateWebConstant(profile.Web)); | ||
public static IChannelProfile CreateChannelProfile(Oasys.Taxonomy.Profiles.IChannelProfile profile) { | ||
return IChannelProfile.Create(profile.Depth, CreateFlange(profile.Flanges), CreateWebConstant(profile.Web)); | ||
} | ||
|
||
public static Oasys.Profiles.ICircleHollowProfile CreateCircleHollowProfile(ICircleHollowProfile profile) { | ||
return Oasys.Profiles.ICircleHollowProfile.Create(profile.Diameter, profile.WallThickness); | ||
public static ICircleHollowProfile CreateCircleHollowProfile(Oasys.Taxonomy.Profiles.ICircleHollowProfile profile) { | ||
return ICircleHollowProfile.Create(profile.Diameter, profile.WallThickness); | ||
} | ||
|
||
public static Oasys.Profiles.ICircleProfile CreateCircleProfile(ICircleProfile profile) { | ||
return Oasys.Profiles.ICircleProfile.Create(profile.Diameter); | ||
public static ICircleProfile CreateCircleProfile(Oasys.Taxonomy.Profiles.ICircleProfile profile) { | ||
return ICircleProfile.Create(profile.Diameter); | ||
} | ||
|
||
public static Oasys.Profiles.ICruciformSymmetricalProfile CreateCruciformSymmetricalProfile(ICruciformSymmetricalProfile profile) { | ||
return Oasys.Profiles.ICruciformSymmetricalProfile.Create(profile.Depth, CreateFlange(profile.Flange), CreateWebConstant(profile.Web)); | ||
public static ICruciformSymmetricalProfile CreateCruciformSymmetricalProfile( | ||
Oasys.Taxonomy.Profiles.ICruciformSymmetricalProfile profile) { | ||
return ICruciformSymmetricalProfile.Create(profile.Depth, CreateFlange(profile.Flange), | ||
CreateWebConstant(profile.Web)); | ||
} | ||
|
||
public static Oasys.Profiles.IEllipseHollowProfile CreateEllipseHollowProfile(IEllipseHollowProfile profile) { | ||
return Oasys.Profiles.IEllipseHollowProfile.Create(profile.Depth, profile.Width, profile.WallThickness); | ||
public static IEllipseHollowProfile CreateEllipseHollowProfile( | ||
Oasys.Taxonomy.Profiles.IEllipseHollowProfile profile) { | ||
return IEllipseHollowProfile.Create(profile.Depth, profile.Width, profile.WallThickness); | ||
} | ||
|
||
public static Oasys.Profiles.IEllipseProfile CreateEllipseProfile(IEllipseProfile profile) { | ||
return Oasys.Profiles.IEllipseProfile.Create(profile.Depth, profile.Width); | ||
public static IEllipseProfile CreateEllipseProfile(Oasys.Taxonomy.Profiles.IEllipseProfile profile) { | ||
return IEllipseProfile.Create(profile.Depth, profile.Width); | ||
} | ||
|
||
public static Oasys.Profiles.IGeneralCProfile CreateGeneralCProfile(IGeneralCProfile profile) { | ||
return Oasys.Profiles.IGeneralCProfile.Create(profile.Depth, profile.FlangeWidth, profile.Lip, profile.Thickness); | ||
public static IGeneralCProfile CreateGeneralCProfile(Oasys.Taxonomy.Profiles.IGeneralCProfile profile) { | ||
return IGeneralCProfile.Create(profile.Depth, profile.FlangeWidth, profile.Lip, profile.Thickness); | ||
} | ||
|
||
public static Oasys.Profiles.IGeneralZProfile CreateGeneralZProfile(IGeneralZProfile profile) { | ||
return Oasys.Profiles.IGeneralZProfile.Create(profile.Depth, profile.TopFlangeWidth, profile.BottomFlangeWidth, profile.TopLip, profile.BottomLip, profile.Thickness); | ||
public static IGeneralZProfile CreateGeneralZProfile(Oasys.Taxonomy.Profiles.IGeneralZProfile profile) { | ||
return IGeneralZProfile.Create(profile.Depth, profile.TopFlangeWidth, profile.BottomFlangeWidth, profile.TopLip, | ||
profile.BottomLip, profile.Thickness); | ||
} | ||
|
||
public static Oasys.Profiles.IIBeamAsymmetricalProfile CreateIBeamAsymmetricalProfile(IIBeamAsymmetricalProfile profile) { | ||
return Oasys.Profiles.IIBeamAsymmetricalProfile.Create(profile.Depth, CreateFlange(profile.TopFlange), CreateFlange(profile.BottomFlange), CreateWeb(profile.Web)); | ||
public static IIBeamAsymmetricalProfile CreateIBeamAsymmetricalProfile( | ||
Oasys.Taxonomy.Profiles.IIBeamAsymmetricalProfile profile) { | ||
return IIBeamAsymmetricalProfile.Create(profile.Depth, CreateFlange(profile.TopFlange), | ||
CreateFlange(profile.BottomFlange), CreateWeb(profile.Web)); | ||
} | ||
|
||
public static Oasys.Profiles.IIBeamCellularProfile CreateIBeamCellularProfile(IIBeamCellularProfile profile) { | ||
return Oasys.Profiles.IIBeamCellularProfile.Create(profile.Depth, CreateFlange(profile.Flanges), CreateWebConstant(profile.Web), profile.WebOpening); | ||
public static IIBeamCellularProfile CreateIBeamCellularProfile( | ||
Oasys.Taxonomy.Profiles.IIBeamCellularProfile profile) { | ||
return IIBeamCellularProfile.Create(profile.Depth, CreateFlange(profile.Flanges), CreateWebConstant(profile.Web), | ||
profile.WebOpening); | ||
} | ||
|
||
public static Oasys.Profiles.IIBeamSymmetricalProfile CreateIBeamSymmetricalProfile(IIBeamProfile profile) { | ||
return Oasys.Profiles.IIBeamSymmetricalProfile.Create(profile.Depth, CreateFlange(profile.Flanges), CreateWebConstant(profile.Web)); | ||
public static IIBeamSymmetricalProfile CreateIBeamSymmetricalProfile(IIBeamProfile profile) { | ||
return IIBeamSymmetricalProfile.Create(profile.Depth, CreateFlange(profile.Flanges), | ||
CreateWebConstant(profile.Web)); | ||
} | ||
|
||
public static Oasys.Profiles.IPerimeterProfile CreatePerimeterProfile(IPerimeterProfile profile) { | ||
var perimeter = Oasys.Profiles.IPerimeterProfile.Create(); | ||
public static IPerimeterProfile CreatePerimeterProfile(Oasys.Taxonomy.Profiles.IPerimeterProfile profile) { | ||
var perimeter = IPerimeterProfile.Create(); | ||
perimeter.SolidPolygon = CreatePolygon(profile.Perimeter); | ||
|
||
foreach (IPolygon polygon in profile.VoidPolygons) { | ||
foreach (var polygon in profile.VoidPolygons) { | ||
perimeter.VoidPolygons.Add(CreatePolygon(polygon)); | ||
} | ||
|
||
return perimeter; | ||
} | ||
|
||
private static Oasys.Profiles.IPolygon CreatePolygon(IPolygon p) { | ||
var polygon = Oasys.Profiles.IPolygon.Create(); | ||
foreach (IPoint2d point in p.Points) { | ||
polygon.Points.Add(Oasys.Profiles.IPoint.Create(point.Y, point.Z)); | ||
} | ||
return polygon; | ||
public static IRectangleHollowProfile CreateRectangleHollowProfile( | ||
Oasys.Taxonomy.Profiles.IRectangleHollowProfile profile) { | ||
return IRectangleHollowProfile.Create(profile.Depth, CreateFlange(profile.Flanges), | ||
CreateWebConstant(profile.Webs)); | ||
} | ||
|
||
public static Oasys.Profiles.IRectangleHollowProfile CreateRectangleHollowProfile(IRectangleHollowProfile profile) { | ||
return Oasys.Profiles.IRectangleHollowProfile.Create(profile.Depth, CreateFlange(profile.Flanges), CreateWebConstant(profile.Webs)); | ||
public static IRectangleProfile CreateRectangleProfile(Oasys.Taxonomy.Profiles.IRectangleProfile profile) { | ||
return IRectangleProfile.Create(profile.Depth, profile.Width); | ||
} | ||
|
||
public static Oasys.Profiles.IRectangleProfile CreateRectangleProfile(IRectangleProfile profile) { | ||
return Oasys.Profiles.IRectangleProfile.Create(profile.Depth, profile.Width); | ||
public static IStadiumProfile CreateStadiumProfile(IRectoCircleProfile profile) { | ||
return IStadiumProfile.Create(profile.Depth, profile.Width); | ||
} | ||
|
||
public static Oasys.Profiles.IFlange CreateFlange(IFlange flange) { | ||
return Oasys.Profiles.IFlange.Create(flange.Width, flange.Thickness); | ||
public static IRectoEllipseProfile CreateRectoEllipseProfile(Oasys.Taxonomy.Profiles.IRectoEllipseProfile profile) { | ||
return IRectoEllipseProfile.Create(profile.Depth, profile.DepthFlat, profile.Width, profile.WidthFlat); | ||
} | ||
|
||
public static Oasys.Profiles.IStadiumProfile CreateStadiumProfile(IRectoCircleProfile profile) { | ||
return Oasys.Profiles.IStadiumProfile.Create(profile.Depth, profile.Width); | ||
public static ISecantPileProfile CreateSecantPileProfile(Oasys.Taxonomy.Profiles.ISecantPileProfile profile) { | ||
return ISecantPileProfile.Create(profile.Diameter, profile.PileCentres, profile.PileCount, profile.IsWall); | ||
} | ||
|
||
public static Oasys.Profiles.IRectoEllipseProfile CreateRectoEllipseProfile(IRectoEllipseProfile profile) { | ||
return Oasys.Profiles.IRectoEllipseProfile.Create(profile.Depth, profile.DepthFlat, profile.Width, profile.WidthFlat); | ||
public static ISheetPileProfile CreateSheetPileProfile(Oasys.Taxonomy.Profiles.ISheetPileProfile profile) { | ||
return ISheetPileProfile.Create(profile.Depth, profile.Width, profile.TopFlangeWidth, profile.BottomFlangeWidth, | ||
profile.FlangeThickness, profile.WebThickness); | ||
} | ||
|
||
public static Oasys.Profiles.ISecantPileProfile CreateSecantPileProfile(ISecantPileProfile profile) { | ||
return Oasys.Profiles.ISecantPileProfile.Create(profile.Diameter, profile.PileCentres, profile.PileCount, profile.IsWall); | ||
public static ITrapezoidProfile CreateTrapezoidProfile(Oasys.Taxonomy.Profiles.ITrapezoidProfile profile) { | ||
return ITrapezoidProfile.Create(profile.Depth, profile.TopWidth, profile.BottomWidth); | ||
} | ||
|
||
public static Oasys.Profiles.ISheetPileProfile CreateSheetPileProfile(ISheetPileProfile profile) { | ||
return Oasys.Profiles.ISheetPileProfile.Create(profile.Depth, profile.Width, profile.TopFlangeWidth, profile.BottomFlangeWidth, profile.FlangeThickness, profile.WebThickness); | ||
public static ITSectionProfile CreateTSectionProfile(Oasys.Taxonomy.Profiles.ITSectionProfile profile) { | ||
return ITSectionProfile.Create(profile.Depth, CreateFlange(profile.Flange), CreateWeb(profile.Web)); | ||
} | ||
|
||
public static Oasys.Profiles.ITrapezoidProfile CreateTrapezoidProfile(ITrapezoidProfile profile) { | ||
return Oasys.Profiles.ITrapezoidProfile.Create(profile.Depth, profile.TopWidth, profile.BottomWidth); | ||
//helpers | ||
|
||
public static IPolygon CreatePolygon(Oasys.Taxonomy.Geometry.IPolygon p) { | ||
var polygon = IPolygon.Create(); | ||
if (p == null || p.Points == null || !p.Points.Any()) { | ||
return polygon; | ||
} | ||
|
||
foreach (var point in p.Points) { | ||
polygon.Points.Add(IPoint.Create(point.Y, point.Z)); | ||
} | ||
|
||
return polygon; | ||
} | ||
|
||
public static Oasys.Profiles.ITSectionProfile CreateTSectionProfile(ITSectionProfile profile) { | ||
return Oasys.Profiles.ITSectionProfile.Create(profile.Depth, CreateFlange(profile.Flange), CreateWeb(profile.Web)); | ||
public static IFlange CreateFlange(Oasys.Taxonomy.Profiles.IFlange flange) { | ||
return flange == null ? null : IFlange.Create(flange.Width, flange.Thickness); | ||
} | ||
|
||
public static Oasys.Profiles.IWebConstant CreateWebConstant(IWebConstant web) { | ||
return Oasys.Profiles.IWebConstant.Create(web.Thickness); | ||
public static IWebConstant CreateWebConstant(Oasys.Taxonomy.Profiles.IWebConstant web) { | ||
return IWebConstant.Create(web.Thickness); | ||
} | ||
|
||
public static Oasys.Profiles.IWebTapered CreateWebTapered(IWebTapered web) { | ||
return Oasys.Profiles.IWebTapered.Create(web.TopThickness, web.BottomThickness); | ||
public static IWebTapered CreateWebTapered(Oasys.Taxonomy.Profiles.IWebTapered web) { | ||
return IWebTapered.Create(web.TopThickness, web.BottomThickness); | ||
} | ||
|
||
public static Oasys.Profiles.IWeb CreateWeb(IWeb web) { | ||
if (web is IWebConstant webConstant) { | ||
return CreateWebConstant(webConstant); | ||
} else if (web is IWebTapered webTapered) { | ||
return CreateWebTapered(webTapered); | ||
} else { return null; } | ||
public static IWeb CreateWeb(Oasys.Taxonomy.Profiles.IWeb web) { | ||
IWeb result = null; | ||
switch (web) { | ||
case Oasys.Taxonomy.Profiles.IWebConstant webConstant: | ||
result = CreateWebConstant(webConstant); | ||
break; | ||
case Oasys.Taxonomy.Profiles.IWebTapered webTapered: | ||
result = CreateWebTapered(webTapered); | ||
break; | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
Oops, something went wrong.