Index: DamEngine/branches/nwo_18.1/release/nl-NL/Deltares.DamEngine.Interface.resources.dll =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/release/Deltares.DamEngine.Version.pdb =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/release/Deltares.DamEngine.Version.dll =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/release/Deltares.DamEngine.Calculators.dll =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs =================================================================== diff -u -r1848 -r1850 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 1848) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 1850) @@ -88,7 +88,7 @@ public double? PlLineOffsetFactorBelowShoulderCrest { get; set; } public bool? UsePlLineOffsetBelowDikeCrestMiddle { get; set; } public bool? UsePlLineOffsetFactorBelowShoulderCrest { get; set; } - + private double WaterLevelToUse() { if (isUseLowWaterLevel) @@ -478,11 +478,11 @@ double headAtEnd = plLine.Points.Last().Z - slopeGradient * lengthFromLastPlPointToEnd; Line waterLevelPolderLine = - new Line(new Point2D(this.surfaceLine.Geometry.Points.First().X, this.WaterLevelPolder), + new Line(new Point2D(this.surfaceLine.Geometry.Points.First().X, this.WaterLevelPolder), new Point2D(this.surfaceLine.Geometry.Points.Last().X, WaterLevelPolder)); Line slopeLine = new Line( - new Point2D(this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder).X, headAtLastPlPoint), + new Point2D(this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder).X, headAtLastPlPoint), new Point2D(this.surfaceLine.Geometry.Points.Last().X, headAtEnd)); var intersectionPoint = new Point2D(); @@ -744,6 +744,7 @@ bool isRemoveAllPlPointsBackToDikeToeAtRiver; bool isSkipAdjustmentInDitch; + bool isSkipAdjustmentInNwo; DetermineHowToActDueToDitch(out isSkipAdjustmentInDitch, out isRemoveAllPlPointsBackToDikeToeAtRiver); foreach (GeometryPoint surfacePoint in relevantSurfacePointsList) @@ -900,7 +901,46 @@ } } + /// + /// Determines how to act due to NWO. + /// + /// if set to true [is skip adjustment in Nwo]. + /// if set to true [is remove all pl points back to dike toe at river]. + private void DetermineHowToActDueToNwo(out bool isSkipAdjustmentInNwo, out bool isRemoveAllPlPointsBackToDikeToeAtRiver) + { + if (this.surfaceLine.HasNwo()) + { + double thicknessAquitardAtTopNwo = + DetermineThicknessAquitardAtCharacteristicPoint(CharacteristicPointType.NonWaterRetainingObjectPoint4).Value; + double thicknessAquitardAtBottomNwo = + DetermineThicknessAquitardAtCharacteristicPoint(CharacteristicPointType.NonWaterRetainingObjectPoint3).Value; + double widthNwoAtTop = this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint4).X - + this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint1).X; + double widthNwoAtBottom = + this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint4).X - + this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint1).X; + if ((thicknessAquitardAtTopNwo > widthNwoAtTop) && + (thicknessAquitardAtBottomNwo > widthNwoAtBottom)) + { + isRemoveAllPlPointsBackToDikeToeAtRiver = false; + isSkipAdjustmentInNwo = true; + } + else + { + isRemoveAllPlPointsBackToDikeToeAtRiver = true; + isSkipAdjustmentInNwo = false; + } + } + else + { + isRemoveAllPlPointsBackToDikeToeAtRiver = false; + isSkipAdjustmentInNwo = false; + } + } + + + /// /// Due to accuracy surfacelevel could be slightly below toplevel of toplevel soilprofile /// Adjust toplevel of soilprofile to avoid this /// @@ -952,367 +992,405 @@ // currentPL1Line is needed when calculating uplift reduction for PL3 and Pl4 if (plLineType == PlLineType.Pl1) { - // var PlLine = PlLines.Lines[PlLineType]; - // AdaptPL1ForNonWaterRetainingObject(ref PlLine); - // PlLines.Lines[PlLineType] = PlLine; + var plLine = plLines.Lines[plLineType]; + AdaptPL1ForNonWaterRetainingObject(ref plLine); + plLines.Lines[plLineType] = plLine; currentPl1Line = plLines.Lines[plLineType]; } } return plLines; } -// private IEnumerable FindAllPlLinePointsAtNWOLocation(PlLine pl1Line) -// { -// IEnumerable results = pl1Line.GetPointSegmentBetween(this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint1).X - cOffsetPhreaticLineBelowSurface, -// this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint4).X + cOffsetPhreaticLineBelowSurface); -// -// return results; -// } + private IEnumerable FindAllPlLinePointsAtNWOLocation(PlLine pl1Line) + { + IEnumerable results = pl1Line.GetPointSegmentBetween(this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint1).X - cOffsetPhreaticLineBelowSurface, + this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint4).X + cOffsetPhreaticLineBelowSurface); -// private void AdaptPL1ForNonWaterRetainingObject(ref PlLine pl1Line) -// { -// // check if nwo points are available as CharacteristicPoints -// var nwo1 = this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint1); -// var nwo2 = this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint2); -// var nwo3 = this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint3); -// var nwo4 = this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.NonWaterRetainingObjectPoint4); -// if ((nwo1 != null) && (nwo2 != null) && (nwo3 != null) && (nwo4 != null)) -// { -// -// // Find all points in the Pl line that (might) coincide with the NWO -// IEnumerable plPointsToBeMoved = FindAllPlLinePointsAtNWOLocation(pl1Line); -// -// PlLinePoint nwo1Pl = null; -// PlLinePoint nwo2Pl = null; -// PlLinePoint nwo3Pl = null; -// PlLinePoint nwo4Pl = null; -// -// // For NWO point, determine whether a pl point has to be added -// if (pl1Line.PositionXzOfPointRelatedToPlLine(nwo1) != PlLinePointPositionXzType.AbovePlLine) -// { -// nwo1Pl = new PlLinePoint(nwo1.X, nwo1.Z - cOffsetPhreaticLineBelowSurface); -// } -// if (pl1Line.PositionXzOfPointRelatedToPlLine(nwo2) != PlLinePointPositionXzType.AbovePlLine) -// { -// nwo2Pl = new PlLinePoint(nwo2.X, nwo2.Z - cOffsetPhreaticLineBelowSurface); -// } -// if (pl1Line.PositionXzOfPointRelatedToPlLine(nwo3) != PlLinePointPositionXzType.AbovePlLine) -// { -// nwo3Pl = new PlLinePoint(nwo3.X, nwo3.Z - cOffsetPhreaticLineBelowSurface); -// } -// if (pl1Line.PositionXzOfPointRelatedToPlLine(nwo4) != PlLinePointPositionXzType.AbovePlLine) -// { -// nwo4Pl = new PlLinePoint(nwo4.X, nwo4.Z - cOffsetPhreaticLineBelowSurface); -// } -// -// // Find the intersections of pl line and NWO and handle these -// // Intersection between nwo point1 and nwo point2 only when nwo point1 is above pl line and nwo point2 is below PlLine -// PlLinePoint intersection1 = null; -// if ((nwo1Pl == null) && (nwo2Pl != null)) -// { -// var lineNWO = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(nwo1.X, 0, nwo1.Z), EndPoint = new GeometryPoint(nwo2.X, 0, nwo2.Z) }; -// var ips = pl1Line.IntersectionPointsXzWithLineXz(lineNWO); -// if (ips.Count > 0) -// { -// intersection1 = new PlLinePoint(ips.First().X, ips.First().Z); -// } -// } -// // Intersection between nwo point3 and nwo point4 only when nwo point3 is below pl line and nwo point4 is above PlLine -// PlLinePoint intersection2 = null; -// if ((nwo3Pl != null) && (nwo4Pl == null)) -// { -// var lineNWO = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(nwo3.X, 0, nwo3.Z), EndPoint = new GeometryPoint(nwo4.X, 0, nwo4.Z) }; -// var ips = pl1Line.IntersectionPointsXzWithLineXz(lineNWO); -// if (ips.Count > 0) -// { -// intersection2 = new PlLinePoint(ips.Last().X, ips.Last().Z); -// } -// } -// -// // Handle making the NWO empty -// if ((NWOPhreaticAdaption != null) && (NWOPhreaticAdaption == PhreaticAdaptionType.MakeEmpty)) -// { -// // for the polderside, the pl line is always allowed to be adapted. For the riverside, the pl line may only be adapted when the original waterlevel is runs through the nwo. -// RemoveAllWaterFromNonWaterRetainingObject(nwo1, pl1Line, nwo1Pl, nwo2Pl, nwo3Pl, nwo4Pl, intersection1, intersection2, plPointsToBeMoved); -// } -// // Handle making the waterlevel horizontal in the NWO at the Riverside when needed (Polderside is already done when needed, see CreatePhreaticLineSegmentsInShoulderAndPolder. -// if ((NWOPhreaticAdaption != null) && (NWOPhreaticAdaption == PhreaticAdaptionType.None)) -// { -// // For the riverside, the pl line may only be adapted when the original waterlevel is runs through the nwo and is not already level. -// if ((nwo1.X <= this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).X) && ((intersection1 != null) || (intersection2 != null))) -// { -// double requiredWaterLevel; -// // Check whether adaption of intersection points is needed -// if (intersection2 == null) -// { -// // only intersection 1 avaialable so add intersection 2 -// // first see if nwo3/4 intersects, if not try nwo2/3. If still no intersection found valid level not possible, raise error -// MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1(nwo2, nwo3, nwo4, pl1Line, nwo3Pl, nwo4Pl, intersection1); -// requiredWaterLevel = intersection1.Z; -// } -// else -// { -// if (intersection1 == null) -// { -// // only intersection 2 avaialable so add intersection 1 -// // first see if nwo1/2 intersects, if not try nwo2/3. If still no intersection found valid level not possible, raise error -// MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2(nwo1, nwo2, nwo3, pl1Line, nwo1Pl, nwo2Pl, nwo3Pl, intersection2); -// requiredWaterLevel = intersection2.Z; -// } -// else -// { -// // intersection 1 and intersection 2 available. Only act when levels were different. -// requiredWaterLevel = Math.Min(intersection1.Z, intersection2.Z); -// if ((Math.Abs(intersection1.Z - intersection2.Z) > GeometryPoint.Precision)) -// { -// if (intersection1.Z < intersection2.Z) -// { -// // make level in NWO intersection1.Z -// MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1And2(nwo2, nwo3, nwo4, pl1Line, nwo3Pl, intersection1, intersection2); -// } -// else -// { -// // make level in NWO intersection2.Z -// MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2And1(nwo1, nwo2, nwo3, pl1Line, nwo2Pl, intersection1, intersection2); -// } -// -// } -// } -// } -// -// // Move all the points in the pl line itself that need to be moved to the horizontal proper level. -// foreach (var PlLinePoint in plPointsToBeMoved) -// { -// PlLinePoint.Z = requiredWaterLevel; -// } -// pl1Line.DeleteCoinsidingPoints(GeometryPoint.Precision); -// } -// } -// } -// } + return results; + } -// private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2And1(GeometryPoint nwo1, GeometryPoint nwo2, GeometryPoint nwo3, PlLine pl1Line, PlLinePoint nwo2Pl, PlLinePoint intersection1, PlLinePoint intersection2) -// { -// var lineNWO = new Line { BeginPoint = new Point2D(nwo1.X, nwo1.Z), EndPoint = new Point2D(nwo2.X, nwo2.Z) }; -// var linePL = new Line { BeginPoint = new Point2D(nwo1.X, intersection2.Z), EndPoint = new Point2D(intersection2.X, intersection2.Z) }; -// var isp = new GeometryPoint(); -// if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) -// { -// var newP1 = pl1Line.EnsurePointAtX(intersection2.X, GeometryPoint.Precision); -// newP1.Z = intersection2.Z; -// var newP2 = pl1Line.EnsurePointAtX(isp.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP2.Z = intersection2.Z; -// var newP3 = pl1Line.EnsurePointAtX(intersection1.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP3.Z = intersection1.Z; -// } -// else -// { -// var lineNWOb = new Line { BeginPoint = new Point2D(nwo2.X, nwo2.Z), EndPoint = new Point2D(nwo3.X, nwo3.Z) }; -// if (LineHelper.GetStrictIntersectionPoint(lineNWOb, linePL, ref isp)) -// { -// var newP1 = pl1Line.EnsurePointAtX(intersection2.X, GeometryPoint.Precision); -// newP1.Z = intersection2.Z; -// var newP2 = pl1Line.EnsurePointAtX(isp.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP2.Z = intersection2.Z; -// var newP3 = pl1Line.EnsurePointAtX(nwo2Pl.X, GeometryPoint.Precision); -// newP3.Z = nwo2Pl.Z; -// if (nwo2Pl.X > intersection1.X) -// { -// var newP4 = pl1Line.EnsurePointAtX(intersection1.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP4.Z = intersection1.Z; -// } -// -// } -// else -// { -// throw new PlLinesCreatorException("Could not create the intersectionsection points between NWO and Phreatic line to create horizontal level."); -// } -// } -// } + private void AdaptPL1ForNonWaterRetainingObject(ref PlLine pl1Line) + { + // check if nwo points are available as CharacteristicPoints + var nwo1 = this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType + .NonWaterRetainingObjectPoint1); + var nwo2 = this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType + .NonWaterRetainingObjectPoint2); + var nwo3 = this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType + .NonWaterRetainingObjectPoint3); + var nwo4 = this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType + .NonWaterRetainingObjectPoint4); + if ((nwo1 != null) && (nwo2 != null) && (nwo3 != null) && (nwo4 != null)) + { -// private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1And2(GeometryPoint nwo2, GeometryPoint nwo3, GeometryPoint nwo4, PlLine pl1Line, PlLinePoint nwo3Pl, PlLinePoint intersection1, PlLinePoint intersection2) -// { -// var lineNWO = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(nwo3.X, 0, nwo3.Z), EndPoint = new GeometryPoint(nwo4.X, 0, nwo4.Z) }; -// var linePL = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(intersection1.X, 0, intersection1.Z), EndPoint = new GeometryPoint(nwo4.X, 0, intersection1.Z) }; -// var isp = new GeometryPoint(); -// if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) -// { -// var newP1 = pl1Line.EnsurePointAtX(intersection1.X, GeometryPoint.Precision); -// newP1.Z = intersection1.Z; -// var newP2 = pl1Line.EnsurePointAtX(isp.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP2.Z = intersection1.Z; -// var newP3 = pl1Line.EnsurePointAtX(intersection2.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP3.Z = intersection2.Z; -// } -// else -// { -// var lineNWOb = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(nwo2.X, 0, nwo2.Z), EndPoint = new GeometryPoint(nwo3.X, 0, nwo3.Z) }; -// if (LineHelper.GetStrictIntersectionPoint(lineNWOb, linePL, ref isp)) -// { -// var newP1 = pl1Line.EnsurePointAtX(intersection1.X, GeometryPoint.Precision); -// newP1.Z = intersection1.Z; -// var newP2 = pl1Line.EnsurePointAtX(isp.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP2.Z = intersection1.Z; -// var newP3 = pl1Line.EnsurePointAtX(nwo3Pl.X, GeometryPoint.Precision); -// newP3.Z = nwo3Pl.Z; -// if (nwo3Pl.X < intersection2.X) -// { -// var newP4 = pl1Line.EnsurePointAtX(intersection2.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP4.Z = intersection2.Z; -// } -// } -// else -// { -// throw new PlLinesCreatorException("Could not create the intersectionsection points between NWO and Phreatic line to create horizontal level."); -// } -// } -// } + // Find all points in the Pl line that (might) coincide with the NWO + IEnumerable plPointsToBeMoved = FindAllPlLinePointsAtNWOLocation(pl1Line); -// private void RemoveAllWaterFromNonWaterRetainingObject(GeometryPoint nwo1, PlLine pl1Line, PlLinePoint nwo1Pl, PlLinePoint nwo2Pl, PlLinePoint nwo3Pl, PlLinePoint nwo4Pl, PlLinePoint intersection1, PlLinePoint intersection2, IEnumerable plPointsToBeMoved) -// { -// if ((nwo1.X >= this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder).X) || -// ((intersection1 != null) && (intersection2 != null))) -// { -// // Move all the points in the pl line itself that need to be moved to below the surfaceline. -// MoveSelectedPlLinePointsBelowSurfaceLine(plPointsToBeMoved); -// -// // now add all extra points to the pl line -// if (nwo1Pl != null) -// { -// var newP = pl1Line.EnsurePointAtX(nwo1Pl.X, GeometryPoint.Precision); -// newP.Z = nwo1Pl.Z; -// } -// if (nwo2Pl != null) -// { -// var newP = pl1Line.EnsurePointAtX(nwo2Pl.X, GeometryPoint.Precision); -// newP.Z = nwo2Pl.Z; -// } -// if (nwo3Pl != null) -// { -// var newP = pl1Line.EnsurePointAtX(nwo3Pl.X, GeometryPoint.Precision); -// newP.Z = nwo3Pl.Z; -// } -// if (nwo4Pl != null) -// { -// var newP = pl1Line.EnsurePointAtX(nwo4Pl.X, GeometryPoint.Precision); -// newP.Z = nwo4Pl.Z; -// } -// // Note: for intersection points, apply offset in X direction not in Z. -// if (intersection1 != null) -// { -// var newP = pl1Line.EnsurePointAtX(intersection1.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP.Z = intersection1.Z; -// } -// if (intersection2 != null) -// { -// var newP = pl1Line.EnsurePointAtX(intersection2.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP.Z = intersection2.Z; -// } -// pl1Line.DeleteCoinsidingPoints(GeometryPoint.Precision); -// } -// } + PlLinePoint nwo1Pl = null; + PlLinePoint nwo2Pl = null; + PlLinePoint nwo3Pl = null; + PlLinePoint nwo4Pl = null; -// private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2(GeometryPoint nwo1, GeometryPoint nwo2, GeometryPoint nwo3, PlLine pl1Line, PlLinePoint nwo1Pl, PlLinePoint nwo2Pl, PlLinePoint nwo3Pl, PlLinePoint intersection2) -// { -// var lineNWO = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(nwo1.X, 0, nwo1.Z), EndPoint = new GeometryPoint(nwo2.X, 0, nwo2.Z) }; -// var linePL = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(nwo1.X, 0, intersection2.Z), EndPoint = new GeometryPoint(intersection2.X, 0, intersection2.Z) }; -// var isp = new GeometryPoint(); -// if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) -// { -// var newP1 = pl1Line.EnsurePointAtX(intersection2.X, GeometryPoint.Precision); -// newP1.Z = intersection2.Z; -// var newP2 = pl1Line.EnsurePointAtX(isp.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP2.Z = intersection2.Z; -// if (nwo1Pl != null) -// { -// var newP3 = pl1Line.EnsurePointAtX(nwo1Pl.X, GeometryPoint.Precision); -// newP3.Z = nwo1Pl.Z; -// } -// } -// else -// { -// var lineNWOb = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(nwo2.X, 0, nwo2.Z), EndPoint = new GeometryPoint(nwo3.X, 0, nwo3.Z) }; -// if (LineHelper.GetStrictIntersectionPoint(lineNWOb, linePL, ref isp)) -// { -// var newP1 = pl1Line.EnsurePointAtX(intersection2.X, GeometryPoint.Precision); -// newP1.Z = intersection2.Z; -// var newP2 = pl1Line.EnsurePointAtX(isp.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP2.Z = intersection2.Z; -// if (nwo2Pl != null) -// { -// var newP3 = pl1Line.EnsurePointAtX(nwo2Pl.X, GeometryPoint.Precision); -// newP3.Z = nwo2Pl.Z; -// if ((nwo1Pl != null) && (nwo2Pl.X > nwo1Pl.X)) -// { -// var newP4 = pl1Line.EnsurePointAtX(nwo1Pl.X, GeometryPoint.Precision); -// newP4.Z = nwo1Pl.Z; -// } -// } -// } -// else -// { -// throw new PlLinesCreatorException("Could not create the intersectionsection points between NWO and Phreatic line to create horizontal level."); -// } -// } -// } + GeometryPoint intersectPoint = new GeometryPoint(); + GeometryPoint intersectPoint2 = new GeometryPoint(); -// private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1(GeometryPoint nwo2, GeometryPoint nwo3, GeometryPoint nwo4, PlLine pl1Line, PlLinePoint nwo3Pl, PlLinePoint nwo4Pl, PlLinePoint intersection1) -// { -// var lineNWO = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(nwo3.X, 0, nwo3.Z), EndPoint = new GeometryPoint(nwo4.X, 0, nwo4.Z) }; -// var linePL = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(intersection1.X, 0, intersection1.Z), EndPoint = new GeometryPoint(nwo4.X, 0, intersection1.Z) }; -// var isp = new GeometryPoint(); -// if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) -// { -// var newP1 = pl1Line.EnsurePointAtX(intersection1.X, GeometryPoint.Precision); -// newP1.Z = intersection1.Z; -// var newP2 = pl1Line.EnsurePointAtX(isp.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP2.Z = intersection1.Z; -// if (nwo4Pl != null) -// { -// var newP3 = pl1Line.EnsurePointAtX(nwo4Pl.X, GeometryPoint.Precision); -// newP3.Z = nwo4Pl.Z; -// } -// } -// else -// { -// var lineNWOb = new Deltares.Geometry.Line { BeginPoint = new GeometryPoint(nwo2.X, 0, nwo2.Z), EndPoint = new GeometryPoint(nwo3.X, 0, nwo3.Z) }; -// if (LineHelper.GetStrictIntersectionPoint(lineNWOb, linePL, ref isp)) -// { -// var newP1 = pl1Line.EnsurePointAtX(intersection1.X, GeometryPoint.Precision); -// newP1.Z = intersection1.Z; -// var newP2 = pl1Line.EnsurePointAtX(isp.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); -// newP2.Z = intersection1.Z; -// if (nwo3Pl != null) -// { -// var newP3 = pl1Line.EnsurePointAtX(nwo3Pl.X, GeometryPoint.Precision); -// newP3.Z = nwo3Pl.Z; -// if ((nwo4Pl != null) && (nwo4Pl.X > nwo3Pl.X)) -// { -// var newP4 = pl1Line.EnsurePointAtX(nwo4Pl.X, GeometryPoint.Precision); -// newP4.Z = nwo4Pl.Z; -// } -// } -// } -// else -// { -// throw new PlLinesCreatorException("Could not create the intersectionsection points between NWO and Phreatic line to create horizontal level."); -// } -// } -// } + // For NWO point, determine whether a pl point has to be added + if (pl1Line.PositionXzOfPointRelatedToPlLine(nwo1) != PlLinePointPositionXzType.AbovePlLine) + { + nwo1Pl = new PlLinePoint(nwo1.X, nwo1.Z - cOffsetPhreaticLineBelowSurface); + } -// private void MoveSelectedPlLinePointsBelowSurfaceLine(IEnumerable plPointsToBeMoved) -// { -// foreach (var PlLinePoint in plPointsToBeMoved) -// { -// // Determine which of these points must be moved and move them -// if (this.surfaceLine.Geometry.PositionXzOfPointRelatedToExtrapolatedLine(PlLinePoint) != -// RelativeXzPosition.BelowGeometricLine) -// { -// PlLinePoint.Z = this.surfaceLine.Geometry.GetZatX(PlLinePoint.X) - cOffsetPhreaticLineBelowSurface; -// } -// } -// } + if (pl1Line.PositionXzOfPointRelatedToPlLine(nwo2) != PlLinePointPositionXzType.AbovePlLine) + { + nwo2Pl = new PlLinePoint(nwo2.X, nwo2.Z - cOffsetPhreaticLineBelowSurface); + } + if (pl1Line.PositionXzOfPointRelatedToPlLine(nwo3) != PlLinePointPositionXzType.AbovePlLine) + { + nwo3Pl = new PlLinePoint(nwo3.X, nwo3.Z - cOffsetPhreaticLineBelowSurface); + } + + if (pl1Line.PositionXzOfPointRelatedToPlLine(nwo4) != PlLinePointPositionXzType.AbovePlLine) + { + nwo4Pl = new PlLinePoint(nwo4.X, nwo4.Z - cOffsetPhreaticLineBelowSurface); + } + + // Find the intersections of pl line and NWO and handle these + // Intersection between nwo point1 and nwo point2 only when nwo point1 is above pl line and nwo point2 is below plLine + // PlLinePoint intersection1 = null; + bool intersection1 = false; + if ((nwo1Pl == null) && (nwo2Pl != null)) + { + const double maxDouble = 99999.999; + var phreaticPolderPartialLine = new Line(); + //#bka: hier niet langer ook starten met waterlevel als waterlevel onder bottomditch zit! + phreaticPolderPartialLine.SetBeginAndEndPoints(new Point2D(pl1Line.Points[0].X, waterLevelPolder), + new Point2D(maxDouble, waterLevelPolder)); + + var lineNwo = new Line(); + lineNwo.SetBeginAndEndPoints(new Point2D(nwo1.X, nwo1.Z), new Point2D(nwo2.X, nwo2.Z)); + + intersection1 = + LineHelper.GetStrictIntersectionPoint(phreaticPolderPartialLine, lineNwo, ref intersectPoint); + + } + + + + // Intersection between nwo point3 and nwo point4 only when nwo point3 is below pl line and nwo point4 is above plLine + // PlLinePoint intersection2 = null; + bool intersection2 = false; + if ((nwo3Pl != null) && (nwo4Pl == null)) + { + const double maxDouble = 99999.999; + var phreaticPolderPartialLine = new Line(); + //#bka: hier niet langer ook starten met waterlevel als waterlevel onder bottomditch zit! + phreaticPolderPartialLine.SetBeginAndEndPoints(new Point2D(pl1Line.Points[0].X, waterLevelPolder), + new Point2D(maxDouble, waterLevelPolder)); + + var lineNwo = new Line(); + lineNwo.SetBeginAndEndPoints(new Point2D(nwo3.X, nwo3.Z), new Point2D(nwo4.X, nwo4.Z)); + + intersection2 = + LineHelper.GetStrictIntersectionPoint(phreaticPolderPartialLine, lineNwo, ref intersectPoint2); + } + + + //// Handle making the NWO empty + //if ((NWOPhreaticAdaption != null) && (NWOPhreaticAdaption == PhreaticAdaptionType.MakeEmpty)) + //{ + // // for the polderside, the pl line is always allowed to be adapted. For the riverside, the pl line may only be adapted when the original waterlevel is runs through the nwo. + // RemoveAllWaterFromNonWaterRetainingObject(nwo1, pl1Line, nwo1Pl, nwo2Pl, nwo3Pl, nwo4Pl, + // intersectPoint, intersectPoint2, plPointsToBeMoved); + //} + + //// Handle making the waterlevel horizontal in the NWO at the Riverside when needed (Polderside is already done when needed, see CreatePhreaticLineSegmentsInShoulderAndPolder. + //if ((NWOPhreaticAdaption != null) && (NWOPhreaticAdaption == PhreaticAdaptionType.None)) + //{ + // if (nwo1Pl == null && nwo2Pl != null && nwo3Pl != null && nwo4Pl == null) + //{ + // For the riverside, the pl line may only be adapted when the original waterlevel is runs through the nwo and is not already level. + if ((nwo1.X <= this.surfaceLine.CharacteristicPoints + .GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).X) && + ((intersection1) || (intersection2))) + { + double requiredWaterLevel; + // Check whether adaption of intersection points is needed + if (!intersection2) + { + // only intersection 1 avaialable so add intersection 2 + // first see if nwo3/4 intersects, if not try nwo2/3. If still no intersection found valid level not possible, raise error + MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1(nwo2, nwo3, nwo4, pl1Line, + nwo3Pl, nwo4Pl, intersectPoint); + requiredWaterLevel = intersectPoint.Z; + } + else if (!intersection1) + { + // only intersection 2 avaialable so add intersection 1 + // first see if nwo1/2 intersects, if not try nwo2/3. If still no intersection found valid level not possible, raise error + MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2(nwo1, nwo2, nwo3, + pl1Line, nwo1Pl, nwo2Pl, nwo3Pl, intersectPoint2); + requiredWaterLevel = intersectPoint2.Z; + } + else + { + // intersection 1 and intersection 2 available. Only act when levels were different. + requiredWaterLevel = Math.Min(intersectPoint.Z, intersectPoint2.Z); + if ((Math.Abs(intersectPoint.Z - intersectPoint2.Z) > GeometryPoint.Precision)) + { + if (intersectPoint.Z < intersectPoint2.Z) + { + // make level in NWO intersection1.Z + MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1And2(nwo2, nwo3, + nwo4, pl1Line, nwo3Pl, intersectPoint, intersectPoint2); + } + else + { + // make level in NWO intersection2.Z + MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2And1(nwo1, nwo2, + nwo3, pl1Line, nwo2Pl, intersectPoint, intersectPoint2); + } + + } + } + + + // Move all the points in the pl line itself that need to be moved to the horizontal proper level. + foreach (var plLinePoint in plPointsToBeMoved) + { + plLinePoint.Z = requiredWaterLevel; + } + + pl1Line.DeleteCoinsidingPoints(GeometryPoint.Precision); + } + // } + // } + } + } + + + private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2And1(GeometryPoint nwo1, GeometryPoint nwo2, GeometryPoint nwo3, PlLine pl1Line, PlLinePoint nwo2Pl, GeometryPoint intersection1, GeometryPoint intersection2) + { + var lineNWO = new Line { BeginPoint = new Point2D(nwo1.X, nwo1.Z), EndPoint = new Point2D(nwo2.X, nwo2.Z) }; + var linePL = new Line { BeginPoint = new Point2D(nwo1.X, intersection2.Z), EndPoint = new Point2D(intersection2.X, intersection2.Z) }; + var isp = new GeometryPoint(); + if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) + { + var newP1 = pl1Line.EnsurePointAtX(intersection2.X, GeometryPoint.Precision); + newP1.Z = intersection2.Z; + var newP2 = pl1Line.EnsurePointAtX(isp.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP2.Z = intersection2.Z; + var newP3 = pl1Line.EnsurePointAtX(intersection1.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP3.Z = intersection1.Z; + } + else + { + var lineNWOb = new Line { BeginPoint = new Point2D(nwo2.X, nwo2.Z), EndPoint = new Point2D(nwo3.X, nwo3.Z) }; + if (LineHelper.GetStrictIntersectionPoint(lineNWOb, linePL, ref isp)) + { + var newP1 = pl1Line.EnsurePointAtX(intersection2.X, GeometryPoint.Precision); + newP1.Z = intersection2.Z; + var newP2 = pl1Line.EnsurePointAtX(isp.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP2.Z = intersection2.Z; + var newP3 = pl1Line.EnsurePointAtX(nwo2Pl.X, GeometryPoint.Precision); + newP3.Z = nwo2Pl.Z; + if (nwo2Pl.X > intersection1.X) + { + var newP4 = pl1Line.EnsurePointAtX(intersection1.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP4.Z = intersection1.Z; + } + } + else + { + throw new PlLinesCreatorException("Could not create the intersectionsection points between NWO and Phreatic line to create horizontal level."); + } + } + } + + private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1And2(GeometryPoint nwo2, GeometryPoint nwo3, GeometryPoint nwo4, PlLine pl1Line, PlLinePoint nwo3Pl, GeometryPoint intersection1, GeometryPoint intersection2) + { + var lineNWO = new Line{ BeginPoint = new Point2D(nwo3.X,nwo3.Z), EndPoint = new Point2D(nwo4.X, nwo4.Z) }; + var linePL = new Line { BeginPoint = new Point2D(intersection1.X, intersection1.Z), EndPoint = new Point2D(nwo4.X, intersection1.Z) }; + var isp = new GeometryPoint(); + if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) + { + var newP1 = pl1Line.EnsurePointAtX(intersection1.X, GeometryPoint.Precision); + newP1.Z = intersection1.Z; + var newP2 = pl1Line.EnsurePointAtX(isp.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP2.Z = intersection1.Z; + var newP3 = pl1Line.EnsurePointAtX(intersection2.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP3.Z = intersection2.Z; + } + else + { + var lineNWOb = new Line{ BeginPoint = new Point2D(nwo2.X, nwo2.Z), EndPoint = new Point2D(nwo3.X, nwo3.Z) }; + if (LineHelper.GetStrictIntersectionPoint(lineNWOb, linePL, ref isp)) + { + var newP1 = pl1Line.EnsurePointAtX(intersection1.X, GeometryPoint.Precision); + newP1.Z = intersection1.Z; + var newP2 = pl1Line.EnsurePointAtX(isp.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP2.Z = intersection1.Z; + var newP3 = pl1Line.EnsurePointAtX(nwo3Pl.X, GeometryPoint.Precision); + newP3.Z = nwo3Pl.Z; + if (nwo3Pl.X < intersection2.X) + { + var newP4 = pl1Line.EnsurePointAtX(intersection2.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP4.Z = intersection2.Z; + } + } + else + { + throw new PlLinesCreatorException("Could not create the intersectionsection points between NWO and Phreatic line to create horizontal level."); + } + } + } + + private void RemoveAllWaterFromNonWaterRetainingObject(GeometryPoint nwo1, PlLine pl1Line, PlLinePoint nwo1Pl, PlLinePoint nwo2Pl, PlLinePoint nwo3Pl, PlLinePoint nwo4Pl, PlLinePoint intersection1, PlLinePoint intersection2, IEnumerable plPointsToBeMoved) + { + if ((nwo1.X >= this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder).X) || + ((intersection1 != null) && (intersection2 != null))) + { + // Move all the points in the pl line itself that need to be moved to below the surfaceline. + MoveSelectedPLLinePointsBelowSurfaceLine(plPointsToBeMoved); + + // now add all extra points to the pl line + if (nwo1Pl != null) + { + var newP = pl1Line.EnsurePointAtX(nwo1Pl.X, GeometryPoint.Precision); + newP.Z = nwo1Pl.Z; + } + if (nwo2Pl != null) + { + var newP = pl1Line.EnsurePointAtX(nwo2Pl.X, GeometryPoint.Precision); + newP.Z = nwo2Pl.Z; + } + if (nwo3Pl != null) + { + var newP = pl1Line.EnsurePointAtX(nwo3Pl.X, GeometryPoint.Precision); + newP.Z = nwo3Pl.Z; + } + if (nwo4Pl != null) + { + var newP = pl1Line.EnsurePointAtX(nwo4Pl.X, GeometryPoint.Precision); + newP.Z = nwo4Pl.Z; + } + // Note: for intersection points, apply offset in X direction not in Z. + if (intersection1 != null) + { + var newP = pl1Line.EnsurePointAtX(intersection1.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP.Z = intersection1.Z; + } + if (intersection2 != null) + { + var newP = pl1Line.EnsurePointAtX(intersection2.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP.Z = intersection2.Z; + } + pl1Line.DeleteCoinsidingPoints(GeometryPoint.Precision); + } + } + + private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2(GeometryPoint nwo1, GeometryPoint nwo2, GeometryPoint nwo3, PlLine pl1Line, PlLinePoint nwo1Pl, PlLinePoint nwo2Pl, PlLinePoint nwo3Pl, GeometryPoint intersection2) + { + var lineNWO = new Line { BeginPoint = new Point2D(nwo1.X, nwo1.Z), EndPoint = new Point2D(nwo2.X, nwo2.Z) }; + var linePL = new Line { BeginPoint = new Point2D(nwo1.X, intersection2.Z), EndPoint = new Point2D(intersection2.X,intersection2.Z) }; + var isp = new GeometryPoint(); + if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) + { + var newP1 = pl1Line.EnsurePointAtX(intersection2.X, GeometryPoint.Precision); + newP1.Z = intersection2.Z; + var newP2 = pl1Line.EnsurePointAtX(isp.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP2.Z = intersection2.Z; + if (nwo1Pl != null) + { + var newP3 = pl1Line.EnsurePointAtX(nwo1Pl.X, GeometryPoint.Precision); + newP3.Z = nwo1Pl.Z; + } + } + else + { + var lineNWOb = new Line { BeginPoint = new Point2D(nwo2.X, nwo2.Z), EndPoint = new Point2D(nwo3.X, nwo3.Z) }; + if (LineHelper.GetStrictIntersectionPoint(lineNWOb, linePL, ref isp)) + { + var newP1 = pl1Line.EnsurePointAtX(intersection2.X, GeometryPoint.Precision); + newP1.Z = intersection2.Z; + var newP2 = pl1Line.EnsurePointAtX(isp.X - cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP2.Z = intersection2.Z; + if (nwo2Pl != null) + { + var newP3 = pl1Line.EnsurePointAtX(nwo2Pl.X, GeometryPoint.Precision); + newP3.Z = nwo2Pl.Z; + if ((nwo1Pl != null) && (nwo2Pl.X > nwo1Pl.X)) + { + var newP4 = pl1Line.EnsurePointAtX(nwo1Pl.X, GeometryPoint.Precision); + newP4.Z = nwo1Pl.Z; + } + } + } + else + { + throw new PlLinesCreatorException("Could not create the intersectionsection points between NWO and Phreatic line to create horizontal level."); + } + } + } + + private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1(GeometryPoint nwo2, GeometryPoint nwo3, GeometryPoint nwo4, PlLine pl1Line, PlLinePoint nwo3Pl, PlLinePoint nwo4Pl, GeometryPoint intersection1) + { + var lineNWO = new Line { BeginPoint = new Point2D(nwo3.X, nwo3.Z), EndPoint = new Point2D(nwo4.X, nwo4.Z) }; + var linePL = new Line { BeginPoint = new Point2D(intersection1.X,intersection1.Z), EndPoint = new Point2D(nwo4.X, intersection1.Z) }; + var isp = new GeometryPoint(); + if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) + { + var newP1 = pl1Line.EnsurePointAtX(intersection1.X, GeometryPoint.Precision); + newP1.Z = intersection1.Z; + var newP2 = pl1Line.EnsurePointAtX(isp.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP2.Z = intersection1.Z; + if (nwo4Pl != null) + { + var newP3 = pl1Line.EnsurePointAtX(nwo4Pl.X, GeometryPoint.Precision); + newP3.Z = nwo4Pl.Z; + } + } + else + { + var lineNWOb = new Line { BeginPoint = new Point2D(nwo2.X, nwo2.Z), EndPoint = new Point2D(nwo3.X, nwo3.Z) }; + if (LineHelper.GetStrictIntersectionPoint(lineNWOb, linePL, ref isp)) + { + var newP1 = pl1Line.EnsurePointAtX(intersection1.X, GeometryPoint.Precision); + newP1.Z = intersection1.Z; + var newP2 = pl1Line.EnsurePointAtX(isp.X + cOffsetPhreaticLineBelowSurface, GeometryPoint.Precision); + newP2.Z = intersection1.Z; + if (nwo3Pl != null) + { + var newP3 = pl1Line.EnsurePointAtX(nwo3Pl.X, GeometryPoint.Precision); + newP3.Z = nwo3Pl.Z; + if ((nwo4Pl != null) && (nwo4Pl.X > nwo3Pl.X)) + { + var newP4 = pl1Line.EnsurePointAtX(nwo4Pl.X, GeometryPoint.Precision); + newP4.Z = nwo4Pl.Z; + } + } + } + else + { + throw new PlLinesCreatorException("Could not create the intersectionsection points between NWO and Phreatic line to create horizontal level."); + } + } + } + + private void MoveSelectedPLLinePointsBelowSurfaceLine(IEnumerable plPointsToBeMoved) + { + foreach (var plLinePoint in plPointsToBeMoved) + { + // Determine which of these points must be moved and move them + if (this.surfaceLine.Geometry.GetZatX(plLinePoint.X) - cOffsetPhreaticLineBelowSurface > plLinePoint.Z ) + //.PositionXzOfPointRelatedToExtrapolatedLine(plLinePoint) != + // RelativeXzPosition.BelowGeometricLine) + { + plLinePoint.Z = this.surfaceLine.Geometry.GetZatX(plLinePoint.X) - cOffsetPhreaticLineBelowSurface; + } + } + } + /// /// /// @@ -1353,9 +1431,11 @@ switch (modelParametersForPlLines.PlLineCreationMethod) { case PlLineCreationMethod.ExpertKnowledgeLinearInDike: - case PlLineCreationMethod.ExpertKnowledgeRRD: plLines = CreateAllPlLinesWithExpertKnowledge(location); + case PlLineCreationMethod.ExpertKnowledgeRRD: + plLines = CreateAllPlLinesWithExpertKnowledge(location); break; - case PlLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD: plLines = CreateAllPlLinesWithGaugesWithFallbackToExpertKnowledgeRrd(location); + case PlLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD: + plLines = CreateAllPlLinesWithGaugesWithFallbackToExpertKnowledgeRrd(location); break; } @@ -1581,7 +1661,7 @@ { //if (!surfaceLine.IsNonWaterRetainingObjectPoint(point)) //{ - phreaticLine.Points.Add(new PlLinePoint(point.X, point.Z - cPlLineOffsetBelowSurface)); + phreaticLine.Points.Add(new PlLinePoint(point.X, point.Z - cPlLineOffsetBelowSurface)); //} } @@ -1615,7 +1695,7 @@ { if (UsePlLineOffsetBelowDikeCrestMiddle.HasValue && UsePlLineOffsetBelowDikeCrestMiddle.Value && PlLineOffsetBelowDikeCrestMiddle != null) { - var middleDikeCrestX = (pointDikeTopAtRiver.X + pointDikeTopAtPolder.X)*0.5; + var middleDikeCrestX = (pointDikeTopAtRiver.X + pointDikeTopAtPolder.X) * 0.5; var middleDikeCrestZ = waterLevelRiverHigh - PlLineOffsetBelowDikeCrestMiddle.Value; // Check whether middleDikeCrestZ is above the surface line. If so, than use the value at the surfaceline instead. var allZ = surfaceLine.Geometry.GetAllZatXForLine(middleDikeCrestX); @@ -1734,7 +1814,7 @@ } var isDitchPresent = (ditchDikeSidePoint != null); - + // if there is a ditch, then adjust it. if (isDitchPresent) { @@ -1752,7 +1832,7 @@ if (phreaticLine.Points[phreaticLine.Points.Count - 1].Z > WaterLevelPolder) { AddPhreaticLineAlongSurfaceLevel(phreaticLine); - } + } } //Validate if endpoint surface has reached @@ -1801,7 +1881,7 @@ const double maxDouble = 99999.999; var phreaticPolderPartialLine = new Line(); //#bka: hier niet langer ook starten met waterlevel als waterlevel onder bottomditch zit! - phreaticPolderPartialLine.SetBeginAndEndPoints(new Point2D(phreaticLine.Points[0].X, waterLevelPolder), + phreaticPolderPartialLine.SetBeginAndEndPoints(new Point2D(phreaticLine.Points[0].X, waterLevelPolder), new Point2D(maxDouble, waterLevelPolder)); AddIntersectionDitchDikeSegmentPolderLevelToPhreatic(phreaticLine, surfacePointIndex, phreaticPolderPartialLine); AddIntersectionDitchPolderSegmentPolderLevelToPhreatic(phreaticLine, phreaticPolderPartialLine); @@ -1823,7 +1903,7 @@ var lineDitchPolderSide = new Line(); if (indexatDitchPolder > 1) { - lineDitchPolderSide.SetBeginAndEndPoints(new Point2D(surfaceLine.Geometry.Points[indexatDitchPolder - 1].X, surfaceLine.Geometry.Points[indexatDitchPolder - 1].Z), + lineDitchPolderSide.SetBeginAndEndPoints(new Point2D(surfaceLine.Geometry.Points[indexatDitchPolder - 1].X, surfaceLine.Geometry.Points[indexatDitchPolder - 1].Z), new Point2D(surfaceLine.Geometry.Points[indexatDitchPolder].X, surfaceLine.Geometry.Points[indexatDitchPolder].Z)); GeometryPoint intersectDitchPolderPhreatic = new GeometryPoint(); @@ -1851,11 +1931,11 @@ /// /// private void AddIntersectionDitchDikeSegmentPolderLevelToPhreatic(PlLine phreaticLine, int surfacePointIndex, Line phreaticPolderPartialLine) - { + {///// if (surfacePointIndex + 1 < surfaceLine.Geometry.Points.Count) { var lineDitchDikeSide = new Line(); - lineDitchDikeSide.SetBeginAndEndPoints(new Point2D(surfaceLine.Geometry.Points[surfacePointIndex].X, surfaceLine.Geometry.Points[surfacePointIndex].Z), + lineDitchDikeSide.SetBeginAndEndPoints(new Point2D(surfaceLine.Geometry.Points[surfacePointIndex].X, surfaceLine.Geometry.Points[surfacePointIndex].Z), new Point2D(surfaceLine.Geometry.Points[surfacePointIndex + 1].X, surfaceLine.Geometry.Points[surfacePointIndex + 1].Z)); GeometryPoint intersectDitchDikePhreatic = new GeometryPoint(); @@ -1899,7 +1979,7 @@ var polderlevelLine = new Line(); double startXCoordinate = this.surfaceLine.Geometry.Points.OrderBy(p => p.X).First().X; GeometryPoint pointEndOfprofile = SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.SurfaceLevelInside); - polderlevelLine.SetBeginAndEndPoints(new Point2D(startXCoordinate, polderLevel), + polderlevelLine.SetBeginAndEndPoints(new Point2D(startXCoordinate, polderLevel), new Point2D(pointEndOfprofile.X, polderLevel)); ThrowWhenWaterLevelAboveDike(polderLevel, SurfaceLine); @@ -1911,7 +1991,7 @@ for (int surfacePointIndex = startPosition; surfacePointIndex < endPosition; surfacePointIndex++) { var surfaceLineSegment = new Line(); - surfaceLineSegment.SetBeginAndEndPoints(new Point2D(SurfaceLine.Geometry.Points[surfacePointIndex].X, SurfaceLine.Geometry.Points[surfacePointIndex].Z), + surfaceLineSegment.SetBeginAndEndPoints(new Point2D(SurfaceLine.Geometry.Points[surfacePointIndex].X, SurfaceLine.Geometry.Points[surfacePointIndex].Z), new Point2D(SurfaceLine.Geometry.Points[surfacePointIndex + 1].X, SurfaceLine.Geometry.Points[surfacePointIndex + 1].Z)); GeometryPoint intersectPoint = new GeometryPoint(); if (LineHelper.GetStrictIntersectionPoint(surfaceLineSegment, polderlevelLine, ref intersectPoint)) @@ -2065,7 +2145,7 @@ { CreatePhreaticLineSegmentsInsideDikeForHighRiverLevel(phreaticLine); } - CreatePhreaticLineSegmentsInShoulderAndPolder(phreaticLine); + CreatePhreaticLineSegmentsInShoulderAndPolder(phreaticLine); //Check if phreatic line is above ValidatePhreaticAboveWaterLevelPolder(phreaticLine); Index: DamEngine/branches/nwo_18.1/release/Deltares.DamEngine.Interface.pdb =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/release/Deltares.DamEngine.Data.pdb =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/release/nl-NL/Deltares.DamEngine.Calculators.resources.dll =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/release/Deltares.DamEngine.Data.dll =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/release/Deltares.DamEngine.Interface.dll =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/release/Deltares.DamEngine.Io.pdb =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2Extensions.cs =================================================================== diff -u -r1848 -r1850 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2Extensions.cs (.../SurfaceLine2Extensions.cs) (revision 1848) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2Extensions.cs (.../SurfaceLine2Extensions.cs) (revision 1850) @@ -352,6 +352,19 @@ } /// + /// Checks if a surfaceline has all characteristic point types required to describe + /// a ditch. + /// + /// Surfaceline to be checked. + /// True if there are characteristic points defined that described the + /// Nwo; False otherwise. + public static bool HasNwo(this SurfaceLine2 line) + { + return IsDefined(line, CharacteristicPointType.NonWaterRetainingObjectPoint1) && + IsDefined(line, CharacteristicPointType.NonWaterRetainingObjectPoint4); + } + + /// /// Determines whether ditch is correct. /// /// true if ditch is correct, otherwise false Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/Geotechnics/CharacteristicPointType.cs =================================================================== diff -u -r1848 -r1850 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/Geotechnics/CharacteristicPointType.cs (.../CharacteristicPointType.cs) (revision 1848) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/Geotechnics/CharacteristicPointType.cs (.../CharacteristicPointType.cs) (revision 1850) @@ -113,6 +113,26 @@ DitchPolderSide = 19, // Insteek sloot polderzijde /// + /// The Non Water Retaining Object Point 1 + /// + NonWaterRetainingObjectPoint1 = 20, + + /// + /// The Non Water Retaining Object Point 2 + /// + NonWaterRetainingObjectPoint2 = 21, + + /// + /// The Non Water Retaining Object Point 3 + /// + NonWaterRetainingObjectPoint3 = 23, + + /// + /// The Non Water Retaining Object Point 4 + /// + NonWaterRetainingObjectPoint4 = 24, + + /// /// The surface level inside /// SurfaceLevelInside = 25, // Maaiveld binnenwaarts Index: DamEngine/branches/nwo_18.1/release/Deltares.DamEngine.Calculators.pdb =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Interface/ConversionHelper.cs =================================================================== diff -u -r1848 -r1850 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Interface/ConversionHelper.cs (.../ConversionHelper.cs) (revision 1848) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Interface/ConversionHelper.cs (.../ConversionHelper.cs) (revision 1850) @@ -207,6 +207,12 @@ public const int CpBottomDitchDikeSide = 17; // Slootbodem dijkzijde public const int CpBottomDitchPolderSide = 18; // Slootbodem polderzijde public const int CpDitchPolderSide = 19; // Insteek sloot polderzijde + + public const int CpNonWaterRetainingObjectPoint1 = 20; + public const int CpNonWaterRetainingObjectPoint2 = 21; + public const int CpNonWaterRetainingObjectPoint3 = 23; + public const int CpNonWaterRetainingObjectPoint4 = 24; + public const int CpSurfaceLevelInside = 25; // Maaiveld binnenwaarts /// @@ -235,6 +241,12 @@ {CpBottomDitchDikeSide, CharacteristicPointType.BottomDitchDikeSide}, {CpBottomDitchPolderSide, CharacteristicPointType.BottomDitchPolderSide}, {CpDitchPolderSide, CharacteristicPointType.DitchPolderSide}, + + {CpNonWaterRetainingObjectPoint1,CharacteristicPointType.NonWaterRetainingObjectPoint1}, + {CpNonWaterRetainingObjectPoint2,CharacteristicPointType.NonWaterRetainingObjectPoint2}, + {CpNonWaterRetainingObjectPoint3,CharacteristicPointType.NonWaterRetainingObjectPoint3}, + {CpNonWaterRetainingObjectPoint4,CharacteristicPointType.NonWaterRetainingObjectPoint4}, + {CpSurfaceLevelInside, CharacteristicPointType.SurfaceLevelInside} }; return translationTable[inputPointType]; @@ -266,6 +278,12 @@ {CharacteristicPointType.BottomDitchDikeSide, CpBottomDitchDikeSide}, {CharacteristicPointType.BottomDitchPolderSide, CpBottomDitchPolderSide}, {CharacteristicPointType.DitchPolderSide, CpDitchPolderSide}, + + {CharacteristicPointType.NonWaterRetainingObjectPoint1, CpNonWaterRetainingObjectPoint1}, + {CharacteristicPointType.NonWaterRetainingObjectPoint2, CpNonWaterRetainingObjectPoint2}, + {CharacteristicPointType.NonWaterRetainingObjectPoint3, CpNonWaterRetainingObjectPoint3}, + {CharacteristicPointType.NonWaterRetainingObjectPoint4, CpNonWaterRetainingObjectPoint4}, + {CharacteristicPointType.SurfaceLevelInside, CpSurfaceLevelInside} }; return translationTable[characteristicPointType]; Index: DamEngine/branches/nwo_18.1/release/nl-NL/Deltares.DamEngine.Data.resources.dll =================================================================== diff -u -r1848 -r1850 Binary files differ Index: DamEngine/branches/nwo_18.1/release/Deltares.DamEngine.Io.dll =================================================================== diff -u -r1848 -r1850 Binary files differ