Skip to content

Commit

Permalink
Merged PR 47704: Filling out VOs and Adapters for 3D Points, Lines, a…
Browse files Browse the repository at this point in the history
…nd Rectangles

Filling out and making symmetric our set of VOs and adapters for:
- Point3D (MathNET and Windows)
- Line3D (MathNET)
- Rect3D (Windows)

And handling all combinations of T, Nullable<T>, and List<T>.

Added descriptions to all configuration properties for these.

Related work items: #132887
  • Loading branch information
sandrist committed Oct 29, 2020
1 parent 267c66a commit 03880fd
Show file tree
Hide file tree
Showing 21 changed files with 490 additions and 291 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.Psi.Visualization.Adapters
{
using System.Collections.Generic;
using System.Linq;
using MathNet.Spatial.Euclidean;
using Microsoft.Psi.Visualization.Data;

/// <summary>
/// Used to adapt streams of lists of <see cref="Line3D"/> to lists of nullable <see cref="Line3D"/>.
/// </summary>
[StreamAdapter]
public class Line3DListToNullableAdapter : StreamAdapter<List<Line3D>, List<Line3D?>>
{
/// <summary>
/// Initializes a new instance of the <see cref="Line3DListToNullableAdapter"/> class.
/// </summary>
public Line3DListToNullableAdapter()
: base(Adapter)
{
}

private static List<Line3D?> Adapter(List<Line3D> value, Envelope env)
{
return value?.Select(p => p as Line3D?).ToList();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.Psi.Visualization.Adapters
{
using MathNet.Spatial.Euclidean;
using Microsoft.Psi.Visualization.Data;

/// <summary>
/// Used to adapt streams of <see cref="Line3D"/> into nullable <see cref="Line3D"/>.
/// </summary>
[StreamAdapter]
public class Line3DToNullableAdapter : StreamAdapter<Line3D, Line3D?>
{
/// <summary>
/// Initializes a new instance of the <see cref="Line3DToNullableAdapter"/> class.
/// </summary>
public Line3DToNullableAdapter()
: base(Adapter)
{
}

private static Line3D? Adapter(Line3D value, Envelope env)
{
return value;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.Psi.Visualization.Adapters
{
using System.Collections.Generic;
using System.Linq;
using Microsoft.Psi.Visualization.Data;

using MathNet = MathNet.Spatial.Euclidean;
using Windows = System.Windows.Media.Media3D;

/// <summary>
/// Used to adapt streams of lists of nullable <see cref="MathNet.Point3D"/> into lists of nullable <see cref="Windows.Point3D"/>.
/// </summary>
[StreamAdapter]
public class MathNetNullablePoint3DListToWindowsNullablePoint3DListAdapter : StreamAdapter<List<MathNet.Point3D?>, List<Windows.Point3D?>>
{
/// <summary>
/// Initializes a new instance of the <see cref="MathNetNullablePoint3DListToWindowsNullablePoint3DListAdapter"/> class.
/// </summary>
public MathNetNullablePoint3DListToWindowsNullablePoint3DListAdapter()
: base(Adapter)
{
}

private static List<Windows.Point3D?> Adapter(List<MathNet.Point3D?> value, Envelope env)
{
return value?.Select(p => p.HasValue ? new Windows.Point3D(p.Value.X, p.Value.Y, p.Value.Z) as Windows.Point3D? : null).ToList();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.Psi.Visualization.Adapters
{
using Microsoft.Psi.Visualization.Data;

using MathNet = MathNet.Spatial.Euclidean;
using Windows = System.Windows.Media.Media3D;

/// <summary>
/// Used to adapt streams of nullable <see cref="MathNet.Point3D"/> into nullable <see cref="Windows.Point3D"/>.
/// </summary>
[StreamAdapter]
public class MathNetNullablePoint3DToWindowsNullablePoint3DAdapter : StreamAdapter<MathNet.Point3D?, Windows.Point3D?>
{
/// <summary>
/// Initializes a new instance of the <see cref="MathNetNullablePoint3DToWindowsNullablePoint3DAdapter"/> class.
/// </summary>
public MathNetNullablePoint3DToWindowsNullablePoint3DAdapter()
: base(Adapter)
{
}

private static Windows.Point3D? Adapter(MathNet.Point3D? value, Envelope env)
{
return value.HasValue ? new Windows.Point3D(value.Value.X, value.Value.Y, value.Value.Z) as Windows.Point3D? : null;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ namespace Microsoft.Psi.Visualization.Adapters
using Windows = System.Windows.Media.Media3D;

/// <summary>
/// Used to adapt streams of lists of MathNet.Spatial.Eudlidean.Point3Ds into lists of System.Windows.Media.Media32.Point3Ds.
/// Used to adapt streams of lists of <see cref="MathNet.Point3D"/> into lists of nullable <see cref="Windows.Point3D"/>.
/// </summary>
[StreamAdapter]
public class MathNetPoint3DListToWindowsPoint3DListAdapter : StreamAdapter<List<MathNet.Point3D>, List<Windows.Point3D>>
public class MathNetPoint3DListToWindowsNullablePoint3DListAdapter : StreamAdapter<List<MathNet.Point3D>, List<Windows.Point3D?>>
{
/// <summary>
/// Initializes a new instance of the <see cref="MathNetPoint3DListToWindowsPoint3DListAdapter"/> class.
/// Initializes a new instance of the <see cref="MathNetPoint3DListToWindowsNullablePoint3DListAdapter"/> class.
/// </summary>
public MathNetPoint3DListToWindowsPoint3DListAdapter()
public MathNetPoint3DListToWindowsNullablePoint3DListAdapter()
: base(Adapter)
{
}

private static List<Windows.Point3D> Adapter(List<MathNet.Point3D> value, Envelope env)
private static List<Windows.Point3D?> Adapter(List<MathNet.Point3D> value, Envelope env)
{
return value.Select(p => new Windows.Point3D(p.X, p.Y, p.Z)).ToList();
return value?.Select(p => new Windows.Point3D(p.X, p.Y, p.Z) as Windows.Point3D?).ToList();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.Psi.Visualization.Adapters
{
using Microsoft.Psi.Visualization.Data;

using MathNet = MathNet.Spatial.Euclidean;
using Windows = System.Windows.Media.Media3D;

/// <summary>
/// Used to adapt streams of <see cref="MathNet.Point3D"/> into nullable <see cref="Windows.Point3D"/>.
/// </summary>
[StreamAdapter]
public class MathNetPoint3DToWindowsNullablePoint3DAdapter : StreamAdapter<MathNet.Point3D, Windows.Point3D?>
{
/// <summary>
/// Initializes a new instance of the <see cref="MathNetPoint3DToWindowsNullablePoint3DAdapter"/> class.
/// </summary>
public MathNetPoint3DToWindowsNullablePoint3DAdapter()
: base(Adapter)
{
}

private static Windows.Point3D? Adapter(MathNet.Point3D value, Envelope env)
{
return new Windows.Point3D(value.X, value.Y, value.Z);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.Psi.Visualization.Adapters
{
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media.Media3D;
using Microsoft.Psi.Visualization.Data;

/// <summary>
/// Used to adapt streams of lists of <see cref="Rect3D"/> to lists of nullable <see cref="Rect3D"/>.
/// </summary>
[StreamAdapter]
public class Rect3DListToNullableAdapter : StreamAdapter<List<Rect3D>, List<Rect3D?>>
{
/// <summary>
/// Initializes a new instance of the <see cref="Rect3DListToNullableAdapter"/> class.
/// </summary>
public Rect3DListToNullableAdapter()
: base(Adapter)
{
}

private static List<Rect3D?> Adapter(List<Rect3D> value, Envelope env)
{
return value?.Select(p => p as Rect3D?).ToList();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.Psi.Visualization.Adapters
{
using System.Windows.Media.Media3D;
using Microsoft.Psi.Visualization.Data;

/// <summary>
/// Used to adapt streams of <see cref="Rect3D"/> into nullable <see cref="Rect3D"/>.
/// </summary>
[StreamAdapter]
public class Rect3DToNullableAdapter : StreamAdapter<Rect3D, Rect3D?>
{
/// <summary>
/// Initializes a new instance of the <see cref="Rect3DToNullableAdapter"/> class.
/// </summary>
public Rect3DToNullableAdapter()
: base(Adapter)
{
}

private static Rect3D? Adapter(Rect3D value, Envelope env)
{
return value;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.Psi.Visualization.Adapters
{
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media.Media3D;
using Microsoft.Psi.Visualization.Data;

/// <summary>
/// Used to adapt streams of lists of <see cref="Point3D"/> to lists of nullable <see cref="Point3D"/>.
/// </summary>
[StreamAdapter]
public class WindowsPoint3DListToNullableAdapter : StreamAdapter<List<Point3D>, List<Point3D?>>
{
/// <summary>
/// Initializes a new instance of the <see cref="WindowsPoint3DListToNullableAdapter"/> class.
/// </summary>
public WindowsPoint3DListToNullableAdapter()
: base(Adapter)
{
}

private static List<Point3D?> Adapter(List<Point3D> value, Envelope env)
{
return value?.Select(p => p as Point3D?).ToList();
}
}
}

0 comments on commit 03880fd

Please sign in to comment.