Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r3004 -r3025 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 3004) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 3025) @@ -36,17 +36,21 @@ using Deltares.DamEngine.Data.Standard; using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.MacroStability.CSharpWrapper; +using Deltares.MacroStability.CSharpWrapper.Input; +using Deltares.MacroStability.CSharpWrapper.Output; using Deltares.MacroStability.Standard; +using CharacteristicPointType = Deltares.DamEngine.Data.Geotechnics.CharacteristicPointType; using GeometryPoint = Deltares.DamEngine.Data.Geometry.GeometryPoint; using LogMessage = Deltares.DamEngine.Data.Standard.Logging.LogMessage; using LogMessageType = Deltares.DamEngine.Data.Standard.Logging.LogMessageType; +using Soil = Deltares.DamEngine.Data.Geotechnics.Soil; namespace Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityInwards { public class MacroStabilityInwardsKernelWrapper : IKernelWrapper { private Calculator stabilityCalculator; - + private int lastIterationIndex; /// @@ -94,7 +98,8 @@ var waterNet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, damKernelInput.SubSoilScenario.SoilProfile1D, penetrationLength, left, right); TrafficLoad trafficLoad = null; - if (damKernelInput.Location.StabilityOptions.TrafficLoad.HasValue && !damKernelInput.Location.StabilityOptions.TrafficLoad.Value.AlmostZero()) + if (damKernelInput.Location.StabilityOptions != null && damKernelInput.Location.StabilityOptions.TrafficLoad.HasValue && + !damKernelInput.Location.StabilityOptions.TrafficLoad.Value.AlmostZero()) { trafficLoad = new TrafficLoad(); trafficLoad.Pressure = damKernelInput.Location.StabilityOptions.TrafficLoad.Value; @@ -129,26 +134,26 @@ private void EnsureSoilProfile2DIsFilled(SoilGeometryProbability subSoilScenario, SurfaceLine2 surfaceLine2, Soil dikeEmbankmentSoil) { - // var soilProfile2D = subSoilScenario.SoilProfile2D; - // if (soilProfile2D == null) - // { - // var soilSurfaceProfile = new SoilSurfaceProfile - // { - // SoilProfile = subSoilScenario.SoilProfile1D, - // SurfaceLine2 = surfaceLine2, - // Name = surfaceLine2.Name + "_" + subSoilScenario.SoilProfile1D.Name, - // DikeEmbankmentMaterial = dikeEmbankmentSoil - // }; - // // Convert the soilsurfacesoilprofile to a SoilProfile2D to be able to edit it properly. - // var soilProfile2DNew = soilSurfaceProfile.ConvertToSoilProfile2D(); - // //soilSurfaceProfile.Dispose(); - // // For some obscure reason, the created soilProfile2D is handled wrong in the UI (see DSB=786). - // // Its curves do not seem to match the surfaces in the events send on selecting and dragging a curve. - // // This causes the strange behaviour. To solve this, a Clone is made of the soilProfile2D and that clone is added instead. - // //soilProfile2D = (SoilProfile2D)soilProfile2D.Clone(); - // //soilProfile2DNew.Dispose(); - // soilProfile2D = soilProfile2DNew; - // } + var soilProfile2D = subSoilScenario.SoilProfile2D; + if (soilProfile2D == null) + { + // var soilSurfaceProfile = new SoilSurfaceProfile + // { + // SoilProfile = subSoilScenario.SoilProfile1D, + // SurfaceLine2 = surfaceLine2, + // Name = surfaceLine2.Name + "_" + subSoilScenario.SoilProfile1D.Name, + // DikeEmbankmentMaterial = dikeEmbankmentSoil + // }; + // // Convert the soilsurfacesoilprofile to a SoilProfile2D to be able to edit it properly. + // var soilProfile2DNew = soilSurfaceProfile.ConvertToSoilProfile2D(); + // //soilSurfaceProfile.Dispose(); + // // For some obscure reason, the created soilProfile2D is handled wrong in the UI (see DSB=786). + // // Its curves do not seem to match the surfaces in the events send on selecting and dragging a curve. + // // This causes the strange behaviour. To solve this, a Clone is made of the soilProfile2D and that clone is added instead. + // //soilProfile2D = (SoilProfile2D)soilProfile2D.Clone(); + // //soilProfile2DNew.Dispose(); + // soilProfile2D = soilProfile2DNew; + } } private PrepareResult PrepareKernel(MacroStability.CSharpWrapper.Input.MacroStabilityInput input) @@ -185,9 +190,39 @@ /// public int Validate(IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, out List messages) { - // Todo implement validation as soon as it has been implemented in the C# wrapper. + MacroStabilityKernelDataInput macroStabilityKernelDataInput = (MacroStabilityKernelDataInput)kernelDataInput; + var result = Deltares.MacroStability.CSharpWrapper.Validator.Validate((MacroStabilityInput)macroStabilityKernelDataInput.Input); messages = new List(); - return 0; + if (result.IsValid) + { + return 0; + } + + (kernelDataOutput as MacroStabilityOutput).CalculationResult = CalculationResult.InvalidInputData; + foreach (var resultMessage in result.Messages) + { + var message = new LogMessage(); + message.Message = resultMessage.Content; + switch (resultMessage.MessageType) + { + case MessageType.Error: + { + message.MessageType = LogMessageType.Error; + break; + } + case MessageType.Info: + { + message.MessageType = LogMessageType.Info; + break; + } + case MessageType.Warning: + { + message.MessageType = LogMessageType.Warning; + break; + } + }; + } + return 1; } ///