private static bool DoesSoilModelGeometryIntersectWithSurfaceLineGeometry(PipingStochasticSoilModel stochasticSoilModel, Segment2D[] surfaceLineSegments) { IEnumerable <Segment2D> soilProfileGeometrySegments = Math2D.ConvertPointsToLineSegments(stochasticSoilModel.Geometry); return(soilProfileGeometrySegments.Any(s => DoesSegmentIntersectWithSegmentArray(s, surfaceLineSegments))); }
/// <summary> /// Indicates whether a stochastic soil model intersects with a surface line. /// </summary> /// <param name="stochasticSoilModel">The stochastic soil model used to match a surface line.</param> /// <param name="surfaceLine">The surface line used to match a stochastic soil model.</param> /// <returns><c>true</c> when the <paramref name="stochasticSoilModel"/> intersects with the <paramref name="surfaceLine"/>; /// <c>false</c> otherwise.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> public static bool IntersectsWithSurfaceLineGeometry(this PipingStochasticSoilModel stochasticSoilModel, PipingSurfaceLine surfaceLine) { if (stochasticSoilModel == null) { throw new ArgumentNullException(nameof(stochasticSoilModel)); } if (surfaceLine == null) { throw new ArgumentNullException(nameof(surfaceLine)); } Segment2D[] surfaceLineSegments = Math2D.ConvertPointsToLineSegments(GetSurfaceLine2DGeometry(surfaceLine)).ToArray(); return(DoesSoilModelGeometryIntersectWithSurfaceLineGeometry(stochasticSoilModel, surfaceLineSegments)); }
/// <summary> /// Updates the <see cref="PipingStochasticSoilModel"/> with the properties from <paramref name="fromModel"/>. /// </summary> /// <param name="fromModel">The <see cref="PipingStochasticSoilModel"/> to /// obtain the property values from.</param> /// <returns>The differences summed up in an instance of <see cref="PipingStochasticSoilModelProfileDifference"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="fromModel"/> /// is <c>null</c>.</exception> /// <exception cref="InvalidOperationException">Thrown when <see cref="StochasticSoilProfiles"/> /// contains multiple profiles with the same name, and <paramref name="fromModel"/> also contains a /// profile with the same name. /// </exception> public PipingStochasticSoilModelProfileDifference Update(PipingStochasticSoilModel fromModel) { if (fromModel == null) { throw new ArgumentNullException(nameof(fromModel)); } Name = fromModel.Name; Geometry = fromModel.Geometry; var newSoilProfiles = new List <PipingSoilProfile>(); var updatedProfiles = new List <PipingStochasticSoilProfile>(); var addedProfiles = new List <PipingStochasticSoilProfile>(); var removedProfiles = new List <PipingStochasticSoilProfile>(); foreach (PipingStochasticSoilProfile fromProfile in fromModel.StochasticSoilProfiles) { PipingStochasticSoilProfile sameProfile = StochasticSoilProfiles.SingleOrDefault( sp => IsSame(sp, fromProfile) ); if (sameProfile != null) { if (!sameProfile.Equals(fromProfile)) { sameProfile.Update(fromProfile); updatedProfiles.Add(sameProfile); } } else { stochasticSoilProfiles.Add(fromProfile); addedProfiles.Add(fromProfile); } newSoilProfiles.Add(fromProfile.SoilProfile); } PipingStochasticSoilProfile[] remainingProfiles = StochasticSoilProfiles.Where( sp => !newSoilProfiles.Any(newSp => IsSame(newSp, sp.SoilProfile))).ToArray(); foreach (PipingStochasticSoilProfile profileToRemove in remainingProfiles) { stochasticSoilProfiles.Remove(profileToRemove); removedProfiles.Add(profileToRemove); } return(new PipingStochasticSoilModelProfileDifference(addedProfiles, updatedProfiles, removedProfiles)); }