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