public void PointInPolygon_InnerRingsNull_ThrowsArgumentNullException() { // Call void Call() => AdvancedMath2D.PointInPolygon(new Point2D(0, 0), Enumerable.Empty <Point2D>(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("innerRings", exception.ParamName); }
public void PointInPolygon_PointNull_ThrowsArgumentNullException() { // Call void Call() => AdvancedMath2D.PointInPolygon(null, Enumerable.Empty <Point2D>(), Enumerable.Empty <IEnumerable <Point2D> >()); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("point", exception.ParamName); }
public void PointInPolygon_PointOutsidePolygon_ReturnsFalse(IEnumerable <Point2D> outerRing, IEnumerable <IEnumerable <Point2D> > innerRings) { // Setup var point = new Point2D(-1, -1); // Call bool pointInPolygon = AdvancedMath2D.PointInPolygon(point, outerRing, innerRings); // Assert Assert.IsFalse(pointInPolygon); }
public void PointInPolygon_PointInHole_ReturnsFalse() { // Setup Point2D[] outerRing = CreateCustomPolygon(); Point2D[][] innerRings = CreateInnerRings(); var point = new Point2D(2, 3); // Call bool pointInPolygon = AdvancedMath2D.PointInPolygon(point, outerRing, innerRings); // Assert Assert.IsFalse(pointInPolygon); }
/// <summary> /// Gets the <see cref="MacroStabilityInwardsSoilLayer2D"/> the <paramref name="preconsolidationStress"/> is placed on. /// </summary> /// <param name="layers">The layers of the profile.</param> /// <param name="preconsolidationStress">The <see cref="IMacroStabilityInwardsPreconsolidationStress"/> to get the layer for.</param> /// <returns>The <see cref="MacroStabilityInwardsSoilLayer2D"/> the <paramref name="preconsolidationStress"/> is placed on; /// or <c>null</c> when no layer can be found.</returns> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> public static MacroStabilityInwardsSoilLayer2D GetLayerForPreconsolidationStress( IEnumerable <MacroStabilityInwardsSoilLayer2D> layers, IMacroStabilityInwardsPreconsolidationStress preconsolidationStress) { if (layers == null) { throw new ArgumentNullException(nameof(layers)); } if (preconsolidationStress == null) { throw new ArgumentNullException(nameof(preconsolidationStress)); } return(layers.SingleOrDefault(l => AdvancedMath2D.PointInPolygon( preconsolidationStress.Location, l.OuterRing.Points, l.NestedLayers.Select(nl => nl.OuterRing.Points)))); }
private static void AssertYieldStressStatePoints(IEnumerable <MacroStabilityInwardsSoilLayer2D> layers, IEnumerable <IMacroStabilityInwardsPreconsolidationStress> preconsolidationStresses, IEnumerable <PersistableStatePoint> yieldStressStatePoints) { Assert.AreEqual(preconsolidationStresses.Count(), yieldStressStatePoints.Count()); for (var j = 0; j < preconsolidationStresses.Count(); j++) { IMacroStabilityInwardsPreconsolidationStress preconsolidationStress = preconsolidationStresses.ElementAt(j); MacroStabilityInwardsSoilLayer2D layerWithPreconsolidationStress = layers.Single(l => AdvancedMath2D.PointInPolygon( preconsolidationStress.Location, l.OuterRing.Points, l.NestedLayers.Select(nl => nl.OuterRing.Points))); PersistableStatePoint yieldStressStatePoint = yieldStressStatePoints.ElementAt(j); Assert.IsNotNull(yieldStressStatePoint.Id); Assert.AreEqual($"Grensspanning - {layerWithPreconsolidationStress.Data.MaterialName}", yieldStressStatePoint.Label); Assert.IsNotNull(yieldStressStatePoint.LayerId); Assert.IsFalse(yieldStressStatePoint.IsProbabilistic); Assert.AreEqual(preconsolidationStress.Location.X, yieldStressStatePoint.Point.X); Assert.AreEqual(preconsolidationStress.Location.Y, yieldStressStatePoint.Point.Z); Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPreconsolidationStress(preconsolidationStress).GetDesignValue(), yieldStressStatePoint.Stress.YieldStress); } }