Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2.cs
===================================================================
diff -u -r3893 -r4000
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2.cs (.../SurfaceLine2.cs) (revision 3893)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2.cs (.../SurfaceLine2.cs) (revision 4000)
@@ -46,25 +46,14 @@
{
geometry = new GeometryPointString();
characteristicPoints = new CharacteristicPointSet
- {
- GeometryMustContainPoint = true
- };
+ {
+ GeometryMustContainPoint = true
+ };
LandwardDirection = LandwardDirection.PositiveX;
Name = LocalizationManager.GetTranslatedText(this, "DefaultNameSurfaceLine2");
}
///
- /// Deep clone the object.
- ///
- ///
- public SurfaceLine2 FullDeepClone()
- {
- SurfaceLine2 surfaceLine2 = new SurfaceLine2();
- surfaceLine2.SetValuesFromOtherSurfaceLine(this, true);
- return surfaceLine2;
- }
-
- ///
/// The geometrical description of the surface line.
///
/// Aggregation relationship.
@@ -104,6 +93,17 @@
public LandwardDirection LandwardDirection { get; set; }
///
+ /// Deep clone the object.
+ ///
+ ///
+ public SurfaceLine2 FullDeepClone()
+ {
+ var surfaceLine2 = new SurfaceLine2();
+ surfaceLine2.SetValuesFromOtherSurfaceLine(this, true);
+ return surfaceLine2;
+ }
+
+ ///
/// Define a new characteristic point on the surface line with the given characteristic
/// point annotation.
///
@@ -114,21 +114,20 @@
if (annotations == null || annotations.Length == 0)
{
CharacteristicPoints.Add(new CharacteristicPoint
- {
- GeometryPoint = geometryPoint,
- CharacteristicPointType = CharacteristicPointType.None
- });
+ {
+ GeometryPoint = geometryPoint,
+ CharacteristicPointType = CharacteristicPointType.None
+ });
}
else
{
- foreach (var type in annotations)
+ foreach (CharacteristicPointType type in annotations)
{
-
CharacteristicPoints.Add(new CharacteristicPoint
- {
- GeometryPoint = geometryPoint,
- CharacteristicPointType = type
- });
+ {
+ GeometryPoint = geometryPoint,
+ CharacteristicPointType = type
+ });
}
}
}
@@ -142,8 +141,8 @@
/// The annotations for geometryPoint with x, z/>.
public void AddCharacteristicPoint(double x, double z, params CharacteristicPointType[] annotations)
{
- GeometryPoint geometryPoint = new GeometryPoint(x, z);
- AddCharacteristicPoint(geometryPoint, annotations);
+ var geometryPoint = new GeometryPoint(x, z);
+ AddCharacteristicPoint(geometryPoint, annotations);
}
///
@@ -166,39 +165,6 @@
}
///
- /// Gets the points orderd by x.
- ///
- ///
- /// The points orderd by x.
- ///
- private IEnumerable PointsOrderedByX
- {
- get
- {
- return Geometry.Points.OrderBy(p => p.X);
- }
- }
-
- ///
- /// Tests if the given point is between the given start X and end X.
- ///
- /// The point.
- /// The start x.
- /// The end x.
- /// true if the given point is between the given start X and end X, otherwise false
- private bool TestIncluding(GeometryPoint point, double startX, double endX)
- {
- if (point == null)
- {
- return false;
- }
-
- double x = point.X;
- return (x >= startX || x.AlmostEquals(startX, GeometryPoint.Precision))
- && (x <= endX || x.AlmostEquals(endX, GeometryPoint.Precision));
- }
-
- ///
/// Gets the point segment including given start x and end x.
///
/// The start x.
@@ -214,7 +180,7 @@
return from point in PointsOrderedByX
where TestIncluding(point, startX, endX)
- orderby point.X ascending
+ orderby point.X
select point;
}
@@ -229,6 +195,15 @@
}
///
+ /// Copy all characteristic point related data from another .
+ ///
+ /// Data source
+ public void Assign(SurfaceLine2 source)
+ {
+ SetValuesFromOtherSurfaceLine(source);
+ }
+
+ ///
/// Returns a that represents this instance.
///
///
@@ -249,19 +224,44 @@
{
return CharacteristicPoints.Geometry.GetGeometryBounds();
}
+
return null;
}
///
- /// Copy all characteristic point related data from another .
+ /// Gets the points orderd by x.
///
- /// Data source
- public void Assign(SurfaceLine2 source)
+ ///
+ /// The points orderd by x.
+ ///
+ private IEnumerable PointsOrderedByX
{
- SetValuesFromOtherSurfaceLine(source);
+ get
+ {
+ return Geometry.Points.OrderBy(p => p.X);
+ }
}
///
+ /// Tests if the given point is between the given start X and end X.
+ ///
+ /// The point.
+ /// The start x.
+ /// The end x.
+ /// true if the given point is between the given start X and end X, otherwise false
+ private bool TestIncluding(GeometryPoint point, double startX, double endX)
+ {
+ if (point == null)
+ {
+ return false;
+ }
+
+ double x = point.X;
+ return (x >= startX || x.AlmostEquals(startX, GeometryPoint.Precision))
+ && (x <= endX || x.AlmostEquals(endX, GeometryPoint.Precision));
+ }
+
+ ///
/// Sets the values from another surface line.
///
/// The source.
@@ -278,17 +278,17 @@
CharacteristicPoints.GeometryMustContainPoint = source.CharacteristicPoints.GeometryMustContainPoint;
Geometry = cloneGeometry ? source.Geometry.Clone() : source.Geometry;
- var geometryAnnotations = GetCharacteristicAnnotationsInSource(source, cloneGeometry);
+ Dictionary geometryAnnotations = GetCharacteristicAnnotationsInSource(source, cloneGeometry);
// Reconstruct annotation state from dictionary:
if (CharacteristicPoints.GeometryMustContainPoint)
{
- foreach (var annotation in geometryAnnotations)
+ foreach (KeyValuePair annotation in geometryAnnotations)
{
- for (int i = 0; i < annotation.Value.Length; i++)
+ for (var i = 0; i < annotation.Value.Length; i++)
{
- var index = -1;
- for (int j = 0; j < CharacteristicPoints.Count; j++)
+ int index = -1;
+ for (var j = 0; j < CharacteristicPoints.Count; j++)
{
if (ReferenceEquals(CharacteristicPoints[j].GeometryPoint, annotation.Key))
{
@@ -315,9 +315,9 @@
}
else
{
- foreach (var annotation in geometryAnnotations)
+ foreach (KeyValuePair annotation in geometryAnnotations)
{
- AddCharacteristicPoint((GeometryPoint)annotation.Key.Clone(), annotation.Value);
+ AddCharacteristicPoint((GeometryPoint) annotation.Key.Clone(), annotation.Value);
}
}
}
@@ -353,14 +353,15 @@
private Dictionary GetCharacteristicAnnotationsInSource_GeometryMustContainPoints(SurfaceLine2 source, bool cloneGeometry)
{
var geometryAnnotations = new Dictionary();
- for (int i = 0; i < source.Geometry.Count; i++)
+ for (var i = 0; i < source.Geometry.Count; i++)
{
- var annotationsForPoint = source.GetCharacteristicPoints(source.Geometry.Points[i]).Where(cpt => cpt != CharacteristicPointType.None).ToArray();
+ CharacteristicPointType[] annotationsForPoint = source.GetCharacteristicPoints(source.Geometry.Points[i]).Where(cpt => cpt != CharacteristicPointType.None).ToArray();
if (annotationsForPoint.Length > 0)
{
geometryAnnotations[Geometry.Points[i]] = annotationsForPoint;
}
}
+
return geometryAnnotations;
}
@@ -374,16 +375,16 @@
private static Dictionary GetCharacteristicAnnotationsInSource_GeometryMustNotContainPoints(SurfaceLine2 source)
{
var geometryAnnotations = new Dictionary();
- foreach (var characteristicPoint in source.CharacteristicPoints)
+ foreach (CharacteristicPoint characteristicPoint in source.CharacteristicPoints)
{
if (!geometryAnnotations.ContainsKey(characteristicPoint.GeometryPoint))
{
geometryAnnotations[characteristicPoint.GeometryPoint] =
source.GetCharacteristicPoints(characteristicPoint.GeometryPoint).ToArray();
}
}
+
return geometryAnnotations;
}
-
}
}
\ No newline at end of file