From 56eed23e4e8f229099665352185e3f1501c0b82b Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Mon, 17 Jun 2024 13:02:17 +0100 Subject: [PATCH 01/10] arcs received (tested with Rhino and AutoCAD commits) --- .../ArcToHostConverter.cs | 39 ++++--------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs index ec46307cfc..c06e9f171b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs @@ -4,8 +4,7 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; -//TODO: Ellipses don't convert correctly, see Autocad test stream -//[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter { private readonly ITypedConverter _pointConverter; @@ -19,36 +18,14 @@ public CurveToHostConverter(ITypedConverter pointConver public ACG.Polyline Convert(SOG.Arc target) { - // Determine the number of vertices to create along the arc - int numVertices = Math.Max((int)target.length, 50); // Determine based on desired segment length or other criteria - List pointsOriginal = new(); + // MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(target.startPoint, 1); + ACG.MapPoint fromPt = _pointConverter.Convert(target.startPoint); + ACG.MapPoint toPt = _pointConverter.Convert(target.endPoint); + ACG.MapPoint midPt = _pointConverter.Convert(target.midPoint); + ACG.Coordinate2D interiorPt = new(midPt); - // get correct direction - double? angleStart = target.startAngle; - double? fullAngle = target.endAngle - target.startAngle; - double? radius = target.radius; + ACG.EllipticArcSegment segment = ACG.EllipticArcBuilderEx.CreateCircularArc(fromPt, toPt, interiorPt); - if (angleStart == null || fullAngle == null || radius == null) - { - throw new SpeckleConversionException("Conversion failed: Arc doesn't have start & end angle or radius"); - } - - // Calculate the vertices along the arc - for (int i = 0; i <= numVertices; i++) - { - // Calculate the point along the arc - double angle = (double)angleStart + (double)fullAngle * (i / (double)numVertices); - SOG.Point pointOnArc = - new( - target.plane.origin.x + (double)radius * Math.Cos(angle), - target.plane.origin.y + (double)radius * Math.Sin(angle), - target.plane.origin.z - ); - - pointsOriginal.Add(pointOnArc); - } - - var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + return new ACG.PolylineBuilderEx(segment, ACG.AttributeFlags.HasZ).ToGeometry(); } } From 68b0ac44c828acdb6ffad44c1169b091f5242644 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Mon, 17 Jun 2024 17:08:19 +0100 Subject: [PATCH 02/10] add SpetialRef to every new host geometry --- .../MeshListToHostConverter.cs | 9 ++- .../ArcToHostConverter.cs | 18 ++++-- .../CircleToHostConverter.cs | 3 +- .../CurveToHostConverter.cs | 25 ++++++++ .../EllipseToHostConverter.cs | 61 +++++++++++-------- .../LineToHostConverter.cs | 13 +++- .../PolycurveToHostConverter.cs | 35 +++++++---- .../PolylineToHostConverter.cs | 13 +++- .../Geometry/PointSingleToHostConverter.cs | 3 +- .../ToSpeckle/Raw/NurbsCurveConverter.cs | 2 +- 10 files changed, 130 insertions(+), 52 deletions(-) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs index 7730f54308..ebbb76ca19 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs @@ -7,10 +7,15 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; public class MeshListToHostConverter : ITypedConverter, ACG.Multipatch> { private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; - public MeshListToHostConverter(ITypedConverter pointConverter) + public MeshListToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) { _pointConverter = pointConverter; + _contextStack = contextStack; } public ACG.Multipatch Convert(List target) @@ -19,7 +24,7 @@ public ACG.Multipatch Convert(List target) { throw new SpeckleConversionException("Feature contains no geometries"); } - ACG.MultipatchBuilderEx multipatchPart = new(); + ACG.MultipatchBuilderEx multipatchPart = new(_contextStack.Current.Document.Map.SpatialReference); foreach (SOG.Mesh part in target) { part.TriangulateMesh(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs index c06e9f171b..7e73072bb3 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs @@ -5,26 +5,34 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter +public class ArcToHostConverter : IToHostTopLevelConverter, ITypedConverter { private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; - public CurveToHostConverter(ITypedConverter pointConverter) + public ArcToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) { _pointConverter = pointConverter; + _contextStack = contextStack; } public object Convert(Base target) => Convert((SOG.Arc)target); public ACG.Polyline Convert(SOG.Arc target) { - // MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(target.startPoint, 1); ACG.MapPoint fromPt = _pointConverter.Convert(target.startPoint); ACG.MapPoint toPt = _pointConverter.Convert(target.endPoint); ACG.MapPoint midPt = _pointConverter.Convert(target.midPoint); - ACG.Coordinate2D interiorPt = new(midPt); - ACG.EllipticArcSegment segment = ACG.EllipticArcBuilderEx.CreateCircularArc(fromPt, toPt, interiorPt); + ACG.EllipticArcSegment segment = ACG.EllipticArcBuilderEx.CreateCircularArc( + fromPt, + toPt, + new ACG.Coordinate2D(midPt), + _contextStack.Current.Document.Map.SpatialReference + ); return new ACG.PolylineBuilderEx(segment, ACG.AttributeFlags.HasZ).ToGeometry(); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs index d4ffe06c35..16b13d73d1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs @@ -36,7 +36,8 @@ public ACG.Polyline Convert(SOG.Circle target) ACG.EllipticArcSegment circleSegment = ACG.EllipticArcBuilderEx.CreateCircle( new ACG.Coordinate2D(centerPt.X, centerPt.Y), (double)target.radius * scaleFactor, - ACG.ArcOrientation.ArcClockwise + ACG.ArcOrientation.ArcClockwise, + _contextStack.Current.Document.Map.SpatialReference ); var circlePolyline = new ACG.PolylineBuilderEx(circleSegment, ACG.AttributeFlags.HasZ).ToGeometry(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs new file mode 100644 index 0000000000..de2973d72f --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs @@ -0,0 +1,25 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; + +[NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter +{ + private readonly IRootToHostConverter _converter; + + public CurveToHostConverter(IRootToHostConverter converter) + { + _converter = converter; + } + + public object Convert(Base target) => Convert((SOG.Curve)target); + + public ACG.Polyline Convert(SOG.Curve target) + { + // before we have a better idea how to recreate periodic curve + SOG.Polyline segment = target.displayValue; + return (ACG.Polyline)_converter.Convert(segment); + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs index 94ee04b951..4c7cdae47c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs @@ -1,53 +1,60 @@ -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Core.Kits; using Speckle.Core.Models; namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; -//TODO: Ellipses don't convert correctly, see Autocad test stream -// [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class EllipseToHostConverter : IToHostTopLevelConverter, ITypedConverter { private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; - public EllipseToHostConverter(ITypedConverter pointConverter) + public EllipseToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) { _pointConverter = pointConverter; + _contextStack = contextStack; } public object Convert(Base target) => Convert((SOG.Ellipse)target); public ACG.Polyline Convert(SOG.Ellipse target) { - // Determine the number of vertices to create along the Ellipse - int numVertices = Math.Max((int)target.length, 100); // Determine based on desired segment length or other criteria - List pointsOriginal = new(); - + // dummy check if (target.firstRadius == null || target.secondRadius == null) { - throw new SpeckleConversionException("Conversion failed: Ellipse doesn't have 1st and 2nd radius"); + throw new ArgumentException("Invalid Ellipse provided"); } - // Calculate the vertices along the arc - for (int i = 0; i <= numVertices; i++) - { - // Calculate the point along the arc - double angle = 2 * Math.PI * (i / (double)numVertices); - SOG.Point pointOnEllipse = - new( - target.plane.origin.x + (double)target.secondRadius * Math.Cos(angle), - target.plane.origin.y + (double)target.firstRadius * Math.Sin(angle), - target.plane.origin.z - ); - - pointsOriginal.Add(pointOnEllipse); - } - if (pointsOriginal[0] != pointsOriginal[^1]) + ACG.MapPoint centerPt = _pointConverter.Convert(target.plane.origin); + double scaleFactor = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); + + // set default values + double angle = Math.Atan2(target.plane.xdir.y, target.plane.xdir.x); + double majorAxeRadius = (double)target.firstRadius; + double minorAxisRatio = (double)target.secondRadius / majorAxeRadius; + + // adjust if needed + if (minorAxisRatio > 1) { - pointsOriginal.Add(pointsOriginal[0]); + majorAxeRadius = (double)target.secondRadius; + minorAxisRatio = 1 / minorAxisRatio; + angle += Math.PI / 2; } - var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + ACG.EllipticArcSegment segment = ACG.EllipticArcBuilderEx.CreateEllipse( + new ACG.Coordinate2D(centerPt), + angle, + majorAxeRadius * scaleFactor, + minorAxisRatio, + ACG.ArcOrientation.ArcCounterClockwise, + _contextStack.Current.Document.Map.SpatialReference + ); + + return new ACG.PolylineBuilderEx(segment, ACG.AttributeFlags.HasZ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs index 60a1447d7b..452880d19f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs @@ -8,10 +8,15 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; public class LineSingleToHostConverter : IToHostTopLevelConverter, ITypedConverter { private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; - public LineSingleToHostConverter(ITypedConverter pointConverter) + public LineSingleToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) { _pointConverter = pointConverter; + _contextStack = contextStack; } public object Convert(Base target) => Convert((SOG.Line)target); @@ -20,6 +25,10 @@ public ACG.Polyline Convert(SOG.Line target) { List originalPoints = new() { target.start, target.end }; IEnumerable points = originalPoints.Select(x => _pointConverter.Convert(x)); - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + return new ACG.PolylineBuilderEx( + points, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs index 35adddb385..b4bd577e94 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs @@ -9,38 +9,51 @@ public class PolycurveToHostConverter : IToHostTopLevelConverter, ITypedConverte { private readonly ITypedConverter _pointConverter; private readonly IRootToHostConverter _converter; + private readonly IConversionContextStack _contextStack; public PolycurveToHostConverter( ITypedConverter pointConverter, - IRootToHostConverter converter + IRootToHostConverter converter, + IConversionContextStack contextStack ) { _pointConverter = pointConverter; _converter = converter; + _contextStack = contextStack; } public object Convert(Base target) => Convert((SOG.Polycurve)target); public ACG.Polyline Convert(SOG.Polycurve target) { - List points = new(); + List pointsToCheckOrientation = new(); + List segments = new(); + foreach (var segment in target.segments) { - if (segment is SOG.Arc) - { - throw new NotImplementedException("Polycurves with arc segments are not supported"); - } ACG.Polyline converted = (ACG.Polyline)_converter.Convert((Base)segment); - List newPts = converted.Points.ToList(); + List segmentPts = converted.Points.ToList(); // reverse new segment if needed - if (points.Count > 0 && newPts.Count > 0 && points[^1] != newPts[0] && points[^1] == newPts[^1]) + if ( + pointsToCheckOrientation.Count > 0 + && segmentPts.Count > 0 + && pointsToCheckOrientation[^1] != segmentPts[0] + && pointsToCheckOrientation[^1] == segmentPts[^1] + ) { - newPts.Reverse(); + segmentPts.Reverse(); + ACG.Geometry reversedLine = ACG.GeometryEngine.Instance.ReverseOrientation(converted); + converted = (ACG.Polyline)reversedLine; } - points.AddRange(newPts); + pointsToCheckOrientation.AddRange(segmentPts); + segments.Add(converted); } - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + return new ACG.PolylineBuilderEx( + segments, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs index 6615607b98..95c5e1a400 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs @@ -8,10 +8,15 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; public class PolylineToHostConverter : IToHostTopLevelConverter, ITypedConverter { private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; - public PolylineToHostConverter(ITypedConverter pointConverter) + public PolylineToHostConverter( + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) { _pointConverter = pointConverter; + _contextStack = contextStack; } public object Convert(Base target) => Convert((SOG.Polyline)target); @@ -24,6 +29,10 @@ public ACG.Polyline Convert(SOG.Polyline target) { points.Add(points[0]); } - return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); + return new ACG.PolylineBuilderEx( + points, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs index e30ec589e5..3beeebf661 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs @@ -22,7 +22,8 @@ public ACG.MapPoint Convert(SOG.Point target) return new ACG.MapPointBuilderEx( target.x * scaleFactor, target.y * scaleFactor, - target.z * scaleFactor + target.z * scaleFactor, + _contextStack.Current.Document.Map.SpatialReference ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs index 6cf8dca53d..2e7ad37bae 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs @@ -1,4 +1,4 @@ -using Rhino; +using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; From b46096dff216d311be80d9cb425178a62b98fb0a Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Mon, 17 Jun 2024 17:12:19 +0100 Subject: [PATCH 03/10] don't receive non-flat arcs, circles, ellipses --- .../Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs | 6 ++++++ .../Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs | 6 ++++++ .../Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs index 7e73072bb3..8133ced560 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs @@ -23,6 +23,12 @@ public ArcToHostConverter( public ACG.Polyline Convert(SOG.Arc target) { + if ( + target.plane.normal.x != 0 || target.plane.normal.y != 0 || target.plane.xdir.z != 0 || target.plane.ydir.z != 0 + ) + { + throw new ArgumentException("Only 2d-Arc shape is supported"); + } ACG.MapPoint fromPt = _pointConverter.Convert(target.startPoint); ACG.MapPoint toPt = _pointConverter.Convert(target.endPoint); ACG.MapPoint midPt = _pointConverter.Convert(target.midPoint); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs index 16b13d73d1..aad97c181d 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs @@ -28,6 +28,12 @@ public ACG.Polyline Convert(SOG.Circle target) { throw new SpeckleConversionException("Conversion failed: Circle doesn't have a radius"); } + if ( + target.plane.normal.x != 0 || target.plane.normal.y != 0 || target.plane.xdir.z != 0 || target.plane.ydir.z != 0 + ) + { + throw new ArgumentException("Only 2d-Circle shape is supported"); + } // create a native ArcGIS circle segment ACG.MapPoint centerPt = _pointConverter.Convert(target.plane.origin); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs index 4c7cdae47c..6e0b5d2902 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs @@ -29,6 +29,12 @@ public ACG.Polyline Convert(SOG.Ellipse target) { throw new ArgumentException("Invalid Ellipse provided"); } + if ( + target.plane.normal.x != 0 || target.plane.normal.y != 0 || target.plane.xdir.z != 0 || target.plane.ydir.z != 0 + ) + { + throw new ArgumentException("Only 2d-Ellipse shape is supported"); + } ACG.MapPoint centerPt = _pointConverter.Convert(target.plane.origin); double scaleFactor = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); From 39a13ead58891002636645a1ac5a69e25832bdbd Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Mon, 17 Jun 2024 21:37:16 +0100 Subject: [PATCH 04/10] add nurbs curves --- .../ArcToHostConverter.cs | 6 +- .../CircleToHostConverter.cs | 8 +- .../CurveToHostConverter.cs | 104 +++++++++++++++++- .../EllipseToHostConverter.cs | 6 +- 4 files changed, 117 insertions(+), 7 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs index 8133ced560..9bb4dabd00 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs @@ -40,6 +40,10 @@ public ACG.Polyline Convert(SOG.Arc target) _contextStack.Current.Document.Map.SpatialReference ); - return new ACG.PolylineBuilderEx(segment, ACG.AttributeFlags.HasZ).ToGeometry(); + return new ACG.PolylineBuilderEx( + segment, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs index aad97c181d..62aaefaa8d 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs @@ -46,8 +46,10 @@ public ACG.Polyline Convert(SOG.Circle target) _contextStack.Current.Document.Map.SpatialReference ); - var circlePolyline = new ACG.PolylineBuilderEx(circleSegment, ACG.AttributeFlags.HasZ).ToGeometry(); - - return circlePolyline; + return new ACG.PolylineBuilderEx( + circleSegment, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs index de2973d72f..ba057048d9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs @@ -8,18 +8,118 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter { private readonly IRootToHostConverter _converter; + private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; - public CurveToHostConverter(IRootToHostConverter converter) + public CurveToHostConverter( + IRootToHostConverter converter, + ITypedConverter pointConverter, + IConversionContextStack contextStack + ) { _converter = converter; + _pointConverter = pointConverter; + _contextStack = contextStack; } public object Convert(Base target) => Convert((SOG.Curve)target); public ACG.Polyline Convert(SOG.Curve target) { - // before we have a better idea how to recreate periodic curve + // before we have a better way to recreate periodic curve SOG.Polyline segment = target.displayValue; return (ACG.Polyline)_converter.Convert(segment); + /* + List bezierCurves = ConvertNurbsToBezier(target); + + return new ACG.PolylineBuilderEx( + bezierCurves, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); + */ + } + + private List ConvertNurbsToBezier(SOG.Curve nurbsCurve) + { + if (nurbsCurve == null || nurbsCurve.points == null || nurbsCurve.knots == null) // || nurbsCurve.weights == null) + { + throw new ArgumentNullException(nameof(nurbsCurve), "Invalid Curve provided."); + } + + List bezierCurves = new(); + + // Insert knots to create Bezier segments + List refinedKnots = RefineKnotVector(nurbsCurve.knots, nurbsCurve.degree); + List refinedControlPoints = InsertKnots(nurbsCurve, refinedKnots); + + // Create Bezier curves from segments + int numSegments = refinedKnots.Count - 1 - (2 * nurbsCurve.degree); + for (int i = 0; i < numSegments; i++) + { + List bezierControlPoints = new(); + for (int j = 0; j < 4; j++) + { + bezierControlPoints.Add(refinedControlPoints[i + j]); + } + ACG.CubicBezierSegment bezierCurve = new ACG.CubicBezierBuilderEx( + bezierControlPoints, + _contextStack.Current.Document.Map.SpatialReference + ).ToSegment(); + bezierCurves.Add(bezierCurve); + } + + return bezierCurves; + } + + private List RefineKnotVector(List knotVector, int degree) + { + List refinedKnots = new(knotVector); + + // Insert knots to create Bezier segments + int n = knotVector.Count - degree - 1; + for (int i = degree + 1; i < n; i += degree) + { + for (int j = 0; j < degree; j++) + { + refinedKnots.Insert(i + j + 1, knotVector[i]); + } + } + + return refinedKnots; + } + + private List InsertKnots(SOG.Curve nurbsCurve, List refinedKnots) + { + List refinedControlPoints = new(); + for (int i = 0; i < nurbsCurve.points.Count / 3; i++) + { + refinedControlPoints.Add( + _pointConverter.Convert( + new SOG.Point( + nurbsCurve.points[i * 3], + nurbsCurve.points[i * 3 + 1], + nurbsCurve.points[i * 3 + 2], + nurbsCurve.units + ) + ) + ); + } + + int p = nurbsCurve.degree; + for (int i = p + 1; i < refinedKnots.Count - p - 1; i++) + { + double alpha = (refinedKnots[i] - nurbsCurve.knots[i - p]) / (nurbsCurve.knots[i] - nurbsCurve.knots[i - p]); + + ACG.MapPoint newControlPoint = new ACG.MapPointBuilderEx( + (1.0 - alpha) * refinedControlPoints[i - p - 1].X + alpha * refinedControlPoints[i - p].X, + (1.0 - alpha) * refinedControlPoints[i - p - 1].Y + alpha * refinedControlPoints[i - p].Y, + (1.0 - alpha) * refinedControlPoints[i - p - 1].Z + alpha * refinedControlPoints[i - p].Z, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); + refinedControlPoints.Insert(i, newControlPoint); + } + + return refinedControlPoints; } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs index 6e0b5d2902..17c2fab7c0 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs @@ -61,6 +61,10 @@ public ACG.Polyline Convert(SOG.Ellipse target) _contextStack.Current.Document.Map.SpatialReference ); - return new ACG.PolylineBuilderEx(segment, ACG.AttributeFlags.HasZ).ToGeometry(); + return new ACG.PolylineBuilderEx( + segment, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); } } From ec7b49f6956e24da19f2ae441746bdb45c5772fd Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 28 Jun 2024 18:48:33 +0100 Subject: [PATCH 05/10] more specific exceptions --- .../ArcToHostConverter.cs | 4 +- .../CircleToHostConverter.cs | 2 +- .../CurveToHostConverter.cs | 125 ------------------ .../EllipseToHostConverter.cs | 12 +- 4 files changed, 9 insertions(+), 134 deletions(-) delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs index 9bb4dabd00..3f0de1a1db 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs @@ -24,10 +24,10 @@ public ArcToHostConverter( public ACG.Polyline Convert(SOG.Arc target) { if ( - target.plane.normal.x != 0 || target.plane.normal.y != 0 || target.plane.xdir.z != 0 || target.plane.ydir.z != 0 + target.startPoint.z != target.midPoint.z || target.startPoint.z != target.endPoint.z ) { - throw new ArgumentException("Only 2d-Arc shape is supported"); + throw new ArgumentException("Only Arc in XY plane are supported"); } ACG.MapPoint fromPt = _pointConverter.Convert(target.startPoint); ACG.MapPoint toPt = _pointConverter.Convert(target.endPoint); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs index 62aaefaa8d..f4472b8999 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs @@ -32,7 +32,7 @@ public ACG.Polyline Convert(SOG.Circle target) target.plane.normal.x != 0 || target.plane.normal.y != 0 || target.plane.xdir.z != 0 || target.plane.ydir.z != 0 ) { - throw new ArgumentException("Only 2d-Circle shape is supported"); + throw new ArgumentException("Only Circles in XY plane are supported"); } // create a native ArcGIS circle segment diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs deleted file mode 100644 index ba057048d9..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CurveToHostConverter.cs +++ /dev/null @@ -1,125 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; - -[NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter -{ - private readonly IRootToHostConverter _converter; - private readonly ITypedConverter _pointConverter; - private readonly IConversionContextStack _contextStack; - - public CurveToHostConverter( - IRootToHostConverter converter, - ITypedConverter pointConverter, - IConversionContextStack contextStack - ) - { - _converter = converter; - _pointConverter = pointConverter; - _contextStack = contextStack; - } - - public object Convert(Base target) => Convert((SOG.Curve)target); - - public ACG.Polyline Convert(SOG.Curve target) - { - // before we have a better way to recreate periodic curve - SOG.Polyline segment = target.displayValue; - return (ACG.Polyline)_converter.Convert(segment); - /* - List bezierCurves = ConvertNurbsToBezier(target); - - return new ACG.PolylineBuilderEx( - bezierCurves, - ACG.AttributeFlags.HasZ, - _contextStack.Current.Document.Map.SpatialReference - ).ToGeometry(); - */ - } - - private List ConvertNurbsToBezier(SOG.Curve nurbsCurve) - { - if (nurbsCurve == null || nurbsCurve.points == null || nurbsCurve.knots == null) // || nurbsCurve.weights == null) - { - throw new ArgumentNullException(nameof(nurbsCurve), "Invalid Curve provided."); - } - - List bezierCurves = new(); - - // Insert knots to create Bezier segments - List refinedKnots = RefineKnotVector(nurbsCurve.knots, nurbsCurve.degree); - List refinedControlPoints = InsertKnots(nurbsCurve, refinedKnots); - - // Create Bezier curves from segments - int numSegments = refinedKnots.Count - 1 - (2 * nurbsCurve.degree); - for (int i = 0; i < numSegments; i++) - { - List bezierControlPoints = new(); - for (int j = 0; j < 4; j++) - { - bezierControlPoints.Add(refinedControlPoints[i + j]); - } - ACG.CubicBezierSegment bezierCurve = new ACG.CubicBezierBuilderEx( - bezierControlPoints, - _contextStack.Current.Document.Map.SpatialReference - ).ToSegment(); - bezierCurves.Add(bezierCurve); - } - - return bezierCurves; - } - - private List RefineKnotVector(List knotVector, int degree) - { - List refinedKnots = new(knotVector); - - // Insert knots to create Bezier segments - int n = knotVector.Count - degree - 1; - for (int i = degree + 1; i < n; i += degree) - { - for (int j = 0; j < degree; j++) - { - refinedKnots.Insert(i + j + 1, knotVector[i]); - } - } - - return refinedKnots; - } - - private List InsertKnots(SOG.Curve nurbsCurve, List refinedKnots) - { - List refinedControlPoints = new(); - for (int i = 0; i < nurbsCurve.points.Count / 3; i++) - { - refinedControlPoints.Add( - _pointConverter.Convert( - new SOG.Point( - nurbsCurve.points[i * 3], - nurbsCurve.points[i * 3 + 1], - nurbsCurve.points[i * 3 + 2], - nurbsCurve.units - ) - ) - ); - } - - int p = nurbsCurve.degree; - for (int i = p + 1; i < refinedKnots.Count - p - 1; i++) - { - double alpha = (refinedKnots[i] - nurbsCurve.knots[i - p]) / (nurbsCurve.knots[i] - nurbsCurve.knots[i - p]); - - ACG.MapPoint newControlPoint = new ACG.MapPointBuilderEx( - (1.0 - alpha) * refinedControlPoints[i - p - 1].X + alpha * refinedControlPoints[i - p].X, - (1.0 - alpha) * refinedControlPoints[i - p - 1].Y + alpha * refinedControlPoints[i - p].Y, - (1.0 - alpha) * refinedControlPoints[i - p - 1].Z + alpha * refinedControlPoints[i - p].Z, - _contextStack.Current.Document.Map.SpatialReference - ).ToGeometry(); - refinedControlPoints.Insert(i, newControlPoint); - } - - return refinedControlPoints; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs index 17c2fab7c0..d2a8b62337 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs @@ -27,13 +27,13 @@ public ACG.Polyline Convert(SOG.Ellipse target) // dummy check if (target.firstRadius == null || target.secondRadius == null) { - throw new ArgumentException("Invalid Ellipse provided"); + throw new ArgumentException("Ellipse is missing the first or second radius"); } if ( target.plane.normal.x != 0 || target.plane.normal.y != 0 || target.plane.xdir.z != 0 || target.plane.ydir.z != 0 ) { - throw new ArgumentException("Only 2d-Ellipse shape is supported"); + throw new ArgumentException("Only Ellipses in XY plane are supported"); } ACG.MapPoint centerPt = _pointConverter.Convert(target.plane.origin); @@ -41,13 +41,13 @@ public ACG.Polyline Convert(SOG.Ellipse target) // set default values double angle = Math.Atan2(target.plane.xdir.y, target.plane.xdir.x); - double majorAxeRadius = (double)target.firstRadius; - double minorAxisRatio = (double)target.secondRadius / majorAxeRadius; + double majorAxisRadius = (double)target.firstRadius; + double minorAxisRatio = (double)target.secondRadius / majorAxisRadius; // adjust if needed if (minorAxisRatio > 1) { - majorAxeRadius = (double)target.secondRadius; + majorAxisRadius = (double)target.secondRadius; minorAxisRatio = 1 / minorAxisRatio; angle += Math.PI / 2; } @@ -55,7 +55,7 @@ public ACG.Polyline Convert(SOG.Ellipse target) ACG.EllipticArcSegment segment = ACG.EllipticArcBuilderEx.CreateEllipse( new ACG.Coordinate2D(centerPt), angle, - majorAxeRadius * scaleFactor, + majorAxisRadius * scaleFactor, minorAxisRatio, ACG.ArcOrientation.ArcCounterClockwise, _contextStack.Current.Document.Map.SpatialReference From 3a77152cd778995649d61a83942ae5e3f2bee74e Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 28 Jun 2024 21:16:20 +0100 Subject: [PATCH 06/10] namespaces and densification for arc-polygon edges --- .../PointFeatureToSpeckleConverter.cs | 35 ------- .../SegmentCollectionToSpeckleConverter.cs | 65 ------------- .../Raw}/FeatureClassToHostConverter.cs | 2 +- .../Raw}/GeometryToHostConverter.cs | 2 +- .../Raw}/MeshListToHostConverter.cs | 2 +- .../Raw}/MultipatchListToHostConverter.cs | 2 +- .../Raw}/PointListToHostConverter.cs | 2 +- .../Raw}/PointSingleToHostConverter.cs | 2 +- .../Raw}/PointcloudLayerToHostConverter.cs | 2 +- .../Raw}/Polygon3dListToHostConverter.cs | 4 +- .../Raw}/PolygonListToHostConverter.cs | 4 +- .../Raw}/PolylineListToHostConverter.cs | 4 +- .../Raw}/TableToHostConverter.cs | 6 +- .../TopLevel}/ArcToHostConverter.cs | 2 +- .../TopLevel}/CircleToHostConverter.cs | 2 +- .../TopLevel}/EllipseToHostConverter.cs | 2 +- .../TopLevel}/FallbackToHostConverter.cs | 2 +- .../TopLevel}/LineToHostConverter.cs | 2 +- .../TopLevel}/MeshToHostConverter.cs | 2 +- .../TopLevel}/PointToHostConverter.cs | 2 +- .../TopLevel}/PolycurveToHostConverter.cs | 2 +- .../TopLevel}/PolylineToHostConverter.cs | 2 +- .../TopLevel}/RasterLayerToHostConverter.cs | 2 +- .../TopLevel}/VectorLayerToHostConverter.cs | 2 +- .../Raw}/EnvelopBoxToSpeckleConverter.cs | 6 +- .../Raw}/GeometryToSpeckleBase.cs | 2 +- .../Raw}/GisFeatureToSpeckleConverter.cs | 9 +- .../Raw}/GisRasterToSpeckleConverter.cs | 8 +- .../MultipatchFeatureToSpeckleConverter.cs | 6 +- .../MultipointFeatureToSpeckleConverter.cs | 2 +- .../Raw}/PointToSpeckleConverter.cs | 4 +- .../Raw}/PolygonFeatureToSpeckleConverter.cs | 4 +- .../Raw}/PolylineFeatureToSpeckleConverter.cs | 6 +- .../SegmentCollectionToSpeckleConverter.cs | 96 +++++++++++++++++++ .../PointcloudLayerToSpeckleConverter.cs | 13 ++- .../RasterLayerToSpeckleConverter.cs | 10 +- .../TopLevel}/TableToSpeckleConverter.cs | 10 +- .../VectorLayerToSpeckleConverter.cs | 14 +-- .../{Geometry => Utils}/GeometryExtension.cs | 2 +- 39 files changed, 170 insertions(+), 176 deletions(-) delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs delete mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToHost/Raw}/FeatureClassToHostConverter.cs (99%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToHost/Raw}/GeometryToHostConverter.cs (98%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/MeshListToHostConverter.cs (95%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/MultipatchListToHostConverter.cs (93%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/PointListToHostConverter.cs (91%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry => ToHost/Raw}/PointSingleToHostConverter.cs (94%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToHost/Raw}/PointcloudLayerToHostConverter.cs (90%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/Polygon3dListToHostConverter.cs (95%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/PolygonListToHostConverter.cs (94%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/GisFeatureGeometriesToHost => ToHost/Raw}/PolylineListToHostConverter.cs (92%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToHost/Raw}/TableToHostConverter.cs (98%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/ArcToHostConverter.cs (95%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/CircleToHostConverter.cs (96%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/EllipseToHostConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry => ToHost/TopLevel}/FallbackToHostConverter.cs (96%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/LineToHostConverter.cs (94%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/MeshToHostConverter.cs (91%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/PointToHostConverter.cs (89%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/PolycurveToHostConverter.cs (96%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry/ISpeckleObjectToHost => ToHost/TopLevel}/PolylineToHostConverter.cs (94%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToHost/TopLevel}/RasterLayerToHostConverter.cs (90%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToHost/TopLevel}/VectorLayerToHostConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry => ToSpeckle/Raw}/EnvelopBoxToSpeckleConverter.cs (96%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/GeometryToSpeckleBase.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/GisFeatureToSpeckleConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/GisRasterToSpeckleConverter.cs (99%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/MultipatchFeatureToSpeckleConverter.cs (98%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/MultipointFeatureToSpeckleConverter.cs (92%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry => ToSpeckle/Raw}/PointToSpeckleConverter.cs (95%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/PolygonFeatureToSpeckleConverter.cs (96%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Features => ToSpeckle/Raw}/PolylineFeatureToSpeckleConverter.cs (91%) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToSpeckle/TopLevel}/PointcloudLayerToSpeckleConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToSpeckle/TopLevel}/RasterLayerToSpeckleConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToSpeckle/TopLevel}/TableToSpeckleConverter.cs (97%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Layers => ToSpeckle/TopLevel}/VectorLayerToSpeckleConverter.cs (98%) rename DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/{Geometry => Utils}/GeometryExtension.cs (99%) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs deleted file mode 100644 index 7b53a664de..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Speckle.Converters.Common; - -namespace Speckle.Converters.ArcGIS3.Features; - -[NameAndRankValue(nameof(ACG.MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointFeatureToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter -{ - private readonly IConversionContextStack _contextStack; - - public PointFeatureToSpeckleConverter(IConversionContextStack contextStack) - { - _contextStack = contextStack; - } - - public Base Convert(object target) => Convert((ACG.MapPoint)target); - - public Base Convert(ACG.MapPoint target) - { - if ( - ACG.GeometryEngine.Instance.Project(target, _contextStack.Current.Document.Map.SpatialReference) - is not ACG.MapPoint reprojectedPt - ) - { - throw new SpeckleConversionException( - $"Conversion to Spatial Reference {_contextStack.Current.Document.Map.SpatialReference} failed" - ); - } - List geometry = - new() { new SOG.Point(reprojectedPt.X, reprojectedPt.Y, reprojectedPt.Z, _contextStack.Current.SpeckleUnits) }; - - return geometry[0]; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs deleted file mode 100644 index 2d3c93fce8..0000000000 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; - -namespace Speckle.Converters.ArcGIS3.Geometry; - -public class SegmentCollectionToSpeckleConverter : ITypedConverter -{ - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _pointConverter; - - public SegmentCollectionToSpeckleConverter( - IConversionContextStack contextStack, - ITypedConverter pointConverter - ) - { - _contextStack = contextStack; - _pointConverter = pointConverter; - } - - public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) - { - // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html - double len = 0; - - List points = new(); - foreach (var segment in target) - { - len += segment.Length; - - // specific conversion per segment type - switch (segment.SegmentType) - { - case ACG.SegmentType.Line: - points = AddPtsToPolylinePts( - points, - new List() - { - _pointConverter.Convert(segment.StartPoint), - _pointConverter.Convert(segment.EndPoint) - } - ); - break; - default: - throw new SpeckleConversionException($"Segment of type '{segment.SegmentType}' cannot be converted"); - } - } - SOG.Polyline polyline = - new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) { }; - - return polyline; - } - - private List AddPtsToPolylinePts(List points, List newSegmentPts) - { - if (points.Count == 0 || points[^1] != newSegmentPts[0]) - { - points.AddRange(newSegmentPts); - } - else - { - points.AddRange(newSegmentPts.GetRange(1, newSegmentPts.Count - 1)); - } - return points; - } -} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/FeatureClassToHostConverter.cs similarity index 99% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/FeatureClassToHostConverter.cs index 0a084ffee8..d491ca2a1e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/FeatureClassToHostConverter.cs @@ -8,7 +8,7 @@ using Speckle.Core.Models; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class FeatureClassToHostConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/GeometryToHostConverter.cs similarity index 98% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/GeometryToHostConverter.cs index 2ee8dc31d2..9ec0f3d279 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/GeometryToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class GeometryToHostConverter : ITypedConverter, ACG.Geometry> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MeshListToHostConverter.cs similarity index 95% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MeshListToHostConverter.cs index ebbb76ca19..941f6ac70f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MeshListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MeshListToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class MeshListToHostConverter : ITypedConverter, ACG.Multipatch> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MultipatchListToHostConverter.cs similarity index 93% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MultipatchListToHostConverter.cs index e2a4d6028e..44c961e9bc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/MultipatchListToHostConverter.cs @@ -1,7 +1,7 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class MultipatchListToHostConverter : ITypedConverter, ACG.Multipatch> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointListToHostConverter.cs similarity index 91% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointListToHostConverter.cs index ac1d3e5467..e1204f36c5 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointListToHostConverter.cs @@ -1,7 +1,7 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class PointListToHostConverter : ITypedConverter, ACG.Multipoint> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointSingleToHostConverter.cs similarity index 94% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointSingleToHostConverter.cs index 3beeebf661..75bb57b476 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointSingleToHostConverter.cs @@ -3,7 +3,7 @@ using Speckle.Core.Kits; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class PointToHostConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointcloudLayerToHostConverter.cs similarity index 90% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointcloudLayerToHostConverter.cs index 2011596618..fa04b92fa0 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PointcloudLayerToHostConverter.cs @@ -3,7 +3,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class PointcloudLayerToHostConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/Polygon3dListToHostConverter.cs similarity index 95% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/Polygon3dListToHostConverter.cs index 72f6951056..5d68c5be91 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/Polygon3dListToHostConverter.cs @@ -1,7 +1,7 @@ -using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class Polygon3dListToHostConverter : ITypedConverter, ACG.Multipatch> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolygonListToHostConverter.cs similarity index 94% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolygonListToHostConverter.cs index b6aa76cb1c..6acc30b826 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolygonListToHostConverter.cs @@ -1,7 +1,7 @@ -using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class PolygonListToHostConverter : ITypedConverter, ACG.Polygon> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolylineListToHostConverter.cs similarity index 92% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolylineListToHostConverter.cs index 97983c42bf..d512a23d94 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/PolylineListToHostConverter.cs @@ -1,7 +1,7 @@ -using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class PolylineListToHostConverter : ITypedConverter, ACG.Polyline> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/TableToHostConverter.cs similarity index 98% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/TableToHostConverter.cs index 374f09c23d..8af12954d6 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/TableToHostConverter.cs @@ -1,13 +1,13 @@ +using ArcGIS.Core.Data; using ArcGIS.Core.Data.DDL; using ArcGIS.Core.Data.Exceptions; -using ArcGIS.Core.Data; using Objects.GIS; using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; -using Speckle.Converters.Common; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; public class TableLayerToHostConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs similarity index 95% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs index 3f0de1a1db..dc653336a1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class ArcToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/CircleToHostConverter.cs similarity index 96% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/CircleToHostConverter.cs index f4472b8999..089ac64b1b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/CircleToHostConverter.cs @@ -3,7 +3,7 @@ using Speckle.Core.Kits; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class CircleToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/EllipseToHostConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/EllipseToHostConverter.cs index d2a8b62337..d839109fb2 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/EllipseToHostConverter.cs @@ -3,7 +3,7 @@ using Speckle.Core.Kits; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class EllipseToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/FallbackToHostConverter.cs similarity index 96% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/FallbackToHostConverter.cs index ec9f1eef77..0f777c297c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/FallbackToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class FallbackToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/LineToHostConverter.cs similarity index 94% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/LineToHostConverter.cs index 452880d19f..ab562f2395 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/LineToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/LineToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class LineSingleToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/MeshToHostConverter.cs similarity index 91% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/MeshToHostConverter.cs index 8de4c957e4..d9f60803f5 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/MeshToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class MeshToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PointToHostConverter.cs similarity index 89% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PointToHostConverter.cs index abf671574a..4fe87d57ac 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PointToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointToHostConverter : IToHostTopLevelConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs similarity index 96% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs index b4bd577e94..3b97f43886 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PolycurveToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolylineToHostConverter.cs similarity index 94% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolylineToHostConverter.cs index 95c5e1a400..d32e32d022 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolylineToHostConverter.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PolylineToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/RasterLayerToHostConverter.cs similarity index 90% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/RasterLayerToHostConverter.cs index f97cbc5dd8..6ffb334009 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/RasterLayerToHostConverter.cs @@ -3,7 +3,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(RasterLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class RasterLayerToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/VectorLayerToHostConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/VectorLayerToHostConverter.cs index d4438f7339..5c7dd8c9eb 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/VectorLayerToHostConverter.cs @@ -6,7 +6,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel; [NameAndRankValue(nameof(VectorLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class VectorLayerToHostConverter : IToHostTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/EnvelopBoxToSpeckleConverter.cs similarity index 96% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/EnvelopBoxToSpeckleConverter.cs index 15dad97faf..0296c5d328 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/EnvelopBoxToSpeckleConverter.cs @@ -1,9 +1,9 @@ using ArcGIS.Core.Geometry; -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; using Objects.Primitive; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class EnvelopToSpeckleConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GeometryToSpeckleBase.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GeometryToSpeckleBase.cs index db4c5cab66..951432f74c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GeometryToSpeckleBase.cs @@ -2,7 +2,7 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class GeometryToSpeckleBaseList : ITypedConverter> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisFeatureToSpeckleConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisFeatureToSpeckleConverter.cs index a3c9d41e40..aa82bf5a2c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisFeatureToSpeckleConverter.cs @@ -1,11 +1,10 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; using ArcGIS.Core.Data; -using Speckle.Converters.ArcGIS3.Geometry; -using Speckle.Converters.Common; using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class GisFeatureToSpeckleConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisRasterToSpeckleConverter.cs similarity index 99% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisRasterToSpeckleConverter.cs index af3e268b8b..7d67bfd67c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/GisRasterToSpeckleConverter.cs @@ -1,10 +1,10 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Objects.GIS; using ArcGIS.Core.Data.Raster; +using Objects.GIS; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class GisRasterToSpeckleConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipatchFeatureToSpeckleConverter.cs similarity index 98% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipatchFeatureToSpeckleConverter.cs index 2e15ae765b..7b60ee416f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipatchFeatureToSpeckleConverter.cs @@ -1,9 +1,9 @@ -using Speckle.Converters.Common.Objects; +using Speckle.Converters.ArcGIS3.Utils; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; using Speckle.Core.Models; -using Speckle.Converters.ArcGIS3.Geometry; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class MultipatchFeatureToSpeckleConverter : ITypedConverter> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipointFeatureToSpeckleConverter.cs similarity index 92% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipointFeatureToSpeckleConverter.cs index c7e1669038..c6d6299ffb 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/MultipointFeatureToSpeckleConverter.cs @@ -1,6 +1,6 @@ using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class MultipointFeatureToSpeckleConverter : ITypedConverter> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PointToSpeckleConverter.cs similarity index 95% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PointToSpeckleConverter.cs index 198af4e5ee..e77591ee3f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PointToSpeckleConverter.cs @@ -1,8 +1,8 @@ using ArcGIS.Core.Geometry; -using Speckle.Converters.Common.Objects; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Geometry; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class PointToSpeckleConverter : ITypedConverter { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolygonFeatureToSpeckleConverter.cs similarity index 96% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolygonFeatureToSpeckleConverter.cs index 3bbf377d3b..23034aa454 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolygonFeatureToSpeckleConverter.cs @@ -1,8 +1,8 @@ -using Speckle.Converters.Common.Objects; using Objects.GIS; using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class PolygonFeatureToSpeckleConverter : ITypedConverter> { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolylineFeatureToSpeckleConverter.cs similarity index 91% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolylineFeatureToSpeckleConverter.cs index 92bc6ff70e..a8cc1a99d3 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/PolylineFeatureToSpeckleConverter.cs @@ -1,7 +1,7 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -namespace Speckle.Converters.ArcGIS3.Features; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; public class PolyineFeatureToSpeckleConverter : ITypedConverter> { @@ -23,7 +23,7 @@ public PolyineFeatureToSpeckleConverter( List polylineList = new(); ACG.Polyline polylineToConvert = target; - // segmentize the polylines with curves using precision value of the Map's Spatial Reference + // densify the polylines with curves using precision value of the Map's Spatial Reference if (target.HasCurves is true) { double tolerance = _contextStack.Current.Document.Map.SpatialReference.XYTolerance; @@ -32,11 +32,11 @@ public PolyineFeatureToSpeckleConverter( target, tolerance * conversionFactorToMeter ); - polylineToConvert = (ACG.Polyline)densifiedPolyline; if (densifiedPolyline == null) { throw new ArgumentException("Polyline densification failed"); } + polylineToConvert = (ACG.Polyline)densifiedPolyline; } foreach (var segmentCollection in polylineToConvert.Parts) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs new file mode 100644 index 0000000000..544d95c298 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs @@ -0,0 +1,96 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.ArcGIS3.ToSpeckle.Raw; + +public class SegmentCollectionToSpeckleConverter : ITypedConverter +{ + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _pointConverter; + + public SegmentCollectionToSpeckleConverter( + IConversionContextStack contextStack, + ITypedConverter pointConverter + ) + { + _contextStack = contextStack; + _pointConverter = pointConverter; + } + + public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) + { + // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html + double len = 0; + + List points = new(); + foreach (var segment in target) + { + len += segment.Length; + + if (segment.SegmentType != ACG.SegmentType.Line) + { + // densify the segments with curves using precision value of the Map's Spatial Reference + ACG.Polyline polylineFromSegment = new ACG.PolylineBuilderEx( + segment, + ACG.AttributeFlags.HasZ, + _contextStack.Current.Document.Map.SpatialReference + ).ToGeometry(); + + double tolerance = _contextStack.Current.Document.Map.SpatialReference.XYTolerance; + double conversionFactorToMeter = _contextStack.Current.Document.Map.SpatialReference.Unit.ConversionFactor; + var densifiedPolyline = ACG.GeometryEngine.Instance.DensifyByDeviation( + polylineFromSegment, + tolerance * conversionFactorToMeter + ); + if (densifiedPolyline == null) + { + throw new ArgumentException("Segment densification failed"); + } + + ACG.Polyline polylineToConvert = (ACG.Polyline)densifiedPolyline; + // add points from each segment of the densified original segment + ACG.ReadOnlyPartCollection subParts = polylineToConvert.Parts; + foreach (ACG.ReadOnlySegmentCollection subSegments in subParts) + { + foreach (ACG.Segment? subSegment in subSegments) + { + points = AddPtsToPolylinePts( + points, + new List() + { + _pointConverter.Convert(subSegment.StartPoint), _pointConverter.Convert(subSegment.EndPoint) + } + ); + } + } + } + else + { + points = AddPtsToPolylinePts( + points, + new List() + { + _pointConverter.Convert(segment.StartPoint), _pointConverter.Convert(segment.EndPoint) + } + ); + } + } + SOG.Polyline polyline = + new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) { }; + + return polyline; + } + + private List AddPtsToPolylinePts(List points, List newSegmentPts) + { + if (points.Count == 0 || points[^1] != newSegmentPts[0]) + { + points.AddRange(newSegmentPts); + } + else + { + points.AddRange(newSegmentPts.GetRange(1, newSegmentPts.Count - 1)); + } + return points; + } +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/PointcloudLayerToSpeckleConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/PointcloudLayerToSpeckleConverter.cs index 6c1590aaa3..2ad672dea9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/PointcloudLayerToSpeckleConverter.cs @@ -1,13 +1,12 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; -using ArcGIS.Core.Data.Analyst3D; using ArcGIS.Core.CIM; -using Speckle.Converters.ArcGIS3.Geometry; -using Speckle.Core.Models; +using ArcGIS.Core.Data.Analyst3D; +using ArcGIS.Desktop.Mapping; using Speckle.Converters.ArcGIS3.Utils; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.TopLevel; [NameAndRankValue(nameof(LasDatasetLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointCloudToSpeckleConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/RasterLayerToSpeckleConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/RasterLayerToSpeckleConverter.cs index 3afee5b6c3..22a93c52a9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/RasterLayerToSpeckleConverter.cs @@ -1,12 +1,12 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; +using ArcGIS.Core.Data.Raster; +using ArcGIS.Core.Geometry; using Objects.GIS; using Speckle.Converters.Common; -using ArcGIS.Core.Geometry; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; using RasterLayer = ArcGIS.Desktop.Mapping.RasterLayer; -using ArcGIS.Core.Data.Raster; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.TopLevel; [NameAndRankValue(nameof(RasterLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class RasterLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/TableToSpeckleConverter.cs similarity index 97% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/TableToSpeckleConverter.cs index 110f752fc9..7649211f18 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/TableToSpeckleConverter.cs @@ -1,11 +1,11 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; +using ArcGIS.Core.Data; +using ArcGIS.Desktop.Mapping; using Objects.GIS; using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; -using ArcGIS.Core.Data; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.TopLevel; [NameAndRankValue(nameof(StandaloneTable), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class StandaloneTableToSpeckleConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/VectorLayerToSpeckleConverter.cs similarity index 98% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/VectorLayerToSpeckleConverter.cs index 5712ecc8ee..8d2a36e33f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/TopLevel/VectorLayerToSpeckleConverter.cs @@ -1,14 +1,14 @@ -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; -using Objects.GIS; -using Speckle.Converters.Common; -using ArcGIS.Desktop.Mapping; +using ArcGIS.Core.CIM; using ArcGIS.Core.Data; using ArcGIS.Core.Geometry; +using ArcGIS.Desktop.Mapping; +using Objects.GIS; using Speckle.Converters.ArcGIS3.Utils; -using ArcGIS.Core.CIM; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; -namespace Speckle.Converters.ArcGIS3.Layers; +namespace Speckle.Converters.ArcGIS3.ToSpeckle.TopLevel; [NameAndRankValue(nameof(FeatureLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class VectorLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GeometryExtension.cs similarity index 99% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GeometryExtension.cs index cd0e8bfbd0..1bc46399f2 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GeometryExtension.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/GeometryExtension.cs @@ -1,7 +1,7 @@ using ArcGIS.Core.CIM; using Speckle.Converters.Common; -namespace Speckle.Converters.ArcGIS3.Geometry; +namespace Speckle.Converters.ArcGIS3.Utils; public static class GeometryUtils { From 0bf9e9fd6183b453699af682833285464a8be983 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 28 Jun 2024 21:33:40 +0100 Subject: [PATCH 07/10] formatting --- .../Raw/SegmentCollectionToSpeckleConverter.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs index 544d95c298..f0b71ef47c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToSpeckle/Raw/SegmentCollectionToSpeckleConverter.cs @@ -26,7 +26,7 @@ public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) foreach (var segment in target) { len += segment.Length; - + if (segment.SegmentType != ACG.SegmentType.Line) { // densify the segments with curves using precision value of the Map's Spatial Reference @@ -35,7 +35,7 @@ public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) ACG.AttributeFlags.HasZ, _contextStack.Current.Document.Map.SpatialReference ).ToGeometry(); - + double tolerance = _contextStack.Current.Document.Map.SpatialReference.XYTolerance; double conversionFactorToMeter = _contextStack.Current.Document.Map.SpatialReference.Unit.ConversionFactor; var densifiedPolyline = ACG.GeometryEngine.Instance.DensifyByDeviation( @@ -46,7 +46,7 @@ public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) { throw new ArgumentException("Segment densification failed"); } - + ACG.Polyline polylineToConvert = (ACG.Polyline)densifiedPolyline; // add points from each segment of the densified original segment ACG.ReadOnlyPartCollection subParts = polylineToConvert.Parts; @@ -58,7 +58,8 @@ public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) points, new List() { - _pointConverter.Convert(subSegment.StartPoint), _pointConverter.Convert(subSegment.EndPoint) + _pointConverter.Convert(subSegment.StartPoint), + _pointConverter.Convert(subSegment.EndPoint) } ); } @@ -70,7 +71,8 @@ public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) points, new List() { - _pointConverter.Convert(segment.StartPoint), _pointConverter.Convert(segment.EndPoint) + _pointConverter.Convert(segment.StartPoint), + _pointConverter.Convert(segment.EndPoint) } ); } From 9010fa98d9b5b8455d7f144328c9a52f530d0f8f Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 28 Jun 2024 23:43:06 +0100 Subject: [PATCH 08/10] formatting --- .../ToHost/TopLevel/ArcToHostConverter.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs index dc653336a1..f334713612 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/ArcToHostConverter.cs @@ -23,9 +23,7 @@ public ArcToHostConverter( public ACG.Polyline Convert(SOG.Arc target) { - if ( - target.startPoint.z != target.midPoint.z || target.startPoint.z != target.endPoint.z - ) + if (target.startPoint.z != target.midPoint.z || target.startPoint.z != target.endPoint.z) { throw new ArgumentException("Only Arc in XY plane are supported"); } From 7666608b659184c1d7f5b6cdee16983bfbcae00e Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Mon, 1 Jul 2024 16:47:36 +0100 Subject: [PATCH 09/10] added ICUrve converter (not used yet); added check for sequential Polycurve --- .../ToHost/Raw/CurveToHostConverter.cs | 52 +++++++++++++++++++ .../TopLevel/PolycurveToHostConverter.cs | 19 +++---- 2 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/CurveToHostConverter.cs diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/CurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/CurveToHostConverter.cs new file mode 100644 index 0000000000..57bd7b3c83 --- /dev/null +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/Raw/CurveToHostConverter.cs @@ -0,0 +1,52 @@ +using Objects; +using Speckle.Converters.Common.Objects; + +namespace Speckle.Converters.ArcGIS3.ToHost.Raw; + +public class CurveToHostConverter : ITypedConverter +{ + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _polyCurveConverter; + + public CurveToHostConverter( + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter ellipseConverter, + ITypedConverter circleConverter, + ITypedConverter polylineConverter, + ITypedConverter polyCurveConverter + ) + { + _lineConverter = lineConverter; + _arcConverter = arcConverter; + _ellipseConverter = ellipseConverter; + _circleConverter = circleConverter; + _polylineConverter = polylineConverter; + _polyCurveConverter = polyCurveConverter; + } + + /// + /// Converts a given ICurve object to an ACG.Polyline object. + /// + /// The ICurve object to convert. + /// The converted RG.Curve object. + /// Thrown when the conversion is not supported for the given type of curve. + /// ⚠️ This conversion does NOT perform scaling. + public ACG.Polyline Convert(ICurve target) => + target switch + { + SOG.Line line => _lineConverter.Convert(line), + SOG.Arc arc => _arcConverter.Convert(arc), + SOG.Circle circle => _circleConverter.Convert(circle), + SOG.Ellipse ellipse => _ellipseConverter.Convert(ellipse), + SOG.Spiral spiral => _polylineConverter.Convert(spiral.displayValue), + SOG.Polyline polyline => _polylineConverter.Convert(polyline), + SOG.Curve curve => _polylineConverter.Convert(curve.displayValue), + SOG.Polycurve polyCurve => _polyCurveConverter.Convert(polyCurve), + _ => throw new NotSupportedException($"Unable to convert curves of type {target.GetType().Name}") + }; +} diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs index 3b97f43886..f6912aee8f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs @@ -26,27 +26,20 @@ public PolycurveToHostConverter( public ACG.Polyline Convert(SOG.Polycurve target) { - List pointsToCheckOrientation = new(); + ACG.MapPoint? lastConvertedPt = null; List segments = new(); foreach (var segment in target.segments) { - ACG.Polyline converted = (ACG.Polyline)_converter.Convert((Base)segment); + ACG.Polyline converted = (ACG.Polyline)_converter.Convert((Base)segment); //CurveConverter.NotNull().Convert(segment); List segmentPts = converted.Points.ToList(); - // reverse new segment if needed - if ( - pointsToCheckOrientation.Count > 0 - && segmentPts.Count > 0 - && pointsToCheckOrientation[^1] != segmentPts[0] - && pointsToCheckOrientation[^1] == segmentPts[^1] - ) + if (lastConvertedPt != null && segmentPts.Count > 0 && lastConvertedPt != segmentPts[0]) { - segmentPts.Reverse(); - ACG.Geometry reversedLine = ACG.GeometryEngine.Instance.ReverseOrientation(converted); - converted = (ACG.Polyline)reversedLine; + throw new SpeckleConversionException("Polycurve segments are not in a correct sequence/orientation"); } - pointsToCheckOrientation.AddRange(segmentPts); + + lastConvertedPt = segmentPts[^1]; segments.Add(converted); } From bcb7e9900631d0fd785b8ccfa0dca5f48d5ee0d5 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Mon, 1 Jul 2024 17:26:26 +0100 Subject: [PATCH 10/10] precision points --- .../ToHost/TopLevel/PolycurveToHostConverter.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs index f6912aee8f..ba57e347f6 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ToHost/TopLevel/PolycurveToHostConverter.cs @@ -34,7 +34,15 @@ public ACG.Polyline Convert(SOG.Polycurve target) ACG.Polyline converted = (ACG.Polyline)_converter.Convert((Base)segment); //CurveConverter.NotNull().Convert(segment); List segmentPts = converted.Points.ToList(); - if (lastConvertedPt != null && segmentPts.Count > 0 && lastConvertedPt != segmentPts[0]) + if ( + lastConvertedPt != null + && segmentPts.Count > 0 + && ( + Math.Round(lastConvertedPt.X, 6) != Math.Round(segmentPts[0].X, 6) + || Math.Round(lastConvertedPt.Y, 6) != Math.Round(segmentPts[0].Y, 6) + || Math.Round(lastConvertedPt.Z, 6) != Math.Round(segmentPts[0].Z, 6) + ) + ) { throw new SpeckleConversionException("Polycurve segments are not in a correct sequence/orientation"); }