Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.cs =================================================================== diff -u -rd90619dfb54877db8067f27218c45ad4e5dab55d -ra3b8f844591b20947be3f6383e2112c0abe5dd10 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.cs (.../MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.cs) (revision d90619dfb54877db8067f27218c45ad4e5dab55d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.cs (.../MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.cs) (revision a3b8f844591b20947be3f6383e2112c0abe5dd10) @@ -41,7 +41,9 @@ /// A new containing geometries from the /// under the . /// Thrown when any parameter is null. - public static MacroStabilityInwardsSoilProfileUnderSurfaceLine Create(MacroStabilityInwardsSoilProfile1D soilProfile, + /// Thrown when the given type + /// is not supported. + public static MacroStabilityInwardsSoilProfileUnderSurfaceLine Create(IMacroStabilityInwardsSoilProfile soilProfile, MacroStabilityInwardsSurfaceLine surfaceLine) { if (soilProfile == null) @@ -52,6 +54,23 @@ { throw new ArgumentNullException(nameof(surfaceLine)); } + + var profile1D = soilProfile as MacroStabilityInwardsSoilProfile1D; + if (profile1D != null) + { + return Create(profile1D, surfaceLine); + } + var profile2D = soilProfile as MacroStabilityInwardsSoilProfile2D; + if (profile2D != null) + { + return Create(profile2D); + } + throw new NotSupportedException(); + } + + private static MacroStabilityInwardsSoilProfileUnderSurfaceLine Create(MacroStabilityInwardsSoilProfile1D soilProfile, + MacroStabilityInwardsSurfaceLine surfaceLine) + { Point2D[] localizedSurfaceLine = surfaceLine.LocalGeometry.ToArray(); double geometryBottom = Math.Min(soilProfile.Bottom, localizedSurfaceLine.Min(p => p.Y)) - 1; @@ -66,20 +85,8 @@ return GeometriesToIntersections(layerGeometries, surfaceLineGeometry); } - /// - /// Creates a new . - /// - /// The soil profile containing layers. - /// A new containing geometries from the - /// . - /// Thrown when is null. - public static MacroStabilityInwardsSoilProfileUnderSurfaceLine Create(MacroStabilityInwardsSoilProfile2D soilProfile) + private static MacroStabilityInwardsSoilProfileUnderSurfaceLine Create(MacroStabilityInwardsSoilProfile2D soilProfile) { - if (soilProfile == null) - { - throw new ArgumentNullException(nameof(soilProfile)); - } - IEnumerable layersUnderSurfaceLine = soilProfile.Layers.Select( layer => new MacroStabilityInwardsSoilLayerUnderSurfaceLine( RingToPoints(layer.OuterRing),