Skip to content

Commit

Permalink
Dui3 124 receiving curves arcs ellipses nurbs curves (#3521)
Browse files Browse the repository at this point in the history
* arcs received (tested with Rhino and AutoCAD commits)

* add SpatialRef to every new host geometry

* don't receive non-flat arcs, circles, ellipses

* more specific exceptions

* namespaces and densification for arc-polygon edges

* added ICurve converter (not used yet); added check for sequential Polycurve

* precision points
  • Loading branch information
KatKatKateryna authored Jul 1, 2024
1 parent b6141ff commit a71d37d
Show file tree
Hide file tree
Showing 43 changed files with 442 additions and 337 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Objects;
using Speckle.Converters.Common.Objects;

namespace Speckle.Converters.ArcGIS3.ToHost.Raw;

public class CurveToHostConverter : ITypedConverter<ICurve, ACG.Polyline>
{
private readonly ITypedConverter<SOG.Line, ACG.Polyline> _lineConverter;
private readonly ITypedConverter<SOG.Arc, ACG.Polyline> _arcConverter;
private readonly ITypedConverter<SOG.Ellipse, ACG.Polyline> _ellipseConverter;
private readonly ITypedConverter<SOG.Circle, ACG.Polyline> _circleConverter;
private readonly ITypedConverter<SOG.Polyline, ACG.Polyline> _polylineConverter;
private readonly ITypedConverter<SOG.Polycurve, ACG.Polyline> _polyCurveConverter;

public CurveToHostConverter(
ITypedConverter<SOG.Line, ACG.Polyline> lineConverter,
ITypedConverter<SOG.Arc, ACG.Polyline> arcConverter,
ITypedConverter<SOG.Ellipse, ACG.Polyline> ellipseConverter,
ITypedConverter<SOG.Circle, ACG.Polyline> circleConverter,
ITypedConverter<SOG.Polyline, ACG.Polyline> polylineConverter,
ITypedConverter<SOG.Polycurve, ACG.Polyline> polyCurveConverter
)
{
_lineConverter = lineConverter;
_arcConverter = arcConverter;
_ellipseConverter = ellipseConverter;
_circleConverter = circleConverter;
_polylineConverter = polylineConverter;
_polyCurveConverter = polyCurveConverter;
}

/// <summary>
/// Converts a given ICurve object to an ACG.Polyline object.
/// </summary>
/// <param name="target">The ICurve object to convert.</param>
/// <returns>The converted RG.Curve object.</returns>
/// <exception cref="NotSupportedException">Thrown when the conversion is not supported for the given type of curve.</exception>
/// <remarks>⚠️ This conversion does NOT perform scaling.</remarks>
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}")
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<VectorLayer, FeatureClass>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IReadOnlyList<Base>, ACG.Geometry>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
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<List<SOG.Mesh>, ACG.Multipatch>
{
private readonly ITypedConverter<SOG.Point, ACG.MapPoint> _pointConverter;
private readonly IConversionContextStack<ArcGISDocument, ACG.Unit> _contextStack;

public MeshListToHostConverter(ITypedConverter<SOG.Point, ACG.MapPoint> pointConverter)
public MeshListToHostConverter(
ITypedConverter<SOG.Point, ACG.MapPoint> pointConverter,
IConversionContextStack<ArcGISDocument, ACG.Unit> contextStack
)
{
_pointConverter = pointConverter;
_contextStack = contextStack;
}

public ACG.Multipatch Convert(List<SOG.Mesh> target)
Expand All @@ -19,7 +24,7 @@ public ACG.Multipatch Convert(List<SOG.Mesh> 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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<List<SGIS.GisMultipatchGeometry>, ACG.Multipatch>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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<List<SOG.Point>, ACG.Multipoint>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SOG.Point, ACG.MapPoint>
{
Expand All @@ -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();
}
}
Loading

0 comments on commit a71d37d

Please sign in to comment.