diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs index cb031d6265..61f304fb93 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/DependencyInjection/ArcGISConnectorModule.cs @@ -41,7 +41,7 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); builder.AddTransient(); - builder.AddScoped(); + builder.AddScoped(); builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); // register send operation and dependencies diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs index 4d4caa9e7a..865c0abdcb 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Receive/HostObjectBuilder.cs @@ -12,9 +12,9 @@ namespace Speckle.Connectors.ArcGIS.Operations.Receive; -public class HostObjectBuilder : IHostObjectBuilder +public class ArcGISHostObjectBuilder : IHostObjectBuilder { - private readonly ISpeckleConverterToHost _toHostConverter; + private readonly IRootToHostConverter _converter; private readonly IArcGISProjectUtils _arcGISProjectUtils; private readonly INonNativeFeaturesUtils _nonGisFeaturesUtils; @@ -22,15 +22,15 @@ public class HostObjectBuilder : IHostObjectBuilder private readonly IConversionContextStack _contextStack; private readonly GraphTraversal _traverseFunction; - public HostObjectBuilder( - ISpeckleConverterToHost toHostConverter, + public ArcGISHostObjectBuilder( + IRootToHostConverter converter, IArcGISProjectUtils arcGISProjectUtils, IConversionContextStack contextStack, INonNativeFeaturesUtils nonGisFeaturesUtils, GraphTraversal traverseFunction ) { - _toHostConverter = toHostConverter; + _converter = converter; _arcGISProjectUtils = arcGISProjectUtils; _contextStack = contextStack; _nonGisFeaturesUtils = nonGisFeaturesUtils; @@ -44,7 +44,7 @@ GraphTraversal traverseFunction List objectIds ) { - Geometry converted = (Geometry)_toHostConverter.Convert(obj); + Geometry converted = (Geometry)_converter.Convert(obj); objectIds.Add(obj.id); List objPath = path.ToList(); objPath.Add(obj.speckle_type.Split(".")[^1]); @@ -53,7 +53,7 @@ List objectIds public (string, string) ConvertNativeLayers(Base obj, string[] path, List objectIds) { - string converted = (string)_toHostConverter.Convert(obj); + string converted = (string)_converter.Convert(obj); objectIds.Add(obj.id); string objPath = $"{string.Join("\\", path)}\\{((Collection)obj).name}"; return (objPath, converted); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs index f6ff7824b1..ec933d68b1 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Operations/Send/RootObjectBuilder.cs @@ -50,7 +50,7 @@ private Collection ConvertObjects( { // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? // begin the unit of work - using var uow = _unitOfWorkFactory.Resolve(); + using var uow = _unitOfWorkFactory.Resolve(); var converter = uow.Service; // var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs index 70db8d0228..27159ce2f9 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadBasicConnectorBinding.cs @@ -82,18 +82,14 @@ public void HighlightModel(string modelCardId) if (model is SenderModelCard senderModelCard) { - List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects( - senderModelCard.SendFilter.NotNull().GetObjectIds() - ); - objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); + var dbObjects = doc.GetObjects(senderModelCard.SendFilter.NotNull().GetObjectIds()); + objectIds = dbObjects.Select(tuple => tuple.Root.Id).ToArray(); } if (model is ReceiverModelCard receiverModelCard) { - List<(DBObject obj, string applicationId)> dbObjects = doc.GetObjects( - (receiverModelCard.ReceiveResult?.BakedObjectIds).NotNull() - ); - objectIds = dbObjects.Select(tuple => tuple.obj.Id).ToArray(); + var dbObjects = doc.GetObjects((receiverModelCard.ReceiveResult?.BakedObjectIds).NotNull()); + objectIds = dbObjects.Select(tuple => tuple.Root.Id).ToArray(); } if (objectIds.Length == 0) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs index 4ee724bfa7..d33db5b048 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Bindings/AutocadSendBinding.cs @@ -8,6 +8,7 @@ using Speckle.Connectors.Utils.Cancellation; using Speckle.Core.Logging; using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Autocad.Operations.Send; using Speckle.Connectors.Utils.Operations; using Speckle.Core.Models; using ICancelable = System.Reactive.Disposables.ICancelable; @@ -121,7 +122,7 @@ private async Task SendInternal(string modelCardId) { try { - using var uow = _unitOfWorkFactory.Resolve>(); + using var uow = _unitOfWorkFactory.Resolve>(); // 0 - Init cancellation token source -> Manager also cancel it if exist before CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId); @@ -132,8 +133,9 @@ private async Task SendInternal(string modelCardId) } // Get elements to convert - List<(DBObject obj, string applicationId)> autocadObjects = - Application.DocumentManager.CurrentDocument.GetObjects(modelCard.SendFilter.NotNull().GetObjectIds()); + List autocadObjects = Application.DocumentManager.CurrentDocument.GetObjects( + modelCard.SendFilter.NotNull().GetObjectIds() + ); if (autocadObjects.Count == 0) { throw new InvalidOperationException("No objects were found. Please update your send filter!"); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs index a7702d9c2e..e2ec747ba9 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs @@ -1,4 +1,3 @@ -using Autodesk.AutoCAD.DatabaseServices; using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Autocad.Bindings; @@ -16,8 +15,6 @@ using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Operations; -using Speckle.Converters.Autocad; -using Speckle.Converters.Common; using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.Autocad.DependencyInjection; @@ -41,12 +38,12 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); // Operations - builder.AddScoped>(); + builder.AddScoped>(); builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); // Object Builders - builder.AddScoped(); - builder.AddSingleton, RootObjectBuilder>(); + builder.AddScoped(); + builder.AddSingleton, AutocadRootObjectBuilder>(); // Register bindings @@ -59,8 +56,6 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); builder.AddSingleton(); - builder.AddSingleton, AutocadToSpeckleUnitConverter>(); - // register send filters builder.AddTransient(); } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs index 5462c67269..a0ab9e54a2 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/Extensions/DocumentExtensions.cs @@ -1,12 +1,13 @@ using Autodesk.AutoCAD.DatabaseServices; +using Speckle.Connectors.Autocad.Operations.Send; namespace Speckle.Connectors.Autocad.HostApp.Extensions; public static class DocumentExtensions { - public static List<(DBObject, string)> GetObjects(this Document doc, IEnumerable objectIds) + public static List GetObjects(this Document doc, IEnumerable objectIds) { - List<(DBObject, string)> objects = new(); + List objects = new(); using (TransactionContext.StartTransaction(doc)) { Transaction tr = doc.Database.TransactionManager.TopTransaction; @@ -20,7 +21,7 @@ public static class DocumentExtensions { if (tr.GetObject(myObjectId, OpenMode.ForRead) is DBObject dbObject) { - objects.Add((dbObject, objectIdHandle)); + objects.Add(new(dbObject, objectIdHandle)); } } } diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs similarity index 95% rename from DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs rename to DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs index edb8cfa827..9b6b081c5e 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/HostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Receive/AutocadHostObjectBuilder.cs @@ -10,14 +10,14 @@ namespace Speckle.Connectors.Autocad.Operations.Receive; -public class HostObjectBuilder : IHostObjectBuilder +public class AutocadHostObjectBuilder : IHostObjectBuilder { - private readonly ISpeckleConverterToHost _converter; + private readonly IRootToHostConverter _converter; private readonly AutocadLayerManager _autocadLayerManager; private readonly GraphTraversal _traversalFunction; - public HostObjectBuilder( - ISpeckleConverterToHost converter, + public AutocadHostObjectBuilder( + IRootToHostConverter converter, AutocadLayerManager autocadLayerManager, GraphTraversal traversalFunction ) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs new file mode 100644 index 0000000000..6696617b23 --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObject.cs @@ -0,0 +1,5 @@ +using Autodesk.AutoCAD.DatabaseServices; + +namespace Speckle.Connectors.Autocad.Operations.Send; + +public record AutocadRootObject(DBObject Root, string ApplicationId); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs similarity index 82% rename from DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs rename to DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs index 621979f9bb..0155986fe4 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Operations/Send/AutocadRootObjectBuilder.cs @@ -8,18 +8,18 @@ namespace Speckle.Connectors.Autocad.Operations.Send; -public class RootObjectBuilder : IRootObjectBuilder<(DBObject obj, string applicationId)> +public class AutocadRootObjectBuilder : IRootObjectBuilder { - private readonly ISpeckleConverterToSpeckle _converter; + private readonly IRootToSpeckleConverter _converter; private readonly string[] _documentPathSeparator = { "\\" }; - public RootObjectBuilder(ISpeckleConverterToSpeckle converter) + public AutocadRootObjectBuilder(IRootToSpeckleConverter converter) { _converter = converter; } public Base Build( - IReadOnlyList<(DBObject obj, string applicationId)> objects, + IReadOnlyList objects, SendInfo sendInfo, Action? onOperationProgressed = null, CancellationToken ct = default @@ -39,13 +39,10 @@ public Base Build( Dictionary collectionCache = new(); int count = 0; - foreach ((DBObject obj, string applicationId) tuple in objects) + foreach (var (root, applicationId) in objects) { ct.ThrowIfCancellationRequested(); - var dbObject = tuple.obj; - var applicationId = tuple.applicationId; - try { Base converted; @@ -58,7 +55,7 @@ public Base Build( } else { - converted = _converter.Convert(dbObject); + converted = _converter.Convert(root); if (converted == null) { @@ -69,7 +66,7 @@ public Base Build( } // Create and add a collection for each layer if not done so already. - if ((tuple.obj as Entity)?.Layer is string layer) + if ((root as Entity)?.Layer is string layer) { if (!collectionCache.TryGetValue(layer, out Collection? collection)) { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems index 271ae9efd6..d45686060d 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -26,8 +26,9 @@ - - + + + diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorShared.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs similarity index 96% rename from DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorShared.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index b9e5bf7556..4d6a302e27 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorShared.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -56,6 +56,6 @@ public void Load(SpeckleContainerBuilder builder) // send operation and dependencies builder.AddScoped>(); - builder.AddScoped, RootObjectBuilder>(); + builder.AddScoped, RevitRootObjectBuilder>(); } } diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs similarity index 89% rename from DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs rename to DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index ab17b54882..2f7f484807 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -8,24 +8,17 @@ namespace Speckle.Connectors.Revit.Operations.Send; -public class RootObjectBuilder : IRootObjectBuilder +public class RevitRootObjectBuilder : IRootObjectBuilder { // POC: SendSelection and RevitConversionContextStack should be interfaces, former needs interfaces - private readonly ISpeckleConverterToSpeckle _converter; - private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; + private readonly IRootToSpeckleConverter _converter; private readonly IRevitConversionContextStack _contextStack; private readonly Dictionary _collectionCache; private readonly Collection _rootObject; - public RootObjectBuilder( - ISpeckleConverterToSpeckle converter, - ToSpeckleConvertedObjectsCache convertedObjectsCache, - IRevitConversionContextStack contextStack - ) + public RevitRootObjectBuilder(IRootToSpeckleConverter converter, IRevitConversionContextStack contextStack) { _converter = converter; - // POC: needs considering if this is something to add now or needs refactoring - _convertedObjectsCache = convertedObjectsCache; _contextStack = contextStack; // Note, this class is instantiated per unit of work (aka per send operation), so we can safely initialize what we need in here. diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems index 2391c8144a..d7bcb0a2d3 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Speckle.Connectors.RevitShared.projitems @@ -26,8 +26,8 @@ - - + + CefSharpPanel.xaml diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs index ebda7699de..3cc59fd408 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs @@ -62,6 +62,6 @@ public void Load(SpeckleContainerBuilder builder) builder.AddScoped>(); builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); - builder.AddSingleton, RootObjectBuilder>(); + builder.AddSingleton, RhinoRootObjectBuilder>(); } } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs index 48bc85ce99..f0a2f5822e 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/RhinoHostObjectBuilder.cs @@ -11,17 +11,17 @@ namespace Speckle.Connectors.Rhino7.Operations.Receive; public class RhinoHostObjectBuilder : IHostObjectBuilder { - private readonly ISpeckleConverterToHost _toHostConverter; + private readonly IRootToHostConverter _converter; private readonly IConversionContextStack _contextStack; private readonly GraphTraversal _traverseFunction; public RhinoHostObjectBuilder( - ISpeckleConverterToHost toHostConverter, + IRootToHostConverter converter, IConversionContextStack contextStack, GraphTraversal traverseFunction ) { - _toHostConverter = toHostConverter; + _converter = converter; _contextStack = contextStack; _traverseFunction = traverseFunction; } @@ -106,7 +106,7 @@ CancellationToken cancellationToken onOperationProgressed?.Invoke("Converting & creating objects", (double)++count / objects.Count); - var result = _toHostConverter.Convert(baseObj); + var result = _converter.Convert(baseObj); var conversionIds = HandleConversionResult(result, baseObj, layerIndex); newObjectIds.AddRange(conversionIds); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs similarity index 96% rename from DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs rename to DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs index bc760a5679..e599829eaa 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Send/RhinoRootObjectBuilder.cs @@ -12,11 +12,11 @@ namespace Speckle.Connectors.Rhino7.Operations.Send; /// /// Stateless builder object to turn an into a object /// -public class RootObjectBuilder : IRootObjectBuilder +public class RhinoRootObjectBuilder : IRootObjectBuilder { private readonly IUnitOfWorkFactory _unitOfWorkFactory; - public RootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) + public RhinoRootObjectBuilder(IUnitOfWorkFactory unitOfWorkFactory) { _unitOfWorkFactory = unitOfWorkFactory; } @@ -48,7 +48,7 @@ private Collection ConvertObjects( { // POC: does this feel like the right place? I am wondering if this should be called from within send/rcv? // begin the unit of work - using var uow = _unitOfWorkFactory.Resolve(); + using var uow = _unitOfWorkFactory.Resolve(); var converter = uow.Service; var rootObjectCollection = new Collection { name = RhinoDoc.ActiveDoc.Name ?? "Unnamed document" }; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs index fc7cc0b773..a2bc5383a9 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/ArcGISConverterModule.cs @@ -11,9 +11,9 @@ public class ArcGISConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + //don't need a host specific RootToSpeckleConverter + builder.AddConverterCommon(); // most things should be InstancePerLifetimeScope so we get one per operation - builder.AddScoped(); builder.AddScoped(); builder.AddScoped(); builder.AddScoped(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs index be2c0e835b..a40e3d15d7 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISToSpeckleUnitConverter.cs @@ -7,29 +7,31 @@ namespace Speckle.Converters.ArcGIS3; public class ArcGISToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private readonly Dictionary _unitMapping = new(); + private static readonly IReadOnlyDictionary s_unitMapping = Create(); - public ArcGISToSpeckleUnitConverter() + private static IReadOnlyDictionary Create() { + var dict = new Dictionary(); // POC: we should have a unit test to confirm these are as expected and don't change //_unitMapping[LinearUnit.] = Units.Meters; - _unitMapping[LinearUnit.Millimeters.Name] = Units.Millimeters; - _unitMapping[LinearUnit.Centimeters.Name] = Units.Centimeters; - _unitMapping[LinearUnit.Meters.Name] = Units.Meters; - _unitMapping[LinearUnit.Kilometers.Name] = Units.Kilometers; - _unitMapping[LinearUnit.Inches.Name] = Units.Inches; - _unitMapping[LinearUnit.Feet.Name] = Units.Feet; - _unitMapping[LinearUnit.Yards.Name] = Units.Yards; - _unitMapping[LinearUnit.Miles.Name] = Units.Miles; + dict[LinearUnit.Millimeters.Name] = Units.Millimeters; + dict[LinearUnit.Centimeters.Name] = Units.Centimeters; + dict[LinearUnit.Meters.Name] = Units.Meters; + dict[LinearUnit.Kilometers.Name] = Units.Kilometers; + dict[LinearUnit.Inches.Name] = Units.Inches; + dict[LinearUnit.Feet.Name] = Units.Feet; + dict[LinearUnit.Yards.Name] = Units.Yards; + dict[LinearUnit.Miles.Name] = Units.Miles; //_unitMapping[LinearUnit.Decimeters] = Units.; //_unitMapping[LinearUnit.NauticalMiles] = Units.; + return dict; } public string ConvertOrThrow(Unit hostUnit) { var linearUnit = LinearUnit.CreateLinearUnit(hostUnit.Wkt).Name; - if (_unitMapping.TryGetValue(linearUnit, out string? value)) + if (s_unitMapping.TryGetValue(linearUnit, out string? value)) { return value; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeConversion.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeTopLevelConverter.cs similarity index 61% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeConversion.cs rename to DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeTopLevelConverter.cs index c920467276..1c02e2120b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeConversion.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/FakeTopLevelConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.ArcGIS3; [NameAndRankValue(nameof(String), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class FakeConversion : IHostObjectToSpeckleConversion, IRawConversion +public class FakeTopLevelConverter : IToSpeckleTopLevelConverter, ITypedConverter { - public Base Convert(object target) => RawConvert((String)target); + public Base Convert(object target) => Convert((String)target); - public Point RawConvert(String target) + public Point Convert(String target) { return new Point(0, 0, 100) { ["customText"] = target }; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs index 4ca74197b5..2ee8dc31d2 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToHostConverter.cs @@ -4,20 +4,20 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class GeometryToHostConverter : IRawConversion, ACG.Geometry> +public class GeometryToHostConverter : ITypedConverter, ACG.Geometry> { - private readonly IRawConversion, ACG.Polyline> _polylineConverter; - private readonly IRawConversion, ACG.Multipoint> _multipointConverter; - private readonly IRawConversion, ACG.Multipatch> _polygon3dConverter; - private readonly IRawConversion, ACG.Polygon> _polygonConverter; - private readonly IRawConversion, ACG.Multipatch> _multipatchConverter; + private readonly ITypedConverter, ACG.Polyline> _polylineConverter; + private readonly ITypedConverter, ACG.Multipoint> _multipointConverter; + private readonly ITypedConverter, ACG.Multipatch> _polygon3dConverter; + private readonly ITypedConverter, ACG.Polygon> _polygonConverter; + private readonly ITypedConverter, ACG.Multipatch> _multipatchConverter; public GeometryToHostConverter( - IRawConversion, ACG.Polyline> polylineConverter, - IRawConversion, ACG.Multipoint> multipointConverter, - IRawConversion, ACG.Multipatch> polygon3dConverter, - IRawConversion, ACG.Polygon> polygonConverter, - IRawConversion, ACG.Multipatch> multipatchConverter + ITypedConverter, ACG.Polyline> polylineConverter, + ITypedConverter, ACG.Multipoint> multipointConverter, + ITypedConverter, ACG.Multipatch> polygon3dConverter, + ITypedConverter, ACG.Polygon> polygonConverter, + ITypedConverter, ACG.Multipatch> multipatchConverter ) { _polylineConverter = polylineConverter; @@ -27,7 +27,7 @@ public GeometryToHostConverter( _multipatchConverter = multipatchConverter; } - public ACG.Geometry RawConvert(IReadOnlyList target) + public ACG.Geometry Convert(IReadOnlyList target) { try { @@ -36,15 +36,15 @@ public ACG.Geometry RawConvert(IReadOnlyList target) switch (target[0]) { case SOG.Point point: - return _multipointConverter.RawConvert(target.Cast().ToList()); + return _multipointConverter.Convert(target.Cast().ToList()); case SOG.Polyline polyline: - return _polylineConverter.RawConvert(target.Cast().ToList()); + return _polylineConverter.Convert(target.Cast().ToList()); case SGIS.PolygonGeometry3d geometry3d: - return _polygon3dConverter.RawConvert(target.Cast().ToList()); + return _polygon3dConverter.Convert(target.Cast().ToList()); case SGIS.PolygonGeometry geometry: - return _polygonConverter.RawConvert(target.Cast().ToList()); + return _polygonConverter.Convert(target.Cast().ToList()); case SGIS.GisMultipatchGeometry mesh: - return _multipatchConverter.RawConvert(target.Cast().ToList()); + return _multipatchConverter.Convert(target.Cast().ToList()); default: throw new NotSupportedException($"No conversion found for type {target[0]}"); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs index f32ca4bdde..db4c5cab66 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GeometryToSpeckleBase.cs @@ -4,20 +4,20 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class GeometryToSpeckleBaseList : IRawConversion> +public class GeometryToSpeckleBaseList : ITypedConverter> { - private readonly IRawConversion _pointToSpeckleConverter; - private readonly IRawConversion> _multiPointFeatureConverter; - private readonly IRawConversion> _polylineFeatureConverter; - private readonly IRawConversion> _polygonFeatureConverter; - private readonly IRawConversion> _multipatchFeatureConverter; + private readonly ITypedConverter _pointToSpeckleConverter; + private readonly ITypedConverter> _multiPointFeatureConverter; + private readonly ITypedConverter> _polylineFeatureConverter; + private readonly ITypedConverter> _polygonFeatureConverter; + private readonly ITypedConverter> _multipatchFeatureConverter; public GeometryToSpeckleBaseList( - IRawConversion pointToSpeckleConverter, - IRawConversion> multiPointFeatureConverter, - IRawConversion> polylineFeatureConverter, - IRawConversion> polygonFeatureConverter, - IRawConversion> multipatchFeatureConverter + ITypedConverter pointToSpeckleConverter, + ITypedConverter> multiPointFeatureConverter, + ITypedConverter> polylineFeatureConverter, + ITypedConverter> polygonFeatureConverter, + ITypedConverter> multipatchFeatureConverter ) { _pointToSpeckleConverter = pointToSpeckleConverter; @@ -27,17 +27,17 @@ public GeometryToSpeckleBaseList( _multipatchFeatureConverter = multipatchFeatureConverter; } - public IReadOnlyList RawConvert(ACG.Geometry target) + public IReadOnlyList Convert(ACG.Geometry target) { try { return target switch { - ACG.MapPoint point => new List() { _pointToSpeckleConverter.RawConvert(point) }, - ACG.Multipoint multipoint => _multiPointFeatureConverter.RawConvert(multipoint), - ACG.Polyline polyline => _polylineFeatureConverter.RawConvert(polyline), - ACG.Polygon polygon => _polygonFeatureConverter.RawConvert(polygon), - ACG.Multipatch multipatch => _multipatchFeatureConverter.RawConvert(multipatch), // GisMultipatchGeometry or PolygonGeometry3d + ACG.MapPoint point => new List() { _pointToSpeckleConverter.Convert(point) }, + ACG.Multipoint multipoint => _multiPointFeatureConverter.Convert(multipoint), + ACG.Polyline polyline => _polylineFeatureConverter.Convert(polyline), + ACG.Polygon polygon => _polygonFeatureConverter.Convert(polygon), + ACG.Multipatch multipatch => _multipatchFeatureConverter.Convert(multipatch), // GisMultipatchGeometry or PolygonGeometry3d _ => throw new NotSupportedException($"No conversion found for {target.GetType().Name}"), }; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs index ff34d8fa0d..10aac2ae25 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisFeatureToSpeckleConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class GisFeatureToSpeckleConverter : IRawConversion +public class GisFeatureToSpeckleConverter : ITypedConverter { - private readonly IRawConversion> _geometryConverter; + private readonly ITypedConverter> _geometryConverter; - public GisFeatureToSpeckleConverter(IRawConversion> geometryConverter) + public GisFeatureToSpeckleConverter(ITypedConverter> geometryConverter) { _geometryConverter = geometryConverter; } @@ -48,7 +48,7 @@ private List GenerateFeatureDisplayValueList(List speckleShapes) return displayVal; } - public SGIS.GisFeature RawConvert(Row target) + public SGIS.GisFeature Convert(Row target) { // get attributes var attributes = new Base(); @@ -94,7 +94,7 @@ public SGIS.GisFeature RawConvert(Row target) else { var shape = (ACG.Geometry)target[geometryField]; - var speckleShapes = _geometryConverter.RawConvert(shape).ToList(); + var speckleShapes = _geometryConverter.Convert(shape).ToList(); // if geometry is primitive if ( diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs index a223c1713b..bcee923315 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/GisRasterToSpeckleConverter.cs @@ -8,13 +8,13 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class GisRasterToSpeckleConverter : IRawConversion +public class GisRasterToSpeckleConverter : ITypedConverter { - private readonly IRawConversion> _geometryConverter; + private readonly ITypedConverter> _geometryConverter; private readonly IConversionContextStack _contextStack; public GisRasterToSpeckleConverter( - IRawConversion> geometryConverter, + ITypedConverter> geometryConverter, IConversionContextStack contextStack ) { @@ -22,7 +22,7 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((Raster)target); + public Base Convert(object target) => Convert((Raster)target); private List GetRasterMeshCoords(Raster target, List> pixelValsPerBand) { @@ -102,7 +102,7 @@ private List GetRasterColors(int bandCount, List> pixelValsPerBa return newColors; } - public RasterElement RawConvert(Raster target) + public RasterElement Convert(Raster target) { // assisting variables var extent = target.GetExtent(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs index 645396f25a..2da8dd6bf1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipatchFeatureToSpeckleConverter.cs @@ -6,21 +6,21 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class MultipatchFeatureToSpeckleConverter : IRawConversion> +public class MultipatchFeatureToSpeckleConverter : ITypedConverter> { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; public MultipatchFeatureToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public IReadOnlyList RawConvert(ACG.Multipatch target) + public IReadOnlyList Convert(ACG.Multipatch target) { List converted = new(); // placeholder, needs to be declared in order to be used in the Ring patch type @@ -35,7 +35,7 @@ public IReadOnlyList RawConvert(ACG.Multipatch target) int ptCount = target.GetPatchPointCount(idx); for (int ptIdx = ptStartIndex; ptIdx < ptStartIndex + ptCount; ptIdx++) { - pointList.Add(_pointConverter.RawConvert(target.Points[ptIdx])); + pointList.Add(_pointConverter.Convert(target.Points[ptIdx])); } allPoints.Add(pointList); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs index 6d7abbab9a..c7e1669038 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/MultipointFeatureToSpeckleConverter.cs @@ -2,21 +2,21 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class MultipointFeatureToSpeckleConverter : IRawConversion> +public class MultipointFeatureToSpeckleConverter : ITypedConverter> { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public MultipointFeatureToSpeckleConverter(IRawConversion pointConverter) + public MultipointFeatureToSpeckleConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public IReadOnlyList RawConvert(ACG.Multipoint target) + public IReadOnlyList Convert(ACG.Multipoint target) { List multipoint = new(); foreach (ACG.MapPoint point in target.Points) { - multipoint.Add(_pointConverter.RawConvert(point)); + multipoint.Add(_pointConverter.Convert(point)); } return multipoint; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs index 7f26b81371..5be96b9357 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PointFeatureToSpeckleConverter.cs @@ -6,7 +6,7 @@ namespace Speckle.Converters.ArcGIS3.Features; [NameAndRankValue(nameof(ACG.MapPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointFeatureToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class PointFeatureToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -15,9 +15,9 @@ public PointFeatureToSpeckleConverter(IConversionContextStack con _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ACG.MapPoint)target); + public Base Convert(object target) => Convert((ACG.MapPoint)target); - public Base RawConvert(ACG.MapPoint target) + public Base Convert(ACG.MapPoint target) { if ( ACG.GeometryEngine.Instance.Project(target, _contextStack.Current.Document.SpatialReference) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs index 4eea1ba419..3bbf377d3b 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolygonFeatureToSpeckleConverter.cs @@ -4,16 +4,16 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class PolygonFeatureToSpeckleConverter : IRawConversion> +public class PolygonFeatureToSpeckleConverter : ITypedConverter> { - private readonly IRawConversion _segmentConverter; + private readonly ITypedConverter _segmentConverter; - public PolygonFeatureToSpeckleConverter(IRawConversion segmentConverter) + public PolygonFeatureToSpeckleConverter(ITypedConverter segmentConverter) { _segmentConverter = segmentConverter; } - public IReadOnlyList RawConvert(ACG.Polygon target) + public IReadOnlyList Convert(ACG.Polygon target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic30235.html List polygonList = new(); @@ -30,7 +30,7 @@ public IReadOnlyList RawConvert(ACG.Polygon target) for (int idx = 0; idx < partCount; idx++) { ACG.ReadOnlySegmentCollection segmentCollection = target.Parts[idx]; - SOG.Polyline polyline = _segmentConverter.RawConvert(segmentCollection); + SOG.Polyline polyline = _segmentConverter.Convert(segmentCollection); bool isExteriorRing = target.IsExteriorRing(idx); if (isExteriorRing is true) diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs index e9bd50001e..2af833bed4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Features/PolylineFeatureToSpeckleConverter.cs @@ -2,22 +2,22 @@ namespace Speckle.Converters.ArcGIS3.Features; -public class PolyineFeatureToSpeckleConverter : IRawConversion> +public class PolyineFeatureToSpeckleConverter : ITypedConverter> { - private readonly IRawConversion _segmentConverter; + private readonly ITypedConverter _segmentConverter; - public PolyineFeatureToSpeckleConverter(IRawConversion segmentConverter) + public PolyineFeatureToSpeckleConverter(ITypedConverter segmentConverter) { _segmentConverter = segmentConverter; } - public IReadOnlyList RawConvert(ACG.Polyline target) + public IReadOnlyList Convert(ACG.Polyline target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html List polylineList = new(); foreach (var segmentCollection in target.Parts) { - polylineList.Add(_segmentConverter.RawConvert(segmentCollection)); + polylineList.Add(_segmentConverter.Convert(segmentCollection)); } return polylineList; } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs index 71638333da..8c62df731d 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/BezierSegmentToSpeckleConverter.cs @@ -4,21 +4,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class BezierSegmentToSpeckleConverter : IRawConversion +public class BezierSegmentToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; public BezierSegmentToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public SOG.Polyline RawConvert(ACG.CubicBezierSegment target) + public SOG.Polyline Convert(ACG.CubicBezierSegment target) { // Determine the number of vertices to create along the arc int numVertices = Math.Max((int)target.Length, 3); // Determine based on desired segment length or other criteria @@ -43,7 +43,7 @@ public SOG.Polyline RawConvert(ACG.CubicBezierSegment target) + t * t * t * target.EndPoint.Y; ACG.MapPoint pointOnCurve = ACG.MapPointBuilderEx.CreateMapPoint(x, y, target.SpatialReference); - points.Add(_pointConverter.RawConvert(pointOnCurve)); + points.Add(_pointConverter.Convert(pointOnCurve)); } // create Speckle Polyline diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs index 11905f94a8..af4c3716c4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EllipticArcSegmentToSpeckleConverter.cs @@ -4,21 +4,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class EllipticArcToSpeckleConverter : IRawConversion +public class EllipticArcToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; public EllipticArcToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public SOG.Polyline RawConvert(ACG.EllipticArcSegment target) + public SOG.Polyline Convert(ACG.EllipticArcSegment target) { // Determine the number of vertices to create along the arc int numVertices = Math.Max((int)target.Length, 3); // Determine based on desired segment length or other criteria @@ -52,7 +52,7 @@ public SOG.Polyline RawConvert(ACG.EllipticArcSegment target) target.SpatialReference ); - points.Add(_pointConverter.RawConvert(pointOnArc)); + points.Add(_pointConverter.Convert(pointOnArc)); } // create Speckle Polyline diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs index 68d74e968f..5a101f250f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/EnvelopBoxToSpeckleConverter.cs @@ -6,21 +6,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class EnvelopToSpeckleConverter : IRawConversion +public class EnvelopToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; public EnvelopToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public SOG.Box RawConvert(Envelope target) + public SOG.Box Convert(Envelope target) { MapPoint pointMin = new MapPointBuilderEx( target.XMin, @@ -34,8 +34,8 @@ public SOG.Box RawConvert(Envelope target) target.ZMax, _contextStack.Current.Document.SpatialReference ).ToGeometry(); - SOG.Point minPtSpeckle = _pointConverter.RawConvert(pointMin); - SOG.Point maxPtSpeckle = _pointConverter.RawConvert(pointMax); + SOG.Point minPtSpeckle = _pointConverter.Convert(pointMin); + SOG.Point maxPtSpeckle = _pointConverter.Convert(pointMax); var units = _contextStack.Current.SpeckleUnits; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs index 3eddcc8d81..ec9f1eef77 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/FallbackToHostConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class FallbackToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class FallbackToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion, ACG.Multipatch> _meshListConverter; - private readonly IRawConversion, ACG.Polyline> _polylineListConverter; - private readonly IRawConversion, ACG.Multipoint> _pointListConverter; + private readonly ITypedConverter, ACG.Multipatch> _meshListConverter; + private readonly ITypedConverter, ACG.Polyline> _polylineListConverter; + private readonly ITypedConverter, ACG.Multipoint> _pointListConverter; public FallbackToHostConverter( - IRawConversion, ACG.Multipatch> meshListConverter, - IRawConversion, ACG.Polyline> polylineListConverter, - IRawConversion, ACG.Multipoint> pointListConverter + ITypedConverter, ACG.Multipatch> meshListConverter, + ITypedConverter, ACG.Polyline> polylineListConverter, + ITypedConverter, ACG.Multipoint> pointListConverter ) { _meshListConverter = meshListConverter; @@ -22,9 +22,9 @@ public FallbackToHostConverter( _pointListConverter = pointListConverter; } - public object Convert(Base target) => RawConvert((DisplayableObject)target); + public object Convert(Base target) => Convert((DisplayableObject)target); - public ACG.Geometry RawConvert(DisplayableObject target) + public ACG.Geometry Convert(DisplayableObject target) { if (!target.displayValue.Any()) { @@ -35,9 +35,9 @@ public ACG.Geometry RawConvert(DisplayableObject target) return first switch { - SOG.Polyline => _polylineListConverter.RawConvert(target.displayValue.Cast().ToList()), - SOG.Mesh => _meshListConverter.RawConvert(target.displayValue.Cast().ToList()), - SOG.Point => _pointListConverter.RawConvert(target.displayValue.Cast().ToList()), + SOG.Polyline => _polylineListConverter.Convert(target.displayValue.Cast().ToList()), + SOG.Mesh => _meshListConverter.Convert(target.displayValue.Cast().ToList()), + SOG.Point => _pointListConverter.Convert(target.displayValue.Cast().ToList()), _ => throw new NotSupportedException($"Found unsupported fallback geometry: {first.GetType()}") }; } 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 42c5df2692..7730f54308 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 @@ -4,16 +4,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class MeshListToHostConverter : IRawConversion, ACG.Multipatch> +public class MeshListToHostConverter : ITypedConverter, ACG.Multipatch> { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public MeshListToHostConverter(IRawConversion pointConverter) + public MeshListToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public ACG.Multipatch RawConvert(List target) + public ACG.Multipatch Convert(List target) { if (target.Count == 0) { @@ -32,7 +32,7 @@ public ACG.Multipatch RawConvert(List target) } int ptIndex = part.faces[i]; newPatch.AddPoint( - _pointConverter.RawConvert( + _pointConverter.Convert( new SOG.Point(part.vertices[ptIndex * 3], part.vertices[ptIndex * 3 + 1], part.vertices[ptIndex * 3 + 2]) { units = part.units diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs index 3966c7addb..e2a4d6028e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/MultipatchListToHostConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class MultipatchListToHostConverter : IRawConversion, ACG.Multipatch> +public class MultipatchListToHostConverter : ITypedConverter, ACG.Multipatch> { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public MultipatchListToHostConverter(IRawConversion pointConverter) + public MultipatchListToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public ACG.Multipatch RawConvert(List target) + public ACG.Multipatch Convert(List target) { if (target.Count == 0) { @@ -25,7 +25,7 @@ public ACG.Multipatch RawConvert(List target) for (int i = 0; i < part.vertices.Count / 3; i++) { newPatch.AddPoint( - _pointConverter.RawConvert( + _pointConverter.Convert( new SOG.Point(part.vertices[i * 3], part.vertices[i * 3 + 1], part.vertices[i * 3 + 2]) ) ); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs index 651c020011..ac1d3e5467 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PointListToHostConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class PointListToHostConverter : IRawConversion, ACG.Multipoint> +public class PointListToHostConverter : ITypedConverter, ACG.Multipoint> { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public PointListToHostConverter(IRawConversion pointConverter) + public PointListToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public ACG.Multipoint RawConvert(List target) + public ACG.Multipoint Convert(List target) { if (target.Count == 0) { @@ -21,7 +21,7 @@ public ACG.Multipoint RawConvert(List target) List pointList = new(); foreach (SOG.Point pt in target) { - pointList.Add(_pointConverter.RawConvert(pt)); + pointList.Add(_pointConverter.Convert(pt)); } return new ACG.MultipointBuilderEx(pointList, ACG.AttributeFlags.HasZ).ToGeometry(); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs index 8a58236e56..72f6951056 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/Polygon3dListToHostConverter.cs @@ -3,21 +3,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class Polygon3dListToHostConverter : IRawConversion, ACG.Multipatch> +public class Polygon3dListToHostConverter : ITypedConverter, ACG.Multipatch> { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _polylineConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _polylineConverter; public Polygon3dListToHostConverter( - IRawConversion pointConverter, - IRawConversion polylineConverter + ITypedConverter pointConverter, + ITypedConverter polylineConverter ) { _pointConverter = pointConverter; _polylineConverter = polylineConverter; } - public ACG.Multipatch RawConvert(List target) + public ACG.Multipatch Convert(List target) { if (target.Count == 0) { @@ -31,7 +31,7 @@ public ACG.Multipatch RawConvert(List target) List boundaryPts = part.boundary.GetPoints(); foreach (SOG.Point pt in boundaryPts) { - newPatch.AddPoint(_pointConverter.RawConvert(pt)); + newPatch.AddPoint(_pointConverter.Convert(pt)); } multipatchPart.Patches.Add(newPatch); @@ -41,7 +41,7 @@ public ACG.Multipatch RawConvert(List target) List loopPts = loop.GetPoints(); foreach (SOG.Point pt in loopPts) { - newLoopPatch.AddPoint(_pointConverter.RawConvert(pt)); + newLoopPatch.AddPoint(_pointConverter.Convert(pt)); } multipatchPart.Patches.Add(newLoopPatch); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs index d8e1fc9ffd..b6aa76cb1c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolygonListToHostConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class PolygonListToHostConverter : IRawConversion, ACG.Polygon> +public class PolygonListToHostConverter : ITypedConverter, ACG.Polygon> { - private readonly IRawConversion _polylineConverter; + private readonly ITypedConverter _polylineConverter; - public PolygonListToHostConverter(IRawConversion polylineConverter) + public PolygonListToHostConverter(ITypedConverter polylineConverter) { _polylineConverter = polylineConverter; } - public ACG.Polygon RawConvert(List target) + public ACG.Polygon Convert(List target) { if (target.Count == 0) { @@ -21,13 +21,13 @@ public ACG.Polygon RawConvert(List target) List polyList = new(); foreach (SGIS.PolygonGeometry poly in target) { - ACG.Polyline boundary = _polylineConverter.RawConvert(poly.boundary); + ACG.Polyline boundary = _polylineConverter.Convert(poly.boundary); ACG.PolygonBuilderEx polyOuterRing = new(boundary); foreach (SOG.Polyline loop in poly.voids) { // adding inner loops: https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geometry#build-a-donut-polygon - ACG.Polyline loopNative = _polylineConverter.RawConvert(loop); + ACG.Polyline loopNative = _polylineConverter.Convert(loop); polyOuterRing.AddPart(loopNative.Copy3DCoordinatesToList()); } ACG.Polygon polygon = polyOuterRing.ToGeometry(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs index cfde1fee8c..97983c42bf 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/GisFeatureGeometriesToHost/PolylineListToHostConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.ArcGIS3.Geometry.GisFeatureGeometriesToHost; -public class PolylineListToHostConverter : IRawConversion, ACG.Polyline> +public class PolylineListToHostConverter : ITypedConverter, ACG.Polyline> { - private readonly IRawConversion _polylineConverter; + private readonly ITypedConverter _polylineConverter; - public PolylineListToHostConverter(IRawConversion polylineConverter) + public PolylineListToHostConverter(ITypedConverter polylineConverter) { _polylineConverter = polylineConverter; } - public ACG.Polyline RawConvert(List target) + public ACG.Polyline Convert(List target) { if (target.Count == 0) { @@ -21,7 +21,7 @@ public ACG.Polyline RawConvert(List target) List polyList = new(); foreach (SOG.Polyline poly in target) { - ACG.Polyline arcgisPoly = _polylineConverter.RawConvert(poly); + ACG.Polyline arcgisPoly = _polylineConverter.Convert(poly); polyList.Add(arcgisPoly); } return new ACG.PolylineBuilderEx(polyList, ACG.AttributeFlags.HasZ).ToGeometry(); 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 635d47ecbc..ec46307cfc 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 @@ -6,18 +6,18 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; //TODO: Ellipses don't convert correctly, see Autocad test stream //[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public CurveToHostConverter(IRawConversion pointConverter) + public CurveToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Arc)target); + public object Convert(Base target) => Convert((SOG.Arc)target); - public ACG.Polyline RawConvert(SOG.Arc target) + 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 @@ -48,7 +48,7 @@ public ACG.Polyline RawConvert(SOG.Arc target) pointsOriginal.Add(pointOnArc); } - var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); + var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); return new ACG.PolylineBuilderEx(points, 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 c9437eac81..cff9770e7d 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 @@ -5,18 +5,18 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CircleToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class CircleToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public CircleToHostConverter(IRawConversion pointConverter) + public CircleToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Circle)target); + public object Convert(Base target) => Convert((SOG.Circle)target); - public ACG.Polyline RawConvert(SOG.Circle target) + public ACG.Polyline Convert(SOG.Circle target) { // Determine the number of vertices to create along the cirlce int numVertices = Math.Max((int)target.length, 100); // Determine based on desired segment length or other criteria @@ -46,7 +46,7 @@ public ACG.Polyline RawConvert(SOG.Circle target) pointsOriginal.Add(pointsOriginal[0]); } - var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); + var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); } } 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 511350cd71..94ee04b951 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 @@ -6,18 +6,18 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; //TODO: Ellipses don't convert correctly, see Autocad test stream // [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class EllipseToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public EllipseToHostConverter(IRawConversion pointConverter) + public EllipseToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Ellipse)target); + public object Convert(Base target) => Convert((SOG.Ellipse)target); - public ACG.Polyline RawConvert(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 @@ -47,7 +47,7 @@ public ACG.Polyline RawConvert(SOG.Ellipse target) pointsOriginal.Add(pointsOriginal[0]); } - var points = pointsOriginal.Select(x => _pointConverter.RawConvert(x)); + var points = pointsOriginal.Select(x => _pointConverter.Convert(x)); return new ACG.PolylineBuilderEx(points, 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 761b20e0b6..60a1447d7b 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 @@ -5,21 +5,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineSingleToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class LineSingleToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public LineSingleToHostConverter(IRawConversion pointConverter) + public LineSingleToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Line)target); + public object Convert(Base target) => Convert((SOG.Line)target); - public ACG.Polyline RawConvert(SOG.Line target) + public ACG.Polyline Convert(SOG.Line target) { List originalPoints = new() { target.start, target.end }; - IEnumerable points = originalPoints.Select(x => _pointConverter.RawConvert(x)); + IEnumerable points = originalPoints.Select(x => _pointConverter.Convert(x)); return new ACG.PolylineBuilderEx(points, ACG.AttributeFlags.HasZ).ToGeometry(); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs index 498c51caae..8de4c957e4 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/MeshToHostConverter.cs @@ -5,19 +5,19 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class MeshToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion, ACG.Multipatch> _meshConverter; + private readonly ITypedConverter, ACG.Multipatch> _meshConverter; - public MeshToHostConverter(IRawConversion, ACG.Multipatch> meshConverter) + public MeshToHostConverter(ITypedConverter, ACG.Multipatch> meshConverter) { _meshConverter = meshConverter; } - public object Convert(Base target) => RawConvert((SOG.Mesh)target); + public object Convert(Base target) => Convert((SOG.Mesh)target); - public ACG.Multipatch RawConvert(SOG.Mesh target) + public ACG.Multipatch Convert(SOG.Mesh target) { - return _meshConverter.RawConvert(new List { target }); + return _meshConverter.Convert(new List { target }); } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs index 3e81f2f983..abf671574a 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/ISpeckleObjectToHost/PointToHostConverter.cs @@ -5,14 +5,14 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostConverter : ISpeckleObjectToHostConversion +public class PointToHostConverter : IToHostTopLevelConverter { - private readonly IRawConversion, ACG.Multipoint> _pointConverter; + private readonly ITypedConverter, ACG.Multipoint> _pointConverter; - public PointToHostConverter(IRawConversion, ACG.Multipoint> pointConverter) + public PointToHostConverter(ITypedConverter, ACG.Multipoint> pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => _pointConverter.RawConvert(new List { (SOG.Point)target }); + public object Convert(Base target) => _pointConverter.Convert(new List { (SOG.Point)target }); } 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 fac6239f52..35adddb385 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 @@ -5,23 +5,23 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class PolycurveToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly ISpeckleConverterToHost _toHostConverter; + private readonly ITypedConverter _pointConverter; + private readonly IRootToHostConverter _converter; public PolycurveToHostConverter( - IRawConversion pointConverter, - ISpeckleConverterToHost toHostConverter + ITypedConverter pointConverter, + IRootToHostConverter converter ) { _pointConverter = pointConverter; - _toHostConverter = toHostConverter; + _converter = converter; } - public object Convert(Base target) => RawConvert((SOG.Polycurve)target); + public object Convert(Base target) => Convert((SOG.Polycurve)target); - public ACG.Polyline RawConvert(SOG.Polycurve target) + public ACG.Polyline Convert(SOG.Polycurve target) { List points = new(); foreach (var segment in target.segments) @@ -30,7 +30,7 @@ public ACG.Polyline RawConvert(SOG.Polycurve target) { throw new NotImplementedException("Polycurves with arc segments are not supported"); } - ACG.Polyline converted = (ACG.Polyline)_toHostConverter.Convert((Base)segment); + ACG.Polyline converted = (ACG.Polyline)_converter.Convert((Base)segment); List newPts = converted.Points.ToList(); // reverse new segment if needed 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 8cf283f144..6615607b98 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 @@ -5,21 +5,21 @@ namespace Speckle.Converters.ArcGIS3.Geometry.ISpeckleObjectToHost; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolylineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class PolylineToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public PolylineToHostConverter(IRawConversion pointConverter) + public PolylineToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Polyline)target); + public object Convert(Base target) => Convert((SOG.Polyline)target); - public ACG.Polyline RawConvert(SOG.Polyline target) + public ACG.Polyline Convert(SOG.Polyline target) { List originalPts = target.GetPoints(); - var points = originalPts.Select(x => _pointConverter.RawConvert(x)).ToList(); + var points = originalPts.Select(x => _pointConverter.Convert(x)).ToList(); if (target.closed && originalPts[0] != originalPts[^1]) { points.Add(points[0]); 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 b51e099727..d444c193ad 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointSingleToHostConverter.cs @@ -6,7 +6,7 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class PointToHostConverter : IRawConversion +public class PointToHostConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -15,9 +15,9 @@ public PointToHostConverter(IConversionContextStack contextStack) _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((SOG.Point)target); + public object Convert(Base target) => Convert((SOG.Point)target); - public ACG.MapPoint RawConvert(SOG.Point target) + public ACG.MapPoint Convert(SOG.Point target) { double scaleFactor = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); return new ACG.MapPointBuilderEx( diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs index 6d0607b7e6..96a2efe233 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/PointToSpeckleConverter.cs @@ -5,7 +5,7 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class PointToSpeckleConverter : IRawConversion +public class PointToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -14,7 +14,7 @@ public PointToSpeckleConverter(IConversionContextStack contextStack) _contextStack = contextStack; } - public SOG.Point RawConvert(MapPoint target) + public SOG.Point Convert(MapPoint target) { try { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs index 1aabe1e188..0c9572c24e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Geometry/SegmentCollectionToSpeckleConverter.cs @@ -4,18 +4,18 @@ namespace Speckle.Converters.ArcGIS3.Geometry; -public class SegmentCollectionToSpeckleConverter : IRawConversion +public class SegmentCollectionToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _bezierConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _bezierConverter; public SegmentCollectionToSpeckleConverter( IConversionContextStack contextStack, - IRawConversion pointConverter, - IRawConversion arcConverter, - IRawConversion bezierConverter + ITypedConverter pointConverter, + ITypedConverter arcConverter, + ITypedConverter bezierConverter ) { _contextStack = contextStack; @@ -24,7 +24,7 @@ public SegmentCollectionToSpeckleConverter( _bezierConverter = bezierConverter; } - public SOG.Polyline RawConvert(ACG.ReadOnlySegmentCollection target) + public SOG.Polyline Convert(ACG.ReadOnlySegmentCollection target) { // https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8480.html double len = 0; @@ -38,20 +38,20 @@ public SOG.Polyline RawConvert(ACG.ReadOnlySegmentCollection target) switch (segment.SegmentType) { case ACG.SegmentType.Line: - points.Add(_pointConverter.RawConvert(segment.StartPoint)); - points.Add(_pointConverter.RawConvert(segment.EndPoint)); + points.Add(_pointConverter.Convert(segment.StartPoint)); + points.Add(_pointConverter.Convert(segment.EndPoint)); break; case ACG.SegmentType.Bezier: var segmentBezier = (ACG.CubicBezierSegment)segment; - points.AddRange(_bezierConverter.RawConvert(segmentBezier).GetPoints()); + points.AddRange(_bezierConverter.Convert(segmentBezier).GetPoints()); break; case ACG.SegmentType.EllipticArc: var segmentElliptic = (ACG.EllipticArcSegment)segment; - points.AddRange(_arcConverter.RawConvert(segmentElliptic).GetPoints()); + points.AddRange(_arcConverter.Convert(segmentElliptic).GetPoints()); break; } } - // var box = _boxConverter.RawConvert(target.Extent); + // var box = _boxConverter.Convert(target.Extent); SOG.Polyline polyline = new(points.SelectMany(pt => new[] { pt.x, pt.y, pt.z }).ToList(), _contextStack.Current.SpeckleUnits) { }; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs index 614cab1729..e05be2a71e 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/FeatureClassToHostConverter.cs @@ -10,15 +10,15 @@ namespace Speckle.Converters.ArcGIS3.Layers; -public class FeatureClassToHostConverter : IRawConversion +public class FeatureClassToHostConverter : ITypedConverter { - private readonly IRawConversion, ACG.Geometry> _gisGeometryConverter; + private readonly ITypedConverter, ACG.Geometry> _gisGeometryConverter; private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISFieldUtils _fieldsUtils; private readonly IArcGISProjectUtils _arcGISProjectUtils; public FeatureClassToHostConverter( - IRawConversion, ACG.Geometry> gisGeometryConverter, + ITypedConverter, ACG.Geometry> gisGeometryConverter, IFeatureClassUtils featureClassUtils, IArcGISFieldUtils fieldsUtils, IArcGISProjectUtils arcGISProjectUtils @@ -72,7 +72,7 @@ private List RecoverOutdatedGisFeatures(VectorLayer target) return gisFeatures; } - public FeatureClass RawConvert(VectorLayer target) + public FeatureClass Convert(VectorLayer target) { GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs index 28a8bdaa6f..2011596618 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToHostConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.ArcGIS3.Layers; -public class PointcloudLayerToHostConverter : IRawConversion +public class PointcloudLayerToHostConverter : ITypedConverter { - public object Convert(Base target) => RawConvert((VectorLayer)target); + public object Convert(Base target) => Convert((VectorLayer)target); - public LasDatasetLayer RawConvert(VectorLayer target) + public LasDatasetLayer Convert(VectorLayer target) { // POC: throw new NotImplementedException($"Receiving Pointclouds is not supported"); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs index d7603ab493..f4d3281629 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/PointcloudLayerToSpeckleConverter.cs @@ -10,16 +10,16 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(LasDatasetLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointCloudToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion + : IToSpeckleTopLevelConverter, + ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public PointCloudToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -68,10 +68,10 @@ private int GetPointColor(LasPoint pt, object renderer) public Base Convert(object target) { - return RawConvert((LasDatasetLayer)target); + return Convert((LasDatasetLayer)target); } - public SGIS.VectorLayer RawConvert(LasDatasetLayer target) + public SGIS.VectorLayer Convert(LasDatasetLayer target) { SGIS.VectorLayer speckleLayer = new(); @@ -102,7 +102,7 @@ public SGIS.VectorLayer RawConvert(LasDatasetLayer target) { using (LasPoint pt = ptCursor.Current) { - specklePts.Add(_pointConverter.RawConvert(pt.ToMapPoint())); + specklePts.Add(_pointConverter.Convert(pt.ToMapPoint())); values.Add(pt.ClassCode); int color = GetPointColor(pt, renderer); speckleColors.Add(color); @@ -116,7 +116,7 @@ public SGIS.VectorLayer RawConvert(LasDatasetLayer target) points = specklePts.SelectMany(pt => new List() { pt.x, pt.y, pt.z }).ToList(), colors = speckleColors, sizes = values, - bbox = _boxConverter.RawConvert(target.QueryExtent()), + bbox = _boxConverter.Convert(target.QueryExtent()), units = _contextStack.Current.SpeckleUnits }; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs index 9e57a0515f..f97cbc5dd8 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToHostConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(RasterLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RasterLayerToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class RasterLayerToHostConverter : IToHostTopLevelConverter, ITypedConverter { - public object Convert(Base target) => RawConvert((RasterLayer)target); + public object Convert(Base target) => Convert((RasterLayer)target); - public string RawConvert(RasterLayer target) + public string Convert(RasterLayer target) { // POC: throw new NotImplementedException($"Receiving Rasters is not supported"); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs index 76302858a1..f5f96584ad 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/RasterLayerToSpeckleConverter.cs @@ -10,15 +10,13 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(RasterLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RasterLayerToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion +public class RasterLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _gisRasterConverter; + private readonly ITypedConverter _gisRasterConverter; private readonly IConversionContextStack _contextStack; public RasterLayerToSpeckleConverter( - IRawConversion gisRasterConverter, + ITypedConverter gisRasterConverter, IConversionContextStack contextStack ) { @@ -28,10 +26,10 @@ IConversionContextStack contextStack public Base Convert(object target) { - return RawConvert((RasterLayer)target); + return Convert((RasterLayer)target); } - public SGIS.RasterLayer RawConvert(RasterLayer target) + public SGIS.RasterLayer Convert(RasterLayer target) { var speckleLayer = new SGIS.RasterLayer(); @@ -63,7 +61,7 @@ public SGIS.RasterLayer RawConvert(RasterLayer target) speckleLayer.units = _contextStack.Current.SpeckleUnits; // write details about the Raster - RasterElement element = _gisRasterConverter.RawConvert(target.GetRaster()); + RasterElement element = _gisRasterConverter.Convert(target.GetRaster()); speckleLayer.elements.Add(element); return speckleLayer; diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs index 2b11816d2f..b330f26dc5 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToHostConverter.cs @@ -8,7 +8,7 @@ namespace Speckle.Converters.ArcGIS3.Layers; -public class TableLayerToHostConverter : IRawConversion +public class TableLayerToHostConverter : ITypedConverter { private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISFieldUtils _fieldsUtils; @@ -25,7 +25,7 @@ IArcGISFieldUtils fieldsUtils _fieldsUtils = fieldsUtils; } - public Table RawConvert(VectorLayer target) + public Table Convert(VectorLayer target) { string databasePath = _arcGISProjectUtils.GetDatabasePath(); FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new(new Uri(databasePath)); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs index 8f88a2df31..31ee4bf6fc 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/TableToSpeckleConverter.cs @@ -10,14 +10,14 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(StandaloneTable), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class StandaloneTableToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion + : IToSpeckleTopLevelConverter, + ITypedConverter { - private readonly IRawConversion _gisFeatureConverter; + private readonly ITypedConverter _gisFeatureConverter; private readonly IConversionContextStack _contextStack; public StandaloneTableToSpeckleConverter( - IRawConversion gisFeatureConverter, + ITypedConverter gisFeatureConverter, IConversionContextStack contextStack ) { @@ -27,10 +27,10 @@ IConversionContextStack contextStack public Base Convert(object target) { - return RawConvert((StandaloneTable)target); + return Convert((StandaloneTable)target); } - public VectorLayer RawConvert(StandaloneTable target) + public VectorLayer Convert(StandaloneTable target) { VectorLayer speckleLayer = new() { name = target.Name, }; @@ -57,7 +57,7 @@ public VectorLayer RawConvert(StandaloneTable target) // Same IDisposable issue appears to happen on Row class too. Docs say it should always be disposed of manually by the caller. using (Row row = rowCursor.Current) { - GisFeature element = _gisFeatureConverter.RawConvert(row); + GisFeature element = _gisFeatureConverter.Convert(row); // replace "attributes", to remove non-visible layer attributes Base elementAttributes = new(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs index 0db9ec6554..8648970fa1 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToHostConverter.cs @@ -10,17 +10,17 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(VectorLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class VectorLayerToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class VectorLayerToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _featureClassConverter; - private readonly IRawConversion _tableConverter; - private readonly IRawConversion _pointcloudLayerConverter; + private readonly ITypedConverter _featureClassConverter; + private readonly ITypedConverter _tableConverter; + private readonly ITypedConverter _pointcloudLayerConverter; private readonly IFeatureClassUtils _featureClassUtils; public VectorLayerToHostConverter( - IRawConversion featureClassConverter, - IRawConversion tableConverter, - IRawConversion pointcloudLayerConverter, + ITypedConverter featureClassConverter, + ITypedConverter tableConverter, + ITypedConverter pointcloudLayerConverter, IFeatureClassUtils featureClassUtils ) { @@ -30,27 +30,27 @@ IFeatureClassUtils featureClassUtils _featureClassUtils = featureClassUtils; } - public object Convert(Base target) => RawConvert((VectorLayer)target); + public object Convert(Base target) => Convert((VectorLayer)target); - public string RawConvert(VectorLayer target) + public string Convert(VectorLayer target) { // pointcloud layers need to be checked separately, because there is no ArcGIS Geometry type // for Pointcloud. In ArcGIS it's a completely different layer class, so "GetLayerGeometryType" // will return "Invalid" type if (target.geomType == "Pointcloud") { - return _pointcloudLayerConverter.RawConvert(target).Name; + return _pointcloudLayerConverter.Convert(target).Name; } // check if Speckle VectorLayer should become a FeatureClass, StandaloneTable or PointcloudLayer GeometryType geomType = _featureClassUtils.GetLayerGeometryType(target); if (geomType != GeometryType.Unknown) // feature class { - return _featureClassConverter.RawConvert(target).GetName(); + return _featureClassConverter.Convert(target).GetName(); } else // table { - return _tableConverter.RawConvert(target).GetName(); + return _tableConverter.Convert(target).GetName(); } } } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs index 017178551d..02a0917b0f 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Layers/VectorLayerToSpeckleConverter.cs @@ -10,15 +10,15 @@ namespace Speckle.Converters.ArcGIS3.Layers; [NameAndRankValue(nameof(FeatureLayer), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class VectorLayerToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class VectorLayerToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _gisFeatureConverter; + private readonly ITypedConverter _gisFeatureConverter; private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISFieldUtils _fieldsUtils; private readonly IConversionContextStack _contextStack; public VectorLayerToSpeckleConverter( - IRawConversion gisFeatureConverter, + ITypedConverter gisFeatureConverter, IFeatureClassUtils featureClassUtils, IArcGISFieldUtils fieldsUtils, IConversionContextStack contextStack @@ -32,7 +32,7 @@ IConversionContextStack contextStack public Base Convert(object target) { - return RawConvert((FeatureLayer)target); + return Convert((FeatureLayer)target); } private string SpeckleGeometryType(string nativeGeometryType) @@ -57,7 +57,7 @@ private string SpeckleGeometryType(string nativeGeometryType) return spekleGeometryType; } - public VectorLayer RawConvert(FeatureLayer target) + public VectorLayer Convert(FeatureLayer target) { VectorLayer speckleLayer = new(); @@ -115,7 +115,7 @@ public VectorLayer RawConvert(FeatureLayer target) // Same IDisposable issue appears to happen on Row class too. Docs say it should always be disposed of manually by the caller. using (Row row = rowCursor.Current) { - GisFeature element = _gisFeatureConverter.RawConvert(row); + GisFeature element = _gisFeatureConverter.Convert(row); // replace element "attributes", to remove those non-visible on Layer level Base elementAttributes = new(); diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs index 89d079d69f..49f46aba53 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/FeatureClassUtils.cs @@ -31,7 +31,7 @@ public void AddFeaturesToFeatureClass( FeatureClass newFeatureClass, List gisFeatures, List fields, - IRawConversion, ACG.Geometry> gisGeometryConverter + ITypedConverter, ACG.Geometry> gisGeometryConverter ) { foreach (GisFeature feat in gisFeatures) @@ -41,7 +41,7 @@ public void AddFeaturesToFeatureClass( if (feat.geometry != null) { List geometryToConvert = feat.geometry; - ACG.Geometry nativeShape = gisGeometryConverter.RawConvert(geometryToConvert); + ACG.Geometry nativeShape = gisGeometryConverter.Convert(geometryToConvert); rowBuffer[newFeatureClass.GetDefinition().GetShapeField()] = nativeShape; } else diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs index 76e753ef02..2946ac3931 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/IFeatureClassUtils.cs @@ -12,7 +12,7 @@ void AddFeaturesToFeatureClass( FeatureClass newFeatureClass, List gisFeatures, List fields, - IRawConversion, ACG.Geometry> gisGeometryConverter + ITypedConverter, ACG.Geometry> gisGeometryConverter ); void AddNonGISFeaturesToFeatureClass( FeatureClass newFeatureClass, diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs index a04d8936a9..1682b8774c 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/NonNativeFeaturesUtils.cs @@ -13,14 +13,14 @@ namespace Speckle.Converters.ArcGIS3.Utils; public class NonNativeFeaturesUtils : INonNativeFeaturesUtils { - private readonly IRawConversion, ACG.Geometry> _gisGeometryConverter; + private readonly ITypedConverter, ACG.Geometry> _gisGeometryConverter; private readonly IArcGISFieldUtils _fieldsUtils; private readonly IFeatureClassUtils _featureClassUtils; private readonly IArcGISProjectUtils _arcGISProjectUtils; private readonly IConversionContextStack _contextStack; public NonNativeFeaturesUtils( - IRawConversion, ACG.Geometry> gisGeometryConverter, + ITypedConverter, ACG.Geometry> gisGeometryConverter, IArcGISFieldUtils fieldsUtils, IFeatureClassUtils featureClassUtils, IArcGISProjectUtils arcGISProjectUtils, diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs index 5b2f42298d..375d2c8170 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/AutocadConverterModule.cs @@ -11,10 +11,7 @@ public class AutocadConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); - // POC: below comment maybe incorrect (sorry if I wrote that!) stateless services - // can be injected as Singleton(), only where we have state we wish to wrap in a unit of work - builder.AddScoped(); + builder.AddConverterCommon(); // single stack per conversion builder.AddScoped, AutocadConversionContextStack>(); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadRootToHostConverter.cs similarity index 85% rename from DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs rename to DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadRootToHostConverter.cs index 85112323be..4a53d211c2 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadRootToHostConverter.cs @@ -6,13 +6,13 @@ namespace Speckle.Converters.Autocad; -public class AutocadConverterToSpeckle : ISpeckleConverterToSpeckle +public class AutocadRootToHostConverter : IRootToSpeckleConverter { - private readonly IFactory _toSpeckle; + private readonly IFactory _toSpeckle; private readonly IConversionContextStack _contextStack; - public AutocadConverterToSpeckle( - IFactory toSpeckle, + public AutocadRootToHostConverter( + IFactory toSpeckle, IConversionContextStack contextStack ) { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs index 3180b4ef94..b5b611e2d9 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/AutocadToSpeckleUnitConverter.cs @@ -7,25 +7,27 @@ namespace Speckle.Converters.Autocad; public class AutocadToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private readonly Dictionary _unitMapping = new(); + private static readonly IReadOnlyDictionary s_unitsMapping = Create(); - public AutocadToSpeckleUnitConverter() + private static IReadOnlyDictionary Create() { + var dict = new Dictionary(); // POC: we should have a unit test to confirm these are as expected and don't change - _unitMapping[UnitsValue.Undefined] = Units.Meters; - _unitMapping[UnitsValue.Millimeters] = Units.Millimeters; - _unitMapping[UnitsValue.Centimeters] = Units.Centimeters; - _unitMapping[UnitsValue.Meters] = Units.Meters; - _unitMapping[UnitsValue.Kilometers] = Units.Kilometers; - _unitMapping[UnitsValue.Inches] = Units.Inches; - _unitMapping[UnitsValue.Feet] = Units.Feet; - _unitMapping[UnitsValue.Yards] = Units.Yards; - _unitMapping[UnitsValue.Miles] = Units.Miles; + dict[UnitsValue.Undefined] = Units.Meters; + dict[UnitsValue.Millimeters] = Units.Millimeters; + dict[UnitsValue.Centimeters] = Units.Centimeters; + dict[UnitsValue.Meters] = Units.Meters; + dict[UnitsValue.Kilometers] = Units.Kilometers; + dict[UnitsValue.Inches] = Units.Inches; + dict[UnitsValue.Feet] = Units.Feet; + dict[UnitsValue.Yards] = Units.Yards; + dict[UnitsValue.Miles] = Units.Miles; + return dict; } public string ConvertOrThrow(UnitsValue hostUnit) { - if (_unitMapping.TryGetValue(hostUnit, out string value)) + if (s_unitsMapping.TryGetValue(hostUnit, out string value)) { return value; } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems index 100e5186db..3644c81cc1 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/Speckle.Converters.AutocadShared.projitems @@ -9,7 +9,7 @@ Speckle.Converters.AutocadShared - + diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs index d5653a7eb1..0d639ab956 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/ArcToHostConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ArcToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class ArcToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _planeConverter; private readonly IConversionContextStack _contextStack; public ArcToHostConverter( - IRawConversion arcConverter, - IRawConversion planeConverter, + ITypedConverter arcConverter, + ITypedConverter planeConverter, IConversionContextStack contextStack ) { @@ -22,16 +22,16 @@ public ArcToHostConverter( _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((SOG.Arc)target); + public object Convert(Base target) => Convert((SOG.Arc)target); - public ADB.Arc RawConvert(SOG.Arc target) + public ADB.Arc Convert(SOG.Arc target) { // the most reliable method to convert to autocad convention is to calculate from start, end, and midpoint // because of different plane & start/end angle conventions - AG.CircularArc3d circularArc = _arcConverter.RawConvert(target); + AG.CircularArc3d circularArc = _arcConverter.Convert(target); // calculate adjusted start and end angles from circularArc reference - AG.Plane plane = _planeConverter.RawConvert(target.plane); + AG.Plane plane = _planeConverter.Convert(target.plane); double angle = circularArc.ReferenceVector.AngleOnPlane(plane); double startAngle = circularArc.StartAngle + angle; double endAngle = circularArc.EndAngle + angle; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs index fa7b5e3c58..2458753639 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/AutocadPolycurveToHostConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.Autocad2023.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Autocad.AutocadPolycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class AutocadPolycurveToHostConverter : ISpeckleObjectToHostConversion +public class AutocadPolycurveToHostConverter : IToHostTopLevelConverter { - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _polyline2dConverter; - private readonly IRawConversion _polyline3dConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _polyline2dConverter; + private readonly ITypedConverter _polyline3dConverter; public AutocadPolycurveToHostConverter( - IRawConversion polylineConverter, - IRawConversion polyline2dConverter, - IRawConversion polyline3dConverter + ITypedConverter polylineConverter, + ITypedConverter polyline2dConverter, + ITypedConverter polyline3dConverter ) { _polylineConverter = polylineConverter; @@ -29,18 +29,18 @@ public object Convert(Base target) switch (polycurve.polyType) { case SOG.Autocad.AutocadPolyType.Light: - return _polylineConverter.RawConvert(polycurve); + return _polylineConverter.Convert(polycurve); case SOG.Autocad.AutocadPolyType.Simple2d: case SOG.Autocad.AutocadPolyType.FitCurve2d: case SOG.Autocad.AutocadPolyType.CubicSpline2d: case SOG.Autocad.AutocadPolyType.QuadSpline2d: - return _polyline2dConverter.RawConvert(polycurve); + return _polyline2dConverter.Convert(polycurve); case SOG.Autocad.AutocadPolyType.Simple3d: case SOG.Autocad.AutocadPolyType.CubicSpline3d: case SOG.Autocad.AutocadPolyType.QuadSpline3d: - return _polyline3dConverter.RawConvert(polycurve); + return _polyline3dConverter.Convert(polycurve); default: throw new SpeckleConversionException("Unknown poly type for AutocadPolycurve"); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs index a83a6b1845..6ec53e825f 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CircleToHostConverter.cs @@ -6,15 +6,15 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CircleToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class CircleToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; private readonly IConversionContextStack _contextStack; public CircleToHostConverter( - IRawConversion pointConverter, - IRawConversion vectorConverter, + ITypedConverter pointConverter, + ITypedConverter vectorConverter, IConversionContextStack contextStack ) { @@ -23,12 +23,12 @@ public CircleToHostConverter( _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((SOG.Circle)target); + public object Convert(Base target) => Convert((SOG.Circle)target); - public ADB.Circle RawConvert(SOG.Circle target) + public ADB.Circle Convert(SOG.Circle target) { - AG.Vector3d normal = _vectorConverter.RawConvert(target.plane.normal); - AG.Point3d origin = _pointConverter.RawConvert(target.plane.origin); + AG.Vector3d normal = _vectorConverter.Convert(target.plane.normal); + AG.Point3d origin = _pointConverter.Convert(target.plane.origin); double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); if (target.radius is null) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs index cc25a40304..2f49ebad17 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/CurveToHostConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.AutocadShared.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; - public CurveToHostConverter(IRawConversion curveConverter) + public CurveToHostConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } - public object Convert(Base target) => RawConvert((SOG.Curve)target); + public object Convert(Base target) => Convert((SOG.Curve)target); - public ADB.Curve RawConvert(SOG.Curve target) => ADB.Curve.CreateFromGeCurve(_curveConverter.RawConvert(target)); + public ADB.Curve Convert(SOG.Curve target) => ADB.Curve.CreateFromGeCurve(_curveConverter.Convert(target)); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs index 708ea51f69..58a59a6803 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/EllipseToHostConverter.cs @@ -6,15 +6,15 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class EllipseToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; private readonly IConversionContextStack _contextStack; public EllipseToHostConverter( - IRawConversion pointConverter, - IRawConversion vectorConverter, + ITypedConverter pointConverter, + ITypedConverter vectorConverter, IConversionContextStack contextStack ) { @@ -23,15 +23,15 @@ public EllipseToHostConverter( _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((SOG.Ellipse)target); + public object Convert(Base target) => Convert((SOG.Ellipse)target); /// Throws if any ellipse radius value is null. - public ADB.Ellipse RawConvert(SOG.Ellipse target) + public ADB.Ellipse Convert(SOG.Ellipse target) { double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); - AG.Point3d origin = _pointConverter.RawConvert(target.plane.origin); - AG.Vector3d normal = _vectorConverter.RawConvert(target.plane.normal); - AG.Vector3d xAxis = _vectorConverter.RawConvert(target.plane.xdir); + AG.Point3d origin = _pointConverter.Convert(target.plane.origin); + AG.Vector3d normal = _vectorConverter.Convert(target.plane.normal); + AG.Vector3d xAxis = _vectorConverter.Convert(target.plane.xdir); // POC: how possibly we might have firstRadius and secondRadius is possibly null? if (target.firstRadius is null || target.secondRadius is null) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs index b07a33c594..d1144816a8 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/LineToHostConverter.cs @@ -5,17 +5,17 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class LineToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public LineToHostConverter(IRawConversion pointConverter) + public LineToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Line)target); + public object Convert(Base target) => Convert((SOG.Line)target); - public ADB.Line RawConvert(SOG.Line target) => - new(_pointConverter.RawConvert(target.start), _pointConverter.RawConvert(target.end)); + public ADB.Line Convert(SOG.Line target) => + new(_pointConverter.Convert(target.start), _pointConverter.Convert(target.end)); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs index e75aa5e91d..5a90a27d1d 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/MeshToHostConverter.cs @@ -7,13 +7,13 @@ namespace Speckle.Converters.Autocad.Geometry; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class MeshToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; private readonly IConversionContextStack _contextStack; public MeshToHostConverter( - IRawConversion pointConverter, + ITypedConverter pointConverter, IConversionContextStack contextStack ) { @@ -21,18 +21,18 @@ public MeshToHostConverter( _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((SOG.Mesh)target); + public object Convert(Base target) => Convert((SOG.Mesh)target); /// /// Mesh conversion requires transaction since it's vertices needed to be added into database in advance.. /// - public ADB.PolyFaceMesh RawConvert(SOG.Mesh target) + public ADB.PolyFaceMesh Convert(SOG.Mesh target) { target.TriangulateMesh(true); // get vertex points using AG.Point3dCollection vertices = new(); - List points = target.GetPoints().Select(o => _pointConverter.RawConvert(o)).ToList(); + List points = target.GetPoints().Select(o => _pointConverter.Convert(o)).ToList(); foreach (var point in points) { vertices.Add(point); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs index 177a5f7808..5816423983 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PointToHostConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class PointToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public PointToHostConverter(IRawConversion pointConverter) + public PointToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Point)target); + public object Convert(Base target) => Convert((SOG.Point)target); - public ADB.DBPoint RawConvert(SOG.Point target) => new(_pointConverter.RawConvert(target)); + public ADB.DBPoint Convert(SOG.Point target) => new(_pointConverter.Convert(target)); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs index a3c458f916..7ba28edb9e 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolycurveToHostConverter.cs @@ -10,14 +10,14 @@ namespace Speckle.Converters.AutocadShared.ToHost.Geometry; /// Otherwise we convert it as spline (list of ADB.Entity) that switch cases according to each segment type. /// [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostConverter : ISpeckleObjectToHostConversion +public class PolycurveToHostConverter : IToHostTopLevelConverter { - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion> _splineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter> _splineConverter; public PolycurveToHostConverter( - IRawConversion polylineConverter, - IRawConversion> splineConverter + ITypedConverter polylineConverter, + ITypedConverter> splineConverter ) { _polylineConverter = polylineConverter; @@ -32,11 +32,11 @@ public object Convert(Base target) if (convertAsSpline || !isPlanar) { - return _splineConverter.RawConvert(polycurve); + return _splineConverter.Convert(polycurve); } else { - return _polylineConverter.RawConvert(polycurve); + return _polylineConverter.Convert(polycurve); } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs index bf5fa03bf8..7bbf367950 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/PolylineToHostConverter.cs @@ -5,21 +5,21 @@ namespace Speckle.Converters.Autocad.ToHost.Geometry; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolylineToHostConverter : ISpeckleObjectToHostConversion, IRawConversion +public class PolylineToHostConverter : IToHostTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public PolylineToHostConverter(IRawConversion pointConverter) + public PolylineToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } - public object Convert(Base target) => RawConvert((SOG.Polyline)target); + public object Convert(Base target) => Convert((SOG.Polyline)target); - public ADB.Polyline3d RawConvert(SOG.Polyline target) + public ADB.Polyline3d Convert(SOG.Polyline target) { AG.Point3dCollection vertices = new(); - target.GetPoints().ForEach(o => vertices.Add(_pointConverter.RawConvert(o))); + target.GetPoints().ForEach(o => vertices.Add(_pointConverter.Convert(o))); return new(ADB.Poly3dType.SimplePoly, vertices, target.closed); } } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs index 8271b5751b..113ae43963 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Geometry/SpeckleFallbackToHostConversion.cs @@ -5,18 +5,18 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SpeckleFallbackToAutocadConversion - : ISpeckleObjectToHostConversion, - IRawConversion> +public class SpeckleFallbackToAutocadTopLevelConverter + : IToHostTopLevelConverter, + ITypedConverter> { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _meshConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _meshConverter; - public SpeckleFallbackToAutocadConversion( - IRawConversion lineConverter, - IRawConversion polylineConverter, - IRawConversion meshConverter + public SpeckleFallbackToAutocadTopLevelConverter( + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter meshConverter ) { _lineConverter = lineConverter; @@ -24,18 +24,18 @@ public SpeckleFallbackToAutocadConversion( _meshConverter = meshConverter; } - public object Convert(Base target) => RawConvert((DisplayableObject)target); + public object Convert(Base target) => Convert((DisplayableObject)target); - public List RawConvert(DisplayableObject target) + public List Convert(DisplayableObject target) { var result = new List(); foreach (var item in target.displayValue) { ADB.Entity x = item switch { - SOG.Line line => _lineConverter.RawConvert(line), - SOG.Polyline polyline => _polylineConverter.RawConvert(polyline), - SOG.Mesh mesh => _meshConverter.RawConvert(mesh), + SOG.Line line => _lineConverter.Convert(line), + SOG.Polyline polyline => _polylineConverter.Convert(polyline), + SOG.Mesh mesh => _meshConverter.Convert(mesh), _ => throw new NotSupportedException($"Found unsupported fallback geometry: {item.GetType()}") }; result.Add(x); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs index c305245a7b..73158e8970 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/ArcToHostRawConverter.cs @@ -5,31 +5,31 @@ namespace Speckle.Converters.Autocad.ToHost.Raw; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ArcToHostRowConverter : IRawConversion +public class ArcToHostRowConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; public ArcToHostRowConverter( - IRawConversion pointConverter, - IRawConversion vectorConverter + ITypedConverter pointConverter, + ITypedConverter vectorConverter ) { _pointConverter = pointConverter; _vectorConverter = vectorConverter; } - public object Convert(Base target) => RawConvert((SOG.Arc)target); + public object Convert(Base target) => Convert((SOG.Arc)target); - public AG.CircularArc3d RawConvert(SOG.Arc target) + public AG.CircularArc3d Convert(SOG.Arc target) { - AG.Point3d start = _pointConverter.RawConvert(target.startPoint); - AG.Point3d end = _pointConverter.RawConvert(target.endPoint); - AG.Point3d mid = _pointConverter.RawConvert(target.midPoint); + AG.Point3d start = _pointConverter.Convert(target.startPoint); + AG.Point3d end = _pointConverter.Convert(target.endPoint); + AG.Point3d mid = _pointConverter.Convert(target.midPoint); AG.CircularArc3d arc = new(start, mid, end); - AG.Vector3d normal = _vectorConverter.RawConvert(target.plane.normal); - AG.Vector3d xdir = _vectorConverter.RawConvert(target.plane.xdir); + AG.Vector3d normal = _vectorConverter.Convert(target.plane.normal); + AG.Vector3d xdir = _vectorConverter.Convert(target.plane.xdir); arc.SetAxes(normal, xdir); if (target.startAngle is double startAngle && target.endAngle is double endAngle) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs index 62c62b14a2..8c78f79845 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline2dRawConverter.cs @@ -5,13 +5,14 @@ namespace Speckle.Converters.Autocad2023.ToHost.Raw; -public class AutocadPolycurveToHostPolyline2dRawConverter : IRawConversion +public class AutocadPolycurveToHostPolyline2dRawConverter + : ITypedConverter { - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _vectorConverter; private readonly IConversionContextStack _contextStack; public AutocadPolycurveToHostPolyline2dRawConverter( - IRawConversion vectorConverter, + ITypedConverter vectorConverter, IConversionContextStack contextStack ) { @@ -19,7 +20,7 @@ public AutocadPolycurveToHostPolyline2dRawConverter( _contextStack = contextStack; } - public ADB.Polyline2d RawConvert(SOG.Autocad.AutocadPolycurve target) + public ADB.Polyline2d Convert(SOG.Autocad.AutocadPolycurve target) { // check for normal if (target.normal is not SOG.Vector normal) @@ -50,7 +51,7 @@ public ADB.Polyline2d RawConvert(SOG.Autocad.AutocadPolycurve target) } // create the polyline2d using the empty constructor - AG.Vector3d convertedNormal = _vectorConverter.RawConvert(normal); + AG.Vector3d convertedNormal = _vectorConverter.Convert(normal); double convertedElevation = elevation * f; ADB.Polyline2d polyline = new() diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs index b681e436c6..1444d8da6a 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/AutocadPolycurveToHostPolyline3dRawConverter.cs @@ -5,7 +5,8 @@ namespace Speckle.Converters.Autocad2023.ToHost.Raw; -public class AutocadPolycurveToHostPolyline3dRawConverter : IRawConversion +public class AutocadPolycurveToHostPolyline3dRawConverter + : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -14,7 +15,7 @@ public AutocadPolycurveToHostPolyline3dRawConverter(IConversionContextStack +public class AutocadPolycurveToHostPolylineRawConverter : ITypedConverter { - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _vectorConverter; private readonly IConversionContextStack _contextStack; public AutocadPolycurveToHostPolylineRawConverter( - IRawConversion vectorConverter, + ITypedConverter vectorConverter, IConversionContextStack contextStack ) { @@ -19,7 +19,7 @@ public AutocadPolycurveToHostPolylineRawConverter( _contextStack = contextStack; } - public ADB.Polyline RawConvert(SOG.Autocad.AutocadPolycurve target) + public ADB.Polyline Convert(SOG.Autocad.AutocadPolycurve target) { if (target.normal is null || target.elevation is null) { @@ -34,7 +34,7 @@ public ADB.Polyline RawConvert(SOG.Autocad.AutocadPolycurve target) ADB.Polyline polyline = new() { - Normal = _vectorConverter.RawConvert(target.normal), + Normal = _vectorConverter.Convert(target.normal), Elevation = (double)target.elevation * f, Closed = target.closed }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs index fa7046334d..5e3e6cc805 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/CurveToHostRawConverter.cs @@ -2,23 +2,23 @@ namespace Speckle.Converters.AutocadShared.ToHost.Raw; -public class CurveToHostRawConverter : IRawConversion +public class CurveToHostRawConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; public CurveToHostRawConverter( - IRawConversion pointConverter, - IRawConversion intervalConverter + ITypedConverter pointConverter, + ITypedConverter intervalConverter ) { _pointConverter = pointConverter; _intervalConverter = intervalConverter; } - public AG.NurbCurve3d RawConvert(SOG.Curve target) + public AG.NurbCurve3d Convert(SOG.Curve target) { - var points = target.GetPoints().Select(p => _pointConverter.RawConvert(p)).ToList(); + var points = target.GetPoints().Select(p => _pointConverter.Convert(p)).ToList(); if (target.closed && target.periodic) { points = points.GetRange(0, points.Count - target.degree); @@ -67,7 +67,7 @@ public AG.NurbCurve3d RawConvert(SOG.Curve target) curve.MakeClosed(); } - curve.SetInterval(_intervalConverter.RawConvert(target.domain)); + curve.SetInterval(_intervalConverter.Convert(target.domain)); return curve; } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs index 58d03626e9..713266fba4 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/IntervalToHostRawConverter.cs @@ -2,10 +2,10 @@ namespace Speckle.Converters.AutocadShared.ToHost.Raw; -public class IntervalToHostRawConverter : IRawConversion +public class IntervalToHostRawConverter : ITypedConverter { /// Throws if target start or end value is null. - public AG.Interval RawConvert(SOP.Interval target) + public AG.Interval Convert(SOP.Interval target) { // POC: the tolerance might be in some settings or in some context? if (target.start is null || target.end is null) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs index 4928988e81..6b100dd28e 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PlaneToHostRawConverter.cs @@ -3,22 +3,22 @@ namespace Speckle.Converters.Autocad.ToHost.Raw; -public class PlaneToHostRawConverter : IRawConversion +public class PlaneToHostRawConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; public PlaneToHostRawConverter( - IRawConversion pointConverter, - IRawConversion vectorConverter + ITypedConverter pointConverter, + ITypedConverter vectorConverter ) { _pointConverter = pointConverter; _vectorConverter = vectorConverter; } - public object Convert(Base target) => RawConvert((SOG.Plane)target); + public object Convert(Base target) => Convert((SOG.Plane)target); - public AG.Plane RawConvert(SOG.Plane target) => - new(_pointConverter.RawConvert(target.origin), _vectorConverter.RawConvert(target.normal)); + public AG.Plane Convert(SOG.Plane target) => + new(_pointConverter.Convert(target.origin), _vectorConverter.Convert(target.normal)); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs index 26be7f9334..467448fbe8 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PointToHostRawConverter.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.Autocad.ToHost.Raw; -public class PointToHostRawConverter : IRawConversion +public class PointToHostRawConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -13,7 +13,7 @@ public PointToHostRawConverter(IConversionContextStack _contextStack = contextStack; } - public AG.Point3d RawConvert(SOG.Point target) + public AG.Point3d Convert(SOG.Point target) { double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); AG.Point3d point = new(target.x * f, target.y * f, target.z * f); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs index b5a182fa2f..faa13f0167 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostPolylineRawConverter.cs @@ -6,21 +6,21 @@ namespace Speckle.Converters.AutocadShared.ToHost.Raw; /// /// If polycurve segments consist of only with Line and Arc, we convert it as ADB.Polyline. /// -public class PolycurveToHostPolylineRawConverter : IRawConversion +public class PolycurveToHostPolylineRawConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; public PolycurveToHostPolylineRawConverter( IConversionContextStack contextStack, - IRawConversion pointConverter + ITypedConverter pointConverter ) { _contextStack = contextStack; _pointConverter = pointConverter; } - public ADB.Polyline RawConvert(SOG.Polycurve target) + public ADB.Polyline Convert(SOG.Polycurve target) { ADB.Polyline polyline = new() { Closed = target.closed }; AG.Plane plane = @@ -35,10 +35,10 @@ public ADB.Polyline RawConvert(SOG.Polycurve target) switch (segment) { case SOG.Line o: - polyline.AddVertexAt(count, _pointConverter.RawConvert(o.start).Convert2d(plane), 0, 0, 0); + polyline.AddVertexAt(count, _pointConverter.Convert(o.start).Convert2d(plane), 0, 0, 0); if (!target.closed && count == target.segments.Count - 1) { - polyline.AddVertexAt(count + 1, _pointConverter.RawConvert(o.end).Convert2d(plane), 0, 0, 0); + polyline.AddVertexAt(count + 1, _pointConverter.Convert(o.end).Convert2d(plane), 0, 0, 0); } count++; @@ -53,16 +53,16 @@ public ADB.Polyline RawConvert(SOG.Polycurve target) } var bulge = Math.Tan((double)angle / 4) * BulgeDirection(arc.startPoint, arc.midPoint, arc.endPoint); - polyline.AddVertexAt(count, _pointConverter.RawConvert(arc.startPoint).Convert2d(plane), bulge, 0, 0); + polyline.AddVertexAt(count, _pointConverter.Convert(arc.startPoint).Convert2d(plane), bulge, 0, 0); if (!target.closed && count == target.segments.Count - 1) { - polyline.AddVertexAt(count + 1, _pointConverter.RawConvert(arc.endPoint).Convert2d(plane), 0, 0, 0); + polyline.AddVertexAt(count + 1, _pointConverter.Convert(arc.endPoint).Convert2d(plane), 0, 0, 0); } count++; break; case SOG.Spiral o: - List vertices = o.displayValue.GetPoints().Select(_pointConverter.RawConvert).ToList(); + List vertices = o.displayValue.GetPoints().Select(_pointConverter.Convert).ToList(); foreach (AG.Point3d vertex in vertices) { polyline.AddVertexAt(count, vertex.Convert2d(plane), 0, 0, 0); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs index 25dbe01f7e..c9c1e1ce66 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/PolycurveToHostSplineRawConverter.cs @@ -5,18 +5,18 @@ namespace Speckle.Converters.AutocadShared.ToHost.Raw; /// /// Polycurve segments might appear in different ICurve types which requires to handle separately for each segment. /// -public class PolycurveToHostSplineRawConverter : IRawConversion> +public class PolycurveToHostSplineRawConverter : ITypedConverter> { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _curveConverter; public PolycurveToHostSplineRawConverter( - IRawConversion lineConverter, - IRawConversion polylineConverter, - IRawConversion arcConverter, - IRawConversion curveConverter + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter arcConverter, + ITypedConverter curveConverter ) { _lineConverter = lineConverter; @@ -25,7 +25,7 @@ public PolycurveToHostSplineRawConverter( _curveConverter = curveConverter; } - public List RawConvert(SOG.Polycurve target) + public List Convert(SOG.Polycurve target) { // POC: We can improve this once we have IIndex of raw converters and we can get rid of case converters? // POC: Should we join entities? @@ -36,16 +36,16 @@ public PolycurveToHostSplineRawConverter( switch (segment) { case SOG.Arc arc: - list.Add(_arcConverter.RawConvert(arc)); + list.Add(_arcConverter.Convert(arc)); break; case SOG.Line line: - list.Add(_lineConverter.RawConvert(line)); + list.Add(_lineConverter.Convert(line)); break; case SOG.Polyline polyline: - list.Add(_polylineConverter.RawConvert(polyline)); + list.Add(_polylineConverter.Convert(polyline)); break; case SOG.Curve curve: - list.Add(_curveConverter.RawConvert(curve)); + list.Add(_curveConverter.Convert(curve)); break; default: break; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs index 3c44da75f2..5897dcf651 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToHost/Raw/VectorToHostRawConverter.cs @@ -5,7 +5,7 @@ namespace Speckle.Converters.Autocad.ToHost.Raw; -public class VectorToHostRawConverter : IRawConversion +public class VectorToHostRawConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -14,9 +14,9 @@ public VectorToHostRawConverter(IConversionContextStack RawConvert((SOG.Vector)target); + public object Convert(Base target) => Convert((SOG.Vector)target); - public AG.Vector3d RawConvert(SOG.Vector target) + public AG.Vector3d Convert(SOG.Vector target) { double f = Units.GetConversionFactor(target.units, _contextStack.Current.SpeckleUnits); return new(target.x * f, target.y * f, target.z * f); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs index 39a60873f0..36d7b796f6 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/ArcToSpeckleConverter.cs @@ -5,17 +5,17 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBArcToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class DBArcToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public DBArcToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion planeConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -25,16 +25,16 @@ public DBArcToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Arc)target); + public Base Convert(object target) => Convert((ADB.Arc)target); - public SOG.Arc RawConvert(ADB.Arc target) + public SOG.Arc Convert(ADB.Arc target) { - SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); - SOG.Point start = _pointConverter.RawConvert(target.StartPoint); - SOG.Point end = _pointConverter.RawConvert(target.EndPoint); - SOG.Point mid = _pointConverter.RawConvert(target.GetPointAtDist(target.Length / 2.0)); + SOG.Plane plane = _planeConverter.Convert(target.GetPlane()); + SOG.Point start = _pointConverter.Convert(target.StartPoint); + SOG.Point end = _pointConverter.Convert(target.EndPoint); + SOG.Point mid = _pointConverter.Convert(target.GetPointAtDist(target.Length / 2.0)); SOP.Interval domain = new(target.StartParam, target.EndParam); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Arc arc = new( diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs index 3bdfb3cf95..18b45a8daf 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/CircleToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBCircleToSpeckleConverter : IHostObjectToSpeckleConversion +public class DBCircleToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public DBCircleToSpeckleConverter( - IRawConversion planeConverter, - IRawConversion boxConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -26,8 +26,8 @@ public DBCircleToSpeckleConverter( public SOG.Circle RawConvert(ADB.Circle target) { - SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Plane plane = _planeConverter.Convert(target.GetPlane()); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Circle circle = new(plane, target.Radius, _contextStack.Current.SpeckleUnits) { length = target.Circumference, bbox = bbox }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs index 06dae2c11b..524e1a1d8c 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/EllipseToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBEllipseToSpeckleConverter : IHostObjectToSpeckleConversion +public class DBEllipseToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public DBEllipseToSpeckleConverter( - IRawConversion planeConverter, - IRawConversion boxConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -26,8 +26,8 @@ public DBEllipseToSpeckleConverter( public SOG.Ellipse RawConvert(ADB.Ellipse target) { - SOG.Plane plane = _planeConverter.RawConvert(new AG.Plane(target.Center, target.MajorAxis, target.MinorAxis)); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Plane plane = _planeConverter.Convert(new AG.Plane(target.Center, target.MajorAxis, target.MinorAxis)); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); // the start and end param corresponds to start and end angle in radians SOP.Interval trim = new(target.StartAngle, target.EndAngle); diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs index f68c1b5ba1..22787e2290 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/LineToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class LineToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public LineToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -22,17 +22,17 @@ public LineToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Line)target); + public Base Convert(object target) => Convert((ADB.Line)target); - public SOG.Line RawConvert(ADB.Line target) => + public SOG.Line Convert(ADB.Line target) => new( - _pointConverter.RawConvert(target.StartPoint), - _pointConverter.RawConvert(target.EndPoint), + _pointConverter.Convert(target.StartPoint), + _pointConverter.Convert(target.EndPoint), _contextStack.Current.SpeckleUnits ) { length = target.Length, domain = new SOP.Interval(0, target.Length), - bbox = _boxConverter.RawConvert(target.GeometricExtents) + bbox = _boxConverter.Convert(target.GeometricExtents) }; } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs index f22f60ef34..20b59aa1aa 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PointToSpeckleConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.DBPoint), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToSpeckleConverter : IHostObjectToSpeckleConversion +public class PointToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public PointToSpeckleConverter(IRawConversion pointConverter) + public PointToSpeckleConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } public Base Convert(object target) => RawConvert((ADB.DBPoint)target); - public SOG.Point RawConvert(ADB.DBPoint target) => _pointConverter.RawConvert(target.Position); + public SOG.Point RawConvert(ADB.DBPoint target) => _pointConverter.Convert(target.Position); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs index 08a1bdbb22..f96503a298 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolyfaceMeshToSpeckleConverter.cs @@ -9,18 +9,18 @@ namespace Speckle.Converters.Autocad.Geometry; /// The class converter. Converts to . /// /// -/// The IHostObjectToSpeckleConversion inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. +/// The IToSpeckleTopLevelConverter inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. /// [NameAndRankValue(nameof(ADB.PolyFaceMesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBPolyfaceMeshToSpeckleConverter : IHostObjectToSpeckleConversion +public class DBPolyfaceMeshToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public DBPolyfaceMeshToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -87,10 +87,10 @@ public SOG.Mesh RawConvert(ADB.PolyFaceMesh target) List vertices = new(dbVertices.Count * 3); foreach (Point3d vert in dbVertices) { - vertices.AddRange(_pointConverter.RawConvert(vert).ToList()); + vertices.AddRange(_pointConverter.Convert(vert).ToList()); } - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Mesh speckleMesh = new(vertices, faces, colors, null, _contextStack.Current.SpeckleUnits) diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs index c18458e89b..330d832cba 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline2dToSpeckleConverter.cs @@ -12,26 +12,26 @@ namespace Speckle.Converters.Autocad.Geometry; /// of type will have only s and s in . /// of type will have only s in . /// of type and will have only one in . -/// The IHostObjectToSpeckleConversion inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. +/// The IToSpeckleTopLevelConverter inheritance should only expect database-resident objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. /// [NameAndRankValue(nameof(ADB.Polyline2d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class Polyline2dToSpeckleConverter : IHostObjectToSpeckleConversion +public class Polyline2dToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _splineConverter; - private readonly IRawConversion _vectorConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _splineConverter; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public Polyline2dToSpeckleConverter( - IRawConversion arcConverter, - IRawConversion lineConverter, - IRawConversion polylineConverter, - IRawConversion splineConverter, - IRawConversion vectorConverter, - IRawConversion boxConverter, + ITypedConverter arcConverter, + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter splineConverter, + ITypedConverter vectorConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -137,7 +137,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) arc.ReverseCurve(); } - segments.Add(_arcConverter.RawConvert(arc)); + segments.Add(_arcConverter.Convert(arc)); previousPoint = arc.EndPoint; break; case ADB.Line line: @@ -146,7 +146,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) line.ReverseCurve(); } - segments.Add(_lineConverter.RawConvert(line)); + segments.Add(_lineConverter.Convert(line)); previousPoint = line.EndPoint; break; } @@ -157,7 +157,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) // for splines, convert the spline curve and display value and add to the segments list if (isSpline) { - SOG.Curve spline = _splineConverter.RawConvert(target.Spline); + SOG.Curve spline = _splineConverter.Convert(target.Spline); SOG.Polyline displayValue = segmentValues.ConvertToSpecklePolyline(_contextStack.Current.SpeckleUnits); if (displayValue != null) { @@ -167,8 +167,8 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline2d target) segments.Add(spline); } - SOG.Vector normal = _vectorConverter.RawConvert(target.Normal); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Vector normal = _vectorConverter.Convert(target.Normal); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Autocad.AutocadPolycurve polycurve = new() { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs index 9434280ca8..fdef5bd478 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/Polyline3dToSpeckleConverter.cs @@ -11,20 +11,20 @@ namespace Speckle.Converters.Autocad.Geometry; /// /// of type will have only one in . /// of type and will have only one in . -/// The IHostObjectToSpeckleConversion inheritance should only expect database-resident Polyline2d objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. +/// The IToSpeckleTopLevelConverter inheritance should only expect database-resident Polyline2d objects. IRawConversion inheritance can expect non database-resident objects, when generated from other converters. /// [NameAndRankValue(nameof(ADB.Polyline3d), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class Polyline3dToSpeckleConverter : IHostObjectToSpeckleConversion +public class Polyline3dToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _splineConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _splineConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public Polyline3dToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion splineConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter splineConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -74,7 +74,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline3d target) if (target.PolyType is not ADB.Poly3dType.SimplePoly) { // get the spline segment - SOG.Curve spline = _splineConverter.RawConvert(target.Spline); + SOG.Curve spline = _splineConverter.Convert(target.Spline); // get the spline displayvalue by exploding the polyline List segmentValues = new(); @@ -112,7 +112,7 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline3d target) segments.Add(polyline); } - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Autocad.AutocadPolycurve polycurve = new() diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs index dce4210940..33a57b6b7f 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/PolylineToSpeckleConverter.cs @@ -12,20 +12,20 @@ namespace Speckle.Converters.Autocad.Geometry; /// [NameAndRankValue(nameof(ADB.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PolylineToSpeckleConverter - : IHostObjectToSpeckleConversion, - IRawConversion + : IToSpeckleTopLevelConverter, + ITypedConverter { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _vectorConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public PolylineToSpeckleConverter( - IRawConversion lineConverter, - IRawConversion arcConverter, - IRawConversion vectorConverter, - IRawConversion boxConverter, + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter vectorConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -36,9 +36,9 @@ public PolylineToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Polyline)target); + public Base Convert(object target) => Convert((ADB.Polyline)target); - public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) + public SOG.Autocad.AutocadPolycurve Convert(ADB.Polyline target) { List value = new(target.NumberOfVertices * 3); List bulges = new(target.NumberOfVertices); @@ -58,11 +58,11 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) { case ADB.SegmentType.Line: AG.LineSegment3d line = target.GetLineSegmentAt(i); - segments.Add(_lineConverter.RawConvert(line)); + segments.Add(_lineConverter.Convert(line)); break; case ADB.SegmentType.Arc: AG.CircularArc3d arc = target.GetArcSegmentAt(i); - segments.Add(_arcConverter.RawConvert(arc)); + segments.Add(_arcConverter.Convert(arc)); break; default: // we are skipping segments of type Empty, Point, and Coincident @@ -70,8 +70,8 @@ public SOG.Autocad.AutocadPolycurve RawConvert(ADB.Polyline target) } } - SOG.Vector normal = _vectorConverter.RawConvert(target.Normal); - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Vector normal = _vectorConverter.Convert(target.Normal); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Autocad.AutocadPolycurve polycurve = new() diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs index d4aabd29d4..059f92f033 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SplineToSpeckleConverter.cs @@ -7,15 +7,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Geometry; [NameAndRankValue(nameof(ADB.Spline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class SplineToSpeckleConverter : IHostObjectToSpeckleConversion, IRawConversion +public class SplineToSpeckleConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _intervalConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public SplineToSpeckleConverter( - IRawConversion intervalConverter, - IRawConversion boxConverter, + ITypedConverter intervalConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -24,9 +24,9 @@ public SplineToSpeckleConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Spline)target); + public Base Convert(object target) => Convert((ADB.Spline)target); - public SOG.Curve RawConvert(ADB.Spline target) + public SOG.Curve Convert(ADB.Spline target) { // get nurbs and geo data ADB.NurbsData data = target.NurbsData; @@ -38,7 +38,7 @@ public SOG.Curve RawConvert(ADB.Spline target) if (target.GetGeCurve() is NurbCurve3d nurbs) { length = nurbs.GetLength(nurbs.StartParameter, nurbs.EndParameter, 0.001); - domain = _intervalConverter.RawConvert(nurbs.GetInterval()); + domain = _intervalConverter.Convert(nurbs.GetInterval()); if (nurbs.Knots.Count < nurbs.NumberOfControlPoints + nurbs.Degree + 1 && target.IsPeriodic) { periodicClosed = true; @@ -109,7 +109,7 @@ public SOG.Curve RawConvert(ADB.Spline target) closed = periodicClosed || target.Closed, length = length, domain = domain, - bbox = _boxConverter.RawConvert(target.GeometricExtents), + bbox = _boxConverter.Convert(target.GeometricExtents), units = _contextStack.Current.SpeckleUnits }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs index 296107a5e0..98686f8006 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Geometry/SubDMeshToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Autocad.Geometry; [NameAndRankValue(nameof(ADB.SubDMesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DBSubDMeshToSpeckleConverter : IHostObjectToSpeckleConversion +public class DBSubDMeshToSpeckleConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public DBSubDMeshToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -30,7 +30,7 @@ public SOG.Mesh RawConvert(ADB.SubDMesh target) var vertices = new List(target.Vertices.Count * 3); foreach (AG.Point3d vert in target.Vertices) { - vertices.AddRange(_pointConverter.RawConvert(vert).ToList()); + vertices.AddRange(_pointConverter.Convert(vert).ToList()); } // faces @@ -67,7 +67,7 @@ public SOG.Mesh RawConvert(ADB.SubDMesh target) .ToList(); // bbox - SOG.Box bbox = _boxConverter.RawConvert(target.GeometricExtents); + SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents); SOG.Mesh speckleMesh = new(vertices, faces, colors, null, _contextStack.Current.SpeckleUnits) { bbox = bbox }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs index 62f798ae11..a36bbb60f6 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/BoxToSpeckleRawConverter.cs @@ -4,13 +4,13 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class BoxToSpeckleRawConverter : IRawConversion +public class BoxToSpeckleRawConverter : ITypedConverter { - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _planeConverter; private readonly IConversionContextStack _contextStack; public BoxToSpeckleRawConverter( - IRawConversion planeConverter, + ITypedConverter planeConverter, IConversionContextStack contextStack ) { @@ -18,9 +18,9 @@ public BoxToSpeckleRawConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((ADB.Extents3d)target); + public Base Convert(object target) => Convert((ADB.Extents3d)target); - public SOG.Box RawConvert(ADB.Extents3d target) + public SOG.Box Convert(ADB.Extents3d target) { // get dimension intervals and volume SOP.Interval xSize = new(target.MinPoint.X, target.MaxPoint.X); @@ -31,7 +31,7 @@ public SOG.Box RawConvert(ADB.Extents3d target) // get the base plane of the bounding box from extents and current UCS var ucs = _contextStack.Current.Document.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d; AG.Plane acadPlane = new(target.MinPoint, ucs.Xaxis, ucs.Yaxis); - SOG.Plane plane = _planeConverter.RawConvert(acadPlane); + SOG.Plane plane = _planeConverter.Convert(acadPlane); SOG.Box box = new(plane, xSize, ySize, zSize, _contextStack.Current.SpeckleUnits) { volume = volume }; diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs index 5979f9d7aa..ec8f91e0b7 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/CircularArc3dToSpeckleConverter.cs @@ -3,15 +3,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class CircularArc3dToSpeckleConverter : IRawConversion +public class CircularArc3dToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _planeConverter; private readonly IConversionContextStack _contextStack; public CircularArc3dToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion planeConverter, + ITypedConverter pointConverter, + ITypedConverter planeConverter, IConversionContextStack contextStack ) { @@ -20,12 +20,12 @@ public CircularArc3dToSpeckleConverter( _contextStack = contextStack; } - public SOG.Arc RawConvert(AG.CircularArc3d target) + public SOG.Arc Convert(AG.CircularArc3d target) { - SOG.Plane plane = _planeConverter.RawConvert(target.GetPlane()); - SOG.Point start = _pointConverter.RawConvert(target.StartPoint); - SOG.Point end = _pointConverter.RawConvert(target.EndPoint); - SOG.Point mid = _pointConverter.RawConvert(target.EvaluatePoint(0.5)); // POC: testing, unsure + SOG.Plane plane = _planeConverter.Convert(target.GetPlane()); + SOG.Point start = _pointConverter.Convert(target.StartPoint); + SOG.Point end = _pointConverter.Convert(target.EndPoint); + SOG.Point mid = _pointConverter.Convert(target.EvaluatePoint(0.5)); // POC: testing, unsure SOP.Interval domain = new(target.GetInterval().LowerBound, target.GetInterval().UpperBound); SOG.Arc arc = diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs index 77613f996d..fe5ac853d4 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/IntervalToSpeckleRawConverter.cs @@ -3,9 +3,9 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class IntervalToSpeckleConverter : IRawConversion +public class IntervalToSpeckleConverter : ITypedConverter { - public Base Convert(object target) => RawConvert((AG.Interval)target); + public Base Convert(object target) => Convert((AG.Interval)target); - public SOP.Interval RawConvert(AG.Interval target) => new(target.LowerBound, target.UpperBound); + public SOP.Interval Convert(AG.Interval target) => new(target.LowerBound, target.UpperBound); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs index f1bc383664..f4079ca5ee 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/LineSegment3dToSpeckleRawConverter.cs @@ -3,13 +3,13 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class LineSegment3dToSpeckleRawConverter : IRawConversion +public class LineSegment3dToSpeckleRawConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; private readonly IConversionContextStack _contextStack; public LineSegment3dToSpeckleRawConverter( - IRawConversion pointConverter, + ITypedConverter pointConverter, IConversionContextStack contextStack ) { @@ -17,10 +17,10 @@ public LineSegment3dToSpeckleRawConverter( _contextStack = contextStack; } - public SOG.Line RawConvert(AG.LineSegment3d target) => + public SOG.Line Convert(AG.LineSegment3d target) => new( - _pointConverter.RawConvert(target.StartPoint), - _pointConverter.RawConvert(target.EndPoint), + _pointConverter.Convert(target.StartPoint), + _pointConverter.Convert(target.EndPoint), _contextStack.Current.SpeckleUnits ) { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs index 86ac812497..4c5bc6f1ce 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PlaneToSpeckleRawConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class PlaneToSpeckleRawConverter : IHostObjectToSpeckleConversion, IRawConversion +public class PlaneToSpeckleRawConverter : IToSpeckleTopLevelConverter, ITypedConverter { - private readonly IRawConversion _vectorConverter; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _pointConverter; private readonly IConversionContextStack _contextStack; public PlaneToSpeckleRawConverter( - IRawConversion vectorConverter, - IRawConversion pointConverter, + ITypedConverter vectorConverter, + ITypedConverter pointConverter, IConversionContextStack contextStack ) { @@ -21,14 +21,14 @@ public PlaneToSpeckleRawConverter( _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((AG.Plane)target); + public Base Convert(object target) => Convert((AG.Plane)target); - public SOG.Plane RawConvert(AG.Plane target) => + public SOG.Plane Convert(AG.Plane target) => new( - _pointConverter.RawConvert(target.PointOnPlane), - _vectorConverter.RawConvert(target.Normal), - _vectorConverter.RawConvert(target.GetCoordinateSystem().Xaxis), - _vectorConverter.RawConvert(target.GetCoordinateSystem().Yaxis), + _pointConverter.Convert(target.PointOnPlane), + _vectorConverter.Convert(target.Normal), + _vectorConverter.Convert(target.GetCoordinateSystem().Xaxis), + _vectorConverter.Convert(target.GetCoordinateSystem().Yaxis), _contextStack.Current.SpeckleUnits ); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs index 5dc90c63ca..df8c45f237 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/PointToSpeckleRawConverter.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class PointToSpeckleRawConverter : IRawConversion +public class PointToSpeckleRawConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -12,6 +12,5 @@ public PointToSpeckleRawConverter(IConversionContextStack - new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); + public SOG.Point Convert(AG.Point3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs index 770e24cf69..2eca1149e5 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.AutocadShared/ToSpeckle/Raw/VectorToSpeckleRawConverter.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.Autocad.ToSpeckle.Raw; -public class VectorToSpeckleRawConverter : IRawConversion +public class VectorToSpeckleRawConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -12,6 +12,6 @@ public VectorToSpeckleRawConverter(IConversionContextStack + public SOG.Vector Convert(AG.Vector3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs index e7cf89a01f..d4e6d197ac 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -13,10 +13,8 @@ public class RevitConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + builder.AddConverterCommon(); builder.AddSingleton(new RevitContext()); - // most things should be InstancePerLifetimeScope so we get one per operation - builder.AddScoped(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.AddScoped(); @@ -24,8 +22,6 @@ public void Load(SpeckleContainerBuilder builder) // POC: the concrete type can come out if we remove all the reference to it builder.AddScoped(); - builder.AddScoped, RevitToSpeckleUnitConverter>(); - builder.AddScoped(); builder.AddScoped(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs index c2c5890b5f..3a9fdb33de 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -6,10 +6,10 @@ namespace Speckle.Converters.RevitShared.Helpers; // POC: needs breaking down https://spockle.atlassian.net/browse/CNX-9354 public sealed class DisplayValueExtractor { - private readonly IRawConversion>, List> _meshByMaterialConverter; + private readonly ITypedConverter>, List> _meshByMaterialConverter; public DisplayValueExtractor( - IRawConversion>, List> meshByMaterialConverter + ITypedConverter>, List> meshByMaterialConverter ) { _meshByMaterialConverter = meshByMaterialConverter; @@ -39,7 +39,7 @@ public DisplayValueExtractor( var meshesByMaterial = GetMeshesByMaterial(meshes, solids); - return _meshByMaterialConverter.RawConvert(meshesByMaterial); + return _meshByMaterialConverter.Convert(meshesByMaterial); } private static Dictionary> GetMeshesByMaterial( diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs index e5fa30d136..2c4f3b2112 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/ParameterObjectAssigner.cs @@ -10,11 +10,11 @@ namespace Speckle.Converters.RevitShared.Helpers; // did it go away? public sealed class ParameterObjectAssigner { - private readonly IRawConversion _paramConverter; + private readonly ITypedConverter _paramConverter; private readonly ParameterValueExtractor _parameterValueExtractor; public ParameterObjectAssigner( - IRawConversion paramConverter, + ITypedConverter paramConverter, ParameterValueExtractor parameterValueExtractor ) { @@ -56,7 +56,7 @@ private void AssignSpeckleParamToBaseObject( { try { - SOBR.Parameter speckleParam = _paramConverter.RawConvert(kv.Value); + SOBR.Parameter speckleParam = _paramConverter.Convert(kv.Value); speckleParam.isTypeParameter = isTypeParameter; paramBase[kv.Key] = speckleParam; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs index cd75314874..9db6d14583 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/SlopeArrowExtractor.cs @@ -4,11 +4,11 @@ namespace Speckle.Converters.RevitShared.Helpers; public class SlopeArrowExtractor : ISlopeArrowExtractor { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; private readonly ParameterValueExtractor _parameterValueExtractor; public SlopeArrowExtractor( - IRawConversion pointConverter, + ITypedConverter pointConverter, ParameterValueExtractor parameterValueExtractor ) { @@ -48,12 +48,12 @@ ParameterValueExtractor parameterValueExtractor public SOG.Point GetSlopeArrowHead(DB.ModelLine slopeArrow) { - return _pointConverter.RawConvert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(1)); + return _pointConverter.Convert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(1)); } public SOG.Point GetSlopeArrowTail(DB.ModelLine slopeArrow) { - return _pointConverter.RawConvert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(0)); + return _pointConverter.Convert(((DB.LocationCurve)slopeArrow.Location).Curve.GetEndPoint(0)); } public double GetSlopeArrowTailOffset(DB.ModelLine slopeArrow) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs index 1bc69a941b..d6ee746e43 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BeamConversionToSpeckle.cs @@ -10,17 +10,17 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. // As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. // CNX-9312 -public class BeamConversionToSpeckle : IRawConversion +public class BeamConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _locationConverter; - private readonly IRawConversion _levelConverter; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; public BeamConversionToSpeckle( - IRawConversion locationConverter, - IRawConversion levelConverter, + ITypedConverter locationConverter, + ITypedConverter levelConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, ParameterObjectAssigner parameterObjectAssigner @@ -33,9 +33,9 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public SOBR.RevitBeam RawConvert(DB.FamilyInstance target) + public SOBR.RevitBeam Convert(DB.FamilyInstance target) { - var baseGeometry = _locationConverter.RawConvert(target.Location); + var baseGeometry = _locationConverter.Convert(target.Location); if (baseGeometry is not ICurve baseCurve) { throw new SpeckleConversionException( @@ -56,7 +56,7 @@ public SOBR.RevitBeam RawConvert(DB.FamilyInstance target) target, DB.BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM ); - speckleBeam.level = _levelConverter.RawConvert(level); + speckleBeam.level = _levelConverter.Convert(level); speckleBeam.displayValue = _displayValueExtractor.GetDisplayValue(target); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs index faebfe4a2b..8f02d4c345 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BoundarySegmentConversionToSpeckle.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class BoundarySegmentConversionToSpeckle : IRawConversion, SOG.Polycurve> +public class BoundarySegmentConversionToSpeckle : ITypedConverter, SOG.Polycurve> { - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; - public BoundarySegmentConversionToSpeckle(IRawConversion curveConverter) + public BoundarySegmentConversionToSpeckle(ITypedConverter curveConverter) { _curveConverter = curveConverter; } - public SOG.Polycurve RawConvert(IList target) + public SOG.Polycurve Convert(IList target) { if (target.Count == 0) { @@ -23,7 +23,7 @@ public SOG.Polycurve RawConvert(IList target) foreach (var segment in target) { DB.Curve revitCurve = segment.GetCurve(); - var curve = _curveConverter.RawConvert(revitCurve); + var curve = _curveConverter.Convert(revitCurve); // POC: We used to attach the `elementID` of every curve in a PolyCurve as a dynamic property. // We've removed this as it seemed unnecessary. diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs index b82ffa2a66..ccae249fe5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/BraceToSpeckleConverter.cs @@ -7,22 +7,22 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. // As-is, what we are saying is that it can take "any Family Instance" and turn it into a Speckle.RevitBeam, which is far from correct. // CNX-9312 -public class BraceToSpeckleConverter : IRawConversion +public class BraceToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _beamConverter; + private readonly ITypedConverter _beamConverter; - public BraceToSpeckleConverter(IRawConversion beamConverter) + public BraceToSpeckleConverter(ITypedConverter beamConverter) { _beamConverter = beamConverter; } - public SOBR.RevitBrace RawConvert(DB.FamilyInstance target) + public SOBR.RevitBrace Convert(DB.FamilyInstance target) { // POC: we might want some easy one-liner here to FamilyMatchesOrThrow(target, DB.Structure.StructuralType.Brace) or similar - // and added in each RawConvert + // and added in each Convert // POC: this and the beam lost the notes we were returning, though this seems against even the original pattern - var beam = _beamConverter.RawConvert(target); + var beam = _beamConverter.Convert(target); var brace = new SOBR.RevitBrace() { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index f50bea3ec5..3c5b738aa9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -10,18 +10,18 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: There is no validation on this converter to prevent conversion from "not a Revit Beam" to a Speckle Beam. // This will definitely explode if we tried. Goes back to the `CanConvert` functionality conversation. -public class ColumnConversionToSpeckle : IRawConversion +public class ColumnConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _locationConverter; - private readonly IRawConversion _levelConverter; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly IRevitConversionContextStack _contextStack; private readonly ParameterObjectAssigner _parameterObjectAssigner; public ColumnConversionToSpeckle( - IRawConversion locationConverter, - IRawConversion levelConverter, + ITypedConverter locationConverter, + ITypedConverter levelConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, IRevitConversionContextStack contextStack, @@ -36,7 +36,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public RevitColumn RawConvert(DB.FamilyInstance target) + public RevitColumn Convert(DB.FamilyInstance target) { FamilySymbol symbol = (FamilySymbol)target.Document.GetElement(target.GetTypeId()); @@ -47,14 +47,14 @@ public RevitColumn RawConvert(DB.FamilyInstance target) target, BuiltInParameter.FAMILY_BASE_LEVEL_PARAM ); - speckleColumn.level = _levelConverter.RawConvert(level); + speckleColumn.level = _levelConverter.Convert(level); Level topLevel = _parameterValueExtractor.GetValueAsDocumentObject( target, BuiltInParameter.FAMILY_TOP_LEVEL_PARAM ); - speckleColumn.topLevel = _levelConverter.RawConvert(topLevel); + speckleColumn.topLevel = _levelConverter.Convert(topLevel); speckleColumn.baseOffset = _parameterValueExtractor.GetValueAsDouble( target, DB.BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM @@ -87,7 +87,7 @@ public RevitColumn RawConvert(DB.FamilyInstance target) private ICurve? GetBaseCurve(DB.FamilyInstance target, double topLevelElevation, double topLevelOffset) { - Base baseGeometry = _locationConverter.RawConvert(target.Location); + Base baseGeometry = _locationConverter.Convert(target.Location); ICurve? baseCurve = baseGeometry as ICurve; if (baseGeometry is ICurve) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs index d6d1119312..d6774a710b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/ArcToSpeckleConverter.cs @@ -5,17 +5,17 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class ArcToSpeckleConverter : IRawConversion +public class ArcToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _planeConverter; private readonly ScalingServiceToSpeckle _scalingService; public ArcToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - IRawConversion planeConverter, + ITypedConverter xyzToPointConverter, + ITypedConverter planeConverter, ScalingServiceToSpeckle scalingService ) { @@ -25,7 +25,7 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Arc RawConvert(DB.Arc target) + public SOG.Arc Convert(DB.Arc target) { // see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128 var arcPlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection); @@ -43,15 +43,15 @@ public SOG.Arc RawConvert(DB.Arc target) return new SOG.Arc() { - plane = _planeConverter.RawConvert(arcPlane), + plane = _planeConverter.Convert(arcPlane), radius = _scalingService.ScaleLength(target.Radius), startAngle = startAngle, endAngle = endAngle, angleRadians = endAngle - startAngle, units = _contextStack.Current.SpeckleUnits, - endPoint = _xyzToPointConverter.RawConvert(end), - startPoint = _xyzToPointConverter.RawConvert(start), - midPoint = _xyzToPointConverter.RawConvert(mid), + endPoint = _xyzToPointConverter.Convert(end), + startPoint = _xyzToPointConverter.Convert(start), + midPoint = _xyzToPointConverter.Convert(mid), length = _scalingService.ScaleLength(target.Length), domain = new Interval(target.GetEndParameter(0), target.GetEndParameter(1)) }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs index 6117a58d45..a891579ad5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/BoundingBoxXYZToSpeckleConverter.cs @@ -4,16 +4,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class BoundingBoxXYZToSpeckleConverter : IRawConversion +public class BoundingBoxXYZToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _planeConverter; public BoundingBoxXYZToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - IRawConversion planeConverter + ITypedConverter xyzToPointConverter, + ITypedConverter planeConverter ) { _contextStack = contextStack; @@ -21,11 +21,11 @@ public BoundingBoxXYZToSpeckleConverter( _planeConverter = planeConverter; } - public SOG.Box RawConvert(DB.BoundingBoxXYZ target) + public SOG.Box Convert(DB.BoundingBoxXYZ target) { // convert min and max pts to speckle first - var min = _xyzToPointConverter.RawConvert(target.Min); - var max = _xyzToPointConverter.RawConvert(target.Max); + var min = _xyzToPointConverter.Convert(target.Min); + var max = _xyzToPointConverter.Convert(target.Max); // get the base plane of the bounding box from the transform var transform = target.Transform; @@ -40,7 +40,7 @@ public SOG.Box RawConvert(DB.BoundingBoxXYZ target) xSize = new Interval(min.x, max.x), ySize = new Interval(min.y, max.y), zSize = new Interval(min.z, max.z), - basePlane = _planeConverter.RawConvert(plane), + basePlane = _planeConverter.Convert(plane), units = _contextStack.Current.SpeckleUnits }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs index cd37f03088..7abdc08cfc 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CircleToSpeckleConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class CircleToSpeckleConverter : IRawConversion +public class CircleToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _planeConverter; private readonly ScalingServiceToSpeckle _scalingService; public CircleToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion planeConverter, + ITypedConverter planeConverter, ScalingServiceToSpeckle scalingService ) { @@ -21,7 +21,7 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Circle RawConvert(DB.Arc target) + public SOG.Circle Convert(DB.Arc target) { // POC: should we check for arc of 360 and throw? Original CircleToSpeckle did not do this. @@ -29,7 +29,7 @@ public SOG.Circle RawConvert(DB.Arc target) var arcPlane = DB.Plane.CreateByNormalAndOrigin(target.Normal, target.Center); var c = new SOG.Circle() { - plane = _planeConverter.RawConvert(arcPlane), + plane = _planeConverter.Convert(arcPlane), radius = _scalingService.ScaleLength(target.Radius), units = _contextStack.Current.SpeckleUnits, length = _scalingService.ScaleLength(target.Length) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs index 6cba92f9cd..4644bc1435 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrArrayToSpecklePolycurveConverter.cs @@ -4,21 +4,21 @@ namespace Speckle.Converters.RevitShared.Raw; -internal sealed class CurveArrArrayToSpecklePolycurveConverter : IRawConversion> +internal sealed class CurveArrArrayToSpecklePolycurveConverter : ITypedConverter> { - private readonly IRawConversion _curveArrayConverter; + private readonly ITypedConverter _curveArrayConverter; - public CurveArrArrayToSpecklePolycurveConverter(IRawConversion curveArrayConverter) + public CurveArrArrayToSpecklePolycurveConverter(ITypedConverter curveArrayConverter) { _curveArrayConverter = curveArrayConverter; } - public List RawConvert(CurveArrArray target) + public List Convert(CurveArrArray target) { List polycurves = new(); foreach (var curveArray in GetCurveArrays(target)) { - polycurves.Add(_curveArrayConverter.RawConvert(curveArray)); + polycurves.Add(_curveArrayConverter.Convert(curveArray)); } return polycurves; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs index 327be89dbf..8ec80fe9f7 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveArrayConversionToSpeckle.cs @@ -7,16 +7,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public sealed class CurveArrayConversionToSpeckle : IRawConversion +public sealed class CurveArrayConversionToSpeckle : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; private readonly ScalingServiceToSpeckle _scalingService; - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; public CurveArrayConversionToSpeckle( IRevitConversionContextStack contextStack, ScalingServiceToSpeckle scalingService, - IRawConversion curveConverter + ITypedConverter curveConverter ) { _contextStack = contextStack; @@ -24,7 +24,7 @@ public CurveArrayConversionToSpeckle( _curveConverter = curveConverter; } - public Polycurve RawConvert(CurveArray target) + public Polycurve Convert(CurveArray target) { List curves = target.Cast().ToList(); @@ -34,7 +34,7 @@ public Polycurve RawConvert(CurveArray target) closed = curves.First().GetEndPoint(0).DistanceTo(curves.Last().GetEndPoint(1)) < RevitConversionContextStack.TOLERANCE, length = _scalingService.ScaleLength(curves.Sum(x => x.Length)), - segments = curves.Select(x => _curveConverter.RawConvert(x)).ToList() + segments = curves.Select(x => _curveConverter.Convert(x)).ToList() }; } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs index ec60b6e0ac..0b034a779c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/CurveConversionToSpeckle.cs @@ -4,22 +4,22 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class CurveConversionToSpeckle : IRawConversion +public class CurveConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _circleConverter; - private readonly IRawConversion _ellipseConverter; - private readonly IRawConversion _nurbsConverter; - private readonly IRawConversion _hermiteConverter; // POC: should this be ICurve? + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _nurbsConverter; + private readonly ITypedConverter _hermiteConverter; // POC: should this be ICurve? public CurveConversionToSpeckle( - IRawConversion lineConverter, - IRawConversion arcConverter, - IRawConversion circleConverter, - IRawConversion ellipseConverter, - IRawConversion nurbsConverter, - IRawConversion hermiteConverter + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter circleConverter, + ITypedConverter ellipseConverter, + ITypedConverter nurbsConverter, + ITypedConverter hermiteConverter ) { _lineConverter = lineConverter; @@ -30,16 +30,16 @@ public CurveConversionToSpeckle( _hermiteConverter = hermiteConverter; } - public ICurve RawConvert(DB.Curve target) + public ICurve Convert(DB.Curve target) { return target switch { - DB.Line line => _lineConverter.RawConvert(line), + DB.Line line => _lineConverter.Convert(line), // POC: are maybe arc.IsCyclic ? - DB.Arc arc => arc.IsClosed ? _circleConverter.RawConvert(arc) : _arcConverter.RawConvert(arc), - DB.Ellipse ellipse => _ellipseConverter.RawConvert(ellipse), - DB.NurbSpline nurbs => _nurbsConverter.RawConvert(nurbs), - DB.HermiteSpline hermite => _hermiteConverter.RawConvert(hermite), + DB.Arc arc => arc.IsClosed ? _circleConverter.Convert(arc) : _arcConverter.Convert(arc), + DB.Ellipse ellipse => _ellipseConverter.Convert(ellipse), + DB.NurbSpline nurbs => _nurbsConverter.Convert(nurbs), + DB.HermiteSpline hermite => _hermiteConverter.Convert(hermite), _ => throw new SpeckleConversionException($"Unsupported curve type {target.GetType()}") }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs index e41d373c4e..96ca62f8f1 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/EllipseToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class EllipseToSpeckleConverter : IRawConversion +public class EllipseToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _planeConverter; private readonly ScalingServiceToSpeckle _scalingService; public EllipseToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion planeConverter, + ITypedConverter planeConverter, ScalingServiceToSpeckle scalingService ) { @@ -22,7 +22,7 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Ellipse RawConvert(DB.Ellipse target) + public SOG.Ellipse Convert(DB.Ellipse target) { using (DB.Plane basePlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection)) { @@ -30,7 +30,7 @@ public SOG.Ellipse RawConvert(DB.Ellipse target) return new SOG.Ellipse() { - plane = _planeConverter.RawConvert(basePlane), + plane = _planeConverter.Convert(basePlane), // POC: scale length correct? seems right? firstRadius = _scalingService.ScaleLength(target.RadiusX), secondRadius = _scalingService.ScaleLength(target.RadiusY), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs index a25569a03e..5aa2a07ed2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/HermiteSplineToSpeckleConverter.cs @@ -2,18 +2,18 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class HerminteSplitToSpeckleConverter : IRawConversion +public class HerminteSplitToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _splineConverter; + private readonly ITypedConverter _splineConverter; - public HerminteSplitToSpeckleConverter(IRawConversion splineConverter) + public HerminteSplitToSpeckleConverter(ITypedConverter splineConverter) { _splineConverter = splineConverter; } - public SOG.Curve RawConvert(DB.HermiteSpline target) + public SOG.Curve Convert(DB.HermiteSpline target) { var nurbs = DB.NurbSpline.Create(target); - return _splineConverter.RawConvert(nurbs); + return _splineConverter.Convert(nurbs); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs index fd00f57360..2405cf0b22 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/LineConversionToSpeckle.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LineConversionToSpeckle : IRawConversion +public class LineConversionToSpeckle : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; + private readonly ITypedConverter _xyzToPointConverter; private readonly ScalingServiceToSpeckle _scalingService; public LineConversionToSpeckle( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, + ITypedConverter xyzToPointConverter, ScalingServiceToSpeckle scalingService ) { @@ -22,12 +22,12 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Line RawConvert(DB.Line target) => + public SOG.Line Convert(DB.Line target) => new() { units = _contextStack.Current.SpeckleUnits, - start = _xyzToPointConverter.RawConvert(target.GetEndPoint(0)), - end = _xyzToPointConverter.RawConvert(target.GetEndPoint(1)), + start = _xyzToPointConverter.Convert(target.GetEndPoint(0)), + end = _xyzToPointConverter.Convert(target.GetEndPoint(1)), domain = new Interval(target.GetEndParameter(0), target.GetEndParameter(1)), length = _scalingService.ScaleLength(target.Length) }; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs index f9d7d760df..29b0bd9f98 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshByMaterialDictionaryToSpeckle.cs @@ -4,16 +4,17 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class MeshByMaterialDictionaryToSpeckle : IRawConversion>, List> +public class MeshByMaterialDictionaryToSpeckle + : ITypedConverter>, List> { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _materialConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _materialConverter; public MeshByMaterialDictionaryToSpeckle( - IRawConversion materialConverter, + ITypedConverter materialConverter, IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter + ITypedConverter xyzToPointConverter ) { _materialConverter = materialConverter; @@ -34,7 +35,7 @@ public MeshByMaterialDictionaryToSpeckle( /// Also note that, for each unique material, the method tries to retrieve the related DB.Material from the current document and convert it. If the conversion is successful, /// the material is added to the corresponding Speckle mesh. If the conversion fails, the operation simply continues without the material. /// - public List RawConvert(Dictionary> target) + public List Convert(Dictionary> target) { var result = new List(target.Keys.Count); @@ -56,7 +57,7 @@ public MeshByMaterialDictionaryToSpeckle( var doc = _contextStack.Current.Document; if (doc.GetElement(materialId) is DB.Material material) { - speckleMesh["renderMaterial"] = _materialConverter.RawConvert(material); + speckleMesh["renderMaterial"] = _materialConverter.Convert(material); } // Append the revit mesh data to the speckle mesh @@ -77,7 +78,7 @@ private void AppendToSpeckleMesh(DB.Mesh mesh, SOG.Mesh speckleMesh) foreach (var vert in mesh.Vertices) { - var (x, y, z) = _xyzToPointConverter.RawConvert(vert); + var (x, y, z) = _xyzToPointConverter.Convert(vert); speckleMesh.vertices.Add(x); speckleMesh.vertices.Add(y); speckleMesh.vertices.Add(z); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs index 635537ea78..2f6c494ba0 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/MeshConversionToSpeckle.cs @@ -4,16 +4,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class MeshConversionToSpeckle : IRawConversion +public class MeshConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _materialConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _materialConverter; private readonly IRevitConversionContextStack _contextStack; public MeshConversionToSpeckle( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - IRawConversion materialConverter + ITypedConverter xyzToPointConverter, + ITypedConverter materialConverter ) { _contextStack = contextStack; @@ -21,7 +21,7 @@ public MeshConversionToSpeckle( _materialConverter = materialConverter; } - public SOG.Mesh RawConvert(DB.Mesh target) + public SOG.Mesh Convert(DB.Mesh target) { var doc = _contextStack.Current.Document; @@ -31,7 +31,7 @@ public SOG.Mesh RawConvert(DB.Mesh target) RenderMaterial? speckleMaterial = null; if (doc.GetElement(target.MaterialElementId) is DB.Material revitMaterial) { - speckleMaterial = _materialConverter.RawConvert(revitMaterial); + speckleMaterial = _materialConverter.Convert(revitMaterial); } return new SOG.Mesh(vertices, faces, units: _contextStack.Current.SpeckleUnits) @@ -46,7 +46,7 @@ private List GetSpeckleMeshVertexData(DB.Mesh target) foreach (var vert in target.Vertices) { - vertices.AddRange(_xyzToPointConverter.RawConvert(vert).ToList()); + vertices.AddRange(_xyzToPointConverter.Convert(vert).ToList()); } return vertices; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs index 8a8015b6de..7229f639e3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/NurbsSplineToSpeckleConverter.cs @@ -5,17 +5,17 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class NurbsSplineToSpeckleConverter : IRawConversion +public class NurbsSplineToSpeckleConverter : ITypedConverter { private readonly IRevitVersionConversionHelper _conversionHelper; private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; + private readonly ITypedConverter _xyzToPointConverter; private readonly ScalingServiceToSpeckle _scalingService; public NurbsSplineToSpeckleConverter( IRevitVersionConversionHelper conversionHelper, IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, + ITypedConverter xyzToPointConverter, ScalingServiceToSpeckle scalingService ) { @@ -25,18 +25,18 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Curve RawConvert(DB.NurbSpline target) + public SOG.Curve Convert(DB.NurbSpline target) { var units = _contextStack.Current.SpeckleUnits; var points = new List(); foreach (var p in target.CtrlPoints) { - var point = _xyzToPointConverter.RawConvert(p); + var point = _xyzToPointConverter.Convert(p); points.AddRange(new List { point.x, point.y, point.z }); } - var coords = target.Tessellate().SelectMany(xyz => _xyzToPointConverter.RawConvert(xyz).ToList()).ToList(); + var coords = target.Tessellate().SelectMany(xyz => _xyzToPointConverter.Convert(xyz).ToList()).ToList(); return new SOG.Curve() { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs index 82fb38a004..27cef7bab6 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PlaneToSpeckleConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PlaneToSpeckleConverter : IRawConversion +public class PlaneToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _xyzToVectorConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _xyzToVectorConverter; public PlaneToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - IRawConversion xyzToVectorConverter + ITypedConverter xyzToPointConverter, + ITypedConverter xyzToVectorConverter ) { _contextStack = contextStack; @@ -20,12 +20,12 @@ public PlaneToSpeckleConverter( _xyzToVectorConverter = xyzToVectorConverter; } - public SOG.Plane RawConvert(DB.Plane target) + public SOG.Plane Convert(DB.Plane target) { - var origin = _xyzToPointConverter.RawConvert(target.Origin); - var normal = _xyzToVectorConverter.RawConvert(target.Normal); - var xdir = _xyzToVectorConverter.RawConvert(target.XVec); - var ydir = _xyzToVectorConverter.RawConvert(target.YVec); + var origin = _xyzToPointConverter.Convert(target.Origin); + var normal = _xyzToVectorConverter.Convert(target.Normal); + var xdir = _xyzToVectorConverter.Convert(target.XVec); + var ydir = _xyzToVectorConverter.Convert(target.YVec); return new SOG.Plane(origin, normal, xdir, ydir, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs index 9f20289b53..ab86301cd2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointCloudToSpeckleConverter.cs @@ -3,16 +3,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PointCloudToSpeckleConverter : IRawConversion +public class PointCloudToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; - private readonly IRawConversion _boundingBoxConverter; + private readonly ITypedConverter _xyzToPointConverter; + private readonly ITypedConverter _boundingBoxConverter; public PointCloudToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter, - IRawConversion boundingBoxConverter + ITypedConverter xyzToPointConverter, + ITypedConverter boundingBoxConverter ) { _contextStack = contextStack; @@ -20,7 +20,7 @@ public PointCloudToSpeckleConverter( _boundingBoxConverter = boundingBoxConverter; } - public SOG.Pointcloud RawConvert(DB.PointCloudInstance target) + public SOG.Pointcloud Convert(DB.PointCloudInstance target) { var boundingBox = target.get_BoundingBox(null); using DB.Transform transform = target.GetTransform(); @@ -33,12 +33,12 @@ public SOG.Pointcloud RawConvert(DB.PointCloudInstance target) var specklePointCloud = new SOG.Pointcloud { points = points - .Select(o => _xyzToPointConverter.RawConvert(transform.OfPoint(o))) + .Select(o => _xyzToPointConverter.Convert(transform.OfPoint(o))) .SelectMany(o => new List() { o.x, o.y, o.z }) .ToList(), colors = points.Select(o => o.Color).ToList(), units = _contextStack.Current.SpeckleUnits, - bbox = _boundingBoxConverter.RawConvert(boundingBox) + bbox = _boundingBoxConverter.Convert(boundingBox) }; return specklePointCloud; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs index 349383fa43..8f6ca703db 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PointConversionToSpeckle.cs @@ -2,14 +2,14 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PointConversionToSpeckle : IRawConversion +public class PointConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _xyzToPointConverter; + private readonly ITypedConverter _xyzToPointConverter; - public PointConversionToSpeckle(IRawConversion xyzToPointConverter) + public PointConversionToSpeckle(ITypedConverter xyzToPointConverter) { _xyzToPointConverter = xyzToPointConverter; } - public SOG.Point RawConvert(DB.Point target) => _xyzToPointConverter.RawConvert(target.Coord); + public SOG.Point Convert(DB.Point target) => _xyzToPointConverter.Convert(target.Coord); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs index 785ee1faf7..5efb22e278 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/PolylineToSpeckleConverter.cs @@ -3,23 +3,23 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class PolylineToSpeckleConverter : IRawConversion +public class PolylineToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; - private readonly IRawConversion _xyzToPointConverter; + private readonly ITypedConverter _xyzToPointConverter; public PolylineToSpeckleConverter( IRevitConversionContextStack contextStack, - IRawConversion xyzToPointConverter + ITypedConverter xyzToPointConverter ) { _contextStack = contextStack; _xyzToPointConverter = xyzToPointConverter; } - public SOG.Polyline RawConvert(DB.PolyLine target) + public SOG.Polyline Convert(DB.PolyLine target) { - var coords = target.GetCoordinates().SelectMany(coord => _xyzToPointConverter.RawConvert(coord).ToList()).ToList(); + var coords = target.GetCoordinates().SelectMany(coord => _xyzToPointConverter.Convert(coord).ToList()).ToList(); return new SOG.Polyline(coords, _contextStack.Current.SpeckleUnits); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs index e9b8d7e77a..e97cf962f4 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/VectorToSpeckleConverter.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class VectorToSpeckleConverter : IRawConversion +public class VectorToSpeckleConverter : ITypedConverter { private readonly IReferencePointConverter _referencePointConverter; private readonly ScalingServiceToSpeckle _scalingService; @@ -17,7 +17,7 @@ ScalingServiceToSpeckle scalingService _scalingService = scalingService; } - public SOG.Vector RawConvert(DB.XYZ target) + public SOG.Vector Convert(DB.XYZ target) { // POC: originally had a concept of not transforming, but this was // optional arg defaulting to false - removing the argument appeared to break nothing diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs index 4322f45094..bf250d06c3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/Geometry/XyzConversionToPoint.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class XyzConversionToPoint : IRawConversion +public class XyzConversionToPoint : ITypedConverter { private readonly ScalingServiceToSpeckle _toSpeckleScalingService; private readonly IRevitConversionContextStack _contextStack; @@ -18,7 +18,7 @@ IRevitConversionContextStack contextStack _contextStack = contextStack; } - public SOG.Point RawConvert(DB.XYZ target) + public SOG.Point Convert(DB.XYZ target) { var pointToSpeckle = new SOG.Point( _toSpeckleScalingService.ScaleLength(target.X), diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs index a47d7d6ee3..33e1d7fea2 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LevelConversionToSpeckle.cs @@ -3,7 +3,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LevelConversionToSpeckle : IRawConversion +public class LevelConversionToSpeckle : ITypedConverter { private readonly ScalingServiceToSpeckle _scalingService; @@ -12,7 +12,7 @@ public LevelConversionToSpeckle(ScalingServiceToSpeckle scalingService) _scalingService = scalingService; } - public SOBR.RevitLevel RawConvert(DB.Level target) + public SOBR.RevitLevel Convert(DB.Level target) { SOBR.RevitLevel level = new() diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs index 65692ed677..29d3378103 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/LocationConversionToSpeckle.cs @@ -5,29 +5,29 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class LocationConversionToSpeckle : IRawConversion +public class LocationConversionToSpeckle : ITypedConverter { - private readonly IRawConversion _curveConverter; - private readonly IRawConversion _xyzConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _xyzConverter; // POC: review IRawConversion which always returns a Base, this is ToSpeckle, so... this breaks // the meaning of IRawConversion, it could be IToSpeckleRawConversion // also a factory type public LocationConversionToSpeckle( - IRawConversion curveConverter, - IRawConversion xyzConverter + ITypedConverter curveConverter, + ITypedConverter xyzConverter ) { _curveConverter = curveConverter; _xyzConverter = xyzConverter; } - public Base RawConvert(DB.Location target) + public Base Convert(DB.Location target) { return target switch { - DB.LocationCurve curve => (_curveConverter.RawConvert(curve.Curve) as Base)!, // POC: ICurve and Base are not related but we know they must be, had to soft cast and then !. - DB.LocationPoint point => _xyzConverter.RawConvert(point.Point), + DB.LocationCurve curve => (_curveConverter.Convert(curve.Curve) as Base)!, // POC: ICurve and Base are not related but we know they must be, had to soft cast and then !. + DB.LocationPoint point => _xyzConverter.Convert(point.Point), _ => throw new SpeckleConversionException($"Unexpected location type {target.GetType()}") }; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs index 5547c028d6..f7f48974f7 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/MaterialConversionToSpeckle.cs @@ -3,9 +3,9 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class MaterialConversionToSpeckle : IRawConversion +public class MaterialConversionToSpeckle : ITypedConverter { - public RenderMaterial RawConvert(DB.Material target) => + public RenderMaterial Convert(DB.Material target) => // POC: not sure we should be pulling in System.Drawing - // maybe this isn't a problem as it's part of the netstandard Fwk // ideally we'd have serialiser of our own colour class, i.e. to serialise to an uint diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs index 0790d2767e..d294360b2d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrArrayToSpeckleConverter.cs @@ -4,23 +4,23 @@ namespace Speckle.Converters.RevitShared.Raw; -internal sealed class ModelCurveArrArrayConverterToSpeckle : IRawConversion +internal sealed class ModelCurveArrArrayConverterToSpeckle : ITypedConverter { - private readonly IRawConversion _modelCurveArrayConverter; + private readonly ITypedConverter _modelCurveArrayConverter; - public ModelCurveArrArrayConverterToSpeckle(IRawConversion modelCurveArrayConverter) + public ModelCurveArrArrayConverterToSpeckle(ITypedConverter modelCurveArrayConverter) { _modelCurveArrayConverter = modelCurveArrayConverter; } - public SOG.Polycurve[] RawConvert(ModelCurveArrArray target) + public SOG.Polycurve[] Convert(ModelCurveArrArray target) { var polycurves = new Polycurve[target.Size]; var revitArrays = target.Cast().ToArray(); for (int i = 0; i < polycurves.Length; i++) { - polycurves[i] = _modelCurveArrayConverter.RawConvert(revitArrays[i]); + polycurves[i] = _modelCurveArrayConverter.Convert(revitArrays[i]); } return polycurves; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs index 50c9bfc003..5bfd4d11bb 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ModelCurveArrayToSpeckleConverter.cs @@ -6,16 +6,16 @@ namespace Speckle.Converters.RevitShared.Raw; -internal sealed class ModelCurveArrayToSpeckleConverter : IRawConversion +internal sealed class ModelCurveArrayToSpeckleConverter : ITypedConverter { private readonly IRevitConversionContextStack _contextStack; private readonly ScalingServiceToSpeckle _scalingService; - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; public ModelCurveArrayToSpeckleConverter( IRevitConversionContextStack contextStack, ScalingServiceToSpeckle scalingService, - IRawConversion curveConverter + ITypedConverter curveConverter ) { _contextStack = contextStack; @@ -23,7 +23,7 @@ public ModelCurveArrayToSpeckleConverter( _curveConverter = curveConverter; } - public SOG.Polycurve RawConvert(DB.ModelCurveArray target) + public SOG.Polycurve Convert(DB.ModelCurveArray target) { SOG.Polycurve polycurve = new(); var curves = target.Cast().Select(mc => mc.GeometryCurve).ToArray(); @@ -39,7 +39,7 @@ public SOG.Polycurve RawConvert(DB.ModelCurveArray target) polycurve.closed = start.DistanceTo(end) < RevitConversionContextStack.TOLERANCE; polycurve.length = _scalingService.ScaleLength(curves.Sum(x => x.Length)); - polycurve.segments.AddRange(curves.Select(x => _curveConverter.RawConvert(x))); + polycurve.segments.AddRange(curves.Select(x => _curveConverter.Convert(x))); return polycurve; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs index 4f58e6234b..a0b1f01da5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ParameterConversionToSpeckle.cs @@ -5,7 +5,7 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; -public class ParameterConversionToSpeckle : IRawConversion +public class ParameterConversionToSpeckle : ITypedConverter { private readonly ParameterValueExtractor _valueExtractor; @@ -14,7 +14,7 @@ public ParameterConversionToSpeckle(ParameterValueExtractor valueExtractor) _valueExtractor = valueExtractor; } - public SOBR.Parameter RawConvert(Parameter target) + public SOBR.Parameter Convert(Parameter target) { string internalName = target.GetInternalName(); ForgeTypeId? unitTypeId = null; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs similarity index 76% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs index 540cd4ccad..78790ee19e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitConverterToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootToHostConverter.cs @@ -6,20 +6,17 @@ namespace Speckle.Converters.RevitShared; // POC: maybe possible to restrict the access so this cannot be created directly? -public class RevitConverterToSpeckle : ISpeckleConverterToSpeckle +public class RevitRootToHostConverter : IRootToSpeckleConverter { - private readonly IConverterResolver _toSpeckle; - private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; + private readonly IConverterResolver _toSpeckle; private readonly ParameterValueExtractor _parameterValueExtractor; - public RevitConverterToSpeckle( - IConverterResolver toSpeckle, - ToSpeckleConvertedObjectsCache convertedObjectsCache, + public RevitRootToHostConverter( + IConverterResolver toSpeckle, ParameterValueExtractor parameterValueExtractor ) { _toSpeckle = toSpeckle; - _convertedObjectsCache = convertedObjectsCache; _parameterValueExtractor = parameterValueExtractor; } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems index f0af693909..5e5d29480e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Speckle.Converters.RevitShared.projitems @@ -52,15 +52,15 @@ - - - + + + - - - - + + + + @@ -72,9 +72,9 @@ - - - - + + + + \ No newline at end of file diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs similarity index 76% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs index a91f949110..f7a94c8d1f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/BaseTopLevelConverterToSpeckle.cs @@ -6,15 +6,15 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: maybe but could be generic abstract Converters.Common? // or maybe it's not actually doing very much now and can come out -public abstract class BaseConversionToSpeckle - : IHostObjectToSpeckleConversion, +public abstract class BaseTopLevelConverterToSpeckle + : IToSpeckleTopLevelConverter, // POC: why do we need to do this for each base conversion? - IRawConversion + ITypedConverter where TSpeckle : Base { public Base Convert(object target) { - var result = RawConvert((THost)target); + var result = Convert((THost)target); // POC: unless I am going bonkers, we've constrained TSpeckle to Base // so it should always BE base? @@ -28,5 +28,5 @@ public Base Convert(object target) return @base; } - public abstract TSpeckle RawConvert(THost target); + public abstract TSpeckle Convert(THost target); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs similarity index 76% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs index 8066b715fe..c3de2636aa 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/CeilingTopLevelConverterToSpeckle.cs @@ -9,19 +9,19 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DB.Ceiling), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -internal sealed class CeilingConversionToSpeckle : BaseConversionToSpeckle +internal sealed class CeilingTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion> _curveArrArrayConverter; - private readonly IRawConversion _levelConverter; + private readonly ITypedConverter> _curveArrArrayConverter; + private readonly ITypedConverter _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; private readonly DisplayValueExtractor _displayValueExtractor; //private readonly HostedElementConversionToSpeckle _hostedElementConverter; - public CeilingConversionToSpeckle( - IRawConversion> curveArrArrayConverter, - IRawConversion levelConverter, + public CeilingTopLevelConverterToSpeckle( + ITypedConverter> curveArrArrayConverter, + ITypedConverter levelConverter, ParameterValueExtractor parameterValueExtractor, ParameterObjectAssigner parameterObjectAssigner, DisplayValueExtractor displayValueExtractor @@ -34,10 +34,10 @@ DisplayValueExtractor displayValueExtractor _displayValueExtractor = displayValueExtractor; } - public override RevitCeiling RawConvert(DB.Ceiling target) + public override RevitCeiling Convert(DB.Ceiling target) { var sketch = (Sketch)target.Document.GetElement(target.SketchId); - List profiles = _curveArrArrayConverter.RawConvert(sketch.Profile); + List profiles = _curveArrArrayConverter.Convert(sketch.Profile); var speckleCeiling = new RevitCeiling(); @@ -59,7 +59,7 @@ public override RevitCeiling RawConvert(DB.Ceiling target) // but it is never being set. We should be setting it var level = _parameterValueExtractor.GetValueAsDocumentObject(target, DB.BuiltInParameter.LEVEL_PARAM); - speckleCeiling.level = _levelConverter.RawConvert(level); + speckleCeiling.level = _levelConverter.Convert(level); _parameterObjectAssigner.AssignParametersToBase(target, speckleCeiling); speckleCeiling.displayValue = _displayValueExtractor.GetDisplayValue(target); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs similarity index 86% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs index 2e6340e853..c9c9ca5e14 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/DirectShapeTopLevelConverterToSpeckle.cs @@ -7,13 +7,13 @@ namespace Speckle.Converters.Revit2023.ToSpeckle; [NameAndRankValue(nameof(DB.DirectShape), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class DirectShapeConversionToSpeckle : BaseConversionToSpeckle +public class DirectShapeTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { private readonly IRevitConversionContextStack _contextStack; private readonly ParameterObjectAssigner _parameterObjectAssigner; private readonly DisplayValueExtractor _displayValueExtractor; - public DirectShapeConversionToSpeckle( + public DirectShapeTopLevelConverterToSpeckle( ParameterObjectAssigner parameterObjectAssigner, IRevitConversionContextStack contextStack, DisplayValueExtractor displayValueExtractor @@ -24,7 +24,7 @@ DisplayValueExtractor displayValueExtractor _displayValueExtractor = displayValueExtractor; } - public override SOBR.DirectShape RawConvert(DB.DirectShape target) + public override SOBR.DirectShape Convert(DB.DirectShape target) { var category = target.Category.GetBuiltInCategory().GetSchemaBuilderCategoryFromBuiltIn(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs similarity index 86% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs index ac3a9fd795..c3b96c9001 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ElementTopLevelConverterToSpeckle.cs @@ -6,16 +6,16 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: not currently used? clearly some missing pieces [NameAndRankValue(nameof(DB.Element), 0)] -public class ElementConversionToSpeckle : BaseConversionToSpeckle +public class ElementTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { private readonly DisplayValueExtractor _displayValueExtractor; - public ElementConversionToSpeckle(DisplayValueExtractor displayValueExtractor) + public ElementTopLevelConverterToSpeckle(DisplayValueExtractor displayValueExtractor) { _displayValueExtractor = displayValueExtractor; } - public override RevitElement RawConvert(DB.Element target) + public override RevitElement Convert(DB.Element target) { RevitElement speckleElement = new(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs index 90b05a640a..d46c93794f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ExtrusionRoofToSpeckleTopLevelConverter.cs @@ -8,20 +8,21 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DB.ExtrusionRoof), 0)] -public class ExtrusionRoofToSpeckleTopLevelConverter : BaseConversionToSpeckle +public class ExtrusionRoofToSpeckleTopLevelConverter + : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion _levelConverter; - private readonly IRawConversion _modelCurveArrayConverter; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter _modelCurveArrayConverter; + private readonly ITypedConverter _pointConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly HostedElementConversionToSpeckle _hostedElementConverter; private readonly ParameterObjectAssigner _parameterObjectAssigner; public ExtrusionRoofToSpeckleTopLevelConverter( - IRawConversion levelConverter, - IRawConversion modelCurveArrayConverter, - IRawConversion pointConverter, + ITypedConverter levelConverter, + ITypedConverter modelCurveArrayConverter, + ITypedConverter pointConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, HostedElementConversionToSpeckle hostedElementConverter, @@ -37,7 +38,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public override RevitExtrusionRoof RawConvert(DB.ExtrusionRoof target) + public override RevitExtrusionRoof Convert(DB.ExtrusionRoof target) { var speckleExtrusionRoof = new RevitExtrusionRoof { @@ -46,15 +47,15 @@ public override RevitExtrusionRoof RawConvert(DB.ExtrusionRoof target) }; var plane = target.GetProfile().get_Item(0).SketchPlane.GetPlane(); speckleExtrusionRoof.referenceLine = new SOG.Line( - _pointConverter.RawConvert(plane.Origin.Add(plane.XVec.Normalize().Negate())), - _pointConverter.RawConvert(plane.Origin) + _pointConverter.Convert(plane.Origin.Add(plane.XVec.Normalize().Negate())), + _pointConverter.Convert(plane.Origin) ); var level = _parameterValueExtractor.GetValueAsDocumentObject( target, DB.BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM ); - speckleExtrusionRoof.level = _levelConverter.RawConvert(level); - speckleExtrusionRoof.outline = _modelCurveArrayConverter.RawConvert(target.GetProfile()); + speckleExtrusionRoof.level = _levelConverter.Convert(level); + speckleExtrusionRoof.outline = _modelCurveArrayConverter.Convert(target.GetProfile()); var elementType = (DB.ElementType)target.Document.GetElement(target.GetTypeId()); speckleExtrusionRoof.type = elementType.Name; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs deleted file mode 100644 index ae7c3f9b2c..0000000000 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceConversionToSpeckle.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.RevitShared.ToSpeckle; - -// POC: bin for now? This is also a parent child relationship and may need a pattern for this -// so we don't end up with some god FamilyInstanceConversionToSpeckle converter -[NameAndRankValue(nameof(DB.FamilyInstance), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public sealed class FamilyInstanceConversionToSpeckle : BaseConversionToSpeckle -{ - private readonly IRawConversion _elementConverter; - private readonly IRawConversion _beamConversion; - private readonly IRawConversion _columnConversion; - private readonly IRawConversion _braceConversion; - - public FamilyInstanceConversionToSpeckle( - IRawConversion elementConverter, - IRawConversion beamConversion, - IRawConversion columnConversion, - IRawConversion braceConversion - ) - { - _elementConverter = elementConverter; - _beamConversion = beamConversion; - _columnConversion = columnConversion; - _braceConversion = braceConversion; - } - - public override Base RawConvert(DB.FamilyInstance target) - { - return target.StructuralType switch - { - DB.Structure.StructuralType.Beam => _beamConversion.RawConvert(target), - DB.Structure.StructuralType.Column => _columnConversion.RawConvert(target), - DB.Structure.StructuralType.Brace => _braceConversion.RawConvert(target), - - // POC: return generic element conversion or throw? - // - //throw new SpeckleConversionException( - // $"No conditional converters registered that could convert object of type {target.GetType()}" - //); - _ => _elementConverter.RawConvert(target) - }; - } -} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs new file mode 100644 index 0000000000..446dcd4383 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FamilyInstanceTopLevelConverterToSpeckle.cs @@ -0,0 +1,46 @@ +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; + +namespace Speckle.Converters.RevitShared.ToSpeckle; + +// POC: bin for now? This is also a parent child relationship and may need a pattern for this +// so we don't end up with some god FamilyInstanceTopLevelConverterToSpeckle converter +[NameAndRankValue(nameof(DB.FamilyInstance), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public sealed class FamilyInstanceTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle +{ + private readonly ITypedConverter _elementConverter; + private readonly ITypedConverter _beamConversion; + private readonly ITypedConverter _columnConversion; + private readonly ITypedConverter _braceConversion; + + public FamilyInstanceTopLevelConverterToSpeckle( + ITypedConverter elementConverter, + ITypedConverter beamConversion, + ITypedConverter columnConversion, + ITypedConverter braceConversion + ) + { + _elementConverter = elementConverter; + _beamConversion = beamConversion; + _columnConversion = columnConversion; + _braceConversion = braceConversion; + } + + public override Base Convert(DB.FamilyInstance target) + { + return target.StructuralType switch + { + DB.Structure.StructuralType.Beam => _beamConversion.Convert(target), + DB.Structure.StructuralType.Column => _columnConversion.Convert(target), + DB.Structure.StructuralType.Brace => _braceConversion.Convert(target), + + // POC: return generic element conversion or throw? + // + //throw new SpeckleConversionException( + // $"No conditional converters registered that could convert object of type {target.GetType()}" + //); + _ => _elementConverter.Convert(target) + }; + } +} diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs similarity index 85% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs index 16b409f294..13d0d3086f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FloorTopLevelConverterToSpeckle.cs @@ -12,18 +12,18 @@ namespace Speckle.Converters.Common; // clould be anywhere or all in once place - rooting through box 274 for something you need, when said box has a miriad different // and unrelated items, is no fun. Plus when you need that item, you end up bringing out the whole box/ [NameAndRankValue(nameof(DB.Floor), 0)] -public class FloorConversionToSpeckle : BaseConversionToSpeckle +public class FloorTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion> _curveArrArrayConverter; - private readonly IRawConversion _levelConverter; + private readonly ITypedConverter> _curveArrArrayConverter; + private readonly ITypedConverter _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; private readonly DisplayValueExtractor _displayValueExtractor; private readonly ISlopeArrowExtractor _slopeArrowExtractor; - public FloorConversionToSpeckle( - IRawConversion> curveArrArrayConverter, - IRawConversion levelConverter, + public FloorTopLevelConverterToSpeckle( + ITypedConverter> curveArrArrayConverter, + ITypedConverter levelConverter, ParameterValueExtractor parameterValueExtractor, ParameterObjectAssigner parameterObjectAssigner, DisplayValueExtractor displayValueExtractor, @@ -38,12 +38,12 @@ ISlopeArrowExtractor slopeArrowExtractor _slopeArrowExtractor = slopeArrowExtractor; } - public override SOBR.RevitFloor RawConvert(DB.Floor target) + public override SOBR.RevitFloor Convert(DB.Floor target) { SOBR.RevitFloor speckleFloor = new(); var sketch = (DB.Sketch)target.Document.GetElement(target.SketchId); - List profiles = _curveArrArrayConverter.RawConvert(sketch.Profile); + List profiles = _curveArrArrayConverter.Convert(sketch.Profile); DB.ElementType type = (DB.ElementType)target.Document.GetElement(target.GetTypeId()); @@ -62,7 +62,7 @@ public override SOBR.RevitFloor RawConvert(DB.Floor target) } var level = _parameterValueExtractor.GetValueAsDocumentObject(target, DB.BuiltInParameter.LEVEL_PARAM); - speckleFloor.level = _levelConverter.RawConvert(level); + speckleFloor.level = _levelConverter.Convert(level); speckleFloor.structural = _parameterValueExtractor.GetValueAsBool(target, DB.BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL) ?? false; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs index c4bc3379de..1c8e74bb04 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/FootPrintRoofToSpeckleTopLevelConverter.cs @@ -11,18 +11,19 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DB.FootPrintRoof), 0)] -public class FootPrintRoofToSpeckleTopLevelConverter : BaseConversionToSpeckle +public class FootPrintRoofToSpeckleTopLevelConverter + : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion _levelConverter; - private readonly IRawConversion _modelCurveArrArrayConverter; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter _modelCurveArrArrayConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly DisplayValueExtractor _displayValueExtractor; private readonly HostedElementConversionToSpeckle _hostedElementConverter; private readonly ParameterObjectAssigner _parameterObjectAssigner; public FootPrintRoofToSpeckleTopLevelConverter( - IRawConversion levelConverter, - IRawConversion modelCurveArrArrayConverter, + ITypedConverter levelConverter, + ITypedConverter modelCurveArrArrayConverter, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, HostedElementConversionToSpeckle hostedElementConverter, @@ -37,7 +38,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public override RevitFootprintRoof RawConvert(FootPrintRoof target) + public override RevitFootprintRoof Convert(FootPrintRoof target) { var baseLevel = _parameterValueExtractor.GetValueAsDocumentObject( target, @@ -58,8 +59,8 @@ out var topLevel RevitFootprintRoof speckleFootprintRoof = new() { - level = _levelConverter.RawConvert(baseLevel), - cutOffLevel = topLevel is not null ? _levelConverter.RawConvert(topLevel) : null, + level = _levelConverter.Convert(baseLevel), + cutOffLevel = topLevel is not null ? _levelConverter.Convert(topLevel) : null, slope = slope }; @@ -67,7 +68,7 @@ out var topLevel // are voids // POC: CNX-9403 in current connector, we are doing serious gymnastics to get the slope of the floor as defined by // slope arrow. The way we are doing it relies on dynamic props and only works for Revit <-> Revit - var profiles = _modelCurveArrArrayConverter.RawConvert(target.GetProfiles()); + var profiles = _modelCurveArrArrayConverter.Convert(target.GetProfiles()); speckleFootprintRoof.outline = profiles.FirstOrDefault(); speckleFootprintRoof.voids = profiles.Skip(1).ToList(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs index 5709bba293..53eef628a9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/HostedElementConversionToSpeckle.cs @@ -12,12 +12,12 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; public class HostedElementConversionToSpeckle { private readonly ToSpeckleConvertedObjectsCache _convertedObjectsCache; - private readonly ISpeckleConverterToSpeckle _converter; + private readonly IRootToSpeckleConverter _converter; private readonly IRevitConversionContextStack _contextStack; public HostedElementConversionToSpeckle( ToSpeckleConvertedObjectsCache convertedObjectsCache, - ISpeckleConverterToSpeckle converter, + IRootToSpeckleConverter converter, IRevitConversionContextStack contextStack ) { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs index 25094cb0e9..240cbe4713 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/ModelCurveToSpeckleTopLevelConverter.cs @@ -8,13 +8,13 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: ModelCurve looks a bit bogus and we may wish to revise what that is and how it inherits // see https://spockle.atlassian.net/browse/CNX-9381 [NameAndRankValue(nameof(DB.ModelCurve), 0)] -public class ModelCurveToSpeckleTopLevelConverter : BaseConversionToSpeckle +public class ModelCurveToSpeckleTopLevelConverter : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; private readonly IRevitConversionContextStack _conversionContext; public ModelCurveToSpeckleTopLevelConverter( - IRawConversion curveConverter, + ITypedConverter curveConverter, IRevitConversionContextStack conversionContext ) { @@ -22,11 +22,11 @@ IRevitConversionContextStack conversionContext _conversionContext = conversionContext; } - public override SOBR.Curve.ModelCurve RawConvert(DB.ModelCurve target) + public override SOBR.Curve.ModelCurve Convert(DB.ModelCurve target) { var modelCurve = new SOBR.Curve.ModelCurve() { - baseCurve = _curveConverter.RawConvert(target.GeometryCurve), + baseCurve = _curveConverter.Convert(target.GeometryCurve), lineStyle = target.LineStyle.Name, elementId = target.Id.ToString(), units = _conversionContext.Current.SpeckleUnits diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelConversion.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs similarity index 85% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelConversion.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs index 464e78ba01..77f9ce831c 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelConversion.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoofBaseToSpeckleTopLevelTopLevelConverter.cs @@ -7,13 +7,14 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DB.RoofBase), 0)] -internal sealed class RoofBaseToSpeckleTopLevelConversion : BaseConversionToSpeckle +internal sealed class RoofBaseToSpeckleTopLevelTopLevelConverter + : BaseTopLevelConverterToSpeckle { private readonly DisplayValueExtractor _displayValueExtractor; private readonly HostedElementConversionToSpeckle _hostedElementConverter; private readonly ParameterObjectAssigner _parameterObjectAssigner; - public RoofBaseToSpeckleTopLevelConversion( + public RoofBaseToSpeckleTopLevelTopLevelConverter( DisplayValueExtractor displayValueExtractor, HostedElementConversionToSpeckle hostedElementConverter, ParameterObjectAssigner parameterObjectAssigner @@ -24,7 +25,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public override RevitRoof RawConvert(RoofBase target) + public override RevitRoof Convert(RoofBase target) { RevitRoof revitRoof = new(); var elementType = (ElementType)target.Document.GetElement(target.GetTypeId()); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs similarity index 68% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs index 16a94cac1e..6e4e1f91cb 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/RoomTopLevelConverterToSpeckle.cs @@ -7,22 +7,22 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; [NameAndRankValue(nameof(DBA.Room), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class RoomConversionToSpeckle : BaseConversionToSpeckle +public class RoomTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { private readonly DisplayValueExtractor _displayValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; - private readonly IRawConversion _levelConverter; + private readonly ITypedConverter _levelConverter; private readonly ParameterValueExtractor _parameterValueExtractor; - private readonly IRawConversion _locationConverter; - private readonly IRawConversion, SOG.Polycurve> _boundarySegmentConverter; + private readonly ITypedConverter _locationConverter; + private readonly ITypedConverter, SOG.Polycurve> _boundarySegmentConverter; - public RoomConversionToSpeckle( + public RoomTopLevelConverterToSpeckle( DisplayValueExtractor displayValueExtractor, ParameterObjectAssigner parameterObjectAssigner, - IRawConversion levelConverter, + ITypedConverter levelConverter, ParameterValueExtractor parameterValueExtractor, - IRawConversion locationConverter, - IRawConversion, SOG.Polycurve> boundarySegmentConverter + ITypedConverter locationConverter, + ITypedConverter, SOG.Polycurve> boundarySegmentConverter ) { _displayValueExtractor = displayValueExtractor; @@ -33,19 +33,19 @@ public RoomConversionToSpeckle( _boundarySegmentConverter = boundarySegmentConverter; } - public override SOBE.Room RawConvert(DBA.Room target) + public override SOBE.Room Convert(DBA.Room target) { var number = target.Number; var name = _parameterValueExtractor.GetValueAsString(target, DB.BuiltInParameter.ROOM_NAME); var area = _parameterValueExtractor.GetValueAsDouble(target, DB.BuiltInParameter.ROOM_AREA); var displayValue = _displayValueExtractor.GetDisplayValue(target); - var basePoint = (SOG.Point)_locationConverter.RawConvert(target.Location); - var level = _levelConverter.RawConvert(target.Level); + var basePoint = (SOG.Point)_locationConverter.Convert(target.Location); + var level = _levelConverter.Convert(target.Level); var profiles = target .GetBoundarySegments(new DB.SpatialElementBoundaryOptions()) - .Select(c => (ICurve)_boundarySegmentConverter.RawConvert(c)) + .Select(c => (ICurve)_boundarySegmentConverter.Convert(c)) .ToList(); var outline = profiles.First(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs similarity index 75% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs index f26cbfb6a6..eea4ea51c9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/TopographyTopLevelConverterToSpeckle.cs @@ -6,12 +6,13 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: needs review feels, BIG, feels like it could be broken down.. // i.e. GetParams(), GetGeom()? feels like it's doing too much [NameAndRankValue(nameof(DBA.TopographySurface), 0)] -public class TopographyConversionToSpeckle : BaseConversionToSpeckle +public class TopographyTopLevelConverterToSpeckle + : BaseTopLevelConverterToSpeckle { private readonly DisplayValueExtractor _displayValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; - public TopographyConversionToSpeckle( + public TopographyTopLevelConverterToSpeckle( DisplayValueExtractor displayValueExtractor, ParameterObjectAssigner parameterObjectAssigner ) @@ -20,7 +21,7 @@ ParameterObjectAssigner parameterObjectAssigner _parameterObjectAssigner = parameterObjectAssigner; } - public override SOBR.RevitTopography RawConvert(DBA.TopographySurface target) + public override SOBR.RevitTopography Convert(DBA.TopographySurface target) { var speckleTopo = new SOBR.RevitTopography { @@ -28,7 +29,7 @@ public override SOBR.RevitTopography RawConvert(DBA.TopographySurface target) elementId = target.Id.ToString() }; - // POC: shouldn't we just do this in the RevitConverterToSpeckle ? + // POC: shouldn't we just do this in the RevitConverter ? _parameterObjectAssigner.AssignParametersToBase(target, speckleTopo); return speckleTopo; diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs similarity index 84% rename from DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs rename to DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs index f69d6a14b5..8e0cce3ba9 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/ToSpeckle/WallTopLevelConverterToSpeckle.cs @@ -12,26 +12,26 @@ namespace Speckle.Converters.RevitShared.ToSpeckle; // POC: needs review feels, BIG, feels like it could be broken down.. // i.e. GetParams(), GetGeom()? feels like it's doing too much [NameAndRankValue(nameof(DB.Wall), 0)] -public class WallConversionToSpeckle : BaseConversionToSpeckle +public class WallTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle { - private readonly IRawConversion _curveConverter; - private readonly IRawConversion _levelConverter; - private readonly IRawConversion> _curveArrArrayConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _levelConverter; + private readonly ITypedConverter> _curveArrArrayConverter; private readonly ParameterValueExtractor _parameterValueExtractor; private readonly IRevitConversionContextStack _contextStack; private readonly DisplayValueExtractor _displayValueExtractor; private readonly ParameterObjectAssigner _parameterObjectAssigner; - private readonly ISpeckleConverterToSpeckle _converter; + private readonly IRootToSpeckleConverter _converter; - public WallConversionToSpeckle( - IRawConversion curveConverter, - IRawConversion levelConverter, - IRawConversion> curveArrArrayConverter, + public WallTopLevelConverterToSpeckle( + ITypedConverter curveConverter, + ITypedConverter levelConverter, + ITypedConverter> curveArrArrayConverter, IRevitConversionContextStack contextStack, ParameterValueExtractor parameterValueExtractor, DisplayValueExtractor displayValueExtractor, ParameterObjectAssigner parameterObjectAssigner, - ISpeckleConverterToSpeckle converter + IRootToSpeckleConverter converter ) { _curveConverter = curveConverter; @@ -44,7 +44,7 @@ ISpeckleConverterToSpeckle converter _converter = converter; } - public override SOBR.RevitWall RawConvert(DB.Wall target) + public override SOBR.RevitWall Convert(DB.Wall target) { SOBR.RevitWall speckleWall = new() { family = target.WallType.FamilyName.ToString(), type = target.WallType.Name }; @@ -66,19 +66,19 @@ private void AssignSpecificParameters(DB.Wall target, RevitWall speckleWall) ); } - speckleWall.baseLine = _curveConverter.RawConvert(locationCurve.Curve); + speckleWall.baseLine = _curveConverter.Convert(locationCurve.Curve); var level = _parameterValueExtractor.GetValueAsDocumentObject( target, DB.BuiltInParameter.WALL_BASE_CONSTRAINT ); - speckleWall.level = _levelConverter.RawConvert(level); + speckleWall.level = _levelConverter.Convert(level); var topLevel = _parameterValueExtractor.GetValueAsDocumentObject( target, DB.BuiltInParameter.WALL_BASE_CONSTRAINT ); - speckleWall.topLevel = _levelConverter.RawConvert(topLevel); + speckleWall.topLevel = _levelConverter.Convert(topLevel); // POC : what to do if these parameters are unset (instead of assigning default) _ = _parameterValueExtractor.TryGetValueAsDouble( @@ -167,7 +167,7 @@ private void AssignVoids(DB.Wall target, SOBR.RevitWall speckleWall) return; } - List polycurves = _curveArrArrayConverter.RawConvert(profile); + List polycurves = _curveArrArrayConverter.Convert(profile); if (polycurves.Count > 1) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs index c2c0fca280..9117848c90 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs @@ -2,7 +2,6 @@ using Speckle.Converters.Common; using Rhino; using Speckle.Converters.Common.DependencyInjection; -using Speckle.Converters.Rhino7.ToSpeckle; namespace Speckle.Converters.Rhino7.DependencyInjection; @@ -10,12 +9,8 @@ public class RhinoConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + builder.AddConverterCommon(); // single stack per conversion builder.AddScoped, RhinoConversionContextStack>(); - - // To Speckle - builder.AddScoped, RhinoToSpeckleUnitConverter>(); - builder.AddScoped(); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseConversion.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs similarity index 77% rename from DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseConversion.cs rename to DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs index 27435f3333..75ff2162c2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseConversion.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs @@ -6,16 +6,16 @@ namespace Speckle.Converters.Rhino7; -public abstract class SpeckleToHostGeometryBaseConversion : ISpeckleObjectToHostConversion +public abstract class SpeckleToHostGeometryBaseTopLevelConverter : IToHostTopLevelConverter where TIn : Base where TOut : RG.GeometryBase { protected IConversionContextStack ContextStack { get; private set; } - private readonly IRawConversion _geometryBaseConverter; + private readonly ITypedConverter _geometryBaseConverter; - protected SpeckleToHostGeometryBaseConversion( + protected SpeckleToHostGeometryBaseTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) { ContextStack = contextStack; @@ -25,7 +25,7 @@ IRawConversion geometryBaseConverter public object Convert(Base target) { var castedBase = (TIn)target; - var result = _geometryBaseConverter.RawConvert(castedBase); + var result = _geometryBaseConverter.Convert(castedBase); /* * POC: CNX-9270 Looking at a simpler, more performant way of doing unit scaling on `ToNative` diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs index 291395ee9e..0068c38ef2 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/ArcToHostConverter.cs @@ -5,14 +5,14 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a SpeckleArcRaw object to a Rhino.Geometry.Arc object or Rhino.Geometry.ArcCurve object. /// -public class ArcToHostConverter : IRawConversion, IRawConversion +public class ArcToHostConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; public ArcToHostConverter( - IRawConversion pointConverter, - IRawConversion intervalConverter + ITypedConverter pointConverter, + ITypedConverter intervalConverter ) { _pointConverter = pointConverter; @@ -26,12 +26,12 @@ public ArcToHostConverter( /// The converted object. /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ This method does not preserve the original curve domain
- public RG.Arc RawConvert(SOG.Arc target) + public RG.Arc Convert(SOG.Arc target) { var rhinoArc = new RG.Arc( - _pointConverter.RawConvert(target.startPoint), - _pointConverter.RawConvert(target.midPoint), - _pointConverter.RawConvert(target.endPoint) + _pointConverter.Convert(target.startPoint), + _pointConverter.Convert(target.midPoint), + _pointConverter.Convert(target.endPoint) ); return rhinoArc; } @@ -45,10 +45,10 @@ public RG.Arc RawConvert(SOG.Arc target) /// The converted object. /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ Converting to instead of preserves the domain of the curve.
- RG.ArcCurve IRawConversion.RawConvert(SOG.Arc target) + RG.ArcCurve ITypedConverter.Convert(SOG.Arc target) { - var rhinoArc = RawConvert(target); - var arcCurve = new RG.ArcCurve(rhinoArc) { Domain = _intervalConverter.RawConvert(target.domain) }; + var rhinoArc = Convert(target); + var arcCurve = new RG.ArcCurve(rhinoArc) { Domain = _intervalConverter.Convert(target.domain) }; return arcCurve; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs index e27a846a1b..db94e2f7f0 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/BrepToHostConverter.cs @@ -5,20 +5,20 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class BrepToHostConverter : IRawConversion +public class BrepToHostConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _curveConverter; - private readonly IRawConversion _surfaceConverter; - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _surfaceConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; public BrepToHostConverter( IConversionContextStack contextStack, - IRawConversion curveConverter, - IRawConversion surfaceConverter, - IRawConversion pointConverter, - IRawConversion intervalConverter + ITypedConverter curveConverter, + ITypedConverter surfaceConverter, + ITypedConverter pointConverter, + ITypedConverter intervalConverter ) { _contextStack = contextStack; @@ -40,17 +40,17 @@ public BrepToHostConverter( /// The Speckle Brep object to be converted. /// The equivalent Rhino Brep object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Brep RawConvert(SOG.Brep target) + public RG.Brep Convert(SOG.Brep target) { var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; var rhinoBrep = new RG.Brep(); // Geometry goes in first, always. Order doesn't matter. - target.Curve3D.ForEach(curve => rhinoBrep.AddEdgeCurve(_curveConverter.RawConvert(curve))); - target.Curve2D.ForEach(curve => rhinoBrep.AddTrimCurve(_curveConverter.RawConvert(curve))); - target.Surfaces.ForEach(surface => rhinoBrep.AddSurface(_surfaceConverter.RawConvert(surface))); - target.Vertices.ForEach(vertex => rhinoBrep.Vertices.Add(_pointConverter.RawConvert(vertex), tolerance)); + target.Curve3D.ForEach(curve => rhinoBrep.AddEdgeCurve(_curveConverter.Convert(curve))); + target.Curve2D.ForEach(curve => rhinoBrep.AddTrimCurve(_curveConverter.Convert(curve))); + target.Surfaces.ForEach(surface => rhinoBrep.AddSurface(_surfaceConverter.Convert(surface))); + target.Vertices.ForEach(vertex => rhinoBrep.Vertices.Add(_pointConverter.Convert(vertex), tolerance)); // Order matters, first edges, then faces, finally loops. target.Edges.ForEach(edge => ConvertSpeckleBrepEdge(rhinoBrep, edge, tolerance)); @@ -151,7 +151,7 @@ private void ConvertSpeckleBrepEdge(RG.Brep rhinoBrep, SOG.BrepEdge speckleEdge, speckleEdge.StartIndex, speckleEdge.EndIndex, speckleEdge.Curve3dIndex, - _intervalConverter.RawConvert(speckleEdge.Domain), + _intervalConverter.Convert(speckleEdge.Domain), tolerance ); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs index 06f31256a5..1431d3fc1a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CircleToHostConverter.cs @@ -4,26 +4,26 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// This class is responsible for converting a into and objects. -/// Implements the interface, +/// Implements the interface, /// providing implementation for to and conversion. /// -public class CircleToHostConverter : IRawConversion, IRawConversion +public class CircleToHostConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; /// /// Constructs a new instance of the class. /// /// - /// An implementation of used to convert into . + /// An implementation of used to convert into . /// /// - /// An implementation of used to convert into . + /// An implementation of used to convert into . /// public CircleToHostConverter( - IRawConversion intervalConverter, - IRawConversion planeConverter + ITypedConverter intervalConverter, + ITypedConverter planeConverter ) { _intervalConverter = intervalConverter; @@ -40,7 +40,7 @@ public CircleToHostConverter( /// /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
- public RG.Circle RawConvert(SOG.Circle target) + public RG.Circle Convert(SOG.Circle target) { if (target.radius == null) { @@ -48,11 +48,11 @@ public RG.Circle RawConvert(SOG.Circle target) throw new ArgumentNullException(nameof(target), "Circle radius cannot be null"); } - var plane = _planeConverter.RawConvert(target.plane); + var plane = _planeConverter.Convert(target.plane); var radius = target.radius.Value; return new RG.Circle(plane, radius); } - RG.ArcCurve IRawConversion.RawConvert(SOG.Circle target) => - new(RawConvert(target)) { Domain = _intervalConverter.RawConvert(target.domain) }; + RG.ArcCurve ITypedConverter.Convert(SOG.Circle target) => + new(Convert(target)) { Domain = _intervalConverter.Convert(target.domain) }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs index a9b13e3b76..a61425dc2a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/CurveToHostConverter.cs @@ -3,26 +3,26 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class CurveToHostConverter : IRawConversion +public class CurveToHostConverter : ITypedConverter { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _ellipseConverter; - private readonly IRawConversion _spiralConverter; - private readonly IRawConversion _circleConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _polyCurveConverter; - private readonly IRawConversion _nurbsCurveConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _ellipseConverter; + private readonly ITypedConverter _spiralConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _polyCurveConverter; + private readonly ITypedConverter _nurbsCurveConverter; public CurveToHostConverter( - IRawConversion lineConverter, - IRawConversion arcConverter, - IRawConversion ellipseConverter, - IRawConversion spiralConverter, - IRawConversion circleConverter, - IRawConversion polylineConverter, - IRawConversion polyCurveConverter, - IRawConversion nurbsCurveConverter + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter ellipseConverter, + ITypedConverter spiralConverter, + ITypedConverter circleConverter, + ITypedConverter polylineConverter, + ITypedConverter polyCurveConverter, + ITypedConverter nurbsCurveConverter ) { _lineConverter = lineConverter; @@ -42,17 +42,17 @@ public CurveToHostConverter( /// 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 RG.Curve RawConvert(ICurve target) => + public RG.Curve Convert(ICurve target) => target switch { - SOG.Line line => _lineConverter.RawConvert(line), - SOG.Arc arc => _arcConverter.RawConvert(arc), - SOG.Circle circle => _circleConverter.RawConvert(circle), - SOG.Ellipse ellipse => _ellipseConverter.RawConvert(ellipse), - SOG.Spiral spiral => _spiralConverter.RawConvert(spiral), - SOG.Polyline polyline => _polylineConverter.RawConvert(polyline), - SOG.Curve curve => _nurbsCurveConverter.RawConvert(curve), - SOG.Polycurve polyCurve => _polyCurveConverter.RawConvert(polyCurve), + 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 => _spiralConverter.Convert(spiral), + SOG.Polyline polyline => _polylineConverter.Convert(polyline), + SOG.Curve curve => _nurbsCurveConverter.Convert(curve), + SOG.Polycurve polyCurve => _polyCurveConverter.Convert(polyCurve), _ => throw new NotSupportedException($"Unable to convert curves of type {target.GetType().Name}") }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs index a394547db8..74f309a61f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/EllipseToHostConverter.cs @@ -3,15 +3,15 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; public class EllipseToHostConverter - : IRawConversion, - IRawConversion + : ITypedConverter, + ITypedConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; public EllipseToHostConverter( - IRawConversion planeConverter, - IRawConversion intervalConverter + ITypedConverter planeConverter, + ITypedConverter intervalConverter ) { _planeConverter = planeConverter; @@ -26,18 +26,14 @@ public EllipseToHostConverter( /// Thrown when or properties are null. /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
- public RG.Ellipse RawConvert(SOG.Ellipse target) + public RG.Ellipse Convert(SOG.Ellipse target) { if (!target.firstRadius.HasValue || !target.secondRadius.HasValue) { throw new InvalidOperationException($"Ellipses cannot have null radii"); } - return new RG.Ellipse( - _planeConverter.RawConvert(target.plane), - target.firstRadius.Value, - target.secondRadius.Value - ); + return new RG.Ellipse(_planeConverter.Convert(target.plane), target.firstRadius.Value, target.secondRadius.Value); } /// @@ -47,15 +43,15 @@ public RG.Ellipse RawConvert(SOG.Ellipse target) /// /// A that represents the provided . /// - RG.NurbsCurve IRawConversion.RawConvert(SOG.Ellipse target) + RG.NurbsCurve ITypedConverter.Convert(SOG.Ellipse target) { - var rhinoEllipse = RawConvert(target); + var rhinoEllipse = Convert(target); var rhinoNurbsEllipse = rhinoEllipse.ToNurbsCurve(); - rhinoNurbsEllipse.Domain = _intervalConverter.RawConvert(target.domain); + rhinoNurbsEllipse.Domain = _intervalConverter.Convert(target.domain); if (target.trimDomain != null) { - rhinoNurbsEllipse = rhinoNurbsEllipse.Trim(_intervalConverter.RawConvert(target.trimDomain)).ToNurbsCurve(); + rhinoNurbsEllipse = rhinoNurbsEllipse.Trim(_intervalConverter.Convert(target.trimDomain)).ToNurbsCurve(); } return rhinoNurbsEllipse; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs index 9865ff8c54..f0363a387d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/FlatPointListToHostConverter.cs @@ -7,7 +7,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a flat list of raw double values to a Point3dList. /// -public class FlatPointListToHostConverter : IRawConversion, Point3dList> +public class FlatPointListToHostConverter : ITypedConverter, Point3dList> { /// /// Converts a flat list of raw double values to a Point3dList. @@ -19,7 +19,7 @@ public class FlatPointListToHostConverter : IRawConversion /// with the numbers being coordinates of each point in the format {x1, y1, z1, x2, y2, z2, ..., xN, yN, zN} /// /// Throws when the input list count is not a multiple of 3. - public Point3dList RawConvert(IReadOnlyList target) + public Point3dList Convert(IReadOnlyList target) { if (target.Count % 3 != 0) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs index 405d1b2ac3..f201283ebd 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/IntervalToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class IntervalToHostConverter : IRawConversion +public class IntervalToHostConverter : ITypedConverter { /// /// Converts a Speckle Interval object to a Rhino.Geometry.Interval object. @@ -11,7 +11,7 @@ public class IntervalToHostConverter : IRawConversion /// The converted Rhino.Geometry.Interval object. /// Thrown when the start or end value of the Interval is null. /// ⚠️ This conversion does NOT perform scaling. - public RG.Interval RawConvert(SOP.Interval target) + public RG.Interval Convert(SOP.Interval target) { if (!target.start.HasValue || !target.end.HasValue) // POC: CNX-9272 Interval start and end being nullable makes no sense. { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs index 2d2846f1bf..c549e96741 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/LineToHostConverter.cs @@ -2,11 +2,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class LineToHostConverter : IRawConversion, IRawConversion +public class LineToHostConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _pointConverter; - public LineToHostConverter(IRawConversion pointConverter) + public LineToHostConverter(ITypedConverter pointConverter) { _pointConverter = pointConverter; } @@ -22,13 +22,13 @@ public LineToHostConverter(IRawConversion pointConverter) /// If you need it preserved you must request a conversion to /// conversion instead /// - public RG.Line RawConvert(SOG.Line target) => - new(_pointConverter.RawConvert(target.start), _pointConverter.RawConvert(target.end)); + public RG.Line Convert(SOG.Line target) => + new(_pointConverter.Convert(target.start), _pointConverter.Convert(target.end)); /// /// Converts a Speckle Line object to a Rhino LineCurve object. /// /// The Speckle Line object to convert. /// Returns the resulting Rhino LineCurve object. - RG.LineCurve IRawConversion.RawConvert(SOG.Line target) => new(RawConvert(target)); + RG.LineCurve ITypedConverter.Convert(SOG.Line target) => new(Convert(target)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs index adf67b4f8f..d3917dafd3 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/MeshToHostConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class MeshToHostConverter : IRawConversion +public class MeshToHostConverter : ITypedConverter { - private readonly IRawConversion, Point3dList> _pointListConverter; + private readonly ITypedConverter, Point3dList> _pointListConverter; - public MeshToHostConverter(IRawConversion, Point3dList> pointListConverter) + public MeshToHostConverter(ITypedConverter, Point3dList> pointListConverter) { _pointListConverter = pointListConverter; } @@ -20,13 +20,13 @@ public MeshToHostConverter(IRawConversion, Point3dList> po /// The Speckle mesh object to convert. /// A Rhino mesh object converted from the Speckle mesh. /// ⚠️ This conversion does NOT perform scaling. - public RG.Mesh RawConvert(SOG.Mesh target) + public RG.Mesh Convert(SOG.Mesh target) { target.AlignVerticesWithTexCoordsByIndex(); RG.Mesh m = new(); - var vertices = _pointListConverter.RawConvert(target.vertices); + var vertices = _pointListConverter.Convert(target.vertices); var colors = target.colors.Select(Color.FromArgb).ToArray(); m.Vertices.AddVertices(vertices); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs index 8a18c5b413..9f9bf52811 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/NurbsCurveToHostConverter.cs @@ -3,11 +3,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class NurbsCurveToHostConverter : IRawConversion +public class NurbsCurveToHostConverter : ITypedConverter { - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _intervalConverter; - public NurbsCurveToHostConverter(IRawConversion intervalConverter) + public NurbsCurveToHostConverter(ITypedConverter intervalConverter) { _intervalConverter = intervalConverter; } @@ -19,7 +19,7 @@ public NurbsCurveToHostConverter(IRawConversion inter /// The converted Rhino NurbsCurve object. /// Thrown when the conversion fails. /// ⚠️ This conversion does NOT perform scaling. - public RG.NurbsCurve RawConvert(SOG.Curve target) + public RG.NurbsCurve Convert(SOG.Curve target) { RG.NurbsCurve nurbsCurve = new(target.degree, target.points.Count / 3); @@ -45,7 +45,7 @@ public RG.NurbsCurve RawConvert(SOG.Curve target) } } - nurbsCurve.Domain = _intervalConverter.RawConvert(target.domain); + nurbsCurve.Domain = _intervalConverter.Convert(target.domain); return nurbsCurve; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs index e4068eeeba..49e10ab69e 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PlaneToHostConverter.cs @@ -2,14 +2,14 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PlaneToHostConverter : IRawConversion +public class PlaneToHostConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; public PlaneToHostConverter( - IRawConversion pointConverter, - IRawConversion vectorConverter + ITypedConverter pointConverter, + ITypedConverter vectorConverter ) { _pointConverter = pointConverter; @@ -22,10 +22,10 @@ public PlaneToHostConverter( /// The Speckle Plane object to be converted. /// The converted Rhino Plane object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Plane RawConvert(SOG.Plane target) => + public RG.Plane Convert(SOG.Plane target) => new( - _pointConverter.RawConvert(target.origin), - _vectorConverter.RawConvert(target.xdir), - _vectorConverter.RawConvert(target.ydir) + _pointConverter.Convert(target.origin), + _vectorConverter.Convert(target.xdir), + _vectorConverter.Convert(target.ydir) ); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs index 327c594cad..a6d749b15c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointCloudToHostConverter.cs @@ -4,11 +4,11 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PointCloudToHostConverter : IRawConversion +public class PointCloudToHostConverter : ITypedConverter { - private readonly IRawConversion, Point3dList> _pointListConverter; + private readonly ITypedConverter, Point3dList> _pointListConverter; - public PointCloudToHostConverter(IRawConversion, Point3dList> pointListConverter) + public PointCloudToHostConverter(ITypedConverter, Point3dList> pointListConverter) { _pointListConverter = pointListConverter; } @@ -19,9 +19,9 @@ public PointCloudToHostConverter(IRawConversion, Point3dLi /// The raw Speckle Pointcloud object to convert. /// The converted Rhino PointCloud object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PointCloud RawConvert(SOG.Pointcloud target) + public RG.PointCloud Convert(SOG.Pointcloud target) { - var rhinoPoints = _pointListConverter.RawConvert(target.points); + var rhinoPoints = _pointListConverter.Convert(target.points); var rhinoPointCloud = new RG.PointCloud(rhinoPoints); if (target.colors.Count == rhinoPoints.Count) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs index 676203ef0a..8ce40bcb59 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PointToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PointToHostConverter : IRawConversion, IRawConversion +public class PointToHostConverter : ITypedConverter, ITypedConverter { /// /// Converts a Speckle Point object to a Rhino Point3d object. @@ -10,7 +10,7 @@ public class PointToHostConverter : IRawConversion, IRawC /// The Speckle Point object to convert. /// The converted Rhino Point3d object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Point3d RawConvert(SOG.Point target) => new(target.x, target.y, target.z); + public RG.Point3d Convert(SOG.Point target) => new(target.x, target.y, target.z); /// /// Converts a Speckle Point object to a Rhino Point object. @@ -18,5 +18,5 @@ public class PointToHostConverter : IRawConversion, IRawC /// The Speckle Point object to convert. /// The converted Rhino Point object. /// ⚠️ This conversion does NOT perform scaling. - RG.Point IRawConversion.RawConvert(SOG.Point target) => new(RawConvert(target)); + RG.Point ITypedConverter.Convert(SOG.Point target) => new(Convert(target)); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs index a1498f07c2..3f35905090 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolyCurveToHostConverter.cs @@ -5,13 +5,13 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PolyCurveToHostConverter : IRawConversion +public class PolyCurveToHostConverter : ITypedConverter { - public IRawConversion? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. + public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _intervalConverter; - public PolyCurveToHostConverter(IRawConversion intervalConverter) + public PolyCurveToHostConverter(ITypedConverter intervalConverter) { _intervalConverter = intervalConverter; } @@ -22,13 +22,13 @@ public PolyCurveToHostConverter(IRawConversion interv /// The SpecklePolyCurve object to convert. /// The converted Rhino PolyCurve object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PolyCurve RawConvert(SOG.Polycurve target) + public RG.PolyCurve Convert(SOG.Polycurve target) { RG.PolyCurve result = new(); foreach (var segment in target.segments) { - var childCurve = CurveConverter.NotNull().RawConvert(segment); + var childCurve = CurveConverter.NotNull().Convert(segment); bool success = result.AppendSegment(childCurve); if (!success) { @@ -36,7 +36,7 @@ public RG.PolyCurve RawConvert(SOG.Polycurve target) } } - result.Domain = _intervalConverter.RawConvert(target.domain); + result.Domain = _intervalConverter.Convert(target.domain); return result; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs index 546becbb40..5abe48fed5 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/PolylineToHostConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; public class PolylineToHostConverter - : IRawConversion, - IRawConversion + : ITypedConverter, + ITypedConverter { - private readonly IRawConversion, Point3dList> _pointListConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter, Point3dList> _pointListConverter; + private readonly ITypedConverter _intervalConverter; public PolylineToHostConverter( - IRawConversion, Point3dList> pointListConverter, - IRawConversion intervalConverter + ITypedConverter, Point3dList> pointListConverter, + ITypedConverter intervalConverter ) { _pointListConverter = pointListConverter; @@ -30,9 +30,9 @@ public PolylineToHostConverter( /// If you need it preserved you must request a conversion to /// conversion instead /// - public RG.Polyline RawConvert(SOG.Polyline target) + public RG.Polyline Convert(SOG.Polyline target) { - var points = _pointListConverter.RawConvert(target.value); + var points = _pointListConverter.Convert(target.value); if (target.closed) { @@ -52,10 +52,10 @@ public RG.Polyline RawConvert(SOG.Polyline target) /// The Speckle polyline object to be converted. /// The converted Rhino Polyline object. /// ⚠️ This conversion does NOT perform scaling. - RG.PolylineCurve IRawConversion.RawConvert(SOG.Polyline target) + RG.PolylineCurve ITypedConverter.Convert(SOG.Polyline target) { - var poly = RawConvert(target).ToPolylineCurve(); - poly.Domain = _intervalConverter.RawConvert(target.domain); + var poly = Convert(target).ToPolylineCurve(); + poly.Domain = _intervalConverter.Convert(target.domain); return poly; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs index eaaf5d92e6..cb7f5a8745 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SpiralToHostConverter.cs @@ -2,14 +2,14 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpiralToHostConverter : IRawConversion +public class SpiralToHostConverter : ITypedConverter { - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _intervalConverter; public SpiralToHostConverter( - IRawConversion polylineConverter, - IRawConversion intervalConverter + ITypedConverter polylineConverter, + ITypedConverter intervalConverter ) { _polylineConverter = polylineConverter; @@ -22,10 +22,10 @@ public SpiralToHostConverter( /// The Speckle Spiral object to be converted. /// A Rhino PolylineCurve object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PolylineCurve RawConvert(SOG.Spiral target) + public RG.PolylineCurve Convert(SOG.Spiral target) { - var result = _polylineConverter.RawConvert(target.displayValue); - result.Domain = _intervalConverter.RawConvert(target.domain); + var result = _polylineConverter.Convert(target.displayValue); + result.Domain = _intervalConverter.Convert(target.domain); return result; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs index 0cb7e67818..91da44ec59 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/SurfaceToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SurfaceToHostConverter : IRawConversion +public class SurfaceToHostConverter : ITypedConverter { /// /// Converts a raw Speckle surface to a Rhino NURBS surface. @@ -10,7 +10,7 @@ public class SurfaceToHostConverter : IRawConversionThe raw Speckle surface to convert. /// The converted Rhino NURBS surface. /// ⚠️ This conversion does NOT perform scaling. - public RG.NurbsSurface RawConvert(SOG.Surface target) + public RG.NurbsSurface Convert(SOG.Surface target) { // Create rhino surface var points = target.GetControlPoints().ToList(); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs index c0b4bd0b61..77e017f0fd 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/Raw/VectorToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class VectorToHostConverter : IRawConversion +public class VectorToHostConverter : ITypedConverter { /// /// Converts a Speckle.Vector object to a Rhino Vector3d object. @@ -10,5 +10,5 @@ public class VectorToHostConverter : IRawConversion /// The Speckle.Vector to be converted. /// The converted Rhino Vector3d object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Vector3d RawConvert(SOG.Vector target) => new(target.x, target.y, target.z); + public RG.Vector3d Convert(SOG.Vector target) => new(target.x, target.y, target.z); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs index 682ccab3e5..12c4420914 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/ArcToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public ArcToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs index c8b963517d..6ca70d3ad1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/BrepToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Brep), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public BrepToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs index d3c21b737f..1493120e57 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/CircleToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public CircleToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs index 20040aa439..e6a4b03a41 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/EllipseToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public EllipseToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs index be7ff4491d..811433890c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/FallbackToHostTopLevelConverter.cs @@ -8,18 +8,18 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class FallbackToHostTopLevelConverter - : ISpeckleObjectToHostConversion, - IRawConversion> + : IToHostTopLevelConverter, + ITypedConverter> { - private readonly IRawConversion _lineConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _meshConverter; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _meshConverter; private readonly IConversionContextStack _contextStack; public FallbackToHostTopLevelConverter( - IRawConversion lineConverter, - IRawConversion polylineConverter, - IRawConversion meshConverter, + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter meshConverter, IConversionContextStack contextStack ) { @@ -29,18 +29,18 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public object Convert(Base target) => RawConvert((DisplayableObject)target); + public object Convert(Base target) => Convert((DisplayableObject)target); - public List RawConvert(DisplayableObject target) + public List Convert(DisplayableObject target) { var result = new List(); foreach (var item in target.displayValue) { RG.GeometryBase x = item switch { - SOG.Line line => _lineConverter.RawConvert(line), - SOG.Polyline polyline => _polylineConverter.RawConvert(polyline), - SOG.Mesh mesh => _meshConverter.RawConvert(mesh), + SOG.Line line => _lineConverter.Convert(line), + SOG.Polyline polyline => _polylineConverter.Convert(polyline), + SOG.Mesh mesh => _meshConverter.Convert(mesh), _ => throw new NotSupportedException($"Found unsupported fallback geometry: {item.GetType()}") }; x.Transform(GetUnitsTransform(item)); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs index 28c5dbe39e..5a64a3ebab 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/LineToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public LineToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs index 573a401934..c7d047df3b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/MeshToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public MeshToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs index fed264c879..987b46161f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/NurbsCurveToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public NurbsCurveToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs index 7a8f5c962a..51a2613e90 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointCloudToHostTopLevelConverter.cs @@ -5,11 +5,12 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Pointcloud), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointCloudToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class PointCloudToHostTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PointCloudToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs index 94d3049b6f..de10053ce9 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PointToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public PointToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs index 48f9555b3b..d6f8d2f14b 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolycurveToHostTopLevelConverter.cs @@ -5,11 +5,11 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class PolycurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public PolycurveToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs index 388cf84bc2..081f217f04 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToHost/TopLevel/PolylineToHostTopLevelConverter.cs @@ -5,11 +5,12 @@ namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolylineToHostTopLevelConverter : SpeckleToHostGeometryBaseConversion +public class PolylineToHostTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PolylineToHostTopLevelConverter( IConversionContextStack contextStack, - IRawConversion geometryBaseConverter + ITypedConverter geometryBaseConverter ) : base(contextStack, geometryBaseConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs index d40330cba6..8a3eee9cb7 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcCurveToSpeckleConverter.cs @@ -6,17 +6,17 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ArcCurveToSpeckleConverter : IRawConversion, IRawConversion +public class ArcCurveToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _circleConverter; - private readonly IRawConversion _arcConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _intervalConverter; private readonly IConversionContextStack _contextStack; public ArcCurveToSpeckleConverter( - IRawConversion circleConverter, - IRawConversion arcConverter, - IRawConversion intervalConverter, + ITypedConverter circleConverter, + ITypedConverter arcConverter, + ITypedConverter intervalConverter, IConversionContextStack contextStack ) { @@ -36,26 +36,26 @@ IConversionContextStack contextStack /// Otherwise, the output will be a Speckle Arc.
/// ✅ This method preserves the domain of the original ArcCurve.
/// - public ICurve RawConvert(RG.ArcCurve target) + public ICurve Convert(RG.ArcCurve target) { var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; if (target.IsCompleteCircle) { target.TryGetCircle(out var getObj, tolerance); - var cir = _circleConverter.RawConvert(getObj); - cir.domain = _intervalConverter.RawConvert(target.Domain); + var cir = _circleConverter.Convert(getObj); + cir.domain = _intervalConverter.Convert(target.Domain); return cir; } - var arc = _arcConverter.RawConvert(target.Arc); - arc.domain = _intervalConverter.RawConvert(target.Domain); + var arc = _arcConverter.Convert(target.Arc); + arc.domain = _intervalConverter.Convert(target.Domain); return arc; } // POC: CNX-9275 Need to implement this because ICurve and Base are not related, this one is needed at the top-level, the other is for better typed experience. // This also causes us to have to force cast ICurve to Base as a result, which is expected to always succeed but not nice. - /// + /// /// The converted ICurve with a cast to object - Base IRawConversion.RawConvert(RG.ArcCurve target) => (Base)RawConvert(target); + Base ITypedConverter.Convert(RG.ArcCurve target) => (Base)Convert(target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs index b96049f613..82c89c2551 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ArcToSpeckleConverter.cs @@ -4,17 +4,17 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ArcToSpeckleConverter : IRawConversion +public class ArcToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public ArcToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion planeConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -32,9 +32,9 @@ IConversionContextStack contextStack /// /// This method assumes the domain of the arc is (0,1) as Arc types in Rhino do not have domain. You may want to request a conversion from ArcCurve instead. /// - public SOG.Arc RawConvert(RG.Arc target) => + public SOG.Arc Convert(RG.Arc target) => new( - _planeConverter.RawConvert(target.Plane), + _planeConverter.Convert(target.Plane), target.Radius, target.StartAngle, target.EndAngle, @@ -42,11 +42,11 @@ public SOG.Arc RawConvert(RG.Arc target) => _contextStack.Current.SpeckleUnits ) { - startPoint = _pointConverter.RawConvert(target.StartPoint), - midPoint = _pointConverter.RawConvert(target.MidPoint), - endPoint = _pointConverter.RawConvert(target.EndPoint), + startPoint = _pointConverter.Convert(target.StartPoint), + midPoint = _pointConverter.Convert(target.MidPoint), + endPoint = _pointConverter.Convert(target.EndPoint), domain = new SOP.Interval(0, 1), length = target.Length, - bbox = _boxConverter.RawConvert(new RG.Box(target.BoundingBox())) + bbox = _boxConverter.Convert(new RG.Box(target.BoundingBox())) }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs index 6c1526f83d..cebd6e5d70 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BoxToSpeckleConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class BoxToSpeckleConverter : IRawConversion +public class BoxToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; private readonly IConversionContextStack _contextStack; public BoxToSpeckleConverter( - IRawConversion planeConverter, - IRawConversion intervalConverter, + ITypedConverter planeConverter, + ITypedConverter intervalConverter, IConversionContextStack contextStack ) { @@ -26,12 +26,12 @@ IConversionContextStack contextStack ///
/// The Rhino Box object to convert. /// The converted Speckle Box object. - public SOG.Box RawConvert(RG.Box target) => + public SOG.Box Convert(RG.Box target) => new( - _planeConverter.RawConvert(target.Plane), - _intervalConverter.RawConvert(target.X), - _intervalConverter.RawConvert(target.Y), - _intervalConverter.RawConvert(target.Z), + _planeConverter.Convert(target.Plane), + _intervalConverter.Convert(target.X), + _intervalConverter.Convert(target.Y), + _intervalConverter.Convert(target.Z), _contextStack.Current.SpeckleUnits ) { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs index ef5e607bc2..236653d4d7 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/BrepToSpeckleConverter.cs @@ -7,23 +7,23 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class BrepToSpeckleConverter : IRawConversion +public class BrepToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _curveConverter; - private readonly IRawConversion _surfaceConverter; - private readonly IRawConversion _meshConverter; - private readonly IRawConversion _boxConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _surfaceConverter; + private readonly ITypedConverter _meshConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; private readonly IConversionContextStack _contextStack; public BrepToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion curveConverter, - IRawConversion surfaceConverter, - IRawConversion meshConverter, - IRawConversion boxConverter, - IRawConversion intervalConverter, + ITypedConverter pointConverter, + ITypedConverter curveConverter, + ITypedConverter surfaceConverter, + ITypedConverter meshConverter, + ITypedConverter boxConverter, + ITypedConverter intervalConverter, IConversionContextStack contextStack ) { @@ -41,7 +41,7 @@ IConversionContextStack contextStack ///
/// The Brep object to convert. /// The converted Speckle Brep object. - public SOG.Brep RawConvert(RG.Brep target) + public SOG.Brep Convert(RG.Brep target) { var tol = _contextStack.Current.Document.ModelAbsoluteTolerance; target.Repair(tol); @@ -57,7 +57,7 @@ public SOG.Brep RawConvert(RG.Brep target) var displayValue = new List(); if (displayMesh != null) { - displayValue.Add(_meshConverter.RawConvert(displayMesh)); + displayValue.Add(_meshConverter.Convert(displayMesh)); } // POC: CNX-9277 Swap input material for something coming from the context. @@ -67,15 +67,15 @@ public SOG.Brep RawConvert(RG.Brep target) // } // Vertices, uv curves, 3d curves and surfaces - var vertices = target.Vertices.Select(vertex => _pointConverter.RawConvert(vertex.Location)).ToList(); - var curves3d = target.Curves3D.Select(curve3d => _curveConverter.RawConvert(curve3d)).ToList(); - var surfaces = target.Surfaces.Select(srf => _surfaceConverter.RawConvert(srf.ToNurbsSurface())).ToList(); + var vertices = target.Vertices.Select(vertex => _pointConverter.Convert(vertex.Location)).ToList(); + var curves3d = target.Curves3D.Select(curve3d => _curveConverter.Convert(curve3d)).ToList(); + var surfaces = target.Surfaces.Select(srf => _surfaceConverter.Convert(srf.ToNurbsSurface())).ToList(); List curves2d; using (_contextStack.Push(Units.None)) { // Curves2D are unitless, so we convert them within a new pushed context with None units. - curves2d = target.Curves2D.Select(curve2d => _curveConverter.RawConvert(curve2d)).ToList(); + curves2d = target.Curves2D.Select(curve2d => _curveConverter.Convert(curve2d)).ToList(); } var speckleBrep = new SOG.Brep @@ -89,7 +89,7 @@ public SOG.Brep RawConvert(RG.Brep target) Orientation = (SOG.BrepOrientation)target.SolidOrientation, volume = target.IsSolid ? target.GetVolume() : 0, area = target.GetArea(), - bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(false))), + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(false))), units = _contextStack.Current.SpeckleUnits }; @@ -131,7 +131,7 @@ public SOG.Brep RawConvert(RG.Brep target) edge.StartVertex?.VertexIndex ?? -1, edge.EndVertex?.VertexIndex ?? -1, edge.ProxyCurveIsReversed, - _intervalConverter.RawConvert(edge.Domain) + _intervalConverter.Convert(edge.Domain) ) ) .ToList(); @@ -153,7 +153,7 @@ public SOG.Brep RawConvert(RG.Brep target) trim.EndVertex.VertexIndex ) { - Domain = _intervalConverter.RawConvert(trim.Domain) + Domain = _intervalConverter.Convert(trim.Domain) }; return t; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs index efb03701b5..0e3f91e3bf 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CircleToSpeckleConverter.cs @@ -5,13 +5,13 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class CircleToSpeckleConverter : IRawConversion +public class CircleToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _planeConverter; + private readonly ITypedConverter _planeConverter; private readonly IConversionContextStack _contextStack; public CircleToSpeckleConverter( - IRawConversion planeConverter, + ITypedConverter planeConverter, IConversionContextStack contextStack ) { @@ -19,7 +19,7 @@ IConversionContextStack contextStack _contextStack = contextStack; } - public Base Convert(object target) => RawConvert((RG.Circle)target); + public Base Convert(object target) => Convert((RG.Circle)target); /// /// Converts a RG.Circle object to a SOG.Circle object. @@ -29,8 +29,8 @@ IConversionContextStack contextStack /// /// ⚠️ This conversion assumes the domain of a circle is (0,1) as Rhino Circle types do not have a domain. If you want to preserve the domain use ArcCurve conversion instead. /// - public SOG.Circle RawConvert(RG.Circle target) => - new(_planeConverter.RawConvert(target.Plane), target.Radius, _contextStack.Current.SpeckleUnits) + public SOG.Circle Convert(RG.Circle target) => + new(_planeConverter.Convert(target.Plane), target.Radius, _contextStack.Current.SpeckleUnits) { domain = new SOP.Interval(0, 1), length = 2 * Math.PI * target.Radius, diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs index f06ea34ed7..d3747e2faf 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/ControlPointToSpeckleConverter.cs @@ -5,7 +5,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ControlPointToSpeckleConverter : IRawConversion +public class ControlPointToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -19,8 +19,8 @@ public ControlPointToSpeckleConverter(IConversionContextStack /// The ControlPoint object to convert. /// The converted Speckle ControlPoint object. - public SOG.ControlPoint RawConvert(RG.ControlPoint target) => + public SOG.ControlPoint Convert(RG.ControlPoint target) => new(target.Location.X, target.Location.Y, target.Location.Z, target.Weight, _contextStack.Current.SpeckleUnits); - public Base Convert(object target) => RawConvert((RG.ControlPoint)target); + public Base Convert(object target) => Convert((RG.ControlPoint)target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs index c842b0d31a..5c792ebaf8 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/CurveToSpeckleConverter.cs @@ -5,20 +5,20 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; // POC: CNX-9278 This converter decides which specific curve conversion to use. IIndex may be a better choice. -public class CurveToSpeckleConverter : IRawConversion, IRawConversion +public class CurveToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _polyCurveConverter; - private readonly IRawConversion _arcCurveConverter; - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _nurbsCurveConverter; - private readonly IRawConversion _lineCurveConverter; + private readonly ITypedConverter _polyCurveConverter; + private readonly ITypedConverter _arcCurveConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _nurbsCurveConverter; + private readonly ITypedConverter _lineCurveConverter; public CurveToSpeckleConverter( - IRawConversion polyCurveConverter, - IRawConversion arcCurveConverter, - IRawConversion polylineConverter, - IRawConversion nurbsCurveConverter, - IRawConversion lineCurveConverter + ITypedConverter polyCurveConverter, + ITypedConverter arcCurveConverter, + ITypedConverter polylineConverter, + ITypedConverter nurbsCurveConverter, + ITypedConverter lineCurveConverter ) { _polyCurveConverter = polyCurveConverter; @@ -37,15 +37,15 @@ public CurveToSpeckleConverter( /// This is the main converter when the type of curve you input or output does not matter to the caller.
/// ⚠️ If an unsupported type of Curve is input, it will be converted to NURBS. /// - public ICurve RawConvert(RG.Curve target) => + public ICurve Convert(RG.Curve target) => target switch { - RG.PolyCurve polyCurve => _polyCurveConverter.RawConvert(polyCurve), - RG.ArcCurve arcCurve => _arcCurveConverter.RawConvert(arcCurve), - RG.PolylineCurve polylineCurve => _polylineConverter.RawConvert(polylineCurve), - RG.LineCurve lineCurve => _lineCurveConverter.RawConvert(lineCurve), - _ => _nurbsCurveConverter.RawConvert(target.ToNurbsCurve()) + RG.PolyCurve polyCurve => _polyCurveConverter.Convert(polyCurve), + RG.ArcCurve arcCurve => _arcCurveConverter.Convert(arcCurve), + RG.PolylineCurve polylineCurve => _polylineConverter.Convert(polylineCurve), + RG.LineCurve lineCurve => _lineCurveConverter.Convert(lineCurve), + _ => _nurbsCurveConverter.Convert(target.ToNurbsCurve()) }; - Base IRawConversion.RawConvert(RG.Curve target) => (Base)RawConvert(target); + Base ITypedConverter.Convert(RG.Curve target) => (Base)Convert(target); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs index d0d0d6b467..fc6b52cc8f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/EllipseToSpeckleConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class EllipseToSpeckleConverter : IRawConversion +public class EllipseToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _planeConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public EllipseToSpeckleConverter( - IRawConversion planeConverter, - IRawConversion boxConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -29,11 +29,11 @@ IConversionContextStack contextStack /// /// ⚠️ Rhino ellipses are not curves. The result is a mathematical representation of an ellipse that can be converted into NURBS for display. /// - public SOG.Ellipse RawConvert(RG.Ellipse target) + public SOG.Ellipse Convert(RG.Ellipse target) { var nurbsCurve = target.ToNurbsCurve(); return new( - _planeConverter.RawConvert(target.Plane), + _planeConverter.Convert(target.Plane), target.Radius1, target.Radius2, _contextStack.Current.SpeckleUnits @@ -42,7 +42,7 @@ public SOG.Ellipse RawConvert(RG.Ellipse target) domain = new SOP.Interval(0, 1), length = nurbsCurve.GetLength(), area = Math.PI * target.Radius1 * target.Radius2, - bbox = _boxConverter.RawConvert(new RG.Box(nurbsCurve.GetBoundingBox(true))) + bbox = _boxConverter.Convert(new RG.Box(nurbsCurve.GetBoundingBox(true))) }; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs index 8bda6f9f1e..272fecafdb 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/IntervalToSpeckleConverter.cs @@ -2,12 +2,12 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class IntervalToSpeckleConverter : IRawConversion +public class IntervalToSpeckleConverter : ITypedConverter { /// /// Converts a Rhino Interval object to a Speckle Interval object. /// /// The Rhino Interval object to be converted. /// The converted Speckle Interval object. - public SOP.Interval RawConvert(RG.Interval target) => new(target.T0, target.T1); + public SOP.Interval Convert(RG.Interval target) => new(target.T0, target.T1); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs index 54daf38549..f40620f78d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/LineToSpeckleConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class LineToSpeckleConverter : IRawConversion, IRawConversion +public class LineToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public LineToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -29,17 +29,13 @@ IConversionContextStack contextStack /// /// ⚠️ This conversion assumes the domain of a line is (0, LENGTH), as Rhino Lines do not have domain. If you want the domain preserved use LineCurve conversions instead. /// - public SOG.Line RawConvert(RG.Line target) => - new( - _pointConverter.RawConvert(target.From), - _pointConverter.RawConvert(target.To), - _contextStack.Current.SpeckleUnits - ) + public SOG.Line Convert(RG.Line target) => + new(_pointConverter.Convert(target.From), _pointConverter.Convert(target.To), _contextStack.Current.SpeckleUnits) { length = target.Length, domain = new SOP.Interval(0, target.Length), - bbox = _boxConverter.RawConvert(new RG.Box(target.BoundingBox)) + bbox = _boxConverter.Convert(new RG.Box(target.BoundingBox)) }; - public SOG.Line RawConvert(RG.LineCurve target) => RawConvert(target.Line); + public SOG.Line Convert(RG.LineCurve target) => Convert(target.Line); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs index 5d116a78c4..73aa3f4a8a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/MeshToSpeckleConverter.cs @@ -5,15 +5,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; [NameAndRankValue(nameof(RG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToSpeckleConverter : IRawConversion +public class MeshToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public MeshToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -28,7 +28,7 @@ IConversionContextStack contextStack /// The Rhino Mesh to be converted. /// The converted Speckle Mesh. /// Thrown when the Rhino Mesh has 0 vertices or faces. - public SOG.Mesh RawConvert(RG.Mesh target) + public SOG.Mesh Convert(RG.Mesh target) { if (target.Vertices.Count == 0 || target.Faces.Count == 0) { @@ -55,7 +55,7 @@ public SOG.Mesh RawConvert(RG.Mesh target) var colors = target.VertexColors.Select(cl => cl.ToArgb()).ToList(); var volume = target.IsClosed ? target.Volume() : 0; - var bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(false))); + var bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(false))); return new SOG.Mesh(vertexCoordinates, faces, colors, textureCoordinates, _contextStack.Current.SpeckleUnits) { 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 372cf34f54..6cf8dca53d 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 @@ -4,17 +4,17 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class NurbsCurveConverter : IRawConversion +public class NurbsCurveConverter : ITypedConverter { - private readonly IRawConversion _polylineConverter; - private readonly IRawConversion _intervalConverter; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public NurbsCurveConverter( - IRawConversion polylineConverter, - IRawConversion intervalConverter, - IRawConversion boxConverter, + ITypedConverter polylineConverter, + ITypedConverter intervalConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -34,7 +34,7 @@ IConversionContextStack contextStack /// It adds 1 extra knot at the start and end of the vector by repeating the first and last value. /// This is because Rhino's standard of (controlPoints + degree + 1) wasn't followed on other software. /// - public SOG.Curve RawConvert(RG.NurbsCurve target) + public SOG.Curve Convert(RG.NurbsCurve target) { target.ToPolyline(0, 1, 0, 0, 0, 0.1, 0, 0, true).TryGetPolyline(out var poly); if (target.IsClosed) @@ -42,7 +42,7 @@ public SOG.Curve RawConvert(RG.NurbsCurve target) poly.Add(poly[0]); } - SOG.Polyline displayValue = _polylineConverter.RawConvert(poly); + SOG.Polyline displayValue = _polylineConverter.Convert(poly); var nurbsCurve = target.ToNurbsCurve(); @@ -60,10 +60,10 @@ public SOG.Curve RawConvert(RG.NurbsCurve target) degree = nurbsCurve.Degree, periodic = nurbsCurve.IsPeriodic, rational = nurbsCurve.IsRational, - domain = _intervalConverter.RawConvert(nurbsCurve.Domain), + domain = _intervalConverter.Convert(nurbsCurve.Domain), closed = nurbsCurve.IsClosed, length = nurbsCurve.GetLength(), - bbox = _boxConverter.RawConvert(new RG.Box(nurbsCurve.GetBoundingBox(true))) + bbox = _boxConverter.Convert(new RG.Box(nurbsCurve.GetBoundingBox(true))) }; return myCurve; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs index d9dd19b64d..0d663ff520 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs @@ -5,17 +5,17 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class NurbsSurfaceToSpeckleConverter : IRawConversion +public class NurbsSurfaceToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _boxConverter; - private readonly IRawConversion _intervalConverter; - private readonly IRawConversion _controlPointConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _controlPointConverter; private readonly IConversionContextStack _contextStack; public NurbsSurfaceToSpeckleConverter( - IRawConversion boxConverter, - IRawConversion intervalConverter, - IRawConversion controlPointConverter, + ITypedConverter boxConverter, + ITypedConverter intervalConverter, + ITypedConverter controlPointConverter, IConversionContextStack contextStack ) { @@ -30,7 +30,7 @@ IConversionContextStack contextStack ///
/// The NurbsSurface object to convert. /// A Surface object representing the converted NurbsSurface. - public SOG.Surface RawConvert(RG.NurbsSurface target) + public SOG.Surface Convert(RG.NurbsSurface target) { var result = new SOG.Surface { @@ -39,12 +39,12 @@ public SOG.Surface RawConvert(RG.NurbsSurface target) rational = target.IsRational, closedU = target.IsClosed(0), closedV = target.IsClosed(1), - domainU = _intervalConverter.RawConvert(target.Domain(0)), - domainV = _intervalConverter.RawConvert(target.Domain(1)), + domainU = _intervalConverter.Convert(target.Domain(0)), + domainV = _intervalConverter.Convert(target.Domain(1)), knotsU = target.KnotsU.ToList(), knotsV = target.KnotsV.ToList(), units = _contextStack.Current.SpeckleUnits, - bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))) + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))) }; result.SetControlPoints(ControlPointsToSpeckle(target.Points)); @@ -61,7 +61,7 @@ public SOG.Surface RawConvert(RG.NurbsSurface target) for (var j = 0; j < controlPoints.CountV; j++) { var pt = controlPoints.GetControlPoint(i, j); - row.Add(_controlPointConverter.RawConvert(pt)); + row.Add(_controlPointConverter.Convert(pt)); } points.Add(row); diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs index f9f973c5cb..40d15be50c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PlaneToSpeckleConverter.cs @@ -4,15 +4,15 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PlaneToSpeckleConverter : IRawConversion +public class PlaneToSpeckleConverter : ITypedConverter { - private readonly IRawConversion _vectorConverter; - private readonly IRawConversion _pointConverter; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _pointConverter; private readonly IConversionContextStack _contextStack; public PlaneToSpeckleConverter( - IRawConversion vectorConverter, - IRawConversion pointConverter, + ITypedConverter vectorConverter, + ITypedConverter pointConverter, IConversionContextStack contextStack ) { @@ -26,12 +26,12 @@ IConversionContextStack contextStack ///
/// The instance of Rhino Plane to convert. /// The converted instance of Speckle Plane. - public SOG.Plane RawConvert(RG.Plane target) => + public SOG.Plane Convert(RG.Plane target) => new( - _pointConverter.RawConvert(target.Origin), - _vectorConverter.RawConvert(target.ZAxis), - _vectorConverter.RawConvert(target.XAxis), - _vectorConverter.RawConvert(target.YAxis), + _pointConverter.Convert(target.Origin), + _vectorConverter.Convert(target.ZAxis), + _vectorConverter.Convert(target.XAxis), + _vectorConverter.Convert(target.YAxis), _contextStack.Current.SpeckleUnits ); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs index 54c08d6ea5..2bfdfdae1c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PointToSpeckleConverter.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PointToSpeckleConverter : IRawConversion, IRawConversion +public class PointToSpeckleConverter : ITypedConverter, ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -18,8 +18,7 @@ public PointToSpeckleConverter(IConversionContextStack con ///
/// The Rhino 3D point to convert. /// The converted Speckle point. - public SOG.Point RawConvert(RG.Point3d target) => - new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); + public SOG.Point Convert(RG.Point3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); - public SOG.Point RawConvert(RG.Point target) => RawConvert(target.Location); + public SOG.Point Convert(RG.Point target) => Convert(target.Location); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs index 291b4c1bc5..6937d6b007 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs @@ -5,16 +5,16 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PolyCurveToSpeckleConverter : IRawConversion +public class PolyCurveToSpeckleConverter : ITypedConverter { - public IRawConversion? CurveConverter { get; set; } // POC: CNX-9279 This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly - private readonly IRawConversion _intervalConverter; - private readonly IRawConversion _boxConverter; + public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9279 This created a circular dependency on the constructor, making it a property allows for the container to resolve it correctly + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; public PolyCurveToSpeckleConverter( - IRawConversion intervalConverter, - IRawConversion boxConverter, + ITypedConverter intervalConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack ) { @@ -32,15 +32,15 @@ IConversionContextStack contextStack /// This method removes the nesting of the PolyCurve by duplicating the segments at a granular level. /// All PolyLIne, PolyCurve and NURBS curves with G1 discontinuities will be broken down. /// - public SOG.Polycurve RawConvert(RG.PolyCurve target) + public SOG.Polycurve Convert(RG.PolyCurve target) { var myPoly = new SOG.Polycurve { closed = target.IsClosed, - domain = _intervalConverter.RawConvert(target.Domain), + domain = _intervalConverter.Convert(target.Domain), length = target.GetLength(), - bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))), - segments = target.DuplicateSegments().Select(x => CurveConverter.NotNull().RawConvert(x)).ToList(), + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))), + segments = target.DuplicateSegments().Select(x => CurveConverter.NotNull().Convert(x)).ToList(), units = _contextStack.Current.SpeckleUnits }; return myPoly; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs index ad202ff632..1ee241e7d1 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/PolylineToSpeckleConverter.cs @@ -5,19 +5,19 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; public class PolylineToSpeckleConverter - : IRawConversion, - IRawConversion + : ITypedConverter, + ITypedConverter { - private readonly IRawConversion _pointConverter; - private readonly IRawConversion _boxConverter; - private readonly IRawConversion _intervalConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; private readonly IConversionContextStack _contextStack; public PolylineToSpeckleConverter( - IRawConversion pointConverter, - IRawConversion boxConverter, + ITypedConverter pointConverter, + ITypedConverter boxConverter, IConversionContextStack contextStack, - IRawConversion intervalConverter + ITypedConverter intervalConverter ) { _pointConverter = pointConverter; @@ -32,10 +32,10 @@ public PolylineToSpeckleConverter( /// The Rhino polyline to be converted. /// The converted Speckle polyline. /// ⚠️ This conversion assumes domain interval is (0,LENGTH) as Rhino Polylines have no domain. If needed, you may want to use PolylineCurve conversion instead. - public SOG.Polyline RawConvert(RG.Polyline target) + public SOG.Polyline Convert(RG.Polyline target) { - var box = _boxConverter.RawConvert(new RG.Box(target.BoundingBox)); - var points = target.Select(pt => _pointConverter.RawConvert(pt)).ToList(); + var box = _boxConverter.Convert(new RG.Box(target.BoundingBox)); + var points = target.Select(pt => _pointConverter.Convert(pt)).ToList(); if (target.IsClosed) { @@ -60,10 +60,10 @@ public SOG.Polyline RawConvert(RG.Polyline target) /// The Rhino PolylineCurve to be converted. /// The converted Speckle polyline. /// ✅ This conversion respects the domain of the original PolylineCurve - public SOG.Polyline RawConvert(RG.PolylineCurve target) + public SOG.Polyline Convert(RG.PolylineCurve target) { - var result = RawConvert(target.ToPolyline()); - result.domain = _intervalConverter.RawConvert(target.Domain); + var result = Convert(target.ToPolyline()); + result.domain = _intervalConverter.Convert(target.Domain); return result; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs index 0acf866e3c..5e4a17e6cb 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/RawPointCloudToSpeckle.cs @@ -4,14 +4,14 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class RawPointCloudToSpeckle : IRawConversion +public class RawPointCloudToSpeckle : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly IRawConversion _boxConverter; + private readonly ITypedConverter _boxConverter; public RawPointCloudToSpeckle( IConversionContextStack contextStack, - IRawConversion boxConverter + ITypedConverter boxConverter ) { _contextStack = contextStack; @@ -23,12 +23,12 @@ public RawPointCloudToSpeckle( ///
/// The Rhino PointCloud object to convert. /// The converted Speckle Pointcloud object. - public SOG.Pointcloud RawConvert(RG.PointCloud target) => + public SOG.Pointcloud Convert(RG.PointCloud target) => new() { points = target.GetPoints().SelectMany(pt => new[] { pt.X, pt.Y, pt.Z }).ToList(), colors = target.GetColors().Select(o => o.ToArgb()).ToList(), - bbox = _boxConverter.RawConvert(new RG.Box(target.GetBoundingBox(true))), + bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))), units = _contextStack.Current.SpeckleUnits }; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs index 6237826d35..489eddedc4 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/VectorToSpeckleConverter.cs @@ -4,7 +4,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class VectorToSpeckleConverter : IRawConversion +public class VectorToSpeckleConverter : ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -18,6 +18,6 @@ public VectorToSpeckleConverter(IConversionContextStack co ///
/// The Rhino Vector3d object to convert. /// The converted Speckle Vector object. - public SOG.Vector RawConvert(RG.Vector3d target) => + public SOG.Vector Convert(RG.Vector3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs deleted file mode 100644 index d581c438e8..0000000000 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/RhinoConverterToSpeckle.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; -using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; - -namespace Speckle.Converters.Rhino7.ToSpeckle; - -public class RhinoConverterToSpeckle : ISpeckleConverterToSpeckle -{ - private readonly IFactory _toSpeckle; - - public RhinoConverterToSpeckle(IFactory toSpeckle) - { - _toSpeckle = toSpeckle; - } - - public Base Convert(object target) - { - var type = target.GetType(); - var objectConverter = _toSpeckle.ResolveInstance(type.Name); - - if (objectConverter == null) - { - throw new NotSupportedException($"No conversion found for {type.Name}"); - } - - return objectConverter.Convert(target); - } -} diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs index b57c8a08e5..7520c1bd83 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/BrepObjectToSpeckleTopLevelConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(BrepObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class BrepObjectToSpeckleTopLevelConverter : IHostObjectToSpeckleConversion +public class BrepObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; - public BrepObjectToSpeckleTopLevelConverter(IRawConversion curveConverter) + public BrepObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } @@ -18,7 +18,7 @@ public BrepObjectToSpeckleTopLevelConverter(IRawConversion cu public Base Convert(object target) { var curveObject = (BrepObject)target; - var speckleCurve = _curveConverter.RawConvert(curveObject.BrepGeometry); + var speckleCurve = _curveConverter.Convert(curveObject.BrepGeometry); return speckleCurve; } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs index 285130be58..a8214a0c97 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/CurveObjectToSpeckleTopLevelConverter.cs @@ -8,7 +8,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(CurveObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class CurveObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public CurveObjectToSpeckleTopLevelConverter(IRawConversion conversion) + public CurveObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } protected override RG.Curve GetTypedGeometry(CurveObject input) => input.CurveGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs index 5be77ff94c..46d2c27586 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/ExtrusionObjectToSpeckleTopLevelConverter.cs @@ -6,11 +6,11 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; [NameAndRankValue(nameof(ExtrusionObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ExtrusionObjectToSpeckleTopLevelConverter : IHostObjectToSpeckleConversion +public class ExtrusionObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter { - private readonly IRawConversion _curveConverter; + private readonly ITypedConverter _curveConverter; - public ExtrusionObjectToSpeckleTopLevelConverter(IRawConversion curveConverter) + public ExtrusionObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } @@ -18,7 +18,7 @@ public ExtrusionObjectToSpeckleTopLevelConverter(IRawConversion { - public MeshObjectToSpeckleTopLevelConverter(IRawConversion conversion) + public MeshObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } protected override RG.Mesh GetTypedGeometry(MeshObject input) => input.MeshGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs index 6436640448..e741e38e49 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointCloudObjectToSpeckleTopLevelConverter.cs @@ -8,7 +8,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; public class PointCloudObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public PointCloudObjectToSpeckleTopLevelConverter(IRawConversion conversion) + public PointCloudObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } protected override RG.PointCloud GetTypedGeometry(PointCloudObject input) => input.PointCloudGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs index e73af8acbf..7d9c750b64 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/PointObjectToSpeckleTopLevelConverter.cs @@ -8,7 +8,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; public class PointObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public PointObjectToSpeckleTopLevelConverter(IRawConversion conversion) + public PointObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } protected override RG.Point GetTypedGeometry(PointObject input) => input.PointGeometry; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs index 3cc03f3930..edff24473a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs @@ -3,15 +3,14 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -public abstract class RhinoObjectToSpeckleTopLevelConverter - : IHostObjectToSpeckleConversion +public abstract class RhinoObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter where TTopLevelIn : Rhino.DocObjects.RhinoObject where TInRaw : RG.GeometryBase where TOutRaw : Base { - public IRawConversion Conversion { get; } + public ITypedConverter Conversion { get; } - protected RhinoObjectToSpeckleTopLevelConverter(IRawConversion conversion) + protected RhinoObjectToSpeckleTopLevelConverter(ITypedConverter conversion) { Conversion = conversion; } @@ -24,7 +23,7 @@ public virtual Base Convert(object target) var typedTarget = (TTopLevelIn)target; var typedGeometry = GetTypedGeometry(typedTarget); - var result = Conversion.RawConvert(typedGeometry); + var result = Conversion.Convert(typedGeometry); // POC: Any common operations for all RhinoObjects should be done here, not on the specific implementer // Things like user-dictionaries and other user-defined metadata. diff --git a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs index e68fce561d..bfd7593aae 100644 --- a/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs +++ b/DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs @@ -4,17 +4,17 @@ namespace Speckle.Autofac.DependencyInjection; [GenerateAutoInterface] -public class Factory : IFactory +public class Factory : IFactory where TValue : class { - private readonly IIndex _types; + private readonly IIndex _types; - public Factory(IIndex types) + public Factory(IIndex types) { _types = types; } - public TValue? ResolveInstance(TKey strongName) + public TValue? ResolveInstance(string strongName) { if (_types.TryGetValue(strongName, out TValue value)) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs index 3f8f9d7d61..6a5fb37913 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs @@ -6,34 +6,31 @@ namespace Speckle.Converters.Common.DependencyInjection; public static class ContainerRegistration { - public static void AddConverterCommon(this SpeckleContainerBuilder builder) + public static void AddConverterCommon( + this SpeckleContainerBuilder builder + ) + where TRootToSpeckleConverter : class, IRootToSpeckleConverter + where THostToSpeckleUnitConverter : class, IHostToSpeckleUnitConverter { + builder.AddScoped(); + builder.AddScoped, THostToSpeckleUnitConverter>(); /* POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file. This will require consolidating across other connectors. */ + builder.AddScoped, Factory>(); builder.AddScoped< - IFactory, - Factory - >(); - builder.AddScoped< - IConverterResolver, - RecursiveConverterResolver + IConverterResolver, + ConverterResolver >(); - builder.AddScoped< - IFactory, - Factory - >(); - builder.AddScoped< - IConverterResolver, - RecursiveConverterResolver - >(); + builder.AddScoped, Factory>(); + builder.AddScoped, ConverterResolver>(); - builder.AddScoped(); + builder.AddScoped(); builder.RegisterRawConversions(); - builder.InjectNamedTypes(); - builder.InjectNamedTypes(); + builder.InjectNamedTypes(); + builder.InjectNamedTypes(); } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs index 77a7b0206b..c4a0800ce7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/NamedTypeInjector.cs @@ -40,7 +40,7 @@ public static void InjectNamedTypes(this SpeckleContainerBuilder containerBui // * Whether the scope should be modified or modifiable // * Whether this is in the write project... hmmm // POC: IsAssignableFrom() - var secondaryType = first.type.GetInterface(typeof(IRawConversion<,>).Name); + var secondaryType = first.type.GetInterface(typeof(ITypedConverter<,>).Name); // POC: should we explode if no found? if (secondaryType != null) { @@ -67,7 +67,7 @@ public static void InjectNamedTypes(this SpeckleContainerBuilder containerBui // * Whether this is in the write project... hmmm // POC: IsAssignableFrom() // NOT very DRY - secondaryType = first.type.GetInterface(typeof(IRawConversion<,>).Name); + secondaryType = first.type.GetInterface(typeof(ITypedConverter<,>).Name); // POC: should we explode if no found? if (secondaryType != null) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs index 9c2530943d..73745af1f7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/RawConversionRegisterer.cs @@ -25,7 +25,7 @@ private static void RegisterRawConversionsForType(ContainerBuilder containerBuil } var rawConversionInterfaces = type.GetInterfaces() - .Where(it => it.IsGenericType && it.GetGenericTypeDefinition() == typeof(IRawConversion<,>)); + .Where(it => it.IsGenericType && it.GetGenericTypeDefinition() == typeof(ITypedConverter<,>)); foreach (var conversionInterface in rawConversionInterfaces) { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs similarity index 80% rename from DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs index 2ff6e8a34e..d20f915ba9 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithFallback.cs @@ -6,21 +6,21 @@ namespace Speckle.Converters.Common.DependencyInjection.ToHost; // POC: CNX-9394 Find a better home for this outside `DependencyInjection` project /// -/// +/// ///
/// If no suitable converter conversion is found, and the target object has a displayValue property /// a converter with strong name of is resolved for. ///
-/// -public sealed class ToHostConverterWithFallback : ISpeckleConverterToHost +/// +public sealed class ConverterWithFallback : IRootToHostConverter { - private readonly IConverterResolver _toHost; - private readonly ToHostConverterWithoutFallback _baseConverter; + private readonly IConverterResolver _toHost; + private readonly ConverterWithoutFallback _baseConverter; - public ToHostConverterWithFallback(IConverterResolver toHost) + public ConverterWithFallback(IConverterResolver toHost) { _toHost = toHost; - _baseConverter = new ToHostConverterWithoutFallback(toHost); + _baseConverter = new ConverterWithoutFallback(toHost); } /// @@ -31,7 +31,7 @@ public ToHostConverterWithFallback(IConverterResolver /// /// The conversion is done in the following order of preference: - /// 1. Direct conversion using the method. + /// 1. Direct conversion using the method. /// 2. Fallback to display value using the method, if a direct conversion is not possible. /// /// If the direct conversion is not available and there is no displayValue, a is thrown. diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithoutFallback.cs similarity index 63% rename from DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithoutFallback.cs index ff69332e87..c6b24fff40 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ToHostConverterWithoutFallback.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ToHost/ConverterWithoutFallback.cs @@ -6,15 +6,15 @@ namespace Speckle.Converters.Common.DependencyInjection.ToHost; // POC: CNX-9394 Find a better home for this outside `DependencyInjection` project /// -/// Provides an implementation for -/// that resolves a via the injected +/// Provides an implementation for +/// that resolves a via the injected /// -/// -public sealed class ToHostConverterWithoutFallback : ISpeckleConverterToHost +/// +public sealed class ConverterWithoutFallback : IRootToHostConverter { - private readonly IConverterResolver _toHost; + private readonly IConverterResolver _toHost; - public ToHostConverterWithoutFallback(IConverterResolver converterResolver) + public ConverterWithoutFallback(IConverterResolver converterResolver) { _toHost = converterResolver; } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs index 178af2782c..723877d0b9 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContext.cs @@ -10,6 +10,6 @@ public ConversionContext(TDocument doc, string speckleUnits) SpeckleUnits = speckleUnits; } - public TDocument Document { get; protected set; } + public TDocument Document { get; } public string SpeckleUnits { get; private set; } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs index 908ce1989d..918a29d3c1 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/ConversionContextStack.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using Speckle.InterfaceGenerator; namespace Speckle.Converters.Common; @@ -8,7 +9,8 @@ namespace Speckle.Converters.Common; "CA1711:Identifiers should not have incorrect suffix", Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" )] -public class ConversionContextStack : IConversionContextStack +[GenerateAutoInterface] +public abstract class ConversionContextStack : IConversionContextStack where TDocument : class { private readonly IHostToSpeckleUnitConverter _unitConverter; diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs deleted file mode 100644 index d06a35f778..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/IConversionContextStack.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Speckle.Converters.Common; - -// POC: Suppressed naming warning for now, but we should evaluate if we should follow this or disable it. -[SuppressMessage( - "Naming", - "CA1711:Identifiers should not have incorrect suffix", - Justification = "Name ends in Stack but it is in fact a Stack, just not inheriting from `System.Collections.Stack`" -)] -public interface IConversionContextStack - where TDocument : class -{ - ContextWrapper Push(string speckleUnit); - ContextWrapper Push(THostUnit hostUnit); - void Pop(); - ConversionContext Current { get; } -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootToHostConverter.cs similarity index 71% rename from DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/IRootToHostConverter.cs index e24e1ddebe..2f11b6e5c4 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToHost.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootToHostConverter.cs @@ -2,7 +2,7 @@ namespace Speckle.Converters.Common; -public interface ISpeckleConverterToHost +public interface IRootToHostConverter { object Convert(Base target); } diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootToSpeckleConverter.cs similarity index 68% rename from DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/IRootToSpeckleConverter.cs index bc7673b5c9..6a19ebb13a 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/ArcGISConverterToSpeckle.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootToSpeckleConverter.cs @@ -1,16 +1,16 @@ using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.InterfaceGenerator; -namespace Speckle.Converters.ArcGIS3; +namespace Speckle.Converters.Common; -//poc: dupe code from rhino -public class ArcGISConverterToSpeckle : ISpeckleConverterToSpeckle +[GenerateAutoInterface] +public class RootToSpeckleConverter : IRootToSpeckleConverter { - private readonly IFactory _toSpeckle; + private readonly IFactory _toSpeckle; - public ArcGISConverterToSpeckle(IFactory toSpeckle) + public RootToSpeckleConverter(IFactory toSpeckle) { _toSpeckle = toSpeckle; } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs deleted file mode 100644 index 459cb99736..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/ISpeckleConverterToSpeckle.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Speckle.Core.Models; - -namespace Speckle.Converters.Common; - -public interface ISpeckleConverterToSpeckle -{ - Base Convert(object target); -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs deleted file mode 100644 index 16613848df..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/FloorConversion.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Speckle.Converters.Common.Objects; - -public class FloorConversion { } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs deleted file mode 100644 index 5ba47c7eda..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IConverterResolver.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Speckle.Converters.Common.Objects; - -public interface IConverterResolver - where TConverter : class -{ - public TConverter? GetConversionForType(Type objectType); -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs deleted file mode 100644 index 0b2060e8c1..0000000000 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IRawConversion.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Speckle.Converters.Common.Objects; - -public interface IRawConversion -{ - TOut RawConvert(TIn target); -} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToHostTopLevelConverter.cs similarity index 83% rename from DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToHostTopLevelConverter.cs index ffb203143f..59869df951 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ISpeckleObjectToHostConversion.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToHostTopLevelConverter.cs @@ -6,7 +6,7 @@ namespace Speckle.Converters.Common.Objects; // * begin scope: https://stackoverflow.com/questions/49595198/autofac-resolving-through-factory-methods // Interceptors? -public interface ISpeckleObjectToHostConversion +public interface IToHostTopLevelConverter { object Convert(Base target); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToSpeckleTopLevelConverter.cs similarity index 83% rename from DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToSpeckleTopLevelConverter.cs index f12977017e..b0d7525e6e 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IHostObjectToSpeckleConversion.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/IToSpeckleTopLevelConverter.cs @@ -6,7 +6,7 @@ namespace Speckle.Converters.Common.Objects; // * begin scope: https://stackoverflow.com/questions/49595198/autofac-resolving-through-factory-methods // Interceptors? -public interface IHostObjectToSpeckleConversion +public interface IToSpeckleTopLevelConverter { Base Convert(object target); } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ITypedConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ITypedConverter.cs new file mode 100644 index 0000000000..80efa37f86 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Objects/ITypedConverter.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.Common.Objects; + +public interface ITypedConverter +{ + TOut Convert(TIn target); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConverterResolver.cs similarity index 62% rename from DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs rename to DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConverterResolver.cs index 88cdcec475..0c18169e5c 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConveterResolver.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RecursiveConverterResolver.cs @@ -1,14 +1,15 @@ using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common.Objects; +using Speckle.InterfaceGenerator; namespace Speckle.Converters.Common; -public sealed class RecursiveConverterResolver : IConverterResolver +[GenerateAutoInterface] +public sealed class ConverterResolver : IConverterResolver where TConverter : class { - private readonly IFactory _factory; + private readonly IFactory _factory; - public RecursiveConverterResolver(IFactory factory) + public ConverterResolver(IFactory factory) { _factory = factory; }