From a999afd24f676284ac4411cc2564aba648448eea Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 17 Jun 2024 09:46:37 +0100 Subject: [PATCH 01/28] add root converter with fallback and tests --- All.sln | 19 + DUI3-DX.slnf | 1 + .../Operations/Send/RevitRootObjectBuilder.cs | 4 +- .../packages.lock.json | 3 +- .../RevitRootElementProvider.cs | 10 + .../FakeType.cs | 85 ++++ .../RootToSpeckleConverterTests.cs | 65 +++ .../Speckle.Converters.Common.Tests.csproj | 29 ++ .../packages.lock.json | 451 ++++++++++++++++++ .../IRootElementProvider.cs | 6 + .../RootConvertManager.cs | 41 ++ .../RootToSpeckleConverter.cs | 39 +- .../Speckle.Converters.Common.csproj | 8 +- 13 files changed, 732 insertions(+), 29 deletions(-) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/IRootElementProvider.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs diff --git a/All.sln b/All.sln index ff3a26c713..1365d9e652 100644 --- a/All.sln +++ b/All.sln @@ -557,6 +557,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B1324D25 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Revit2023.Tests", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023.Tests\Speckle.Converters.Revit2023.Tests.csproj", "{AEC26A0B-25F3-4544-A9D6-A427BFF79250}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Common.Tests", "DUI3-DX\Sdk\Speckle.Converters.Common.Tests\Speckle.Converters.Common.Tests.csproj", "{95E23A97-E5EA-4506-A52C-D3DA9012DA02}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Mac|Any CPU = Debug Mac|Any CPU @@ -2807,6 +2809,22 @@ Global {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|Any CPU.Build.0 = Release|Any CPU {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.ActiveCfg = Release|Any CPU {AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.Build.0 = Release|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|x64.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|x64.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|x64.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|x64.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|Any CPU.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|x64.ActiveCfg = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|x64.Build.0 = Debug|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|Any CPU.Build.0 = Release|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|x64.ActiveCfg = Release|Any CPU + {95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3019,6 +3037,7 @@ Global {F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934} {E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} = {D92751C8-1039-4005-90B2-913E55E0B8BD} {AEC26A0B-25F3-4544-A9D6-A427BFF79250} = {D92751C8-1039-4005-90B2-913E55E0B8BD} + {95E23A97-E5EA-4506-A52C-D3DA9012DA02} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14} diff --git a/DUI3-DX.slnf b/DUI3-DX.slnf index 80e74b0b65..483d0c9d43 100644 --- a/DUI3-DX.slnf +++ b/DUI3-DX.slnf @@ -30,6 +30,7 @@ "DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj", "DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj", + "DUI3-DX\\Sdk\\Speckle.Converters.Common.Tests\\Speckle.Converters.Common.Tests.csproj", "DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj", "Objects\\Objects\\Objects.csproj", "Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj" diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs index 6652aad320..417478e952 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Operations/Send/RevitRootObjectBuilder.cs @@ -72,12 +72,14 @@ public RootObjectBuilderResult Build( var countProgress = 0; // because for(int i = 0; ...) loops are so last year var cacheHitCount = 0; List results = new(revitElements.Count); + var path = new string[2]; foreach (Element revitElement in revitElements) { ct.ThrowIfCancellationRequested(); var cat = revitElement.Category.Name; - var path = new[] { doc.GetElement(revitElement.LevelId) is not Level level ? "No level" : level.Name, cat }; + path[0] = doc.GetElement(revitElement.LevelId) is not Level level ? "No level" : level.Name; + path[1] = cat; var collection = GetAndCreateObjectHostCollection(path); var applicationId = revitElement.Id.ToString(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index 6fdd69eb66..0b4dfd26f3 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -498,8 +498,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.23, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs new file mode 100644 index 0000000000..c248254df6 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs @@ -0,0 +1,10 @@ +using Speckle.Converters.Common; +using Speckle.Revit.Interfaces; + +namespace Speckle.Converters.RevitShared; + +public class RevitRootElementProvider : IRootElementProvider +{ + private static readonly Type s_wrappedElementType = typeof(IRevitElement); + public Type GetRootType() => s_wrappedElementType; +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs new file mode 100644 index 0000000000..884b1108a2 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs @@ -0,0 +1,85 @@ +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Reflection; + +namespace Speckle.Converters.Common.Tests; + +public class FakeType : Type +{ + public FakeType(string name) + { + Name = name; + } + public override object[] GetCustomAttributes(bool inherit) => throw new NotImplementedException(); + + public override bool IsDefined(Type attributeType, bool inherit) => throw new NotImplementedException(); + + public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override Type GetInterface(string name, bool ignoreCase) => throw new NotImplementedException(); + + public override Type[] GetInterfaces() => throw new NotImplementedException(); + + public override EventInfo GetEvent(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override EventInfo[] GetEvents(BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override Type[] GetNestedTypes(BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override Type GetNestedType(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override Type GetElementType() => throw new NotImplementedException(); + + protected override bool HasElementTypeImpl() => throw new NotImplementedException(); + + protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, + ParameterModifier[] modifiers) => + throw new NotImplementedException(); + + public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) => throw new NotImplementedException(); + + protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, + Type[] types, ParameterModifier[] modifiers) => + throw new NotImplementedException(); + + public override MethodInfo[] GetMethods(BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override FieldInfo GetField(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override FieldInfo[] GetFields(BindingFlags bindingAttr) => throw new NotImplementedException(); + + public override MemberInfo[] GetMembers(BindingFlags bindingAttr) => throw new NotImplementedException(); + + protected override TypeAttributes GetAttributeFlagsImpl() => throw new NotImplementedException(); + + protected override bool IsArrayImpl() => throw new NotImplementedException(); + + protected override bool IsByRefImpl() => throw new NotImplementedException(); + + protected override bool IsPointerImpl() => throw new NotImplementedException(); + + protected override bool IsPrimitiveImpl() => throw new NotImplementedException(); + + protected override bool IsCOMObjectImpl() => throw new NotImplementedException(); + + public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, + ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) => + throw new NotImplementedException(); + + public override Type UnderlyingSystemType { get; } + + protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, + Type[] types, ParameterModifier[] modifiers) => + throw new NotImplementedException(); + + public override string Name { get; } + [SuppressMessage("Naming", "CA1720:Identifier contains type name")] public override Guid GUID { get; } = Guid.Empty; + public override Module Module { get; } + public override Assembly Assembly { get; } + public override string FullName { get; } + public override string Namespace { get; } + public override string AssemblyQualifiedName { get; } + public override Type BaseType { get; } + + public override object[] GetCustomAttributes(Type attributeType, bool inherit) => throw new NotImplementedException(); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs new file mode 100644 index 0000000000..2a46ed3f05 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs @@ -0,0 +1,65 @@ +using FluentAssertions; +using Moq; +using NUnit.Framework; +using Speckle.Core.Models; +using Speckle.Revit.Interfaces; + +namespace Speckle.Converters.Common.Tests; + +public class RootToSpeckleConverterTests +{ + private readonly MockRepository _repository = new(MockBehavior.Strict); + + private readonly Mock _rootConvertManager; + private readonly Mock _proxyMapper; + private readonly Mock _rootElementProvider; + + public RootToSpeckleConverterTests() + { + _rootConvertManager = _repository.Create(); + _proxyMapper = _repository.Create(); + _rootElementProvider = _repository.Create(); + } + + [TearDown] + public void Verify() => _repository.VerifyAll(); + + [Test] + public void Convert_BaseType() + { + try + { + Type baseType = new FakeType("baseType"); + Type hostType = new FakeType("hostType"); + + object target = new(); + Type targetType = new FakeType("targetType"); + + object wrappedTarget = new(); + Base converted = new(); + + _rootConvertManager.Setup(x => x.GetTargetType(target)).Returns(targetType); + _rootElementProvider.Setup(x => x.GetRootType()).Returns(baseType); + _proxyMapper.Setup(x => x.GetHostTypeFromMappedType(baseType)).Returns(hostType); + + _proxyMapper.Setup(x => x.GetMappedTypeFromHostType(targetType)).Returns((Type?)null); + _proxyMapper.Setup(x => x.GetMappedTypeFromProxyType(targetType)).Returns((Type?)null); + + + _rootConvertManager.Setup(x => x.IsSubClass(baseType, targetType)).Returns(true); + _proxyMapper.Setup(x => x.CreateProxy(baseType, target)).Returns(wrappedTarget); + _rootConvertManager.Setup(x => x.Convert(baseType, wrappedTarget)).Returns(converted); + + var rootToSpeckleConverter = + new RootToSpeckleConverter(_proxyMapper.Object, _rootConvertManager.Object, _rootElementProvider.Object); + var testConverted = rootToSpeckleConverter.Convert(target); + + testConverted.Should().BeSameAs(converted); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj new file mode 100644 index 0000000000..cbc4e3d32d --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj @@ -0,0 +1,29 @@ + + + + net48 + x64 + false + true + + + + + + + + + + + + + + + + + + ..\..\..\..\speckle-sharp-host-apis\Revit\Revit2023\Speckle.Revit2023.Api\bin\Debug\net48\Speckle.Revit2023.Interfaces.dll + + + + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json new file mode 100644 index 0000000000..18add118ca --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -0,0 +1,451 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "coverlet.collector": { + "type": "Direct", + "requested": "[6.0.2, )", + "resolved": "6.0.2", + "contentHash": "bJShQ6uWRTQ100ZeyiMqcFlhP7WJ+bCuabUs885dJiBEzMsJMSFr7BOyeCw4rgvQokteGi5rKQTlkhfQPUXg2A==" + }, + "FluentAssertions": { + "type": "Direct", + "requested": "[6.12.0, )", + "resolved": "6.12.0", + "contentHash": "ZXhHT2YwP9lajrwSKbLlFqsmCCvFJMoRSK9t7sImfnCyd0OB3MhgxdoMcVqxbq1iyxD6mD2fiackWmBb7ayiXQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.0" + } + }, + "Microsoft.NET.Test.Sdk": { + "type": "Direct", + "requested": "[17.10.0, )", + "resolved": "17.10.0", + "contentHash": "0/2HeACkaHEYU3wc83YlcD2Fi4LMtECJjqrtvw0lPi9DCEa35zSPt1j4fuvM8NagjDqJuh1Ja35WcRtn1Um6/A==", + "dependencies": { + "Microsoft.CodeCoverage": "17.10.0" + } + }, + "Moq": { + "type": "Direct", + "requested": "[4.20.70, )", + "resolved": "4.20.70", + "contentHash": "4rNnAwdpXJBuxqrOCzCyICXHSImOTRktCgCWXWykuF1qwoIsVvEnR7PjbMk/eLOxWvhmj5Kwt+kDV3RGUYcNwg==", + "dependencies": { + "Castle.Core": "5.1.1", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "NUnit": { + "type": "Direct", + "requested": "[4.1.0, )", + "resolved": "4.1.0", + "contentHash": "MT/DpAhjtiytzhTgTqIhBuWx4y26PKfDepYUHUM+5uv4TsryHC2jwFo5e6NhWkApCm/G6kZ80dRjdJFuAxq3rg==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "NUnit.Analyzers": { + "type": "Direct", + "requested": "[4.2.0, )", + "resolved": "4.2.0", + "contentHash": "4fJojPkzdoa4nB2+p6U+fITvPnVvwWSnsmiJ/Dl30xqiL3oxNbYvfeSLVd91hOmEjoUqSwN3Z7j1aFedjqWbUA==" + }, + "PolySharp": { + "type": "Direct", + "requested": "[1.14.1, )", + "resolved": "1.14.1", + "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" + }, + "Speckle.InterfaceGenerator": { + "type": "Direct", + "requested": "[0.9.5, )", + "resolved": "0.9.5", + "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" + }, + "Castle.Core": { + "type": "Transitive", + "resolved": "5.1.1", + "contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g==" + }, + "GraphQL.Client": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "8yPNBbuVBpTptivyAlak4GZvbwbUcjeQTL4vN1HKHRuOykZ4r7l5fcLS6vpyPyLn0x8FsL31xbOIKyxbmR9rbA==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0", + "GraphQL.Client.Abstractions.Websocket": "6.0.0", + "System.Net.WebSockets.Client.Managed": "1.0.22", + "System.Reactive": "5.0.0" + } + }, + "GraphQL.Client.Abstractions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "h7uzWFORHZ+CCjwr/ThAyXMr0DPpzEANDa4Uo54wqCQ+j7qUKwqYTgOrb1W40sqbvNaZm9v/X7It31SUw0maHA==", + "dependencies": { + "GraphQL.Primitives": "6.0.0" + } + }, + "GraphQL.Client.Abstractions.Websocket": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "Nr9bPf8gIOvLuXpqEpqr9z9jslYFJOvd0feHth3/kPqeR3uMbjF5pjiwh4jxyMcxHdr8Pb6QiXkV3hsSyt0v7A==", + "dependencies": { + "GraphQL.Client.Abstractions": "6.0.0" + } + }, + "GraphQL.Primitives": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "Microsoft.CodeCoverage": { + "type": "Transitive", + "resolved": "17.10.0", + "contentHash": "yC7oSlnR54XO5kOuHlVOKtxomNNN1BWXX8lK1G2jaPXT9sUok7kCOoA4Pgs0qyFaCtMrNsprztYMeoEGqCm4uA==" + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Data.Sqlite": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "KGxbPeWsQMnmQy43DSBxAFtHz3l2JX8EWBSGUCvT3CuZ8KsuzbkqMIJMDOxWtG8eZSoCDI04aiVQjWuuV8HmSw==", + "dependencies": { + "Microsoft.Data.Sqlite.Core": "7.0.5", + "SQLitePCLRaw.bundle_e_sqlite3": "2.1.4" + } + }, + "Microsoft.Data.Sqlite.Core": { + "type": "Transitive", + "resolved": "7.0.5", + "contentHash": "FTerRmQPqHrCrnoUzhBu+E+1DNGwyrAMLqHkAqOOOu5pGfyMOj8qQUBxI/gDtWtG11p49UxSfWmBzRNlwZqfUg==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "Transitive", + "resolved": "7.0.0", + "contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.5" + } + }, + "Polly": { + "type": "Transitive", + "resolved": "7.2.3", + "contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==" + }, + "Polly.Contrib.WaitAndRetry": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "1MUQLiSo4KDkQe6nzQRhIU05lm9jlexX5BVsbuw0SL82ynZ+GzAHQxJVDPVBboxV37Po3SG077aX8DuSy8TkaA==" + }, + "Polly.Extensions.Http": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "drrG+hB3pYFY7w1c3BD+lSGYvH2oIclH8GRSehgfyP5kjnFnHKQuuBhuHLv+PWyFuaTDyk/vfRpnxOzd11+J8g==", + "dependencies": { + "Polly": "7.1.0" + } + }, + "Sentry": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "8vbD2o6IR2wrRrkSiRbnodWGWUOqIlwYtzpjvPNOb5raJdOf+zxMwfS8f6nx9bmrTTfDj7KrCB8C/5OuicAc8A==", + "dependencies": { + "System.Reflection.Metadata": "5.0.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.3.0", + "System.Text.Json": "5.0.2" + } + }, + "Sentry.Serilog": { + "type": "Transitive", + "resolved": "3.33.0", + "contentHash": "V8BU7QGWg2qLYfNPqtuTBhC1opysny5l+Ifp6J6PhOeAxU0FssR7nYfbJVetrnLIoh2rd3DlJ6hHYYQosQYcUQ==", + "dependencies": { + "Sentry": "3.33.0", + "Serilog": "2.7.1" + } + }, + "Serilog": { + "type": "Transitive", + "resolved": "2.12.0", + "contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg==" + }, + "Serilog.Enrichers.ClientInfo": { + "type": "Transitive", + "resolved": "1.3.0", + "contentHash": "mTc7PM+wC9Hr7LWSwqt5mmnlAr7RJs+eTb3PGPRhwdOackk95MkhUZognuxXEdlW19HAFNmEBTSBY5DfLwM8jQ==", + "dependencies": { + "Serilog": "2.4.0" + } + }, + "Serilog.Enrichers.GlobalLogContext": { + "type": "Transitive", + "resolved": "3.0.0", + "contentHash": "IIZcj5mAUVhIl/NTA+YI2KC+sPDzcwvs0ZMHH42jsPfl1a4LVX7ohVpw5UK+e3GxuV3Nv239Il5oM2peUIl44g==", + "dependencies": { + "Serilog": "2.12.0" + } + }, + "Serilog.Exceptions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "nc/+hUw3lsdo0zCj0KMIybAu7perMx79vu72w0za9Nsi6mWyNkGXxYxakAjWB7nEmYL6zdmhEQRB4oJ2ALUeug==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Formatting.Compact": { + "type": "Transitive", + "resolved": "1.1.0", + "contentHash": "pNroKVjo+rDqlxNG5PXkRLpfSCuDOBY0ri6jp9PLe505ljqwhwZz8ospy2vWhQlFu5GkIesh3FcDs4n7sWZODA==", + "dependencies": { + "Serilog": "2.8.0" + } + }, + "Serilog.Sinks.Console": { + "type": "Transitive", + "resolved": "4.1.0", + "contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.File": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Serilog.Sinks.PeriodicBatching": { + "type": "Transitive", + "resolved": "3.1.0", + "contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==", + "dependencies": { + "Serilog": "2.0.0" + } + }, + "Serilog.Sinks.Seq": { + "type": "Transitive", + "resolved": "5.2.2", + "contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==", + "dependencies": { + "Serilog": "2.12.0", + "Serilog.Formatting.Compact": "1.1.0", + "Serilog.Sinks.File": "5.0.0", + "Serilog.Sinks.PeriodicBatching": "3.1.0" + } + }, + "SerilogTimings": { + "type": "Transitive", + "resolved": "3.0.1", + "contentHash": "Zs28eTgszAMwpIrbBnWHBI50yuxL50p/dmAUWmy75+axdZYK/Sjm5/5m1N/CisR8acJUhTVcjPZrsB1P5iv0Uw==", + "dependencies": { + "Serilog": "2.10.0" + } + }, + "Speckle.Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "SQLitePCLRaw.bundle_e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "EWI1olKDjFEBMJu0+3wuxwziIAdWDVMYLhuZ3Qs84rrz+DHwD00RzWPZCa+bLnHCf3oJwuFZIRsHT5p236QXww==", + "dependencies": { + "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", + "SQLitePCLRaw.provider.dynamic_cdecl": "2.1.4" + } + }, + "SQLitePCLRaw.core": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "inBjvSHo9UDKneGNzfUfDjK08JzlcIhn1+SP5Y3m6cgXpCxXKCJDy6Mka7LpgSV+UZmKSnC8rTwB0SQ0xKu5pA==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "2C9Q9eX7CPLveJA0rIhf9RXAvu+7nWZu1A2MdG6SD/NOu26TakGgL1nsbc0JAspGijFOo3HoN79xrx8a368fBg==" + }, + "SQLitePCLRaw.provider.dynamic_cdecl": { + "type": "Transitive", + "resolved": "2.1.4", + "contentHash": "ZsaKKhgYF9B1fvcnOGKl3EycNAwd9CRWX7v0rEfuPWhQQ5Jjpvf2VEHahiLIGHio3hxi3EIKFJw9KvyowWOUAw==", + "dependencies": { + "SQLitePCLRaw.core": "2.1.4" + } + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.DoubleNumerics": { + "type": "Transitive", + "resolved": "3.1.3", + "contentHash": "KRKEM/L3KBodjA9VOg3EifFVWUY6EOqaMB05UvPEDm7Zeby/kZW+4kdWUEPzW6xtkwf46p661L9NrbeeQhtLzw==", + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.5", + "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Net.WebSockets.Client.Managed": { + "type": "Transitive", + "resolved": "1.0.22", + "contentHash": "WqEOxPlXjuZrIjUtXNE9NxEfU/n5E35iV2PtoZdJSUC4tlrqwHnTee+wvMIM4OUaJWmwrymeqcgYrE0IkGAgLA==", + "dependencies": { + "System.Buffers": "4.4.0", + "System.Numerics.Vectors": "4.4.0" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" + }, + "System.Reactive": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "erBZjkQHWL9jpasCE/0qKAryzVBJFxGHVBAvgRN1bzM0q2s1S4oYREEEL0Vb+1kA/6BKb5FjUZMp5VXmy+gzkQ==", + "dependencies": { + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, + "System.Reflection.Metadata": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==", + "dependencies": { + "System.Collections.Immutable": "5.0.0" + } + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" + }, + "System.Runtime.InteropServices.RuntimeInformation": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "cbz4YJMqRDR7oLeMRbdYv7mYzc++17lNhScCX0goO2XpGWdvAt60CGN+FHdePUEHCe/Jy9jUlvNAiNdM+7jsOw==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.1", + "contentHash": "KmJ+CJXizDofbq6mpqDoRRLcxgOd2z9X3XoFNULSbvbqVRZkFX3istvr+MUjL6Zw1RT+RNdoI4GYidIINtgvqQ==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4" + } + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "5.0.2", + "contentHash": "I47dVIGiV6SfAyppphxqupertT/5oZkYLDCX6vC3HpOI4ZLjyoKAreUoem2ie6G0RbRuFrlqz/PcTQjfb2DOfQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.1", + "System.Threading.Tasks.Extensions": "4.5.4", + "System.ValueTuple": "4.5.0" + } + }, + "System.Threading.Tasks.Extensions": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.ValueTuple": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ==" + }, + "speckle.autofac": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )", + "Speckle.Core": "[2.0.999-local, )" + } + }, + "speckle.converters.common": { + "type": "Project", + "dependencies": { + "Speckle.Autofac": "[2.0.999-local, )", + "Speckle.Objects": "[2.0.999-local, )" + } + }, + "Speckle.Core": { + "type": "Project", + "dependencies": { + "GraphQL.Client": "[6.0.0, )", + "Microsoft.CSharp": "[4.7.0, )", + "Microsoft.Data.Sqlite": "[7.0.5, )", + "Polly": "[7.2.3, )", + "Polly.Contrib.WaitAndRetry": "[1.1.1, )", + "Polly.Extensions.Http": "[3.0.0, )", + "Sentry": "[3.33.0, )", + "Sentry.Serilog": "[3.33.0, )", + "Serilog": "[2.12.0, )", + "Serilog.Enrichers.ClientInfo": "[1.3.0, )", + "Serilog.Enrichers.GlobalLogContext": "[3.0.0, )", + "Serilog.Exceptions": "[8.4.0, )", + "Serilog.Sinks.Console": "[4.1.0, )", + "Serilog.Sinks.Seq": "[5.2.2, )", + "SerilogTimings": "[3.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", + "System.DoubleNumerics": "[3.1.3, )" + } + }, + "Speckle.Objects": { + "type": "Project", + "dependencies": { + "Speckle.Core": "[2.0.999-local, )" + } + } + } + } +} \ No newline at end of file diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/IRootElementProvider.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootElementProvider.cs new file mode 100644 index 0000000000..e183c154af --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/IRootElementProvider.cs @@ -0,0 +1,6 @@ +namespace Speckle.Converters.Common; + +public interface IRootElementProvider +{ + Type GetRootType(); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs new file mode 100644 index 0000000000..fdd186dda3 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs @@ -0,0 +1,41 @@ +using Speckle.Autofac.DependencyInjection; +using Speckle.Converters.Common.Objects; +using Speckle.Core.Models; +using Speckle.InterfaceGenerator; + +namespace Speckle.Converters.Common; + +[GenerateAutoInterface] +public class RootConvertManager : IRootConvertManager +{ + private readonly IFactory _toSpeckle; + + public RootConvertManager(IFactory toSpeckle) + { + _toSpeckle = toSpeckle; + } + + public Type GetTargetType(object target) => target.GetType(); + public bool IsSubClass(Type baseType, Type childType) => baseType.IsAssignableFrom(childType); + + public Base Convert(Type type, object obj) + { + try + { + var objectConverter = _toSpeckle.ResolveInstance(type.Name); //poc: would be nice to have supertypes resolve + + if (objectConverter == null) + { + throw new NotSupportedException($"No conversion found for {type.Name}"); + } + var convertedObject = objectConverter.Convert(obj); + + return convertedObject; + } + catch (SpeckleConversionException e) + { + Console.WriteLine(e); + throw; // Just rethrowing for now, Logs may be needed here. + } + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs index 04d87e8349..2400d2edc7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs @@ -1,5 +1,3 @@ -using Speckle.Autofac.DependencyInjection; -using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.InterfaceGenerator; using Speckle.Revit.Interfaces; @@ -9,40 +7,35 @@ namespace Speckle.Converters.Common; [GenerateAutoInterface] public class RootToSpeckleConverter : IRootToSpeckleConverter { - private readonly IFactory _toSpeckle; + private readonly IRootConvertManager _rootConvertManager; private readonly IProxyMapper _proxyMapper; + private readonly IRootElementProvider _rootElementProvider; - public RootToSpeckleConverter(IFactory toSpeckle, IProxyMapper proxyMapper) + private readonly Type _revitElementType; + + public RootToSpeckleConverter(IProxyMapper proxyMapper, IRootConvertManager rootConvertManager, IRootElementProvider rootElementProvider) { - _toSpeckle = toSpeckle; _proxyMapper = proxyMapper; + _rootConvertManager = rootConvertManager; + _rootElementProvider = rootElementProvider; + _revitElementType = _proxyMapper.GetHostTypeFromMappedType(_rootElementProvider.GetRootType()).NotNull(); } public Base Convert(object target) { - Type revitType = target.GetType(); + Type revitType = _rootConvertManager.GetTargetType(target); var wrapper = _proxyMapper.WrapIfExists(revitType, target); if (wrapper == null) { - throw new NotSupportedException($"No wrapper found for Revit type: {revitType.Name}"); - } - var (wrappedType, wrappedObject) = wrapper.Value; - try - { - var objectConverter = _toSpeckle.ResolveInstance(wrappedType.Name); //poc: would be nice to have supertypes resolve - - if (objectConverter == null) + //try to fallback to element type + if (_rootConvertManager.IsSubClass(_revitElementType, revitType)) { - throw new NotSupportedException($"No conversion found for {wrappedType.Name}"); + return _rootConvertManager.Convert(_rootElementProvider.GetRootType(), _proxyMapper.CreateProxy(_rootElementProvider.GetRootType(), target)); } - var convertedObject = objectConverter.Convert(wrappedObject); - - return convertedObject; - } - catch (SpeckleConversionException e) - { - Console.WriteLine(e); - throw; // Just rethrowing for now, Logs may be needed here. + throw new NotSupportedException($"No wrapper found for Revit type: {revitType.Name}"); } + var (wrappedType, wrappedObject) = wrapper; + return _rootConvertManager.Convert(wrappedType, wrappedObject); } + } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 761f021575..5d5710f7b7 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -3,12 +3,14 @@ netstandard2.0 - - - + + + ..\..\..\..\speckle-sharp-host-apis\Revit\Revit2023\Speckle.Revit2023.Api\bin\Debug\net48\Speckle.Revit2023.Interfaces.dll + + From 82eb8118b9d9c947b9d7bd04f5c2f2c9b49898ce Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 17 Jun 2024 09:52:04 +0100 Subject: [PATCH 02/28] proper references --- .../RevitConverterModule.cs | 1 + .../Speckle.Converters.Revit2023.Tests.csproj | 2 +- .../packages.lock.json | 11 ++++++----- .../Speckle.Converters.Revit2023.csproj | 2 +- .../Helpers/DisplayValueExtractor.cs | 2 +- .../Raw/Geometry/PointCloudToSpeckleConverter.cs | 2 +- .../Speckle.Converters.Common.Tests.csproj | 6 +----- .../packages.lock.json | 9 ++++++++- .../Speckle.Converters.Common.csproj | 5 ++--- 9 files changed, 22 insertions(+), 18 deletions(-) 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 533baf679e..7900f25180 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -28,5 +28,6 @@ public void Load(SpeckleContainerBuilder builder) builder.AddScoped(); builder.AddScoped(); builder.AddScoped(); + builder.AddScoped(); } } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj index 23e43c993c..296350ca71 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index 0b4dfd26f3..65d1ab0d1b 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.23, )", - "resolved": "0.1.1-preview.0.23", - "contentHash": "H66I9JRUGt1l1YS8aOdniRPDOixRPqua9puGrhGnTEKJ26kVlgkM3FpKfdAMFea4hf03hdqhnFVmNEwgA6mPHA==" + "requested": "[0.1.1-preview.0.24, )", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" }, "Castle.Core": { "type": "Transitive", @@ -498,7 +498,8 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" } }, "speckle.converters.common.dependencyinjection": { @@ -512,7 +513,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.23, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index f2fe665f57..01dc874c3f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + 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 83cd6a4dd6..9dd899678a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/DisplayValueExtractor.cs @@ -103,7 +103,7 @@ List solids //options = ViewSpecificOptions ?? options ?? new Options() { DetailLevel = DetailLevelSetting }; options ??= _revitOptionsFactory.Create(RevitViewDetailLevel.Fine); - IRevitGeometryElement geom; + IRevitGeometryElement? geom; try { geom = element.GetGeometry(options); 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 ee5b81e95d..c552e7dbdf 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 @@ -37,7 +37,7 @@ public SOG.Pointcloud Convert(IRevitPointCloudInstance target) { var minPlane = _revitPlaneUtils.CreateByNormalAndOrigin( _revitxyzUtils.BasisZ, - transform.OfPoint(boundingBox.Min) + transform.OfPoint(boundingBox.NotNull().Min) ); var filter = _revitFilterFactory.CreateMultiPlaneFilter(minPlane); var points = target.GetPoints(filter, 0.0001, 999999); // max limit is 1 mil but 1000000 throws error diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj index cbc4e3d32d..e687d74095 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj @@ -14,16 +14,12 @@ + - - - ..\..\..\..\speckle-sharp-host-apis\Revit\Revit2023\Speckle.Revit2023.Api\bin\Debug\net48\Speckle.Revit2023.Interfaces.dll - - diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json index 18add118ca..745cd3ba1e 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -63,6 +63,12 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, + "Speckle.Revit2023.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.24, )", + "resolved": "0.1.1-preview.0.24", + "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + }, "Castle.Core": { "type": "Transitive", "resolved": "5.1.1", @@ -415,7 +421,8 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )" + "Speckle.Objects": "[2.0.999-local, )", + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 5d5710f7b7..07793ee159 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -7,10 +7,9 @@ + - - ..\..\..\..\speckle-sharp-host-apis\Revit\Revit2023\Speckle.Revit2023.Api\bin\Debug\net48\Speckle.Revit2023.Interfaces.dll - + From b51b3e431dcf9dc1c6dd61ce3ea09a7990e7798c Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 17 Jun 2024 10:36:34 +0100 Subject: [PATCH 03/28] Converters work --- .../RevitConverterModule.cs | 1 + ...rters.Revit2023.DependencyInjection.csproj | 2 +- .../Helpers/IParameterValueExtractor.cs | 2 +- .../Raw/ColumnConversionToSpeckle.cs | 33 ++++++++++--------- 4 files changed, 20 insertions(+), 18 deletions(-) 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 7900f25180..1c7eae1e2f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -14,6 +14,7 @@ public class RevitConverterModule : ISpeckleModule public void Load(SpeckleContainerBuilder builder) { builder.AddConverterCommon(); + builder.ScanAssemblyOfType(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.AddScoped(); diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index 8458d1fdaa..ae4703a46f 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs index 2bfdd4dbae..2a85d7e4de 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs @@ -8,7 +8,7 @@ public interface IParameterValueExtractor { object? GetValue(IRevitParameter parameter); double GetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter); - bool TryGetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter, out double? value); + bool TryGetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter, [NotNullWhen(true)] out double? value); int GetValueAsInt(IRevitElement element, RevitBuiltInParameter builtInParameter); bool? GetValueAsBool(IRevitElement element, RevitBuiltInParameter builtInParameter); string? GetValueAsString(IRevitElement element, RevitBuiltInParameter builtInParameter); 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 f1e5b11c35..9e9a5ca5d4 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -53,19 +53,20 @@ out var level speckleColumn.level = _levelConverter.Convert(level); } - var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.FAMILY_TOP_LEVEL_PARAM); - - speckleColumn.topLevel = _levelConverter.Convert(topLevel); - speckleColumn.baseOffset = _parameterValueExtractor.GetValueAsDouble( - target, - RevitBuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM - ); - - speckleColumn.topOffset = _parameterValueExtractor.GetValueAsDouble( - target, - RevitBuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM - ); - + if ( _parameterValueExtractor.TryGetValueAsRevitLevel(target, RevitBuiltInParameter.FAMILY_TOP_LEVEL_PARAM, out var topLevel)) + { + speckleColumn.topLevel = _levelConverter.Convert(topLevel); + } + + if ( _parameterValueExtractor.TryGetValueAsDouble(target, RevitBuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM, out var baseOffset)) + { + speckleColumn.baseOffset = baseOffset.Value; + } + + if ( _parameterValueExtractor.TryGetValueAsDouble(target, RevitBuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM, out var topOffset)) + { + speckleColumn.topOffset = topOffset.Value; + } speckleColumn.facingFlipped = target.FacingFlipped; speckleColumn.handFlipped = target.HandFlipped; speckleColumn.isSlanted = target.IsSlantedColumn; @@ -77,7 +78,7 @@ out var level } speckleColumn.baseLine = - GetBaseCurve(target, speckleColumn.topLevel.elevation, speckleColumn.topOffset) + GetBaseCurve(target, speckleColumn.topLevel?.elevation, speckleColumn.topOffset) ?? throw new SpeckleConversionException("Unable to find a valid baseCurve for column"); speckleColumn.displayValue = _displayValueExtractor.GetDisplayValue(target); @@ -87,7 +88,7 @@ out var level return speckleColumn; } - private ICurve? GetBaseCurve(IRevitFamilyInstance target, double topLevelElevation, double topLevelOffset) + private ICurve? GetBaseCurve(IRevitFamilyInstance target, double? topLevelElevation, double topLevelOffset) { Base baseGeometry = _locationConverter.Convert(target.Location); ICurve? baseCurve = baseGeometry as ICurve; @@ -110,7 +111,7 @@ out var level return new SOG.Line( basePoint, - new SOG.Point(basePoint.x, basePoint.y, topLevelElevation + topLevelOffset, _contextStack.Current.SpeckleUnits), + new SOG.Point(basePoint.x, basePoint.y, topLevelElevation ?? 0 + topLevelOffset, _contextStack.Current.SpeckleUnits), _contextStack.Current.SpeckleUnits ); } From edb7bb1523e59e9020d4c5b726c255973cb7856f Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 17 Jun 2024 10:36:47 +0100 Subject: [PATCH 04/28] fmt --- .../Helpers/IParameterValueExtractor.cs | 6 +- .../Raw/ColumnConversionToSpeckle.cs | 56 ++++++++++++++----- .../RevitRootElementProvider.cs | 1 + .../FakeType.cs | 50 ++++++++++++----- .../RootToSpeckleConverterTests.cs | 12 ++-- .../RootConvertManager.cs | 1 + .../RootToSpeckleConverter.cs | 12 +++- 7 files changed, 101 insertions(+), 37 deletions(-) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs index 2a85d7e4de..7366b0d055 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Helpers/IParameterValueExtractor.cs @@ -8,7 +8,11 @@ public interface IParameterValueExtractor { object? GetValue(IRevitParameter parameter); double GetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter); - bool TryGetValueAsDouble(IRevitElement element, RevitBuiltInParameter builtInParameter, [NotNullWhen(true)] out double? value); + bool TryGetValueAsDouble( + IRevitElement element, + RevitBuiltInParameter builtInParameter, + [NotNullWhen(true)] out double? value + ); int GetValueAsInt(IRevitElement element, RevitBuiltInParameter builtInParameter); bool? GetValueAsBool(IRevitElement element, RevitBuiltInParameter builtInParameter); string? GetValueAsString(IRevitElement element, RevitBuiltInParameter builtInParameter); 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 9e9a5ca5d4..afcf6f27eb 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -42,6 +42,7 @@ public SOBR.RevitColumn Convert(IRevitFamilyInstance target) SOBR.RevitColumn speckleColumn = new() { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).NotNull().Name }; + //should these all be try? if ( _parameterValueExtractor.TryGetValueAsRevitLevel( target, @@ -52,21 +53,41 @@ out var level { speckleColumn.level = _levelConverter.Convert(level); } + //should these all be try? + if ( + _parameterValueExtractor.TryGetValueAsRevitLevel( + target, + RevitBuiltInParameter.FAMILY_TOP_LEVEL_PARAM, + out var topLevel + ) + ) + { + speckleColumn.topLevel = _levelConverter.Convert(topLevel); + } + + //should these all be try? + if ( + _parameterValueExtractor.TryGetValueAsDouble( + target, + RevitBuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM, + out var baseOffset + ) + ) + { + speckleColumn.baseOffset = baseOffset.Value; + } - if ( _parameterValueExtractor.TryGetValueAsRevitLevel(target, RevitBuiltInParameter.FAMILY_TOP_LEVEL_PARAM, out var topLevel)) - { - speckleColumn.topLevel = _levelConverter.Convert(topLevel); - } - - if ( _parameterValueExtractor.TryGetValueAsDouble(target, RevitBuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM, out var baseOffset)) - { - speckleColumn.baseOffset = baseOffset.Value; - } - - if ( _parameterValueExtractor.TryGetValueAsDouble(target, RevitBuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM, out var topOffset)) - { - speckleColumn.topOffset = topOffset.Value; - } + //should these all be try? + if ( + _parameterValueExtractor.TryGetValueAsDouble( + target, + RevitBuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM, + out var topOffset + ) + ) + { + speckleColumn.topOffset = topOffset.Value; + } speckleColumn.facingFlipped = target.FacingFlipped; speckleColumn.handFlipped = target.HandFlipped; speckleColumn.isSlanted = target.IsSlantedColumn; @@ -111,7 +132,12 @@ out var level return new SOG.Line( basePoint, - new SOG.Point(basePoint.x, basePoint.y, topLevelElevation ?? 0 + topLevelOffset, _contextStack.Current.SpeckleUnits), + new SOG.Point( + basePoint.x, + basePoint.y, + topLevelElevation ?? 0 + topLevelOffset, + _contextStack.Current.SpeckleUnits + ), _contextStack.Current.SpeckleUnits ); } diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs index c248254df6..65aeca21da 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.cs @@ -6,5 +6,6 @@ namespace Speckle.Converters.RevitShared; public class RevitRootElementProvider : IRootElementProvider { private static readonly Type s_wrappedElementType = typeof(IRevitElement); + public Type GetRootType() => s_wrappedElementType; } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs index 884b1108a2..517313bd4b 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/FakeType.cs @@ -10,6 +10,7 @@ public FakeType(string name) { Name = name; } + public override object[] GetCustomAttributes(bool inherit) => throw new NotImplementedException(); public override bool IsDefined(Type attributeType, bool inherit) => throw new NotImplementedException(); @@ -32,15 +33,25 @@ public FakeType(string name) protected override bool HasElementTypeImpl() => throw new NotImplementedException(); - protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, - ParameterModifier[] modifiers) => - throw new NotImplementedException(); + protected override PropertyInfo GetPropertyImpl( + string name, + BindingFlags bindingAttr, + Binder binder, + Type returnType, + Type[] types, + ParameterModifier[] modifiers + ) => throw new NotImplementedException(); public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) => throw new NotImplementedException(); - protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, - Type[] types, ParameterModifier[] modifiers) => - throw new NotImplementedException(); + protected override MethodInfo GetMethodImpl( + string name, + BindingFlags bindingAttr, + Binder binder, + CallingConventions callConvention, + Type[] types, + ParameterModifier[] modifiers + ) => throw new NotImplementedException(); public override MethodInfo[] GetMethods(BindingFlags bindingAttr) => throw new NotImplementedException(); @@ -62,18 +73,31 @@ protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAtt protected override bool IsCOMObjectImpl() => throw new NotImplementedException(); - public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, - ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) => - throw new NotImplementedException(); + public override object InvokeMember( + string name, + BindingFlags invokeAttr, + Binder binder, + object target, + object[] args, + ParameterModifier[] modifiers, + CultureInfo culture, + string[] namedParameters + ) => throw new NotImplementedException(); public override Type UnderlyingSystemType { get; } - protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, - Type[] types, ParameterModifier[] modifiers) => - throw new NotImplementedException(); + protected override ConstructorInfo GetConstructorImpl( + BindingFlags bindingAttr, + Binder binder, + CallingConventions callConvention, + Type[] types, + ParameterModifier[] modifiers + ) => throw new NotImplementedException(); public override string Name { get; } - [SuppressMessage("Naming", "CA1720:Identifier contains type name")] public override Guid GUID { get; } = Guid.Empty; + + [SuppressMessage("Naming", "CA1720:Identifier contains type name")] + public override Guid GUID { get; } = Guid.Empty; public override Module Module { get; } public override Assembly Assembly { get; } public override string FullName { get; } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs index 2a46ed3f05..a94bf874e4 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs @@ -13,7 +13,7 @@ public class RootToSpeckleConverterTests private readonly Mock _rootConvertManager; private readonly Mock _proxyMapper; private readonly Mock _rootElementProvider; - + public RootToSpeckleConverterTests() { _rootConvertManager = _repository.Create(); @@ -44,14 +44,16 @@ public void Convert_BaseType() _proxyMapper.Setup(x => x.GetMappedTypeFromHostType(targetType)).Returns((Type?)null); _proxyMapper.Setup(x => x.GetMappedTypeFromProxyType(targetType)).Returns((Type?)null); - - + _rootConvertManager.Setup(x => x.IsSubClass(baseType, targetType)).Returns(true); _proxyMapper.Setup(x => x.CreateProxy(baseType, target)).Returns(wrappedTarget); _rootConvertManager.Setup(x => x.Convert(baseType, wrappedTarget)).Returns(converted); - var rootToSpeckleConverter = - new RootToSpeckleConverter(_proxyMapper.Object, _rootConvertManager.Object, _rootElementProvider.Object); + var rootToSpeckleConverter = new RootToSpeckleConverter( + _proxyMapper.Object, + _rootConvertManager.Object, + _rootElementProvider.Object + ); var testConverted = rootToSpeckleConverter.Convert(target); testConverted.Should().BeSameAs(converted); diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs index fdd186dda3..4ae930fa1c 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs @@ -16,6 +16,7 @@ public RootConvertManager(IFactory toSpeckle) } public Type GetTargetType(object target) => target.GetType(); + public bool IsSubClass(Type baseType, Type childType) => baseType.IsAssignableFrom(childType); public Base Convert(Type type, object obj) diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs index 2400d2edc7..fac0af321d 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs @@ -13,7 +13,11 @@ public class RootToSpeckleConverter : IRootToSpeckleConverter private readonly Type _revitElementType; - public RootToSpeckleConverter(IProxyMapper proxyMapper, IRootConvertManager rootConvertManager, IRootElementProvider rootElementProvider) + public RootToSpeckleConverter( + IProxyMapper proxyMapper, + IRootConvertManager rootConvertManager, + IRootElementProvider rootElementProvider + ) { _proxyMapper = proxyMapper; _rootConvertManager = rootConvertManager; @@ -30,12 +34,14 @@ public Base Convert(object target) //try to fallback to element type if (_rootConvertManager.IsSubClass(_revitElementType, revitType)) { - return _rootConvertManager.Convert(_rootElementProvider.GetRootType(), _proxyMapper.CreateProxy(_rootElementProvider.GetRootType(), target)); + return _rootConvertManager.Convert( + _rootElementProvider.GetRootType(), + _proxyMapper.CreateProxy(_rootElementProvider.GetRootType(), target) + ); } throw new NotSupportedException($"No wrapper found for Revit type: {revitType.Name}"); } var (wrappedType, wrappedObject) = wrapper; return _rootConvertManager.Convert(wrappedType, wrappedObject); } - } From b82368bd63223ec9956e522c91c24faafe7a3c78 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 17 Jun 2024 13:11:19 +0100 Subject: [PATCH 05/28] added test! --- .../XyzConversionToPointTests.cs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs new file mode 100644 index 0000000000..9dfdc09794 --- /dev/null +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs @@ -0,0 +1,62 @@ +using FluentAssertions; +using Moq; +using NUnit.Framework; +using Objects; +using Speckle.Converters.Common; +using Speckle.Converters.Common.Objects; +using Speckle.Converters.RevitShared.Services; +using Speckle.Converters.RevitShared.ToSpeckle; +using Speckle.Revit.Interfaces; + +namespace Speckle.Converters.Revit2023.Tests; + +public class XyzConversionToPointTests +{ + private readonly MockRepository _repository = new(MockBehavior.Strict); + + private readonly Mock> _revitConversionContextStack; + private readonly Mock _scalingServiceToSpeckle; + + public XyzConversionToPointTests() + { + _revitConversionContextStack = _repository.Create>(); + _scalingServiceToSpeckle = _repository.Create(); + } + + [TearDown] + public void Verify() => _repository.VerifyAll(); + + + [Test] + public void Convert_Point() + { + var x = 3.1; + var y = 3.2; + var z = 3.3; + var xScaled = 4.1; + var yScaled = 4.2; + var zScaled = 4.3; + var xyz = _repository.Create(); + xyz.Setup(x => x.X).Returns(x); + xyz.Setup(x => x.Y).Returns(y); + xyz.Setup(x => x.Z).Returns(z); + + var units = "units"; + var conversionContext = _repository.Create>(); + conversionContext.Setup(x => x.SpeckleUnits).Returns(units); + + _scalingServiceToSpeckle.Setup(a => a.ScaleLength(x)).Returns(xScaled); + _scalingServiceToSpeckle.Setup(a => a.ScaleLength(y)).Returns(yScaled); + _scalingServiceToSpeckle.Setup(a => a.ScaleLength(z)).Returns(zScaled); + + _revitConversionContextStack.Setup(x => x.Current).Returns(conversionContext.Object); + + var converter = new XyzConversionToPoint(_scalingServiceToSpeckle.Object, _revitConversionContextStack.Object); + var point = converter.Convert(xyz.Object); + + point.x.Should().Be(xScaled); + point.y.Should().Be(yScaled); + point.z.Should().Be(zScaled); + point.units.Should().Be(units); + } +} From 055c07737d8e11d0b4a12605ff8eb90ec915c107 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 17 Jun 2024 13:11:44 +0100 Subject: [PATCH 06/28] fmt --- .../XyzConversionToPointTests.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs index 9dfdc09794..dee5979761 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.cs @@ -21,12 +21,11 @@ public XyzConversionToPointTests() { _revitConversionContextStack = _repository.Create>(); _scalingServiceToSpeckle = _repository.Create(); - } + } [TearDown] public void Verify() => _repository.VerifyAll(); - [Test] public void Convert_Point() { @@ -44,13 +43,13 @@ public void Convert_Point() var units = "units"; var conversionContext = _repository.Create>(); conversionContext.Setup(x => x.SpeckleUnits).Returns(units); - + _scalingServiceToSpeckle.Setup(a => a.ScaleLength(x)).Returns(xScaled); _scalingServiceToSpeckle.Setup(a => a.ScaleLength(y)).Returns(yScaled); _scalingServiceToSpeckle.Setup(a => a.ScaleLength(z)).Returns(zScaled); - + _revitConversionContextStack.Setup(x => x.Current).Returns(conversionContext.Object); - + var converter = new XyzConversionToPoint(_scalingServiceToSpeckle.Object, _revitConversionContextStack.Object); var point = converter.Convert(xyz.Object); From b8f11d790cde2366c37e56de0b10a4b853cd31bb Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 17 Jun 2024 17:01:28 +0100 Subject: [PATCH 07/28] One converter to rhino interfaces --- .../Raw/ArcCurveToSpeckleConverter.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) 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 8a3eee9cb7..b7b648dde9 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 @@ -3,20 +3,21 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ArcCurveToSpeckleConverter : ITypedConverter, ITypedConverter +public class ArcCurveToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _circleConverter; - private readonly ITypedConverter _arcConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _circleConverter; + private readonly ITypedConverter _arcConverter; + private readonly ITypedConverter _intervalConverter; private readonly IConversionContextStack _contextStack; public ArcCurveToSpeckleConverter( - ITypedConverter circleConverter, - ITypedConverter arcConverter, - ITypedConverter intervalConverter, + ITypedConverter circleConverter, + ITypedConverter arcConverter, + ITypedConverter intervalConverter, IConversionContextStack contextStack ) { @@ -27,16 +28,16 @@ IConversionContextStack contextStack } /// - /// Converts an RG.ArcCurve to an ICurve. + /// Converts an IRhinoArcCurve to an ICurve. /// - /// The RG.ArcCurve to convert. + /// The IRhinoArcCurve to convert. /// The converted ICurve. /// /// ⚠️ If the provided ArcCurve is a complete circle, a Speckle Circle will be returned. /// Otherwise, the output will be a Speckle Arc.
/// ✅ This method preserves the domain of the original ArcCurve.
///
- public ICurve Convert(RG.ArcCurve target) + public ICurve Convert(IRhinoArcCurve target) { var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; @@ -57,5 +58,5 @@ public ICurve Convert(RG.ArcCurve target) // 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 ITypedConverter.Convert(RG.ArcCurve target) => (Base)Convert(target); + Base ITypedConverter.Convert(IRhinoArcCurve target) => (Base)Convert(target); } From 34760f5dbe73b02d8e4d3b34a6388ce334dd789d Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Tue, 18 Jun 2024 13:38:11 +0100 Subject: [PATCH 08/28] more converters done --- .../ToSpeckle/Raw/ArcToSpeckleConverter.cs | 29 ++++----- .../ToSpeckle/Raw/BoxToSpeckleConverter.cs | 19 +++--- .../ToSpeckle/Raw/BrepToSpeckleConverter.cs | 60 ++++++++++--------- .../ToSpeckle/Raw/CircleToSpeckleConverter.cs | 22 +++---- .../Raw/ControlPointToSpeckleConverter.cs | 14 ++--- .../ToSpeckle/Raw/CurveToSpeckleConverter.cs | 35 +++++------ .../Raw/EllipseToSpeckleConverter.cs | 20 ++++--- .../Raw/IntervalToSpeckleConverter.cs | 5 +- .../ToSpeckle/Raw/LineToSpeckleConverter.cs | 27 +++++---- 9 files changed, 120 insertions(+), 111 deletions(-) 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 82c89c2551..8dbd786d75 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 @@ -1,27 +1,28 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ArcToSpeckleConverter : ITypedConverter +public class ArcToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _boxFactory; public ArcToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter planeConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + ITypedConverter pointConverter, + ITypedConverter planeConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, IRhinoBoxFactory boxFactory) { _pointConverter = pointConverter; _planeConverter = planeConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _boxFactory = boxFactory; } /// @@ -32,7 +33,7 @@ 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 Convert(RG.Arc target) => + public SOG.Arc Convert(IRhinoArc target) => new( _planeConverter.Convert(target.Plane), target.Radius, @@ -47,6 +48,6 @@ public SOG.Arc Convert(RG.Arc target) => endPoint = _pointConverter.Convert(target.EndPoint), domain = new SOP.Interval(0, 1), length = target.Length, - bbox = _boxConverter.Convert(new RG.Box(target.BoundingBox())) + bbox = _boxConverter.Convert(_boxFactory.CreateBox(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 cebd6e5d70..88dff35126 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 @@ -1,19 +1,20 @@ -using Rhino; + using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class BoxToSpeckleConverter : ITypedConverter +public class BoxToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; public BoxToSpeckleConverter( - ITypedConverter planeConverter, - ITypedConverter intervalConverter, - IConversionContextStack contextStack + ITypedConverter planeConverter, + ITypedConverter intervalConverter, + IConversionContextStack contextStack ) { _planeConverter = planeConverter; @@ -26,7 +27,7 @@ IConversionContextStack contextStack /// /// The Rhino Box object to convert. /// The converted Speckle Box object. - public SOG.Box Convert(RG.Box target) => + public SOG.Box Convert(IRhinoBox target) => new( _planeConverter.Convert(target.Plane), _intervalConverter.Convert(target.X), 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 236653d4d7..24b6014674 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 @@ -1,31 +1,32 @@ using Objects; -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Logging; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class BrepToSpeckleConverter : ITypedConverter +public class BrepToSpeckleConverter : ITypedConverter { - 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; + 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; + private readonly IRhinoBoxFactory _rhinoBoxFactory; + private readonly IRhinoMeshFactory _rhinoMeshFactory; public BrepToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter curveConverter, - ITypedConverter surfaceConverter, - ITypedConverter meshConverter, - ITypedConverter boxConverter, - ITypedConverter intervalConverter, - IConversionContextStack contextStack - ) + ITypedConverter pointConverter, + ITypedConverter curveConverter, + ITypedConverter surfaceConverter, + ITypedConverter meshConverter, + ITypedConverter boxConverter, + ITypedConverter intervalConverter, + IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory, IRhinoMeshFactory rhinoMeshFactory) { _pointConverter = pointConverter; _curveConverter = curveConverter; @@ -34,6 +35,8 @@ IConversionContextStack contextStack _boxConverter = boxConverter; _intervalConverter = intervalConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; + _rhinoMeshFactory = rhinoMeshFactory; } /// @@ -41,7 +44,7 @@ IConversionContextStack contextStack /// /// The Brep object to convert. /// The converted Speckle Brep object. - public SOG.Brep Convert(RG.Brep target) + public SOG.Brep Convert(IRhinoBrep target) { var tol = _contextStack.Current.Document.ModelAbsoluteTolerance; target.Repair(tol); @@ -89,7 +92,7 @@ public SOG.Brep Convert(RG.Brep target) Orientation = (SOG.BrepOrientation)target.SolidOrientation, volume = target.IsSolid ? target.GetVolume() : 0, area = target.GetArea(), - bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(false))), + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(false))), units = _contextStack.Current.SpeckleUnits }; @@ -106,7 +109,7 @@ public SOG.Brep Convert(RG.Brep target) return speckleBrep; } - private static List ConvertBrepFaces(RG.Brep brep, SOG.Brep speckleParent) => + private static List ConvertBrepFaces(IRhinoBrep brep, SOG.Brep speckleParent) => brep.Faces .Select( f => @@ -120,7 +123,7 @@ public SOG.Brep Convert(RG.Brep target) ) .ToList(); - private List ConvertBrepEdges(RG.Brep brep, SOG.Brep speckleParent) => + private List ConvertBrepEdges(IRhinoBrep brep, SOG.Brep speckleParent) => brep.Edges .Select( edge => @@ -136,7 +139,7 @@ public SOG.Brep Convert(RG.Brep target) ) .ToList(); - private List ConvertBrepTrims(RG.Brep brep, SOG.Brep speckleParent) => + private List ConvertBrepTrims(IRhinoBrep brep, SOG.Brep speckleParent) => brep.Trims .Select(trim => { @@ -149,8 +152,8 @@ public SOG.Brep Convert(RG.Brep target) (int)trim.IsoStatus, (SOG.BrepTrimType)trim.TrimType, trim.IsReversed(), - trim.StartVertex.VertexIndex, - trim.EndVertex.VertexIndex + trim.StartVertex?.VertexIndex ?? -1, + trim.EndVertex?.VertexIndex ?? -1 ) { Domain = _intervalConverter.Convert(trim.Domain) @@ -160,7 +163,7 @@ public SOG.Brep Convert(RG.Brep target) }) .ToList(); - private List ConvertBrepLoops(RG.Brep brep, SOG.Brep speckleParent) => + private List ConvertBrepLoops(IRhinoBrep brep, SOG.Brep speckleParent) => brep.Loops .Select( loop => @@ -173,14 +176,13 @@ public SOG.Brep Convert(RG.Brep target) ) .ToList(); - private RG.Mesh? GetBrepDisplayMesh(RG.Brep brep) + private IRhinoMesh? GetBrepDisplayMesh(IRhinoBrep brep) { - var joinedMesh = new RG.Mesh(); + var joinedMesh = _rhinoMeshFactory.Create(); // get from settings //Settings.TryGetValue("sendMeshSetting", out string meshSetting); - RG.MeshingParameters mySettings = new(0.05, 0.05); // switch (SelectedMeshSettings) // { // case MeshSettings.CurrentDoc: @@ -194,7 +196,7 @@ public SOG.Brep Convert(RG.Brep target) try { - joinedMesh.Append(RG.Mesh.CreateFromBrep(brep, mySettings)); + joinedMesh.Append(_rhinoMeshFactory.CreateFromBrep(brep, 0.05, 0.05)); return joinedMesh; } catch (Exception ex) when (!ex.IsFatal()) 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 0e3f91e3bf..64ef397045 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 @@ -1,35 +1,35 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class CircleToSpeckleConverter : ITypedConverter +public class CircleToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _planeConverter; + private readonly IConversionContextStack _contextStack; public CircleToSpeckleConverter( - ITypedConverter planeConverter, - IConversionContextStack contextStack + ITypedConverter planeConverter, + IConversionContextStack contextStack ) { _planeConverter = planeConverter; _contextStack = contextStack; } - public Base Convert(object target) => Convert((RG.Circle)target); + public Base Convert(object target) => Convert((IRhinoCircle)target); /// - /// Converts a RG.Circle object to a SOG.Circle object. + /// Converts a IRhinoCircle object to a SOG.Circle object. /// - /// The RG.Circle object to convert. + /// The IRhinoCircle object to convert. /// The converted SOG.Circle object. /// /// ⚠️ 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 Convert(RG.Circle target) => + public SOG.Circle Convert(IRhinoCircle target) => new(_planeConverter.Convert(target.Plane), target.Radius, _contextStack.Current.SpeckleUnits) { domain = new SOP.Interval(0, 1), 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 d3747e2faf..c7d26596dd 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 @@ -1,15 +1,15 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class ControlPointToSpeckleConverter : ITypedConverter +public class ControlPointToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public ControlPointToSpeckleConverter(IConversionContextStack contextStack) + public ControlPointToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -19,8 +19,8 @@ public ControlPointToSpeckleConverter(IConversionContextStack /// The ControlPoint object to convert. /// The converted Speckle ControlPoint object. - public SOG.ControlPoint Convert(RG.ControlPoint target) => + public SOG.ControlPoint Convert(IRhinoControlPoint target) => new(target.Location.X, target.Location.Y, target.Location.Z, target.Weight, _contextStack.Current.SpeckleUnits); - public Base Convert(object target) => Convert((RG.ControlPoint)target); + public Base Convert(object target) => Convert((IRhinoControlPoint)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 5c792ebaf8..580cb2a7d1 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 @@ -1,24 +1,25 @@ using Objects; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; 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 : ITypedConverter, ITypedConverter +public class CurveToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _polyCurveConverter; - private readonly ITypedConverter _arcCurveConverter; - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _nurbsCurveConverter; - private readonly ITypedConverter _lineCurveConverter; + private readonly ITypedConverter _polyCurveConverter; + private readonly ITypedConverter _arcCurveConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _nurbsCurveConverter; + private readonly ITypedConverter _lineCurveConverter; public CurveToSpeckleConverter( - ITypedConverter polyCurveConverter, - ITypedConverter arcCurveConverter, - ITypedConverter polylineConverter, - ITypedConverter nurbsCurveConverter, - ITypedConverter lineCurveConverter + ITypedConverter polyCurveConverter, + ITypedConverter arcCurveConverter, + ITypedConverter polylineConverter, + ITypedConverter nurbsCurveConverter, + ITypedConverter lineCurveConverter ) { _polyCurveConverter = polyCurveConverter; @@ -37,15 +38,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 Convert(RG.Curve target) => + public ICurve Convert(IRhinoCurve target) => target switch { - RG.PolyCurve polyCurve => _polyCurveConverter.Convert(polyCurve), - RG.ArcCurve arcCurve => _arcCurveConverter.Convert(arcCurve), - RG.PolylineCurve polylineCurve => _polylineConverter.Convert(polylineCurve), - RG.LineCurve lineCurve => _lineCurveConverter.Convert(lineCurve), + IRhinoPolyCurve polyCurve => _polyCurveConverter.Convert(polyCurve), + IRhinoArcCurve arcCurve => _arcCurveConverter.Convert(arcCurve), + IRhinoPolylineCurve polylineCurve => _polylineConverter.Convert(polylineCurve), + IRhinoLineCurve lineCurve => _lineCurveConverter.Convert(lineCurve), _ => _nurbsCurveConverter.Convert(target.ToNurbsCurve()) }; - Base ITypedConverter.Convert(RG.Curve target) => (Base)Convert(target); + Base ITypedConverter.Convert(IRhinoCurve 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 fc6b52cc8f..cb86abedfe 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 @@ -1,24 +1,26 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class EllipseToSpeckleConverter : ITypedConverter +public class EllipseToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public EllipseToSpeckleConverter( - ITypedConverter planeConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + ITypedConverter planeConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) { _planeConverter = planeConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -29,7 +31,7 @@ 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 Convert(RG.Ellipse target) + public SOG.Ellipse Convert(IRhinoEllipse target) { var nurbsCurve = target.ToNurbsCurve(); return new( @@ -42,7 +44,7 @@ public SOG.Ellipse Convert(RG.Ellipse target) domain = new SOP.Interval(0, 1), length = nurbsCurve.GetLength(), area = Math.PI * target.Radius1 * target.Radius2, - bbox = _boxConverter.Convert(new RG.Box(nurbsCurve.GetBoundingBox(true))) + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(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 272fecafdb..8044a90e7d 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 @@ -1,13 +1,14 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class IntervalToSpeckleConverter : ITypedConverter +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 Convert(RG.Interval target) => new(target.T0, target.T1); + public SOP.Interval Convert(IRhinoInterval 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 f40620f78d..b279d5e3fd 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 @@ -1,24 +1,25 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class LineToSpeckleConverter : ITypedConverter, ITypedConverter +public class LineToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public LineToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + ITypedConverter pointConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) { _pointConverter = pointConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -29,13 +30,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 Convert(RG.Line target) => + public SOG.Line Convert(IRhinoLine 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.Convert(new RG.Box(target.BoundingBox)) + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.BoundingBox)) }; - public SOG.Line Convert(RG.LineCurve target) => Convert(target.Line); + public SOG.Line Convert(IRhinoLineCurve target) => Convert(target.Line); } From 91d23361f0c4a982a2d25923e75f8b42dced7cab Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Tue, 18 Jun 2024 15:18:30 +0100 Subject: [PATCH 09/28] more converters done! --- .../ToSpeckle/Raw/MeshToSpeckleConverter.cs | 23 ++++++------ .../ToSpeckle/Raw/NurbsCurveConverter.cs | 29 ++++++++------- .../Raw/NurbsSurfaceToSpeckleConverter.cs | 32 ++++++++-------- .../ToSpeckle/Raw/PlaneToSpeckleConverter.cs | 18 ++++----- .../ToSpeckle/Raw/PointToSpeckleConverter.cs | 12 +++--- .../Raw/PolyCurveToSpeckleConverter.cs | 25 +++++++------ .../Raw/PolylineToSpeckleConverter.cs | 37 ++++++++++--------- .../ToSpeckle/Raw/RawPointCloudToSpeckle.cs | 14 ++++--- .../ToSpeckle/Raw/VectorToSpeckleConverter.cs | 12 +++--- 9 files changed, 103 insertions(+), 99 deletions(-) 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 73aa3f4a8a..f96282b7ca 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 @@ -1,25 +1,24 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -[NameAndRankValue(nameof(RG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToSpeckleConverter : ITypedConverter +[NameAndRankValue(nameof(IRhinoMesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class MeshToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public MeshToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + ITypedConverter boxConverter, + IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) { - _pointConverter = pointConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -28,7 +27,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 Convert(RG.Mesh target) + public SOG.Mesh Convert(IRhinoMesh target) { if (target.Vertices.Count == 0 || target.Faces.Count == 0) { @@ -38,7 +37,7 @@ public SOG.Mesh Convert(RG.Mesh target) var vertexCoordinates = target.Vertices.ToPoint3dArray().SelectMany(pt => new[] { pt.X, pt.Y, pt.Z }).ToList(); var faces = new List(); - foreach (RG.MeshNgon polygon in target.GetNgonAndFacesEnumerable()) + foreach (IRhinoMeshNgon polygon in target.GetNgonAndFacesEnumerable()) { var vertIndices = polygon.BoundaryVertexIndexList(); int n = vertIndices.Length; @@ -55,7 +54,7 @@ public SOG.Mesh Convert(RG.Mesh target) var colors = target.VertexColors.Select(cl => cl.ToArgb()).ToList(); var volume = target.IsClosed ? target.Volume() : 0; - var bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(false))); + var bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(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 6cf8dca53d..c6856d3b60 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/Raw/NurbsCurveConverter.cs @@ -1,27 +1,28 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class NurbsCurveConverter : ITypedConverter +public class NurbsCurveConverter : ITypedConverter { - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _intervalConverter; - private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _boxConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public NurbsCurveConverter( - ITypedConverter polylineConverter, - ITypedConverter intervalConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + ITypedConverter polylineConverter, + ITypedConverter intervalConverter, + ITypedConverter boxConverter, + IConversionContextStackcontextStack , IRhinoBoxFactory rhinoBoxFactory) { _polylineConverter = polylineConverter; _intervalConverter = intervalConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -34,7 +35,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 Convert(RG.NurbsCurve target) + public SOG.Curve Convert(IRhinoNurbsCurve target) { target.ToPolyline(0, 1, 0, 0, 0, 0.1, 0, 0, true).TryGetPolyline(out var poly); if (target.IsClosed) @@ -63,7 +64,7 @@ public SOG.Curve Convert(RG.NurbsCurve target) domain = _intervalConverter.Convert(nurbsCurve.Domain), closed = nurbsCurve.IsClosed, length = nurbsCurve.GetLength(), - bbox = _boxConverter.Convert(new RG.Box(nurbsCurve.GetBoundingBox(true))) + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(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 0d663ff520..9e556856ea 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 @@ -1,28 +1,28 @@ -using Rhino; -using Rhino.Geometry.Collections; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class NurbsSurfaceToSpeckleConverter : ITypedConverter +public class NurbsSurfaceToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _boxConverter; - private readonly ITypedConverter _intervalConverter; - private readonly ITypedConverter _controlPointConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _controlPointConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public NurbsSurfaceToSpeckleConverter( - ITypedConverter boxConverter, - ITypedConverter intervalConverter, - ITypedConverter controlPointConverter, - IConversionContextStack contextStack - ) + ITypedConverter boxConverter, + ITypedConverter intervalConverter, + ITypedConverter controlPointConverter, + IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) { _boxConverter = boxConverter; _intervalConverter = intervalConverter; _controlPointConverter = controlPointConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -30,7 +30,7 @@ IConversionContextStack contextStack /// /// The NurbsSurface object to convert. /// A Surface object representing the converted NurbsSurface. - public SOG.Surface Convert(RG.NurbsSurface target) + public SOG.Surface Convert(IRhinoNurbsSurface target) { var result = new SOG.Surface { @@ -44,7 +44,7 @@ public SOG.Surface Convert(RG.NurbsSurface target) knotsU = target.KnotsU.ToList(), knotsV = target.KnotsV.ToList(), units = _contextStack.Current.SpeckleUnits, - bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))) + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(true))) }; result.SetControlPoints(ControlPointsToSpeckle(target.Points)); @@ -52,7 +52,7 @@ public SOG.Surface Convert(RG.NurbsSurface target) return result; } - private List> ControlPointsToSpeckle(NurbsSurfacePointList controlPoints) + private List> ControlPointsToSpeckle(IRhinoNurbsSurfacePointList controlPoints) { var points = new List>(); for (var i = 0; i < controlPoints.CountU; i++) 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 40d15be50c..b2a3264467 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 @@ -1,19 +1,19 @@ -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PlaneToSpeckleConverter : ITypedConverter +public class PlaneToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _vectorConverter; - private readonly ITypedConverter _pointConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly IConversionContextStack _contextStack; public PlaneToSpeckleConverter( - ITypedConverter vectorConverter, - ITypedConverter pointConverter, - IConversionContextStack contextStack + ITypedConverter vectorConverter, + ITypedConverter pointConverter, + IConversionContextStack contextStack ) { _vectorConverter = vectorConverter; @@ -26,7 +26,7 @@ IConversionContextStack contextStack /// /// The instance of Rhino Plane to convert. /// The converted instance of Speckle Plane. - public SOG.Plane Convert(RG.Plane target) => + public SOG.Plane Convert(IRhinoPlane target) => new( _pointConverter.Convert(target.Origin), _vectorConverter.Convert(target.ZAxis), 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 2bfdfdae1c..7a1801f150 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 @@ -1,14 +1,14 @@ -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PointToSpeckleConverter : ITypedConverter, ITypedConverter +public class PointToSpeckleConverter : ITypedConverter, ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public PointToSpeckleConverter(IConversionContextStack contextStack) + public PointToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -18,7 +18,7 @@ public PointToSpeckleConverter(IConversionContextStack con /// /// The Rhino 3D point to convert. /// The converted Speckle point. - public SOG.Point Convert(RG.Point3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); + public SOG.Point Convert(IRhinoPoint3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); - public SOG.Point Convert(RG.Point target) => Convert(target.Location); + public SOG.Point Convert(IRhinoPoint 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 6937d6b007..6b4ae9bdbd 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 @@ -1,26 +1,27 @@ using Objects; -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PolyCurveToSpeckleConverter : ITypedConverter +public class PolyCurveToSpeckleConverter : ITypedConverter { - 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 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; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public PolyCurveToSpeckleConverter( - ITypedConverter intervalConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack - ) + ITypedConverter intervalConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) { _intervalConverter = intervalConverter; _boxConverter = boxConverter; _contextStack = contextStack; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -32,14 +33,14 @@ 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 Convert(RG.PolyCurve target) + public SOG.Polycurve Convert(IRhinoPolyCurve target) { var myPoly = new SOG.Polycurve { closed = target.IsClosed, domain = _intervalConverter.Convert(target.Domain), length = target.GetLength(), - bbox = _boxConverter.Convert(new RG.Box(target.GetBoundingBox(true))), + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(true))), segments = target.DuplicateSegments().Select(x => CurveConverter.NotNull().Convert(x)).ToList(), units = _contextStack.Current.SpeckleUnits }; 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 1ee241e7d1..7cdaec82e7 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 @@ -1,29 +1,30 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; public class PolylineToSpeckleConverter - : ITypedConverter, - ITypedConverter + : ITypedConverter, + ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _boxConverter; - private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public PolylineToSpeckleConverter( - ITypedConverter pointConverter, - ITypedConverter boxConverter, - IConversionContextStack contextStack, - ITypedConverter intervalConverter - ) + ITypedConverter pointConverter, + ITypedConverter boxConverter, + IConversionContextStack contextStack, + ITypedConverter intervalConverter, IRhinoBoxFactory rhinoBoxFactory) { _pointConverter = pointConverter; _boxConverter = boxConverter; _contextStack = contextStack; _intervalConverter = intervalConverter; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -32,9 +33,9 @@ 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 Convert(RG.Polyline target) + public SOG.Polyline Convert(IRhinoPolyline target) { - var box = _boxConverter.Convert(new RG.Box(target.BoundingBox)); + var box = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.BoundingBox)); var points = target.Select(pt => _pointConverter.Convert(pt)).ToList(); if (target.IsClosed) @@ -48,8 +49,8 @@ public SOG.Polyline Convert(RG.Polyline target) ) { bbox = box, - length = target.Length, - domain = new(0, target.Length), + length = target.Count, + domain = new(0, target.Count), closed = target.IsClosed }; } @@ -60,7 +61,7 @@ public SOG.Polyline Convert(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 Convert(RG.PolylineCurve target) + public SOG.Polyline Convert(IRhinoPolylineCurve target) { var result = Convert(target.ToPolyline()); result.domain = _intervalConverter.Convert(target.Domain); 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 5e4a17e6cb..5a30498d07 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 @@ -1,21 +1,23 @@ using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class RawPointCloudToSpeckle : ITypedConverter +public class RawPointCloudToSpeckle : ITypedConverter { private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _boxConverter; + private readonly ITypedConverter _boxConverter; + private readonly IRhinoBoxFactory _rhinoBoxFactory; public RawPointCloudToSpeckle( IConversionContextStack contextStack, - ITypedConverter boxConverter - ) + ITypedConverter boxConverter, IRhinoBoxFactory rhinoBoxFactory) { _contextStack = contextStack; _boxConverter = boxConverter; + _rhinoBoxFactory = rhinoBoxFactory; } /// @@ -23,12 +25,12 @@ public RawPointCloudToSpeckle( /// /// The Rhino PointCloud object to convert. /// The converted Speckle Pointcloud object. - public SOG.Pointcloud Convert(RG.PointCloud target) => + public SOG.Pointcloud Convert(IRhinoPointCloud 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.Convert(new RG.Box(target.GetBoundingBox(true))), + bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(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 489eddedc4..fe5de7db27 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 @@ -1,14 +1,14 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class VectorToSpeckleConverter : ITypedConverter +public class VectorToSpeckleConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; - public VectorToSpeckleConverter(IConversionContextStack contextStack) + public VectorToSpeckleConverter(IConversionContextStack contextStack) { _contextStack = contextStack; } @@ -18,6 +18,6 @@ public VectorToSpeckleConverter(IConversionContextStack co /// /// The Rhino Vector3d object to convert. /// The converted Speckle Vector object. - public SOG.Vector Convert(RG.Vector3d target) => + public SOG.Vector Convert(IRhinoVector3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); } From 1b1e2d68498dbe3bdb6bcd79cb31928bc67a60f1 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Tue, 18 Jun 2024 16:44:31 +0100 Subject: [PATCH 10/28] even more converters --- .../ToHost/Raw/ArcToHostConverter.cs | 32 +++++++++-------- .../ToHost/Raw/CircleToHostConverter.cs | 36 ++++++++++--------- .../ToHost/Raw/EllipseToHostConverter.cs | 32 +++++++++-------- .../Raw/FlatPointListToHostConverter.cs | 21 +++++++---- .../ToHost/Raw/IntervalToHostConverter.cs | 14 ++++++-- .../ToHost/Raw/LineToHostConverter.cs | 17 +++++---- .../ToHost/Raw/NurbsCurveToHostConverter.cs | 21 ++++++----- .../ToHost/Raw/PlaneToHostConverter.cs | 18 +++++----- .../ToHost/Raw/PointCloudToHostConverter.cs | 14 ++++---- .../ToHost/Raw/PointToHostConverter.cs | 14 ++++++-- .../ToHost/Raw/PolyCurveToHostConverter.cs | 20 ++++++----- .../ToHost/Raw/PolylineToHostConverter.cs | 27 +++++++------- .../ToHost/Raw/SpiralToHostConverter.cs | 13 +++---- .../ToHost/Raw/SurfaceToHostConverter.cs | 18 +++++++--- .../ToHost/Raw/VectorToHostConverter.cs | 12 +++++-- .../BrepObjectToSpeckleTopLevelConverter.cs | 12 +++---- .../CurveObjectToSpeckleTopLevelConverter.cs | 12 +++---- ...trusionObjectToSpeckleTopLevelConverter.cs | 12 +++---- .../MeshObjectToSpeckleTopLevelConverter.cs | 12 +++---- ...ntCloudObjectToSpeckleTopLevelConverter.cs | 12 +++---- .../PointObjectToSpeckleTopLevelConverter.cs | 12 +++---- .../RhinoObjectToSpeckleTopLevelConverter.cs | 4 +-- 22 files changed, 223 insertions(+), 162 deletions(-) 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 0068c38ef2..73840337de 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 @@ -1,34 +1,36 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a SpeckleArcRaw object to a Rhino.Geometry.Arc object or Rhino.Geometry.ArcCurve object. /// -public class ArcToHostConverter : ITypedConverter, ITypedConverter +public class ArcToHostConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoArcFactory _rhinoArcFactory; public ArcToHostConverter( - ITypedConverter pointConverter, - ITypedConverter intervalConverter - ) + ITypedConverter pointConverter, + ITypedConverter intervalConverter, IRhinoArcFactory rhinoArcFactory) { _pointConverter = pointConverter; this._intervalConverter = intervalConverter; + _rhinoArcFactory = rhinoArcFactory; } /// - /// Converts a object to a object. + /// Converts a object to a object. /// /// The Speckle Arc object to convert. - /// The converted object. + /// The converted object. /// ⚠️ This conversion does NOT perform scaling. ///
⚠️ This method does not preserve the original curve domain
- public RG.Arc Convert(SOG.Arc target) + public IRhinoArc Convert(SOG.Arc target) { - var rhinoArc = new RG.Arc( + var rhinoArc = _rhinoArcFactory.Create( _pointConverter.Convert(target.startPoint), _pointConverter.Convert(target.midPoint), _pointConverter.Convert(target.endPoint) @@ -39,16 +41,16 @@ public RG.Arc Convert(SOG.Arc target) // POC: CNX-9271 Potential code-smell by directly implementing the interface. We should discuss this further but // since we're using the interfaces instead of the direct type, this may not be an issue. /// - /// Converts a object to a object. + /// Converts a object to a object. /// /// The object to convert. - /// The converted object. + /// The converted object. /// ⚠️ This conversion does NOT perform scaling. - ///
⚠️ Converting to instead of preserves the domain of the curve.
- RG.ArcCurve ITypedConverter.Convert(SOG.Arc target) + ///
⚠️ Converting to instead of preserves the domain of the curve.
+ IRhinoArcCurve ITypedConverter.Convert(SOG.Arc target) { var rhinoArc = Convert(target); - var arcCurve = new RG.ArcCurve(rhinoArc) { Domain = _intervalConverter.Convert(target.domain) }; + var arcCurve = _rhinoArcFactory.Create(rhinoArc, _intervalConverter.Convert(target.domain)); return arcCurve; } } 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 1431d3fc1a..a55bb72f6b 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 @@ -1,46 +1,48 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; /// -/// This class is responsible for converting a into and objects. +/// This class is responsible for converting a into and objects. /// Implements the interface, -/// providing implementation for to and conversion. +/// providing implementation for to and conversion. /// -public class CircleToHostConverter : ITypedConverter, ITypedConverter +public class CircleToHostConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoCircleFactory _rhinoCircleFactory; /// /// 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( - ITypedConverter intervalConverter, - ITypedConverter planeConverter - ) + ITypedConverter intervalConverter, + ITypedConverter planeConverter, IRhinoCircleFactory rhinoCircleFactory) { _intervalConverter = intervalConverter; _planeConverter = planeConverter; + _rhinoCircleFactory = rhinoCircleFactory; } /// - /// Converts the given object into a object. + /// Converts the given object into a object. /// /// The object to convert. - /// The resulting object. + /// The resulting object. /// /// Thrown when the radius of the given object is 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.Circle Convert(SOG.Circle target) + ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
+ public IRhinoCircle Convert(SOG.Circle target) { if (target.radius == null) { @@ -50,9 +52,9 @@ public RG.Circle Convert(SOG.Circle target) var plane = _planeConverter.Convert(target.plane); var radius = target.radius.Value; - return new RG.Circle(plane, radius); + return _rhinoCircleFactory.Create(plane, radius); } - RG.ArcCurve ITypedConverter.Convert(SOG.Circle target) => - new(Convert(target)) { Domain = _intervalConverter.Convert(target.domain) }; + IRhinoArcCurve ITypedConverter.Convert(SOG.Circle target) => + _rhinoCircleFactory.Create(Convert(target), _intervalConverter.Convert(target.domain)); } 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 74f309a61f..a74da6774f 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 @@ -1,49 +1,51 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; public class EllipseToHostConverter - : ITypedConverter, - ITypedConverter + : ITypedConverter, + ITypedConverter { - private readonly ITypedConverter _planeConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _planeConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoEllipseFactory _rhinoEllipseFactory; public EllipseToHostConverter( - ITypedConverter planeConverter, - ITypedConverter intervalConverter - ) + ITypedConverter planeConverter, + ITypedConverter intervalConverter, IRhinoEllipseFactory rhinoEllipseFactory) { _planeConverter = planeConverter; _intervalConverter = intervalConverter; + _rhinoEllipseFactory = rhinoEllipseFactory; } /// - /// Converts an instance of to an while preserving geometric properties. + /// Converts an instance of to an while preserving geometric properties. /// /// The instance to be converted. - /// The resulting after conversion. + /// The resulting after conversion. /// 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 Convert(SOG.Ellipse target) + ///
⚠️ This conversion does not preserve the curve domain. If you need it preserved you must request a conversion to conversion instead
+ public IRhinoEllipse Convert(SOG.Ellipse target) { if (!target.firstRadius.HasValue || !target.secondRadius.HasValue) { throw new InvalidOperationException($"Ellipses cannot have null radii"); } - return new RG.Ellipse(_planeConverter.Convert(target.plane), target.firstRadius.Value, target.secondRadius.Value); + return _rhinoEllipseFactory.Create(_planeConverter.Convert(target.plane), target.firstRadius.Value, target.secondRadius.Value); } /// - /// Converts the provided into a representation. + /// Converts the provided into a representation. /// /// The to convert. /// - /// A that represents the provided . + /// A that represents the provided . /// - RG.NurbsCurve ITypedConverter.Convert(SOG.Ellipse target) + IRhinoNurbsCurve ITypedConverter.Convert(SOG.Ellipse target) { var rhinoEllipse = Convert(target); var rhinoNurbsEllipse = rhinoEllipse.ToNurbsCurve(); 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 f0363a387d..97c2786b44 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 @@ -1,14 +1,21 @@ -using Rhino.Collections; -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; using Speckle.Core.Logging; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; /// /// Converts a flat list of raw double values to a Point3dList. /// -public class FlatPointListToHostConverter : ITypedConverter, Point3dList> +public class FlatPointListToHostConverter : ITypedConverter, IRhinoPoint3dList> { + private readonly IRhinoPointFactory _rhinoPointFactory; + + public FlatPointListToHostConverter(IRhinoPointFactory rhinoPointFactory) + { + _rhinoPointFactory = rhinoPointFactory; + } + /// /// Converts a flat list of raw double values to a Point3dList. /// @@ -19,20 +26,20 @@ public class FlatPointListToHostConverter : ITypedConverter /// Throws when the input list count is not a multiple of 3. - public Point3dList Convert(IReadOnlyList target) + public IRhinoPoint3dList Convert(IReadOnlyList target) { if (target.Count % 3 != 0) { throw new SpeckleException("Array malformed: length%3 != 0."); } - var points = new List(target.Count / 3); + var points = new List(target.Count / 3); for (int i = 2; i < target.Count; i += 3) { - points.Add(new RG.Point3d(target[i - 2], target[i - 1], target[i])); + points.Add(_rhinoPointFactory.Create(target[i - 2], target[i - 1], target[i])); } - return new Point3dList(points); + return _rhinoPointFactory.Create(points); } } 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 f201283ebd..ddaa476970 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 @@ -1,9 +1,17 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class IntervalToHostConverter : ITypedConverter +public class IntervalToHostConverter : ITypedConverter { + private readonly IRhinoIntervalFactory _rhinoIntervalFactory; + + public IntervalToHostConverter(IRhinoIntervalFactory rhinoIntervalFactory) + { + _rhinoIntervalFactory = rhinoIntervalFactory; + } + /// /// Converts a Speckle Interval object to a Rhino.Geometry.Interval object. /// @@ -11,13 +19,13 @@ public class IntervalToHostConverter : ITypedConverterThe 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 Convert(SOP.Interval target) + public IRhinoInterval Convert(SOP.Interval target) { if (!target.start.HasValue || !target.end.HasValue) // POC: CNX-9272 Interval start and end being nullable makes no sense. { throw new ArgumentException("Interval start/end cannot be null"); } - return new RG.Interval(target.start.Value, target.end.Value); + return _rhinoIntervalFactory.Create(target.start.Value, target.end.Value); } } 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 c549e96741..cfb2fcc66c 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 @@ -1,14 +1,17 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class LineToHostConverter : ITypedConverter, ITypedConverter +public class LineToHostConverter : ITypedConverter, ITypedConverter { - private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _pointConverter; + private readonly IRhinoLineFactory _rhinoLineFactory; - public LineToHostConverter(ITypedConverter pointConverter) + public LineToHostConverter(ITypedConverter pointConverter, IRhinoLineFactory rhinoLineFactory) { _pointConverter = pointConverter; + _rhinoLineFactory = rhinoLineFactory; } /// @@ -20,15 +23,15 @@ public LineToHostConverter(ITypedConverter pointConverter /// ///
⚠️ This conversion does not preserve the curve domain. /// If you need it preserved you must request a conversion to - /// conversion instead + /// conversion instead ///
- public RG.Line Convert(SOG.Line target) => - new(_pointConverter.Convert(target.start), _pointConverter.Convert(target.end)); + public IRhinoLine Convert(SOG.Line target) => + _rhinoLineFactory.Create(_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 ITypedConverter.Convert(SOG.Line target) => new(Convert(target)); + IRhinoLineCurve ITypedConverter.Convert(SOG.Line target) => _rhinoLineFactory.Create(Convert(target)); } 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 9f9bf52811..291fd4c5dc 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 @@ -1,15 +1,20 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class NurbsCurveToHostConverter : ITypedConverter +public class NurbsCurveToHostConverter : ITypedConverter { - private readonly ITypedConverter _intervalConverter; + private readonly IRhinoPointFactory _rhinoPointFactory; + private readonly IRhinoCurveFactory _rhinoCurveFactory; + private readonly ITypedConverter _intervalConverter; - public NurbsCurveToHostConverter(ITypedConverter intervalConverter) + public NurbsCurveToHostConverter(ITypedConverter intervalConverter, IRhinoCurveFactory rhinoCurveFactory, IRhinoPointFactory rhinoPointFactory) { _intervalConverter = intervalConverter; + _rhinoCurveFactory = rhinoCurveFactory; + _rhinoPointFactory = rhinoPointFactory; } /// @@ -19,14 +24,14 @@ public NurbsCurveToHostConverter(ITypedConverter inte /// The converted Rhino NurbsCurve object. /// Thrown when the conversion fails. /// ⚠️ This conversion does NOT perform scaling. - public RG.NurbsCurve Convert(SOG.Curve target) + public IRhinoNurbsCurve Convert(SOG.Curve target) { - RG.NurbsCurve nurbsCurve = new(target.degree, target.points.Count / 3); + IRhinoNurbsCurve nurbsCurve = _rhinoCurveFactory.Create(target.degree, target.points.Count / 3); // Hyper optimised curve control point conversion for (int i = 2, j = 0; i < target.points.Count; i += 3, j++) { - var pt = new RG.Point3d(target.points[i - 2], target.points[i - 1], target.points[i]); // Skip the point converter for performance + var pt = _rhinoPointFactory.Create(target.points[i - 2], target.points[i - 1], target.points[i]); // Skip the point converter for performance nurbsCurve.Points.SetPoint(j, pt, target.weights[j]); } @@ -37,11 +42,11 @@ public RG.NurbsCurve Convert(SOG.Curve target) { if (extraKnots == 2) { - nurbsCurve.Knots[j] = target.knots[j + 1]; + nurbsCurve.Knots.SetKnot(j, target.knots[j + 1]); } else { - nurbsCurve.Knots[j] = target.knots[j]; + nurbsCurve.Knots.SetKnot(j, target.knots[j]); } } 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 49e10ab69e..6856178a40 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 @@ -1,19 +1,21 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PlaneToHostConverter : ITypedConverter +public class PlaneToHostConverter : ITypedConverter { - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _vectorConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _vectorConverter; + private readonly IRhinoPlaneFactory _rhinoPlaneFactory; public PlaneToHostConverter( - ITypedConverter pointConverter, - ITypedConverter vectorConverter - ) + ITypedConverter pointConverter, + ITypedConverter vectorConverter, IRhinoPlaneFactory rhinoPlaneFactory) { _pointConverter = pointConverter; _vectorConverter = vectorConverter; + _rhinoPlaneFactory = rhinoPlaneFactory; } /// @@ -22,8 +24,8 @@ public PlaneToHostConverter( /// The Speckle Plane object to be converted. /// The converted Rhino Plane object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Plane Convert(SOG.Plane target) => - new( + public IRhinoPlane Convert(SOG.Plane target) => + _rhinoPlaneFactory.Create( _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 a6d749b15c..7f59009710 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 @@ -1,16 +1,18 @@ using System.Drawing; -using Rhino.Collections; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PointCloudToHostConverter : ITypedConverter +public class PointCloudToHostConverter : ITypedConverter { - private readonly ITypedConverter, Point3dList> _pointListConverter; + private readonly ITypedConverter, IRhinoPoint3dList> _pointListConverter; + private readonly IRhinoPointCloudFactory _rhinoPointCloudFactory; - public PointCloudToHostConverter(ITypedConverter, Point3dList> pointListConverter) + public PointCloudToHostConverter(ITypedConverter, IRhinoPoint3dList> pointListConverter, IRhinoPointCloudFactory rhinoPointCloudFactory) { _pointListConverter = pointListConverter; + _rhinoPointCloudFactory = rhinoPointCloudFactory; } /// @@ -19,10 +21,10 @@ public PointCloudToHostConverter(ITypedConverter, Point3dL /// The raw Speckle Pointcloud object to convert. /// The converted Rhino PointCloud object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PointCloud Convert(SOG.Pointcloud target) + public IRhinoPointCloud Convert(SOG.Pointcloud target) { var rhinoPoints = _pointListConverter.Convert(target.points); - var rhinoPointCloud = new RG.PointCloud(rhinoPoints); + var rhinoPointCloud = _rhinoPointCloudFactory.Create(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 8ce40bcb59..edc4a3d7cb 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 @@ -1,16 +1,24 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PointToHostConverter : ITypedConverter, ITypedConverter +public class PointToHostConverter : ITypedConverter, ITypedConverter { + private readonly IRhinoPointFactory _rhinoPointFactory; + + public PointToHostConverter(IRhinoPointFactory rhinoPointFactory) + { + _rhinoPointFactory = rhinoPointFactory; + } + /// /// Converts a Speckle Point object to a Rhino Point3d object. /// /// The Speckle Point object to convert. /// The converted Rhino Point3d object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Point3d Convert(SOG.Point target) => new(target.x, target.y, target.z); + public IRhinoPoint3d Convert(SOG.Point target) => _rhinoPointFactory.Create(target.x, target.y, target.z); /// /// Converts a Speckle Point object to a Rhino Point object. @@ -18,5 +26,5 @@ public class PointToHostConverter : ITypedConverter, ITyp /// The Speckle Point object to convert. /// The converted Rhino Point object. /// ⚠️ This conversion does NOT perform scaling. - RG.Point ITypedConverter.Convert(SOG.Point target) => new(Convert(target)); + IRhinoPoint ITypedConverter.Convert(SOG.Point target) => _rhinoPointFactory.Create(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 3f35905090..effbce9847 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 @@ -1,19 +1,21 @@ using Objects; -using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class PolyCurveToHostConverter : ITypedConverter +public class PolyCurveToHostConverter : ITypedConverter { - public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoCurveFactory _rhinoCurveFactory; - private readonly ITypedConverter _intervalConverter; - - public PolyCurveToHostConverter(ITypedConverter intervalConverter) + public PolyCurveToHostConverter(ITypedConverter intervalConverter, ITypedConverter curveConverter, IRhinoCurveFactory rhinoCurveFactory) { _intervalConverter = intervalConverter; + _curveConverter = curveConverter; + _rhinoCurveFactory = rhinoCurveFactory; } /// @@ -22,13 +24,13 @@ public PolyCurveToHostConverter(ITypedConverter inter /// The SpecklePolyCurve object to convert. /// The converted Rhino PolyCurve object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PolyCurve Convert(SOG.Polycurve target) + public IRhinoPolyCurve Convert(SOG.Polycurve target) { - RG.PolyCurve result = new(); + IRhinoPolyCurve result = _rhinoCurveFactory.Create(); foreach (var segment in target.segments) { - var childCurve = CurveConverter.NotNull().Convert(segment); + var childCurve = _curveConverter.Convert(segment); bool success = result.AppendSegment(childCurve); if (!success) { 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 5abe48fed5..4d1adff489 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 @@ -1,22 +1,23 @@ -using Rhino.Collections; -using Speckle.Converters.Common.Objects; +using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; public class PolylineToHostConverter - : ITypedConverter, - ITypedConverter + : ITypedConverter, + ITypedConverter { - private readonly ITypedConverter, Point3dList> _pointListConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter, IRhinoPoint3dList> _pointListConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoLineFactory _rhinoLineFactory; public PolylineToHostConverter( - ITypedConverter, Point3dList> pointListConverter, - ITypedConverter intervalConverter - ) + ITypedConverter, IRhinoPoint3dList> pointListConverter, + ITypedConverter intervalConverter, IRhinoLineFactory rhinoLineFactory) { _pointListConverter = pointListConverter; _intervalConverter = intervalConverter; + _rhinoLineFactory = rhinoLineFactory; } /// @@ -28,9 +29,9 @@ public PolylineToHostConverter( /// ///
⚠️ This conversion does not preserve the curve domain. /// If you need it preserved you must request a conversion to - /// conversion instead + /// conversion instead ///
- public RG.Polyline Convert(SOG.Polyline target) + public IRhinoPolyline Convert(SOG.Polyline target) { var points = _pointListConverter.Convert(target.value); @@ -39,7 +40,7 @@ public RG.Polyline Convert(SOG.Polyline target) points.Add(points[0]); } - var poly = new RG.Polyline(points); + var poly = _rhinoLineFactory.Create(points); return poly; } @@ -52,7 +53,7 @@ public RG.Polyline Convert(SOG.Polyline target) /// The Speckle polyline object to be converted. /// The converted Rhino Polyline object. /// ⚠️ This conversion does NOT perform scaling. - RG.PolylineCurve ITypedConverter.Convert(SOG.Polyline target) + IRhinoPolylineCurve ITypedConverter.Convert(SOG.Polyline target) { var poly = Convert(target).ToPolylineCurve(); poly.Domain = _intervalConverter.Convert(target.domain); 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 cb7f5a8745..c3cc3532ce 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 @@ -1,15 +1,16 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SpiralToHostConverter : ITypedConverter +public class SpiralToHostConverter : ITypedConverter { - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _intervalConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _intervalConverter; public SpiralToHostConverter( - ITypedConverter polylineConverter, - ITypedConverter intervalConverter + ITypedConverter polylineConverter, + ITypedConverter intervalConverter ) { _polylineConverter = polylineConverter; @@ -22,7 +23,7 @@ public SpiralToHostConverter( /// The Speckle Spiral object to be converted. /// A Rhino PolylineCurve object. /// ⚠️ This conversion does NOT perform scaling. - public RG.PolylineCurve Convert(SOG.Spiral target) + public IRhinoPolylineCurve Convert(SOG.Spiral target) { var result = _polylineConverter.Convert(target.displayValue); result.Domain = _intervalConverter.Convert(target.domain); 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 91da44ec59..d945c3da8f 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 @@ -1,21 +1,29 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class SurfaceToHostConverter : ITypedConverter +public class SurfaceToHostConverter : ITypedConverter { + private readonly IRhinoSurfaceFactory _rhinoSurfaceFactory; + + public SurfaceToHostConverter(IRhinoSurfaceFactory rhinoSurfaceFactory) + { + _rhinoSurfaceFactory = rhinoSurfaceFactory; + } + /// /// Converts a raw Speckle surface to a Rhino NURBS surface. /// /// The raw Speckle surface to convert. /// The converted Rhino NURBS surface. /// ⚠️ This conversion does NOT perform scaling. - public RG.NurbsSurface Convert(SOG.Surface target) + public IRhinoNurbsSurface Convert(SOG.Surface target) { // Create rhino surface var points = target.GetControlPoints().ToList(); - var result = RG.NurbsSurface.Create( + var result = _rhinoSurfaceFactory.Create( 3, target.rational, target.degreeU + 1, @@ -28,13 +36,13 @@ public RG.NurbsSurface Convert(SOG.Surface target) var correctUKnots = GetCorrectKnots(target.knotsU, target.countU, target.degreeU); for (int i = 0; i < correctUKnots.Count; i++) { - result.KnotsU[i] = correctUKnots[i]; + result.KnotsU.SetKnot(i, correctUKnots[i]); } var correctVKnots = GetCorrectKnots(target.knotsV, target.countV, target.degreeV); for (int i = 0; i < correctVKnots.Count; i++) { - result.KnotsV[i] = correctVKnots[i]; + result.KnotsV.SetKnot(i, correctVKnots[i]); } // Set control points 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 77e017f0fd..85ff17692c 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 @@ -1,14 +1,22 @@ using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class VectorToHostConverter : ITypedConverter +public class VectorToHostConverter : ITypedConverter { + private readonly IRhinoVectorFactory _rhinoVectorFactory; + + public VectorToHostConverter(IRhinoVectorFactory rhinoVectorFactory) + { + _rhinoVectorFactory = rhinoVectorFactory; + } + /// /// Converts a Speckle.Vector object to a Rhino Vector3d object. /// /// The Speckle.Vector to be converted. /// The converted Rhino Vector3d object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Vector3d Convert(SOG.Vector target) => new(target.x, target.y, target.z); + public IRhinoVector3d Convert(SOG.Vector target) => _rhinoVectorFactory.Create(target.x, target.y, target.z); } 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 7520c1bd83..cce82c29e9 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 @@ -1,23 +1,23 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(BrepObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(IRhinoBrepObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class BrepObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _curveConverter; - public BrepObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) + public BrepObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } public Base Convert(object target) { - var curveObject = (BrepObject)target; + var curveObject = (IRhinoBrepObject)target; 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 a8214a0c97..2ff6020bc1 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 @@ -1,15 +1,15 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(CurveObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CurveObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter +[NameAndRankValue(nameof(IRhinoCurveObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class CurveObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public CurveObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public CurveObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override RG.Curve GetTypedGeometry(CurveObject input) => input.CurveGeometry; + protected override IRhinoCurve GetTypedGeometry(IRhinoCurveObject 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 46d2c27586..cc59b338af 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 @@ -1,23 +1,23 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(ExtrusionObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(IRhinoExtrusionObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class ExtrusionObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter { - private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _curveConverter; - public ExtrusionObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) + public ExtrusionObjectToSpeckleTopLevelConverter(ITypedConverter curveConverter) { _curveConverter = curveConverter; } public Base Convert(object target) { - var curveObject = (ExtrusionObject)target; + var curveObject = (IRhinoExtrusionObject)target; var speckleCurve = _curveConverter.Convert(curveObject.ExtrusionGeometry.ToBrep()); return speckleCurve; } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs index f1c9675a04..4a4b5978ee 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/ToSpeckle/TopLevel/MeshObjectToSpeckleTopLevelConverter.cs @@ -1,14 +1,14 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(MeshObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter +[NameAndRankValue(nameof(IRhinoMeshObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +public class MeshObjectToSpeckleTopLevelConverter : RhinoObjectToSpeckleTopLevelConverter { - public MeshObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public MeshObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override RG.Mesh GetTypedGeometry(MeshObject input) => input.MeshGeometry; + protected override IRhinoMesh GetTypedGeometry(IRhinoMeshObject 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 e741e38e49..b25c80d190 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 @@ -1,15 +1,15 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(PointCloudObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(IRhinoPointCloudObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointCloudObjectToSpeckleTopLevelConverter - : RhinoObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { - public PointCloudObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public PointCloudObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override RG.PointCloud GetTypedGeometry(PointCloudObject input) => input.PointCloudGeometry; + protected override IRhinoPointCloud GetTypedGeometry(IRhinoPointCloudObject 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 7d9c750b64..d127aa0266 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 @@ -1,15 +1,15 @@ -using Rhino.DocObjects; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; -[NameAndRankValue(nameof(PointObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] +[NameAndRankValue(nameof(IRhinoPointObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointObjectToSpeckleTopLevelConverter - : RhinoObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { - public PointObjectToSpeckleTopLevelConverter(ITypedConverter conversion) + public PointObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } - protected override RG.Point GetTypedGeometry(PointObject input) => input.PointGeometry; + protected override IRhinoPoint GetTypedGeometry(IRhinoPointObject 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 edff24473a..c21065cd68 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 @@ -4,8 +4,8 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.TopLevel; public abstract class RhinoObjectToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter - where TTopLevelIn : Rhino.DocObjects.RhinoObject - where TInRaw : RG.GeometryBase + where TTopLevelIn : notnull + where TInRaw : notnull where TOutRaw : Base { public ITypedConverter Conversion { get; } From 835c19fe7760f7fbbc037a3871ccd8cd5454e3c6 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Tue, 18 Jun 2024 16:55:30 +0100 Subject: [PATCH 11/28] more conversions --- ...peckleToHostGeometryBaseTopLevelConverter.cs | 17 +++++++++-------- .../PointCloudToHostTopLevelConverter.cs | 12 +++++++----- .../TopLevel/PointToHostTopLevelConverter.cs | 12 +++++++----- .../PolycurveToHostTopLevelConverter.cs | 12 +++++++----- .../TopLevel/PolylineToHostTopLevelConverter.cs | 12 +++++++----- 5 files changed, 37 insertions(+), 28 deletions(-) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs index 75ff2162c2..bf94f5c09a 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs @@ -1,25 +1,26 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7; public abstract class SpeckleToHostGeometryBaseTopLevelConverter : IToHostTopLevelConverter where TIn : Base - where TOut : RG.GeometryBase + where TOut : IRhinoGeometryBase { - protected IConversionContextStack ContextStack { get; private set; } + protected IConversionContextStack ContextStack { get; private set; } private readonly ITypedConverter _geometryBaseConverter; + private readonly IRhinoTransformFactory _transformFactory; protected SpeckleToHostGeometryBaseTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter - ) + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, IRhinoTransformFactory transformFactory) { ContextStack = contextStack; _geometryBaseConverter = geometryBaseConverter; + _transformFactory = transformFactory; } public object Convert(Base target) @@ -35,7 +36,7 @@ public object Convert(Base target) if (castedBase["units"] is string units) { var scaleFactor = Units.GetConversionFactor(units, ContextStack.Current.SpeckleUnits); - var scale = RG.Transform.Scale(RG.Point3d.Origin, scaleFactor); + var scale = _transformFactory.Scale(_transformFactory.Origin, scaleFactor); result.Transform(scale); } 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 51a2613e90..04915824de 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 @@ -1,16 +1,18 @@ -using Rhino; + using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Pointcloud), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PointCloudToHostTopLevelConverter - : SpeckleToHostGeometryBaseTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PointCloudToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 de10053ce9..99dc2600db 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 @@ -1,15 +1,17 @@ -using Rhino; + using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class PointToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public PointToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 d6f8d2f14b..d9e5814210 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 @@ -1,15 +1,17 @@ -using Rhino; + using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class PolycurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public PolycurveToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 081f217f04..e6a9d149ad 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 @@ -1,16 +1,18 @@ -using Rhino; + using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class PolylineToHostTopLevelConverter - : SpeckleToHostGeometryBaseTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PolylineToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } From f30f28bd198454f53898de55d8938e27470cf9ae Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 19 Jun 2024 10:14:18 +0100 Subject: [PATCH 12/28] more top level converters --- .../ToHost/TopLevel/ArcToHostTopLevelConverter.cs | 13 +++++++------ .../ToHost/TopLevel/BrepToHostTopLevelConverter.cs | 13 +++++++------ .../TopLevel/CircleToHostTopLevelConverter.cs | 13 +++++++------ .../TopLevel/EllipseToHostTopLevelConverter.cs | 13 +++++++------ .../ToHost/TopLevel/LineToHostTopLevelConverter.cs | 13 +++++++------ .../ToHost/TopLevel/MeshToHostTopLevelConverter.cs | 13 +++++++------ .../TopLevel/NurbsCurveToHostTopLevelConverter.cs | 13 +++++++------ 7 files changed, 49 insertions(+), 42 deletions(-) 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 12c4420914..ca8b4938bd 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 @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class ArcToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public ArcToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 6ca70d3ad1..1c8706bd99 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 @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Brep), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class BrepToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public BrepToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 1493120e57..942854b10b 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 @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class CircleToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public CircleToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 e6a4b03a41..dbc35c205b 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 @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class EllipseToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public EllipseToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 5a64a3ebab..8767a91e06 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 @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class LineToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public LineToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 c7d047df3b..6cdacc4288 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 @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class MeshToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public MeshToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 987b46161f..19201d066a 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 @@ -1,15 +1,16 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class NurbsCurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter { public NurbsCurveToHostTopLevelConverter( - IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter + IConversionContextStack contextStack, + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory rhinoTransformFactory ) - : base(contextStack, geometryBaseConverter) { } + : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } From e69f0e59cd791bf2216e569aa5840a1bbec95589 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 19 Jun 2024 11:17:09 +0100 Subject: [PATCH 13/28] all rhino types converted --- .../Speckle.Converters.Rhino7/GlobalUsings.cs | 1 - .../RhinoConversionContextStack.cs | 8 +-- .../RhinoToSpeckleUnitConverter.cs | 30 +++++----- .../ToHost/Raw/BrepToHostConverter.cs | 57 ++++++++++--------- .../ToHost/Raw/CurveToHostConverter.cs | 41 ++++++------- .../ToHost/Raw/MeshToHostConverter.cs | 36 ++++++------ .../FallbackToHostTopLevelConverter.cs | 37 ++++++------ .../Raw/ArcCurveToSpeckleConverter.cs | 5 +- .../Raw/EllipseToSpeckleConverter.cs | 7 +-- .../ToSpeckle/Raw/MeshToSpeckleConverter.cs | 7 +-- .../ToSpeckle/Raw/RawPointCloudToSpeckle.cs | 7 +-- 11 files changed, 119 insertions(+), 117 deletions(-) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs index baa44c188e..c88d8e3105 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/GlobalUsings.cs @@ -1,3 +1,2 @@ -global using RG = Rhino.Geometry; global using SOG = Objects.Geometry; global using SOP = Objects.Primitive; diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs index 79ac2f77a4..e0a98d264c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -using Rhino; using Speckle.Converters.Common; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7; @@ -10,8 +10,8 @@ namespace Speckle.Converters.Rhino7; "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 RhinoConversionContextStack : ConversionContextStack +public class RhinoConversionContextStack : ConversionContextStack { - public RhinoConversionContextStack(IHostToSpeckleUnitConverter unitConverter) - : base(RhinoDoc.ActiveDoc, RhinoDoc.ActiveDoc.ModelUnitSystem, unitConverter) { } + public RhinoConversionContextStack(IRhinoDocFactory rhinoDocFactory, IHostToSpeckleUnitConverter unitConverter) + : base(rhinoDocFactory.ActiveDoc(), rhinoDocFactory.ActiveDoc().ModelUnitSystem, unitConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs index 4f4f9c77e4..f7953bc383 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoToSpeckleUnitConverter.cs @@ -1,29 +1,29 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Core.Kits; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7; -public class RhinoToSpeckleUnitConverter : IHostToSpeckleUnitConverter +public class RhinoToSpeckleUnitConverter : IHostToSpeckleUnitConverter { - private readonly Dictionary _unitMapping = new(); + private readonly Dictionary _unitMapping = new(); public RhinoToSpeckleUnitConverter() { // POC: CNX-9269 Add unit test to ensure these don't change. - _unitMapping[UnitSystem.None] = Units.Meters; - _unitMapping[UnitSystem.Millimeters] = Units.Millimeters; - _unitMapping[UnitSystem.Centimeters] = Units.Centimeters; - _unitMapping[UnitSystem.Meters] = Units.Meters; - _unitMapping[UnitSystem.Kilometers] = Units.Kilometers; - _unitMapping[UnitSystem.Inches] = Units.Inches; - _unitMapping[UnitSystem.Feet] = Units.Feet; - _unitMapping[UnitSystem.Yards] = Units.Yards; - _unitMapping[UnitSystem.Miles] = Units.Miles; - _unitMapping[UnitSystem.Unset] = Units.Meters; + _unitMapping[RhinoUnitSystem.None] = Units.Meters; + _unitMapping[RhinoUnitSystem.Millimeters] = Units.Millimeters; + _unitMapping[RhinoUnitSystem.Centimeters] = Units.Centimeters; + _unitMapping[RhinoUnitSystem.Meters] = Units.Meters; + _unitMapping[RhinoUnitSystem.Kilometers] = Units.Kilometers; + _unitMapping[RhinoUnitSystem.Inches] = Units.Inches; + _unitMapping[RhinoUnitSystem.Feet] = Units.Feet; + _unitMapping[RhinoUnitSystem.Yards] = Units.Yards; + _unitMapping[RhinoUnitSystem.Miles] = Units.Miles; + _unitMapping[RhinoUnitSystem.Unset] = Units.Meters; } - public string ConvertOrThrow(UnitSystem hostUnit) + public string ConvertOrThrow(RhinoUnitSystem hostUnit) { if (_unitMapping.TryGetValue(hostUnit, out string value)) { 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 db94e2f7f0..3d5dd2b6e2 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 @@ -1,35 +1,36 @@ using Objects; -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class BrepToHostConverter : ITypedConverter +public class BrepToHostConverter : ITypedConverter { - private readonly IConversionContextStack _contextStack; - private readonly ITypedConverter _curveConverter; - private readonly ITypedConverter _surfaceConverter; - private readonly ITypedConverter _pointConverter; - private readonly ITypedConverter _intervalConverter; + private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _curveConverter; + private readonly ITypedConverter _surfaceConverter; + private readonly ITypedConverter _pointConverter; + private readonly ITypedConverter _intervalConverter; + private readonly IRhinoBrepFactory _rhinoBrepFactory; public BrepToHostConverter( - IConversionContextStack contextStack, - ITypedConverter curveConverter, - ITypedConverter surfaceConverter, - ITypedConverter pointConverter, - ITypedConverter intervalConverter - ) + IConversionContextStack contextStack, + ITypedConverter curveConverter, + ITypedConverter surfaceConverter, + ITypedConverter pointConverter, + ITypedConverter intervalConverter, IRhinoBrepFactory rhinoBrepFactory) { _contextStack = contextStack; _curveConverter = curveConverter; _surfaceConverter = surfaceConverter; _pointConverter = pointConverter; _intervalConverter = intervalConverter; + _rhinoBrepFactory = rhinoBrepFactory; } /// - /// Converts a Speckle to a Rhino . + /// Converts a Speckle to a Rhino . /// /// /// This method converts a Speckle Brep object to its equivalent Rhino Brep representation. @@ -40,11 +41,11 @@ public BrepToHostConverter( /// The Speckle Brep object to be converted. /// The equivalent Rhino Brep object. /// ⚠️ This conversion does NOT perform scaling. - public RG.Brep Convert(SOG.Brep target) + public IRhinoBrep Convert(SOG.Brep target) { var tolerance = _contextStack.Current.Document.ModelAbsoluteTolerance; - var rhinoBrep = new RG.Brep(); + var rhinoBrep = _rhinoBrepFactory.Create(); // Geometry goes in first, always. Order doesn't matter. target.Curve3D.ForEach(curve => rhinoBrep.AddEdgeCurve(_curveConverter.Convert(curve))); @@ -70,21 +71,21 @@ public RG.Brep Convert(SOG.Brep target) } /// - /// Converts a Speckle to a Rhino and adds it to the provided . + /// Converts a Speckle to a Rhino and adds it to the provided . /// /// /// A consists of individual trims. There are special cases for singular trims and trims with defined edge indices. /// Note that edge cases in Brep structures are not fully covered by this method and should be reviewed for robustness improvement. - /// This operation alters the state of the provided by adding a new loop. + /// This operation alters the state of the provided by adding a new loop. /// - /// The where the new loop will be added. + /// The where the new loop will be added. /// The to be converted and added to . /// The tolerance factor used when adding trims and setting their tolerances. - private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, double tol) + private void ConvertSpeckleBrepLoop(IRhinoBrep rhinoBrep, SOG.BrepLoop speckleLoop, double tol) { var f = rhinoBrep.Faces[speckleLoop.FaceIndex]; - rhinoBrep.Loops.Add((RG.BrepLoopType)speckleLoop.Type, f); + rhinoBrep.Loops.Add((RhinoBrepLoopType)speckleLoop.Type, f); // POC: This works but it doesn't fully cover all Brep edge cases and could be the cause of some of our failed Rhino->Rhino breps. // We should check Rhino.Inside as they have similar code structure. @@ -92,7 +93,7 @@ private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, .ToList() .ForEach(trim => { - RG.BrepTrim rhTrim; + IRhinoBrepTrim rhTrim; if (trim.EdgeIndex != -1) { rhTrim = rhinoBrep.Trims.Add( @@ -107,7 +108,7 @@ private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, rhTrim = rhinoBrep.Trims.AddSingularTrim( rhinoBrep.Vertices[trim.EndIndex], rhinoBrep.Loops[trim.LoopIndex], - (RG.IsoStatus)trim.IsoStatus, + (RhinoIsoStatus)trim.IsoStatus, trim.CurveIndex ); } @@ -116,8 +117,8 @@ private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, rhTrim = rhinoBrep.Trims.Add(trim.IsReversed, rhinoBrep.Loops[trim.LoopIndex], trim.CurveIndex); } - rhTrim.IsoStatus = (RG.IsoStatus)trim.IsoStatus; - rhTrim.TrimType = (RG.BrepTrimType)trim.TrimType; + rhTrim.IsoStatus = (RhinoIsoStatus)trim.IsoStatus; + rhTrim.TrimType = (RhinoBrepTrimType)trim.TrimType; rhTrim.SetTolerances(tol, tol); }); } @@ -133,7 +134,7 @@ private void ConvertSpeckleBrepLoop(RG.Brep rhinoBrep, SOG.BrepLoop speckleLoop, /// is untrimmed, and hence added directly as a reference to the curve it points to. /// If the edge is trimmed, it is added based on vertices and subdomain using the supplied tolerance /// - private void ConvertSpeckleBrepEdge(RG.Brep rhinoBrep, SOG.BrepEdge speckleEdge, double tolerance) + private void ConvertSpeckleBrepEdge(IRhinoBrep rhinoBrep, SOG.BrepEdge speckleEdge, double tolerance) { if ( speckleEdge.Domain == null @@ -158,11 +159,11 @@ private void ConvertSpeckleBrepEdge(RG.Brep rhinoBrep, SOG.BrepEdge speckleEdge, } /// - /// Converts a into a and adds it to the provided . + /// Converts a into a and adds it to the provided . /// /// The Rhinoceros brep geometry to which the converted face is added. /// The Speckle brep face to be converted and added. - private void ConvertSpeckleBrepFace(RG.Brep rhinoBrep, SOG.BrepFace speckleFace) + private void ConvertSpeckleBrepFace(IRhinoBrep rhinoBrep, SOG.BrepFace speckleFace) { var f = rhinoBrep.Faces.Add(speckleFace.SurfaceIndex); f.OrientationIsReversed = speckleFace.OrientationReversed; 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 a61425dc2a..d96d413258 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 @@ -1,28 +1,29 @@ using Objects; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class CurveToHostConverter : ITypedConverter +public class CurveToHostConverter : ITypedConverter { - 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; + 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( - ITypedConverter lineConverter, - ITypedConverter arcConverter, - ITypedConverter ellipseConverter, - ITypedConverter spiralConverter, - ITypedConverter circleConverter, - ITypedConverter polylineConverter, - ITypedConverter polyCurveConverter, - ITypedConverter nurbsCurveConverter + ITypedConverter lineConverter, + ITypedConverter arcConverter, + ITypedConverter ellipseConverter, + ITypedConverter spiralConverter, + ITypedConverter circleConverter, + ITypedConverter polylineConverter, + ITypedConverter polyCurveConverter, + ITypedConverter nurbsCurveConverter ) { _lineConverter = lineConverter; @@ -36,13 +37,13 @@ public CurveToHostConverter( } /// - /// Converts a given ICurve object to an RG.Curve object. + /// Converts a given ICurve object to an IRhinoCurve object. /// /// The ICurve object to convert. - /// The converted RG.Curve object. + /// The converted IRhinoCurve object. /// Thrown when the conversion is not supported for the given type of curve. /// ⚠️ This conversion does NOT perform scaling. - public RG.Curve Convert(ICurve target) => + public IRhinoCurve Convert(ICurve target) => target switch { SOG.Line line => _lineConverter.Convert(line), 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 d3917dafd3..2cd3a59e5c 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 @@ -1,17 +1,23 @@ using System.Drawing; using Objects.Utils; -using Rhino.Collections; using Speckle.Converters.Common.Objects; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.Raw; -public class MeshToHostConverter : ITypedConverter +public class MeshToHostConverter : ITypedConverter { - private readonly ITypedConverter, Point3dList> _pointListConverter; + private readonly ITypedConverter, IRhinoPoint3dList> _pointListConverter; + private readonly IRhinoMeshFactory _rhinoMeshFactory; + private readonly IRhinoNgonFactory _rhinoNgonFactory; + private readonly IRhinoPointFactory _rhinoPointFactory; - public MeshToHostConverter(ITypedConverter, Point3dList> pointListConverter) + public MeshToHostConverter(ITypedConverter, IRhinoPoint3dList> pointListConverter, IRhinoMeshFactory rhinoMeshFactory, IRhinoNgonFactory rhinoNgonFactory, IRhinoPointFactory rhinoPointFactory) { _pointListConverter = pointListConverter; + _rhinoMeshFactory = rhinoMeshFactory; + _rhinoNgonFactory = rhinoNgonFactory; + _rhinoPointFactory = rhinoPointFactory; } /// @@ -20,11 +26,11 @@ public MeshToHostConverter(ITypedConverter, Point3dList> p /// The Speckle mesh object to convert. /// A Rhino mesh object converted from the Speckle mesh. /// ⚠️ This conversion does NOT perform scaling. - public RG.Mesh Convert(SOG.Mesh target) + public IRhinoMesh Convert(SOG.Mesh target) { target.AlignVerticesWithTexCoordsByIndex(); - RG.Mesh m = new(); + IRhinoMesh m = _rhinoMeshFactory.Create(); var vertices = _pointListConverter.Convert(target.vertices); var colors = target.colors.Select(Color.FromArgb).ToArray(); @@ -43,7 +49,7 @@ public RG.Mesh Convert(SOG.Mesh target) // POC: CNX-9274 We should abstract this into the `Mesh` class, or some utility class adjacent to it // All converters need to do this so it's going to be a source of repetition // and it is directly tied to how we serialise the data in the mesh. - private void AssignMeshFaces(SOG.Mesh target, RG.Mesh m) + private void AssignMeshFaces(SOG.Mesh target, IRhinoMesh m) { int i = 0; while (i < target.faces.Count) @@ -59,13 +65,12 @@ private void AssignMeshFaces(SOG.Mesh target, RG.Mesh m) if (n == 3) { // triangle - m.Faces.AddFace(new RG.MeshFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3])); + m.Faces.AddFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3]); } else if (n == 4) { // quad - m.Faces.AddFace( - new RG.MeshFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3], target.faces[i + 4]) + m.Faces.AddFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3], target.faces[i + 4] ); } else @@ -76,11 +81,10 @@ private void AssignMeshFaces(SOG.Mesh target, RG.Mesh m) var faceIndices = new List(triangles.Count); for (int t = 0; t < triangles.Count; t += 3) { - var face = new RG.MeshFace(triangles[t], triangles[t + 1], triangles[t + 2]); - faceIndices.Add(m.Faces.AddFace(face)); + faceIndices.Add(m.Faces.AddFace(triangles[t], triangles[t + 1], triangles[t + 2])); } - RG.MeshNgon ngon = RG.MeshNgon.Create(target.faces.GetRange(i + 1, n), faceIndices); + IRhinoMeshNgon ngon = _rhinoNgonFactory.Create(target.faces.GetRange(i + 1, n), faceIndices); m.Ngons.AddNgon(ngon); } @@ -89,13 +93,13 @@ private void AssignMeshFaces(SOG.Mesh target, RG.Mesh m) m.Faces.CullDegenerateFaces(); } - private void AssignTextureCoordinates(SOG.Mesh target, RG.Mesh m) + private void AssignTextureCoordinates(SOG.Mesh target, IRhinoMesh m) { - var textureCoordinates = new RG.Point2f[target.TextureCoordinatesCount]; + var textureCoordinates = new IRhinoPoint2f[target.TextureCoordinatesCount]; for (int ti = 0; ti < target.TextureCoordinatesCount; ti++) { var (u, v) = target.GetTextureCoordinate(ti); - textureCoordinates[ti] = new RG.Point2f(u, v); + textureCoordinates[ti] = _rhinoPointFactory.Create(u, v); } m.TextureCoordinates.SetTextureCoordinates(textureCoordinates); } 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 811433890c..31b9504f1e 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 @@ -1,42 +1,43 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Core.Models; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] public class FallbackToHostTopLevelConverter : IToHostTopLevelConverter, - ITypedConverter> + ITypedConverter> { - private readonly ITypedConverter _lineConverter; - private readonly ITypedConverter _polylineConverter; - private readonly ITypedConverter _meshConverter; - private readonly IConversionContextStack _contextStack; + private readonly ITypedConverter _lineConverter; + private readonly ITypedConverter _polylineConverter; + private readonly ITypedConverter _meshConverter; + private readonly IConversionContextStack _contextStack; + private readonly IRhinoTransformFactory _rhinoTransformFactory; public FallbackToHostTopLevelConverter( - ITypedConverter lineConverter, - ITypedConverter polylineConverter, - ITypedConverter meshConverter, - IConversionContextStack contextStack - ) + ITypedConverter lineConverter, + ITypedConverter polylineConverter, + ITypedConverter meshConverter, + IConversionContextStack contextStack, IRhinoTransformFactory rhinoTransformFactory) { _lineConverter = lineConverter; _polylineConverter = polylineConverter; _meshConverter = meshConverter; _contextStack = contextStack; + _rhinoTransformFactory = rhinoTransformFactory; } public object Convert(Base target) => Convert((DisplayableObject)target); - public List Convert(DisplayableObject target) + public List Convert(DisplayableObject target) { - var result = new List(); + var result = new List(); foreach (var item in target.displayValue) { - RG.GeometryBase x = item switch + IRhinoGeometryBase x = item switch { SOG.Line line => _lineConverter.Convert(line), SOG.Polyline polyline => _polylineConverter.Convert(polyline), @@ -50,7 +51,7 @@ IConversionContextStack contextStack return result; } - private RG.Transform GetUnitsTransform(Base speckleObject) + private IRhinoTransform GetUnitsTransform(Base speckleObject) { /* * POC: CNX-9270 Looking at a simpler, more performant way of doing unit scaling on `ToNative` @@ -60,10 +61,10 @@ private RG.Transform GetUnitsTransform(Base speckleObject) if (speckleObject["units"] is string units) { var scaleFactor = Units.GetConversionFactor(units, _contextStack.Current.SpeckleUnits); - var scale = RG.Transform.Scale(RG.Point3d.Origin, scaleFactor); + var scale = _rhinoTransformFactory.Scale(_rhinoTransformFactory.Origin, scaleFactor); return scale; } - return RG.Transform.Identity; + return _rhinoTransformFactory.Identity; } } 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 b7b648dde9..f262520e97 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 @@ -1,5 +1,4 @@ using Objects; -using Rhino; using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Models; @@ -12,13 +11,13 @@ public class ArcCurveToSpeckleConverter : ITypedConverter _circleConverter; private readonly ITypedConverter _arcConverter; private readonly ITypedConverter _intervalConverter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; public ArcCurveToSpeckleConverter( ITypedConverter circleConverter, ITypedConverter arcConverter, ITypedConverter intervalConverter, - IConversionContextStack contextStack + IConversionContextStack contextStack ) { _circleConverter = circleConverter; 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 cb86abedfe..980a07f56f 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 @@ -1,5 +1,4 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Rhino7.Interfaces; @@ -9,13 +8,13 @@ public class EllipseToSpeckleConverter : ITypedConverter _planeConverter; private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly IRhinoBoxFactory _rhinoBoxFactory; public EllipseToSpeckleConverter( ITypedConverter planeConverter, ITypedConverter boxConverter, - IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) + IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) { _planeConverter = planeConverter; _boxConverter = boxConverter; 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 f96282b7ca..34ff6bd818 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 @@ -1,5 +1,4 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Rhino7.Interfaces; @@ -9,12 +8,12 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; public class MeshToSpeckleConverter : ITypedConverter { private readonly ITypedConverter _boxConverter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly IRhinoBoxFactory _rhinoBoxFactory; public MeshToSpeckleConverter( ITypedConverter boxConverter, - IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) + IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) { _boxConverter = boxConverter; _contextStack = contextStack; 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 5a30498d07..604aab86c2 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 @@ -1,5 +1,4 @@ -using Rhino; -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Rhino7.Interfaces; @@ -7,12 +6,12 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; public class RawPointCloudToSpeckle : ITypedConverter { - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly ITypedConverter _boxConverter; private readonly IRhinoBoxFactory _rhinoBoxFactory; public RawPointCloudToSpeckle( - IConversionContextStack contextStack, + IConversionContextStack contextStack, ITypedConverter boxConverter, IRhinoBoxFactory rhinoBoxFactory) { _contextStack = contextStack; From 70d11568d4ec86b93342f70fcbfae14149ad412f Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 19 Jun 2024 13:34:19 +0100 Subject: [PATCH 14/28] doing Rhino loading and testing --- .../RevitConnectorModule.cs | 15 +++++++++ .../Bindings/RhinoSelectionBinding.cs | 4 +-- .../Bindings/RhinoSendBinding.cs | 7 ++-- .../DependencyInjection/ProxyMapper.cs | 17 ++++++++++ .../RhinoConnectorModule.cs | 7 ++-- .../DependencyInjection/RhinoPlugin.cs | 12 +++---- .../HostApp/RhinoContext.cs | 8 ----- .../HostApp/RhinoIdleManager.cs | 4 ++- .../Interfaces/IRhinoPlugin.cs | 7 ---- .../Plugin/Speckle.Connectors.Rhino7Plugin.cs | 2 +- .../RhinoConverterModule.cs | 6 ++-- .../Speckle.Converters.Common/IProxyMapper.cs | 33 +++++++++++++++++++ .../RootToSpeckleConverter.cs | 3 +- 13 files changed, 86 insertions(+), 39 deletions(-) create mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs delete mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs delete mode 100644 DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs create mode 100644 DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index 879bf05041..a6ef48914c 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -16,8 +16,10 @@ using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; +using Speckle.ProxyGenerator; using Speckle.Revit.Api; using Speckle.Revit.Interfaces; +using IProxyMapper = Speckle.Converters.Common.IProxyMapper; namespace Speckle.Connectors.Revit.DependencyInjection; @@ -74,3 +76,16 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); } } + +public class ProxyMapper : IProxyMapper +{ + public Type? GetMappedTypeFromHostType(Type type) => ProxyMap.GetMappedTypeFromHostType(type); + + public Type? GetMappedTypeFromProxyType(Type type) => ProxyMap.GetMappedTypeFromProxyType(type); + + public Type? GetHostTypeFromMappedType(Type type) => ProxyMap.GetHostTypeFromMappedType(type); + + public object CreateProxy(Type type, object toWrap) => ProxyMap.CreateProxy(type, toWrap); + + public T CreateProxy(object toWrap) => ProxyMap.CreateProxy(toWrap); +} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs index 077a4df2fd..fb8b598c7e 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -13,7 +13,7 @@ public class RhinoSelectionBinding : ISelectionBinding public string Name { get; } = "selectionBinding"; public IBridge Parent { get; set; } - public RhinoSelectionBinding(RhinoIdleManager idleManager, IBridge parent) + public RhinoSelectionBinding(IRhinoIdleManager idleManager, IBridge parent) { Parent = parent; @@ -34,7 +34,7 @@ public RhinoSelectionBinding(RhinoIdleManager idleManager, IBridge parent) private void OnSelectionChanged() { SelectionInfo selInfo = GetSelection(); - Parent?.Send(SELECTION_EVENT, selInfo); + Parent.Send(SELECTION_EVENT, selInfo); } public SelectionInfo GetSelection() diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs index b2c2ab1a20..2d7f995d0a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSendBinding.cs @@ -23,10 +23,9 @@ public sealed class RhinoSendBinding : ISendBinding public IBridge Parent { get; } private readonly DocumentModelStore _store; - private readonly RhinoIdleManager _idleManager; + private readonly IRhinoIdleManager _idleManager; private readonly IUnitOfWorkFactory _unitOfWorkFactory; private readonly List _sendFilters; - private readonly SendOperation _sendOperation; private readonly CancellationManager _cancellationManager; private readonly RhinoSettings _rhinoSettings; @@ -39,10 +38,9 @@ public sealed class RhinoSendBinding : ISendBinding public RhinoSendBinding( DocumentModelStore store, - RhinoIdleManager idleManager, + IRhinoIdleManager idleManager, IBridge parent, IEnumerable sendFilters, - SendOperation sendOperation, IUnitOfWorkFactory unitOfWorkFactory, RhinoSettings rhinoSettings, CancellationManager cancellationManager, @@ -52,7 +50,6 @@ ISendConversionCache sendConversionCache _store = store; _idleManager = idleManager; _unitOfWorkFactory = unitOfWorkFactory; - _sendOperation = sendOperation; _sendFilters = sendFilters.ToList(); _rhinoSettings = rhinoSettings; _cancellationManager = cancellationManager; diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs new file mode 100644 index 0000000000..dabeb71d95 --- /dev/null +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/ProxyMapper.cs @@ -0,0 +1,17 @@ +using Speckle.Converters.Common; +using Speckle.ProxyGenerator; + +namespace Speckle.Connectors.Rhino7.DependencyInjection; + +public class ProxyMapper : IProxyMapper +{ + public Type? GetMappedTypeFromHostType(Type type) => ProxyMap.GetMappedTypeFromHostType(type); + + public Type? GetMappedTypeFromProxyType(Type type) => ProxyMap.GetMappedTypeFromProxyType(type); + + public Type? GetHostTypeFromMappedType(Type type) => ProxyMap.GetHostTypeFromMappedType(type); + + public object CreateProxy(Type type, object toWrap) => ProxyMap.CreateProxy(type, toWrap); + + public T CreateProxy(object toWrap) => ProxyMap.CreateProxy(toWrap); +} 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 a227755c66..16cdc3a7de 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoConnectorModule.cs @@ -10,7 +10,6 @@ using Speckle.Connectors.Rhino7.Bindings; using Speckle.Connectors.Rhino7.Filters; using Speckle.Connectors.Rhino7.HostApp; -using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Connectors.Rhino7.Operations.Send; using Speckle.Connectors.Rhino7.Plugin; using Speckle.Connectors.Utils.Cancellation; @@ -21,7 +20,9 @@ using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; +using Speckle.Converters.Common; using Speckle.Core.Models.GraphTraversal; +using Speckle.Rhino7.Api; namespace Speckle.Connectors.Rhino7.DependencyInjection; @@ -37,6 +38,7 @@ public void Load(SpeckleContainerBuilder builder) builder.AddConnectorUtils(); builder.AddDUI(); builder.AddDUIView(); + builder.ScanAssemblyOfType(); // POC: Overwriting the SyncToMainThread to SyncToCurrentThread for Rhino! builder.AddSingletonInstance(); @@ -44,7 +46,8 @@ public void Load(SpeckleContainerBuilder builder) // Register other connector specific types builder.AddSingleton(); builder.AddSingleton(); - builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); // Register bindings builder.AddSingleton(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs index a295f9f8b6..2262f93f9f 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/DependencyInjection/RhinoPlugin.cs @@ -1,21 +1,17 @@ using Rhino; -using Speckle.Connectors.DUI.WebView; using Speckle.Connectors.Rhino7.HostApp; -using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Connectors.Rhino7.Plugin; +using Speckle.InterfaceGenerator; namespace Speckle.Connectors.Rhino7.DependencyInjection; +[GenerateAutoInterface] public class RhinoPlugin : IRhinoPlugin { - private readonly RhinoIdleManager _idleManager; - private readonly DUI3ControlWebView _panel; - private readonly RhinoSettings _settings; + private readonly IRhinoIdleManager _idleManager; - public RhinoPlugin(DUI3ControlWebView panel, RhinoSettings settings, RhinoIdleManager idleManager) + public RhinoPlugin(IRhinoIdleManager idleManager) { - _panel = panel; - _settings = settings; _idleManager = idleManager; } diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs deleted file mode 100644 index 17b532035a..0000000000 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoContext.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Rhino; - -namespace Speckle.Connectors.Rhino7.HostApp; - -public class RhinoContext -{ - public RhinoDoc Document { get; } = RhinoDoc.ActiveDoc; -} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs index 374d979750..5a88ed6c20 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/HostApp/RhinoIdleManager.cs @@ -1,12 +1,14 @@ using System.Collections.Concurrent; using Rhino; +using Speckle.InterfaceGenerator; namespace Speckle.Connectors.Rhino7.HostApp; /// /// Rhino Idle Manager is a helper util to manage deferred actions. /// -public class RhinoIdleManager +[GenerateAutoInterface] +public class RhinoIdleManager : IRhinoIdleManager { // NOTE: ConcurrentDictionary possibly removing the collection has been modified errors in here private readonly ConcurrentDictionary _sCalls = new(); diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs deleted file mode 100644 index 487c2968f5..0000000000 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Interfaces/IRhinoPlugin.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Speckle.Connectors.Rhino7.Interfaces; - -public interface IRhinoPlugin -{ - void Initialise(); - void Shutdown(); -} diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs index 8dff82b2d5..16e7297e5a 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Plugin/Speckle.Connectors.Rhino7Plugin.cs @@ -2,8 +2,8 @@ using Rhino.PlugIns; using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Rhino7.DependencyInjection; using Speckle.Connectors.Rhino7.HostApp; -using Speckle.Connectors.Rhino7.Interfaces; using Speckle.Core.Kits; using Speckle.Core.Logging; using Speckle.Core.Models.Extensions; 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 088b93cc10..60fac944e0 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs @@ -1,7 +1,7 @@ using Speckle.Autofac.DependencyInjection; using Speckle.Converters.Common; -using Rhino; using Speckle.Converters.Common.DependencyInjection; +using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.DependencyInjection; @@ -9,8 +9,8 @@ public class RhinoConverterModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddConverterCommon(); + builder.AddConverterCommon(); // single stack per conversion - builder.AddScoped, RhinoConversionContextStack>(); + builder.AddScoped, RhinoConversionContextStack>(); } } diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs new file mode 100644 index 0000000000..8b467d9395 --- /dev/null +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/IProxyMapper.cs @@ -0,0 +1,33 @@ +namespace Speckle.Converters.Common; + +public interface IProxyMapper +{ + Type? GetMappedTypeFromHostType(Type type); + Type? GetMappedTypeFromProxyType(Type type); + Type? GetHostTypeFromMappedType(Type type); + + object CreateProxy(Type type, object toWrap); + + T CreateProxy(object toWrap); +} + +public record WrappedType(Type Type, object Target); + +// ghetto default interface implementation :( +public static class ProxyMapExtensions +{ + public static WrappedType? WrapIfExists(this IProxyMapper proxyMap, Type target, object toWrap) + { + var mappedType = proxyMap.GetMappedTypeFromHostType(target); + if (mappedType is not null) + { + return new(mappedType, proxyMap.CreateProxy(mappedType, toWrap)); + } + mappedType = proxyMap.GetMappedTypeFromProxyType(target); + if (mappedType is not null) + { + return new(mappedType, toWrap); + } + return null; + } +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs index 04d87e8349..159276b610 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootToSpeckleConverter.cs @@ -2,7 +2,6 @@ using Speckle.Converters.Common.Objects; using Speckle.Core.Models; using Speckle.InterfaceGenerator; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.Common; @@ -26,7 +25,7 @@ public Base Convert(object target) { throw new NotSupportedException($"No wrapper found for Revit type: {revitType.Name}"); } - var (wrappedType, wrappedObject) = wrapper.Value; + var (wrappedType, wrappedObject) = wrapper; try { var objectConverter = _toSpeckle.ResolveInstance(wrappedType.Name); //poc: would be nice to have supertypes resolve From dbb02a8e43f463dfba2023c9c1d461da7f724595 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 19 Jun 2024 15:01:50 +0100 Subject: [PATCH 15/28] type moving around --- .../DependencyInjection/ProxyMapper.cs | 17 +++++++++++++++++ .../DependencyInjection/RevitConnectorModule.cs | 15 --------------- .../RevitConverterModule.cs | 1 - .../RhinoConverterModule.cs | 1 + .../RhinoRootElementProvider.cs | 9 +++++++++ .../ContainerRegistration.cs | 1 + 6 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs create mode 100644 DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs new file mode 100644 index 0000000000..e4e997c4e2 --- /dev/null +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMapper.cs @@ -0,0 +1,17 @@ +using Speckle.Converters.Common; +using Speckle.ProxyGenerator; + +namespace Speckle.Connectors.Revit.DependencyInjection; + +public class ProxyMapper : IProxyMapper +{ + public Type? GetMappedTypeFromHostType(Type type) => ProxyMap.GetMappedTypeFromHostType(type); + + public Type? GetMappedTypeFromProxyType(Type type) => ProxyMap.GetMappedTypeFromProxyType(type); + + public Type? GetHostTypeFromMappedType(Type type) => ProxyMap.GetHostTypeFromMappedType(type); + + public object CreateProxy(Type type, object toWrap) => ProxyMap.CreateProxy(type, toWrap); + + public T CreateProxy(object toWrap) => ProxyMap.CreateProxy(toWrap); +} diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs index a6ef48914c..879bf05041 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/RevitConnectorModule.cs @@ -16,10 +16,8 @@ using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; using Speckle.Converters.Common; -using Speckle.ProxyGenerator; using Speckle.Revit.Api; using Speckle.Revit.Interfaces; -using IProxyMapper = Speckle.Converters.Common.IProxyMapper; namespace Speckle.Connectors.Revit.DependencyInjection; @@ -76,16 +74,3 @@ public void Load(SpeckleContainerBuilder builder) builder.AddSingleton(); } } - -public class ProxyMapper : IProxyMapper -{ - public Type? GetMappedTypeFromHostType(Type type) => ProxyMap.GetMappedTypeFromHostType(type); - - public Type? GetMappedTypeFromProxyType(Type type) => ProxyMap.GetMappedTypeFromProxyType(type); - - public Type? GetHostTypeFromMappedType(Type type) => ProxyMap.GetHostTypeFromMappedType(type); - - public object CreateProxy(Type type, object toWrap) => ProxyMap.CreateProxy(type, toWrap); - - public T CreateProxy(object toWrap) => ProxyMap.CreateProxy(toWrap); -} 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 1c7eae1e2f..7900f25180 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -14,7 +14,6 @@ public class RevitConverterModule : ISpeckleModule public void Load(SpeckleContainerBuilder builder) { builder.AddConverterCommon(); - builder.ScanAssemblyOfType(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.AddScoped(); 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 60fac944e0..6c315439fe 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoConverterModule.cs @@ -12,5 +12,6 @@ public void Load(SpeckleContainerBuilder builder) builder.AddConverterCommon(); // single stack per conversion builder.AddScoped, RhinoConversionContextStack>(); + builder.AddScoped(); } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs new file mode 100644 index 0000000000..58a13d8107 --- /dev/null +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/RhinoRootElementProvider.cs @@ -0,0 +1,9 @@ +using Speckle.Converters.Common; +using Speckle.Rhino7.Interfaces; + +namespace Speckle.Converters.Rhino7.DependencyInjection; + +public class RhinoRootElementProvider : IRootElementProvider +{ + public Type GetRootType() => typeof(IRhinoObject); +} diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs index 189bbcc6e7..07f974d26a 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/ContainerRegistration.cs @@ -12,6 +12,7 @@ this SpeckleContainerBuilder builder where TRootToSpeckleConverter : class, IRootToSpeckleConverter where THostToSpeckleUnitConverter : class, IHostToSpeckleUnitConverter { + builder.ScanAssemblyOfType(); builder.AddScoped(); builder.AddScoped, THostToSpeckleUnitConverter>(); /* From 409022de54ba351157f50974abbc9fe99cbe6b78 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 19 Jun 2024 15:30:04 +0100 Subject: [PATCH 16/28] update and use interfaces --- .../Speckle.Connectors.Rhino7.csproj | 3 ++- ...erters.Revit2023.DependencyInjection.csproj | 2 +- .../Speckle.Converters.Revit2023.Tests.csproj | 2 +- .../packages.lock.json | 11 +++++------ .../Speckle.Converters.Revit2023.csproj | 2 +- ...onverters.Rhino7.DependencyInjection.csproj | 2 +- .../Speckle.Converters.Rhino7.csproj | 5 ++--- .../Speckle.Converters.Common.Tests.csproj | 2 +- .../packages.lock.json | 18 ++++-------------- .../Speckle.Converters.Common.csproj | 3 --- 10 files changed, 18 insertions(+), 32 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index cf48f27e61..6040c27270 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -15,6 +15,8 @@ + + @@ -41,5 +43,4 @@ Resources.Designer.cs - diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index ae4703a46f..3908fda428 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj index 296350ca71..e0fb9b36be 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index 256510d436..ae58361dad 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "requested": "[0.1.1-preview.0.25, )", + "resolved": "0.1.1-preview.0.25", + "contentHash": "K22SbzxnujxU/elofcsYceLQ2G2ketJWGSM39I+k6IcvRvcy/az5X1fjhzrYtzC0Y+/2aqm0oqydFP+3FROJjg==" }, "Castle.Core": { "type": "Transitive", @@ -490,8 +490,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { @@ -505,7 +504,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.25, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 01dc874c3f..aeb60638de 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index d944ee5ed1..cba4c93e3c 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -11,6 +11,6 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 249814e554..3ce6dae08d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -3,12 +3,11 @@ net48 - - + + - diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj index e687d74095..b5c7aadb16 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json index 745cd3ba1e..19b5ee0cc4 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "requested": "[0.1.1-preview.0.25, )", + "resolved": "0.1.1-preview.0.25", + "contentHash": "K22SbzxnujxU/elofcsYceLQ2G2ketJWGSM39I+k6IcvRvcy/az5X1fjhzrYtzC0Y+/2aqm0oqydFP+3FROJjg==" }, "Castle.Core": { "type": "Transitive", @@ -200,14 +200,6 @@ "Serilog": "2.4.0" } }, - "Serilog.Enrichers.GlobalLogContext": { - "type": "Transitive", - "resolved": "3.0.0", - "contentHash": "IIZcj5mAUVhIl/NTA+YI2KC+sPDzcwvs0ZMHH42jsPfl1a4LVX7ohVpw5UK+e3GxuV3Nv239Il5oM2peUIl44g==", - "dependencies": { - "Serilog": "2.12.0" - } - }, "Serilog.Exceptions": { "type": "Transitive", "resolved": "8.4.0", @@ -421,8 +413,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { @@ -438,7 +429,6 @@ "Sentry.Serilog": "[3.33.0, )", "Serilog": "[2.12.0, )", "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Enrichers.GlobalLogContext": "[3.0.0, )", "Serilog.Exceptions": "[8.4.0, )", "Serilog.Sinks.Console": "[4.1.0, )", "Serilog.Sinks.Seq": "[5.2.2, )", diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj index 07793ee159..9c80cf3aba 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/Speckle.Converters.Common.csproj @@ -8,8 +8,5 @@ - - - From a88d0f73ef5251fbef0fa5f5f65781f3d67c8cdd Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 19 Jun 2024 15:34:24 +0100 Subject: [PATCH 17/28] using clean up --- .../RootToSpeckleConverterTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs index a94bf874e4..9fccc51efa 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/RootToSpeckleConverterTests.cs @@ -2,7 +2,6 @@ using Moq; using NUnit.Framework; using Speckle.Core.Models; -using Speckle.Revit.Interfaces; namespace Speckle.Converters.Common.Tests; From f9cfe6c3c629f19a40e18249e8b0eb4f8860b6e3 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 19 Jun 2024 15:58:32 +0100 Subject: [PATCH 18/28] clean up --- .../RhinoConversionContextStack.cs | 5 ++++- .../SpeckleToHostGeometryBaseTopLevelConverter.cs | 4 +++- .../ToHost/Raw/ArcToHostConverter.cs | 4 +++- .../ToHost/Raw/BrepToHostConverter.cs | 4 +++- .../ToHost/Raw/CircleToHostConverter.cs | 8 ++++++-- .../ToHost/Raw/EllipseToHostConverter.cs | 10 ++++++++-- .../ToHost/Raw/LineToHostConverter.cs | 8 ++++++-- .../ToHost/Raw/MeshToHostConverter.cs | 10 +++++++--- .../ToHost/Raw/NurbsCurveToHostConverter.cs | 8 ++++++-- .../ToHost/Raw/PlaneToHostConverter.cs | 4 +++- .../ToHost/Raw/PointCloudToHostConverter.cs | 5 ++++- .../ToHost/Raw/PointToHostConverter.cs | 3 ++- .../ToHost/Raw/PolyCurveToHostConverter.cs | 6 +++++- .../ToHost/Raw/PolylineToHostConverter.cs | 4 +++- .../ToHost/Raw/SurfaceToHostConverter.cs | 2 +- .../ToHost/TopLevel/FallbackToHostTopLevelConverter.cs | 4 +++- .../TopLevel/PointCloudToHostTopLevelConverter.cs | 5 ++--- .../ToHost/TopLevel/PointToHostTopLevelConverter.cs | 3 +-- .../TopLevel/PolycurveToHostTopLevelConverter.cs | 6 +++--- .../ToHost/TopLevel/PolylineToHostTopLevelConverter.cs | 5 ++--- .../ToSpeckle/Raw/ArcToSpeckleConverter.cs | 4 +++- .../ToSpeckle/Raw/BoxToSpeckleConverter.cs | 3 +-- .../ToSpeckle/Raw/BrepToSpeckleConverter.cs | 5 ++++- .../ToSpeckle/Raw/ControlPointToSpeckleConverter.cs | 3 --- .../ToSpeckle/Raw/EllipseToSpeckleConverter.cs | 4 +++- .../ToSpeckle/Raw/LineToSpeckleConverter.cs | 4 +++- .../ToSpeckle/Raw/MeshToSpeckleConverter.cs | 4 +++- .../ToSpeckle/Raw/NurbsCurveConverter.cs | 4 +++- .../ToSpeckle/Raw/NurbsSurfaceToSpeckleConverter.cs | 4 +++- .../ToSpeckle/Raw/PointToSpeckleConverter.cs | 7 +++++-- .../ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs | 10 +++++++--- .../ToSpeckle/Raw/PolylineToSpeckleConverter.cs | 4 +++- .../ToSpeckle/Raw/RawPointCloudToSpeckle.cs | 4 +++- .../TopLevel/BrepObjectToSpeckleTopLevelConverter.cs | 2 +- .../TopLevel/CurveObjectToSpeckleTopLevelConverter.cs | 3 ++- .../ExtrusionObjectToSpeckleTopLevelConverter.cs | 2 +- .../TopLevel/MeshObjectToSpeckleTopLevelConverter.cs | 3 ++- .../TopLevel/RhinoObjectToSpeckleTopLevelConverter.cs | 8 ++++---- 38 files changed, 126 insertions(+), 60 deletions(-) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs index e0a98d264c..799f32b350 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/RhinoConversionContextStack.cs @@ -12,6 +12,9 @@ namespace Speckle.Converters.Rhino7; )] public class RhinoConversionContextStack : ConversionContextStack { - public RhinoConversionContextStack(IRhinoDocFactory rhinoDocFactory, IHostToSpeckleUnitConverter unitConverter) + public RhinoConversionContextStack( + IRhinoDocFactory rhinoDocFactory, + IHostToSpeckleUnitConverter unitConverter + ) : base(rhinoDocFactory.ActiveDoc(), rhinoDocFactory.ActiveDoc().ModelUnitSystem, unitConverter) { } } diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs index bf94f5c09a..3d5e09c1a0 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/SpeckleToHostGeometryBaseTopLevelConverter.cs @@ -16,7 +16,9 @@ public abstract class SpeckleToHostGeometryBaseTopLevelConverter : IT protected SpeckleToHostGeometryBaseTopLevelConverter( IConversionContextStack contextStack, - ITypedConverter geometryBaseConverter, IRhinoTransformFactory transformFactory) + ITypedConverter geometryBaseConverter, + IRhinoTransformFactory transformFactory + ) { ContextStack = contextStack; _geometryBaseConverter = geometryBaseConverter; 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 73840337de..63d745dec6 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 @@ -14,7 +14,9 @@ public class ArcToHostConverter : ITypedConverter, ITypedCon public ArcToHostConverter( ITypedConverter pointConverter, - ITypedConverter intervalConverter, IRhinoArcFactory rhinoArcFactory) + ITypedConverter intervalConverter, + IRhinoArcFactory rhinoArcFactory + ) { _pointConverter = pointConverter; this._intervalConverter = intervalConverter; 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 3d5dd2b6e2..c579d736a1 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 @@ -19,7 +19,9 @@ public BrepToHostConverter( ITypedConverter curveConverter, ITypedConverter surfaceConverter, ITypedConverter pointConverter, - ITypedConverter intervalConverter, IRhinoBrepFactory rhinoBrepFactory) + ITypedConverter intervalConverter, + IRhinoBrepFactory rhinoBrepFactory + ) { _contextStack = contextStack; _curveConverter = curveConverter; 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 a55bb72f6b..1fbdfd4a2e 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 @@ -8,7 +8,9 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; /// Implements the interface, /// providing implementation for to and conversion. /// -public class CircleToHostConverter : ITypedConverter, ITypedConverter +public class CircleToHostConverter + : ITypedConverter, + ITypedConverter { private readonly ITypedConverter _planeConverter; private readonly ITypedConverter _intervalConverter; @@ -25,7 +27,9 @@ public class CircleToHostConverter : ITypedConverter, /// public CircleToHostConverter( ITypedConverter intervalConverter, - ITypedConverter planeConverter, IRhinoCircleFactory rhinoCircleFactory) + ITypedConverter planeConverter, + IRhinoCircleFactory rhinoCircleFactory + ) { _intervalConverter = intervalConverter; _planeConverter = planeConverter; 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 a74da6774f..c45fa5c3ab 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 @@ -13,7 +13,9 @@ public class EllipseToHostConverter public EllipseToHostConverter( ITypedConverter planeConverter, - ITypedConverter intervalConverter, IRhinoEllipseFactory rhinoEllipseFactory) + ITypedConverter intervalConverter, + IRhinoEllipseFactory rhinoEllipseFactory + ) { _planeConverter = planeConverter; _intervalConverter = intervalConverter; @@ -35,7 +37,11 @@ public IRhinoEllipse Convert(SOG.Ellipse target) throw new InvalidOperationException($"Ellipses cannot have null radii"); } - return _rhinoEllipseFactory.Create(_planeConverter.Convert(target.plane), target.firstRadius.Value, target.secondRadius.Value); + return _rhinoEllipseFactory.Create( + _planeConverter.Convert(target.plane), + target.firstRadius.Value, + target.secondRadius.Value + ); } /// 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 cfb2fcc66c..a66222299f 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 @@ -8,7 +8,10 @@ public class LineToHostConverter : ITypedConverter, I private readonly ITypedConverter _pointConverter; private readonly IRhinoLineFactory _rhinoLineFactory; - public LineToHostConverter(ITypedConverter pointConverter, IRhinoLineFactory rhinoLineFactory) + public LineToHostConverter( + ITypedConverter pointConverter, + IRhinoLineFactory rhinoLineFactory + ) { _pointConverter = pointConverter; _rhinoLineFactory = rhinoLineFactory; @@ -33,5 +36,6 @@ public IRhinoLine Convert(SOG.Line target) => /// /// The Speckle Line object to convert. /// Returns the resulting Rhino LineCurve object. - IRhinoLineCurve ITypedConverter.Convert(SOG.Line target) => _rhinoLineFactory.Create(Convert(target)); + IRhinoLineCurve ITypedConverter.Convert(SOG.Line target) => + _rhinoLineFactory.Create(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 2cd3a59e5c..e24adb8ad1 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 @@ -12,7 +12,12 @@ public class MeshToHostConverter : ITypedConverter private readonly IRhinoNgonFactory _rhinoNgonFactory; private readonly IRhinoPointFactory _rhinoPointFactory; - public MeshToHostConverter(ITypedConverter, IRhinoPoint3dList> pointListConverter, IRhinoMeshFactory rhinoMeshFactory, IRhinoNgonFactory rhinoNgonFactory, IRhinoPointFactory rhinoPointFactory) + public MeshToHostConverter( + ITypedConverter, IRhinoPoint3dList> pointListConverter, + IRhinoMeshFactory rhinoMeshFactory, + IRhinoNgonFactory rhinoNgonFactory, + IRhinoPointFactory rhinoPointFactory + ) { _pointListConverter = pointListConverter; _rhinoMeshFactory = rhinoMeshFactory; @@ -70,8 +75,7 @@ private void AssignMeshFaces(SOG.Mesh target, IRhinoMesh m) else if (n == 4) { // quad - m.Faces.AddFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3], target.faces[i + 4] - ); + m.Faces.AddFace(target.faces[i + 1], target.faces[i + 2], target.faces[i + 3], target.faces[i + 4]); } else { 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 291fd4c5dc..9e2ee516f4 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 @@ -10,7 +10,11 @@ public class NurbsCurveToHostConverter : ITypedConverter _intervalConverter; - public NurbsCurveToHostConverter(ITypedConverter intervalConverter, IRhinoCurveFactory rhinoCurveFactory, IRhinoPointFactory rhinoPointFactory) + public NurbsCurveToHostConverter( + ITypedConverter intervalConverter, + IRhinoCurveFactory rhinoCurveFactory, + IRhinoPointFactory rhinoPointFactory + ) { _intervalConverter = intervalConverter; _rhinoCurveFactory = rhinoCurveFactory; @@ -46,7 +50,7 @@ public IRhinoNurbsCurve Convert(SOG.Curve target) } else { - nurbsCurve.Knots.SetKnot(j, target.knots[j]); + nurbsCurve.Knots.SetKnot(j, target.knots[j]); } } 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 6856178a40..4b18fac738 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 @@ -11,7 +11,9 @@ public class PlaneToHostConverter : ITypedConverter public PlaneToHostConverter( ITypedConverter pointConverter, - ITypedConverter vectorConverter, IRhinoPlaneFactory rhinoPlaneFactory) + ITypedConverter vectorConverter, + IRhinoPlaneFactory rhinoPlaneFactory + ) { _pointConverter = pointConverter; _vectorConverter = vectorConverter; 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 7f59009710..f4a67b8d8d 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 @@ -9,7 +9,10 @@ public class PointCloudToHostConverter : ITypedConverter, IRhinoPoint3dList> _pointListConverter; private readonly IRhinoPointCloudFactory _rhinoPointCloudFactory; - public PointCloudToHostConverter(ITypedConverter, IRhinoPoint3dList> pointListConverter, IRhinoPointCloudFactory rhinoPointCloudFactory) + public PointCloudToHostConverter( + ITypedConverter, IRhinoPoint3dList> pointListConverter, + IRhinoPointCloudFactory rhinoPointCloudFactory + ) { _pointListConverter = pointListConverter; _rhinoPointCloudFactory = rhinoPointCloudFactory; 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 edc4a3d7cb..35938f8ad4 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 @@ -26,5 +26,6 @@ public PointToHostConverter(IRhinoPointFactory rhinoPointFactory) /// The Speckle Point object to convert. /// The converted Rhino Point object. /// ⚠️ This conversion does NOT perform scaling. - IRhinoPoint ITypedConverter.Convert(SOG.Point target) => _rhinoPointFactory.Create(Convert(target)); + IRhinoPoint ITypedConverter.Convert(SOG.Point target) => + _rhinoPointFactory.Create(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 effbce9847..14b51151c9 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 @@ -11,7 +11,11 @@ public class PolyCurveToHostConverter : ITypedConverter _intervalConverter; private readonly IRhinoCurveFactory _rhinoCurveFactory; - public PolyCurveToHostConverter(ITypedConverter intervalConverter, ITypedConverter curveConverter, IRhinoCurveFactory rhinoCurveFactory) + public PolyCurveToHostConverter( + ITypedConverter intervalConverter, + ITypedConverter curveConverter, + IRhinoCurveFactory rhinoCurveFactory + ) { _intervalConverter = intervalConverter; _curveConverter = curveConverter; 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 4d1adff489..b803a07943 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 @@ -13,7 +13,9 @@ public class PolylineToHostConverter public PolylineToHostConverter( ITypedConverter, IRhinoPoint3dList> pointListConverter, - ITypedConverter intervalConverter, IRhinoLineFactory rhinoLineFactory) + ITypedConverter intervalConverter, + IRhinoLineFactory rhinoLineFactory + ) { _pointListConverter = pointListConverter; _intervalConverter = intervalConverter; 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 d945c3da8f..46689761a8 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 @@ -36,7 +36,7 @@ public IRhinoNurbsSurface Convert(SOG.Surface target) var correctUKnots = GetCorrectKnots(target.knotsU, target.countU, target.degreeU); for (int i = 0; i < correctUKnots.Count; i++) { - result.KnotsU.SetKnot(i, correctUKnots[i]); + result.KnotsU.SetKnot(i, correctUKnots[i]); } var correctVKnots = GetCorrectKnots(target.knotsV, target.countV, target.degreeV); 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 31b9504f1e..34c5a989ae 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 @@ -21,7 +21,9 @@ public FallbackToHostTopLevelConverter( ITypedConverter lineConverter, ITypedConverter polylineConverter, ITypedConverter meshConverter, - IConversionContextStack contextStack, IRhinoTransformFactory rhinoTransformFactory) + IConversionContextStack contextStack, + IRhinoTransformFactory rhinoTransformFactory + ) { _lineConverter = lineConverter; _polylineConverter = polylineConverter; 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 04915824de..c4e199b3d4 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 @@ -1,5 +1,4 @@ - -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Rhino7.Interfaces; @@ -12,7 +11,7 @@ public class PointCloudToHostTopLevelConverter public PointCloudToHostTopLevelConverter( IConversionContextStack contextStack, ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IRhinoTransformFactory rhinoTransformFactory ) : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 99dc2600db..6922cf12ad 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 @@ -1,5 +1,4 @@ - -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Rhino7.Interfaces; 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 d9e5814210..96511e2856 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 @@ -1,12 +1,12 @@ - -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToHost.TopLevel; [NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)] -public class PolycurveToHostTopLevelConverter : SpeckleToHostGeometryBaseTopLevelConverter +public class PolycurveToHostTopLevelConverter + : SpeckleToHostGeometryBaseTopLevelConverter { public PolycurveToHostTopLevelConverter( IConversionContextStack contextStack, 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 e6a9d149ad..c098b09930 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 @@ -1,5 +1,4 @@ - -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Rhino7.Interfaces; @@ -12,7 +11,7 @@ public class PolylineToHostTopLevelConverter public PolylineToHostTopLevelConverter( IConversionContextStack contextStack, ITypedConverter geometryBaseConverter, - IRhinoTransformFactory rhinoTransformFactory + IRhinoTransformFactory rhinoTransformFactory ) : base(contextStack, geometryBaseConverter, rhinoTransformFactory) { } } 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 8dbd786d75..0458715c91 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 @@ -16,7 +16,9 @@ public ArcToSpeckleConverter( ITypedConverter pointConverter, ITypedConverter planeConverter, ITypedConverter boxConverter, - IConversionContextStack contextStack, IRhinoBoxFactory boxFactory) + IConversionContextStack contextStack, + IRhinoBoxFactory boxFactory + ) { _pointConverter = pointConverter; _planeConverter = planeConverter; 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 88dff35126..cae6a5d610 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 @@ -1,5 +1,4 @@ - -using Speckle.Converters.Common; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Rhino7.Interfaces; 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 24b6014674..4366f8a089 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 @@ -26,7 +26,10 @@ public BrepToSpeckleConverter( ITypedConverter meshConverter, ITypedConverter boxConverter, ITypedConverter intervalConverter, - IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory, IRhinoMeshFactory rhinoMeshFactory) + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory, + IRhinoMeshFactory rhinoMeshFactory + ) { _pointConverter = pointConverter; _curveConverter = curveConverter; 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 c7d26596dd..0fa733ca87 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 @@ -1,6 +1,5 @@ using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; -using Speckle.Core.Models; using Speckle.Rhino7.Interfaces; namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; @@ -21,6 +20,4 @@ public ControlPointToSpeckleConverter(IConversionContextStackThe converted Speckle ControlPoint object. public SOG.ControlPoint Convert(IRhinoControlPoint target) => new(target.Location.X, target.Location.Y, target.Location.Z, target.Weight, _contextStack.Current.SpeckleUnits); - - public Base Convert(object target) => Convert((IRhinoControlPoint)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 980a07f56f..0420067ae7 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 @@ -14,7 +14,9 @@ public class EllipseToSpeckleConverter : ITypedConverter planeConverter, ITypedConverter boxConverter, - IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory + ) { _planeConverter = planeConverter; _boxConverter = boxConverter; 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 b279d5e3fd..dc480c79fd 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 @@ -14,7 +14,9 @@ public class LineToSpeckleConverter : ITypedConverter, ITy public LineToSpeckleConverter( ITypedConverter pointConverter, ITypedConverter boxConverter, - IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory + ) { _pointConverter = pointConverter; _boxConverter = boxConverter; 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 34ff6bd818..cf7dfbc288 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 @@ -13,7 +13,9 @@ public class MeshToSpeckleConverter : ITypedConverter public MeshToSpeckleConverter( ITypedConverter boxConverter, - IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory + ) { _boxConverter = boxConverter; _contextStack = contextStack; 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 c6856d3b60..e1d81c2a22 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 @@ -16,7 +16,9 @@ public NurbsCurveConverter( ITypedConverter polylineConverter, ITypedConverter intervalConverter, ITypedConverter boxConverter, - IConversionContextStackcontextStack , IRhinoBoxFactory rhinoBoxFactory) + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory + ) { _polylineConverter = polylineConverter; _intervalConverter = intervalConverter; 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 9e556856ea..4f4952622a 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 @@ -16,7 +16,9 @@ public NurbsSurfaceToSpeckleConverter( ITypedConverter boxConverter, ITypedConverter intervalConverter, ITypedConverter controlPointConverter, - IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory + ) { _boxConverter = boxConverter; _intervalConverter = intervalConverter; 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 7a1801f150..c110af447a 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,9 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; -public class PointToSpeckleConverter : ITypedConverter, ITypedConverter +public class PointToSpeckleConverter + : ITypedConverter, + ITypedConverter { private readonly IConversionContextStack _contextStack; @@ -18,7 +20,8 @@ public PointToSpeckleConverter(IConversionContextStack /// The Rhino 3D point to convert. /// The converted Speckle point. - public SOG.Point Convert(IRhinoPoint3d target) => new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); + public SOG.Point Convert(IRhinoPoint3d target) => + new(target.X, target.Y, target.Z, _contextStack.Current.SpeckleUnits); public SOG.Point Convert(IRhinoPoint 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 6b4ae9bdbd..d5dba21eab 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 @@ -7,7 +7,7 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; public class PolyCurveToSpeckleConverter : ITypedConverter { - 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 _curveConverter; private readonly ITypedConverter _intervalConverter; private readonly ITypedConverter _boxConverter; private readonly IConversionContextStack _contextStack; @@ -16,12 +16,16 @@ public class PolyCurveToSpeckleConverter : ITypedConverter intervalConverter, ITypedConverter boxConverter, - IConversionContextStack contextStack, IRhinoBoxFactory rhinoBoxFactory) + IConversionContextStack contextStack, + IRhinoBoxFactory rhinoBoxFactory, + ITypedConverter curveConverter + ) { _intervalConverter = intervalConverter; _boxConverter = boxConverter; _contextStack = contextStack; _rhinoBoxFactory = rhinoBoxFactory; + _curveConverter = curveConverter; } /// @@ -41,7 +45,7 @@ public SOG.Polycurve Convert(IRhinoPolyCurve target) domain = _intervalConverter.Convert(target.Domain), length = target.GetLength(), bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(true))), - segments = target.DuplicateSegments().Select(x => CurveConverter.NotNull().Convert(x)).ToList(), + segments = target.DuplicateSegments().Select(x => _curveConverter.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 7cdaec82e7..33d2d7807f 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 @@ -18,7 +18,9 @@ public PolylineToSpeckleConverter( ITypedConverter pointConverter, ITypedConverter boxConverter, IConversionContextStack contextStack, - ITypedConverter intervalConverter, IRhinoBoxFactory rhinoBoxFactory) + ITypedConverter intervalConverter, + IRhinoBoxFactory rhinoBoxFactory + ) { _pointConverter = pointConverter; _boxConverter = boxConverter; 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 604aab86c2..f7d0fdee98 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 @@ -12,7 +12,9 @@ public class RawPointCloudToSpeckle : ITypedConverter contextStack, - ITypedConverter boxConverter, IRhinoBoxFactory rhinoBoxFactory) + ITypedConverter boxConverter, + IRhinoBoxFactory rhinoBoxFactory + ) { _contextStack = contextStack; _boxConverter = boxConverter; 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 cce82c29e9..d55b39090c 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 @@ -17,7 +17,7 @@ public BrepObjectToSpeckleTopLevelConverter(ITypedConverter +public class CurveObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { public CurveObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } 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 cc59b338af..3c5d93335d 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 @@ -17,7 +17,7 @@ public ExtrusionObjectToSpeckleTopLevelConverter(ITypedConverter +public class MeshObjectToSpeckleTopLevelConverter + : RhinoObjectToSpeckleTopLevelConverter { public MeshObjectToSpeckleTopLevelConverter(ITypedConverter conversion) : base(conversion) { } 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 c21065cd68..f86d7a09f5 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 @@ -8,11 +8,11 @@ public abstract class RhinoObjectToSpeckleTopLevelConverter Conversion { get; } + private readonly ITypedConverter _conversion; protected RhinoObjectToSpeckleTopLevelConverter(ITypedConverter conversion) { - Conversion = conversion; + _conversion = conversion; } // POC: IIndex would fix this as I would just request the type from `RhinoObject.Geometry` directly. @@ -20,10 +20,10 @@ protected RhinoObjectToSpeckleTopLevelConverter(ITypedConverter public virtual Base Convert(object target) { - var typedTarget = (TTopLevelIn)target; + var typedTarget = (TTopLevelIn)target; //can only be this typee var typedGeometry = GetTypedGeometry(typedTarget); - var result = Conversion.Convert(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. From f019f7c28804d7a8e9bd5ee120d081b1f903e308 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 20 Jun 2024 08:35:50 +0100 Subject: [PATCH 19/28] Change reflection --- .../ToSpeckle/Raw/CurveToSpeckleConverter.cs | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) 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 580cb2a7d1..855a2d43d5 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 @@ -38,15 +38,31 @@ 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 Convert(IRhinoCurve target) => - target switch + public ICurve Convert(IRhinoCurve target) + { + var polyline = target.ToPolylineCurve(); + if (polyline is not null) + { + return _polylineConverter.Convert(polyline); + } + var arcCurve = target.ToArcCurve(); + if (arcCurve is not null) + { + return _arcCurveConverter.Convert(arcCurve); + } + var polyCurve = target.ToPolyCurve(); + if (polyCurve is not null) { - IRhinoPolyCurve polyCurve => _polyCurveConverter.Convert(polyCurve), - IRhinoArcCurve arcCurve => _arcCurveConverter.Convert(arcCurve), - IRhinoPolylineCurve polylineCurve => _polylineConverter.Convert(polylineCurve), - IRhinoLineCurve lineCurve => _lineCurveConverter.Convert(lineCurve), - _ => _nurbsCurveConverter.Convert(target.ToNurbsCurve()) - }; + return _polyCurveConverter.Convert(polyCurve); + } + var lineCurve = target.ToLineCurve(); + if (lineCurve is not null) + { + return _lineCurveConverter.Convert(lineCurve); + } + var nurbsCurve = target.ToNurbsCurve(); + return _nurbsCurveConverter.Convert(nurbsCurve); + } Base ITypedConverter.Convert(IRhinoCurve target) => (Base)Convert(target); } From 69cb953bc102b9815ab4ef96eb26e9e5eefe925d Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 20 Jun 2024 09:03:29 +0100 Subject: [PATCH 20/28] update host api and add tests --- Build/Consts.cs | 6 +++++- .../Speckle.Connectors.Rhino7.csproj | 4 ++-- ...erters.Revit2023.DependencyInjection.csproj | 2 +- .../Speckle.Converters.Revit2023.Tests.csproj | 2 +- .../packages.lock.json | 8 ++++---- .../Speckle.Converters.Revit2023.csproj | 2 +- ...onverters.Rhino7.DependencyInjection.csproj | 2 +- .../Speckle.Converters.Rhino7.csproj | 2 +- .../Speckle.Converters.Common.Tests.csproj | 4 ++-- .../packages.lock.json | 18 ++++-------------- 10 files changed, 22 insertions(+), 28 deletions(-) diff --git a/Build/Consts.cs b/Build/Consts.cs index 48a14139b0..2fa9d8deaa 100644 --- a/Build/Consts.cs +++ b/Build/Consts.cs @@ -5,7 +5,11 @@ namespace Build; public static class Consts { public static readonly string[] Solutions = { "DUI3-DX.slnf" }; - public static readonly string[] TestProjects = { "Speckle.Converters.Revit2023.Tests" }; + public static readonly string[] TestProjects = + { + "Speckle.Converters.Revit2023.Tests", + "Speckle.Converters.Common.Tests" + }; public static readonly InstallerProject[] InstallerManifests = { diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index 6040c27270..96a661406d 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index 3908fda428..293ddec6b5 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj index e0fb9b36be..50117603c4 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index ae58361dad..7bb3ee636d 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.25, )", - "resolved": "0.1.1-preview.0.25", - "contentHash": "K22SbzxnujxU/elofcsYceLQ2G2ketJWGSM39I+k6IcvRvcy/az5X1fjhzrYtzC0Y+/2aqm0oqydFP+3FROJjg==" + "requested": "[0.1.1-preview.0.26, )", + "resolved": "0.1.1-preview.0.26", + "contentHash": "bh9v0aQYuy7jlvtiOAZCOFa1NxQHpQUUAeM/wM+imQeiMw/6xhlBx5yT/15N1CL6JJzchKRzTAnK4xDk9WKCmw==" }, "Castle.Core": { "type": "Transitive", @@ -504,7 +504,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.25, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.26, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index aeb60638de..8ca235facc 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index cba4c93e3c..48c45f8719 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -11,6 +11,6 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 3ce6dae08d..547e5436f6 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -4,7 +4,7 @@ net48 - + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj index 713fdb653a..decdf77def 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj @@ -1,4 +1,4 @@ - + net48 @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json index 745cd3ba1e..c5bc6b8f6d 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "requested": "[0.1.1-preview.0.26, )", + "resolved": "0.1.1-preview.0.26", + "contentHash": "bh9v0aQYuy7jlvtiOAZCOFa1NxQHpQUUAeM/wM+imQeiMw/6xhlBx5yT/15N1CL6JJzchKRzTAnK4xDk9WKCmw==" }, "Castle.Core": { "type": "Transitive", @@ -200,14 +200,6 @@ "Serilog": "2.4.0" } }, - "Serilog.Enrichers.GlobalLogContext": { - "type": "Transitive", - "resolved": "3.0.0", - "contentHash": "IIZcj5mAUVhIl/NTA+YI2KC+sPDzcwvs0ZMHH42jsPfl1a4LVX7ohVpw5UK+e3GxuV3Nv239Il5oM2peUIl44g==", - "dependencies": { - "Serilog": "2.12.0" - } - }, "Serilog.Exceptions": { "type": "Transitive", "resolved": "8.4.0", @@ -421,8 +413,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { @@ -438,7 +429,6 @@ "Sentry.Serilog": "[3.33.0, )", "Serilog": "[2.12.0, )", "Serilog.Enrichers.ClientInfo": "[1.3.0, )", - "Serilog.Enrichers.GlobalLogContext": "[3.0.0, )", "Serilog.Exceptions": "[8.4.0, )", "Serilog.Sinks.Console": "[4.1.0, )", "Serilog.Sinks.Seq": "[5.2.2, )", From 90f2b086be93808163caf61e4f69bdf844b2f4ad Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 20 Jun 2024 09:06:43 +0100 Subject: [PATCH 21/28] add no build for tests --- Build/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build/Program.cs b/Build/Program.cs index 815a086a70..61ee6e048c 100644 --- a/Build/Program.cs +++ b/Build/Program.cs @@ -127,7 +127,7 @@ IEnumerable GetFiles(string d) foreach (var file in GetFiles($"**/{t}.csproj")) { - Run("dotnet", $"test {file} -c Release --no-restore --verbosity=normal"); + Run("dotnet", $"test {file} -c Release --no-build --no-restore --verbosity=normal"); } } ); From e11de9e821715369c2855e5ad492063ba587b471 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 20 Jun 2024 11:21:42 +0100 Subject: [PATCH 22/28] revert for circular dependency --- .../RevitConverterModule.cs | 1 - .../ToHost/Raw/PolyCurveToHostConverter.cs | 9 +++++---- .../ToSpeckle/Raw/PolyCurveToSpeckleConverter.cs | 9 ++++----- 3 files changed, 9 insertions(+), 10 deletions(-) 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 1c7eae1e2f..7900f25180 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs @@ -14,7 +14,6 @@ public class RevitConverterModule : ISpeckleModule public void Load(SpeckleContainerBuilder builder) { builder.AddConverterCommon(); - builder.ScanAssemblyOfType(); // POC: do we need ToSpeckleScalingService as is, do we need to interface it out? builder.AddScoped(); 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 14b51151c9..6a2655ed48 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 @@ -1,4 +1,5 @@ using Objects; +using Speckle.Converters.Common; using Speckle.Converters.Common.Objects; using Speckle.Core.Kits; using Speckle.Rhino7.Interfaces; @@ -7,18 +8,17 @@ namespace Speckle.Converters.Rhino7.ToHost.Raw; public class PolyCurveToHostConverter : ITypedConverter { - private readonly ITypedConverter _curveConverter; + public ITypedConverter? CurveConverter { get; set; } // POC: CNX-9311 Circular dependency injected by the container using property. + private readonly ITypedConverter _intervalConverter; private readonly IRhinoCurveFactory _rhinoCurveFactory; public PolyCurveToHostConverter( ITypedConverter intervalConverter, - ITypedConverter curveConverter, IRhinoCurveFactory rhinoCurveFactory ) { _intervalConverter = intervalConverter; - _curveConverter = curveConverter; _rhinoCurveFactory = rhinoCurveFactory; } @@ -31,10 +31,11 @@ IRhinoCurveFactory rhinoCurveFactory public IRhinoPolyCurve Convert(SOG.Polycurve target) { IRhinoPolyCurve result = _rhinoCurveFactory.Create(); + var converter = CurveConverter.NotNull(); foreach (var segment in target.segments) { - var childCurve = _curveConverter.Convert(segment); + var childCurve = converter.Convert(segment); bool success = result.AppendSegment(childCurve); if (!success) { 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 d5dba21eab..10cdf491d5 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 @@ -7,7 +7,8 @@ namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; public class PolyCurveToSpeckleConverter : ITypedConverter { - private readonly ITypedConverter _curveConverter; + 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; @@ -17,15 +18,13 @@ public PolyCurveToSpeckleConverter( ITypedConverter intervalConverter, ITypedConverter boxConverter, IConversionContextStack contextStack, - IRhinoBoxFactory rhinoBoxFactory, - ITypedConverter curveConverter + IRhinoBoxFactory rhinoBoxFactory ) { _intervalConverter = intervalConverter; _boxConverter = boxConverter; _contextStack = contextStack; _rhinoBoxFactory = rhinoBoxFactory; - _curveConverter = curveConverter; } /// @@ -45,7 +44,7 @@ public SOG.Polycurve Convert(IRhinoPolyCurve target) domain = _intervalConverter.Convert(target.Domain), length = target.GetLength(), bbox = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.GetBoundingBox(true))), - segments = target.DuplicateSegments().Select(x => _curveConverter.Convert(x)).ToList(), + segments = target.DuplicateSegments().Select(x => CurveConverter.NotNull().Convert(x)).ToList(), units = _contextStack.Current.SpeckleUnits }; return myPoly; From a20127b3cba4323fa9fe8b0f17cebd7386ab77c1 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 20 Jun 2024 13:36:22 +0100 Subject: [PATCH 23/28] to host fixes --- .../Operations/Receive/DisableRedrawScope.cs | 9 ++-- .../Receive/RhinoHostObjectBuilder.cs | 47 +++++++++---------- .../RootConvertManager.cs | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs index 1182e5de7a..4da1e8a4ef 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs @@ -1,16 +1,17 @@ -using Rhino.DocObjects.Tables; + +using Speckle.Rhino7.Interfaces; namespace Speckle.Connectors.Rhino7.Operations.Receive; /// -/// Helper class to disable within a scope +/// Helper class to disable within a scope /// public sealed class DisableRedrawScope : IDisposable { - private readonly ViewTable _viewTable; + private readonly IRhinoViewTable _viewTable; private readonly bool _returnToStatus; - public DisableRedrawScope(ViewTable viewTable, bool returnToStatus = true) + public DisableRedrawScope(IRhinoViewTable viewTable, bool returnToStatus = true) { _viewTable = viewTable; _returnToStatus = returnToStatus; 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 02f653f08a..25bf5921d1 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 @@ -1,31 +1,30 @@ using System.Diagnostics.Contracts; -using Rhino; -using Rhino.DocObjects; -using Rhino.Geometry; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Conversion; using Speckle.Converters.Common; using Speckle.Core.Logging; using Speckle.Core.Models; using Speckle.Core.Models.GraphTraversal; +using Speckle.Rhino7.Interfaces; namespace Speckle.Connectors.Rhino7.Operations.Receive; public class RhinoHostObjectBuilder : IHostObjectBuilder { private readonly IRootToHostConverter _converter; - private readonly IConversionContextStack _contextStack; + private readonly IConversionContextStack _contextStack; private readonly GraphTraversal _traverseFunction; + private readonly IRhinoDocFactory _rhinoDocFactory; public RhinoHostObjectBuilder( IRootToHostConverter converter, - IConversionContextStack contextStack, - GraphTraversal traverseFunction - ) + IConversionContextStack contextStack, + GraphTraversal traverseFunction, IRhinoDocFactory rhinoDocFactory) { _converter = converter; _contextStack = contextStack; _traverseFunction = traverseFunction; + _rhinoDocFactory = rhinoDocFactory; } public HostObjectBuilderResult Build( @@ -53,15 +52,15 @@ CancellationToken cancellationToken // POC: Potentially refactor out into an IObjectBaker. private HostObjectBuilderResult BakeObjects(IEnumerable objectsGraph, string baseLayerName) { - RhinoDoc doc = _contextStack.Current.Document; - var rootLayerIndex = _contextStack.Current.Document.Layers.Find(Guid.Empty, baseLayerName, RhinoMath.UnsetIntIndex); + var doc = _contextStack.Current.Document; + var rootLayerIndex = _contextStack.Current.Document.Layers.Find(Guid.Empty, baseLayerName, _rhinoDocFactory.UnsetIntIndex); // POC: We could move this out into a separate service for testing and re-use. // Cleans up any previously received objects - if (rootLayerIndex != RhinoMath.UnsetIntIndex) + if (rootLayerIndex != _rhinoDocFactory.UnsetIntIndex) { - Layer documentLayer = doc.Layers[rootLayerIndex]; - Layer[]? childLayers = documentLayer.GetChildren(); + var documentLayer = doc.Layers[rootLayerIndex]; + var childLayers = documentLayer.GetChildren(); if (childLayers != null) { using var layerNoDraw = new DisableRedrawScope(doc.Views); @@ -77,7 +76,7 @@ private HostObjectBuilderResult BakeObjects(IEnumerable object } var cache = new Dictionary(); - rootLayerIndex = doc.Layers.Add(new Layer { Name = baseLayerName }); + rootLayerIndex = doc.Layers.Add(_rhinoDocFactory.CreateLayer(baseLayerName)); cache.Add(baseLayerName, rootLayerIndex); using var noDraw = new DisableRedrawScope(doc.Views); @@ -91,7 +90,7 @@ private HostObjectBuilderResult BakeObjects(IEnumerable object { var path = GetLayerPath(tc); - var fullLayerName = string.Join(Layer.PathSeparator, path); + var fullLayerName = string.Join(_rhinoDocFactory.LayerPathSeparator, path); var layerIndex = cache.TryGetValue(fullLayerName, out int value) ? value : GetAndCreateLayerFromPath(path, baseLayerName, cache); @@ -120,31 +119,31 @@ private IReadOnlyList HandleConversionResult(object conversionResult, Ba List newObjectIds = new(); switch (conversionResult) { - case IEnumerable list: + case IEnumerable list: { - Group group = BakeObjectsAsGroup(originalObject.id, list, layerIndex); + var group = BakeObjectsAsGroup(originalObject.id, list, layerIndex); newObjectIds.Add(group.Id.ToString()); break; } - case GeometryBase newObject: + case IRhinoGeometryBase newObject: { - var newObjectGuid = doc.Objects.Add(newObject, new ObjectAttributes { LayerIndex = layerIndex }); + var newObjectGuid = doc.Objects.Add(newObject, _rhinoDocFactory.CreateAttributes(layerIndex)); newObjectIds.Add(newObjectGuid.ToString()); break; } default: throw new SpeckleConversionException( - $"Unexpected result from conversion: Expected {nameof(GeometryBase)} but instead got {conversionResult.GetType().Name}" + $"Unexpected result from conversion: Expected {nameof(IRhinoGeometryBase)} but instead got {conversionResult.GetType().Name}" ); } return newObjectIds; } - private Group BakeObjectsAsGroup(string groupName, IEnumerable list, int layerIndex) + private IRhinoGroup BakeObjectsAsGroup(string groupName, IEnumerable list, int layerIndex) { var doc = _contextStack.Current.Document; - var objectIds = list.Select(obj => doc.Objects.Add(obj, new ObjectAttributes { LayerIndex = layerIndex })); + var objectIds = list.Select(obj => doc.Objects.Add(obj,_rhinoDocFactory.CreateAttributes(layerIndex))); var groupIndex = _contextStack.Current.Document.Groups.Add(groupName, objectIds); var group = _contextStack.Current.Document.Groups.FindIndex(groupIndex); return group; @@ -154,12 +153,12 @@ private Group BakeObjectsAsGroup(string groupName, IEnumerable lis private int GetAndCreateLayerFromPath(string[] path, string baseLayerName, Dictionary cache) { var currentLayerName = baseLayerName; - RhinoDoc currentDocument = _contextStack.Current.Document; + var currentDocument = _contextStack.Current.Document; var previousLayer = currentDocument.Layers.FindName(currentLayerName); foreach (var layerName in path) { - currentLayerName = baseLayerName + Layer.PathSeparator + layerName; + currentLayerName = baseLayerName + _rhinoDocFactory.LayerPathSeparator + layerName; currentLayerName = currentLayerName.Replace("{", "").Replace("}", ""); // Rhino specific cleanup for gh (see RemoveInvalidRhinoChars) if (cache.TryGetValue(currentLayerName, out int value)) { @@ -168,7 +167,7 @@ private int GetAndCreateLayerFromPath(string[] path, string baseLayerName, Dicti } var cleanNewLayerName = layerName.Replace("{", "").Replace("}", ""); - var newLayer = new Layer { Name = cleanNewLayerName, ParentLayerId = previousLayer.Id }; + var newLayer = _rhinoDocFactory.CreateLayer(cleanNewLayerName, previousLayer.Id); var index = currentDocument.Layers.Add(newLayer); cache.Add(currentLayerName, index); previousLayer = currentDocument.Layers.FindIndex(index); // note we need to get the correct id out, hence why we're double calling this diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs index 4ae930fa1c..6f29a573ad 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/RootConvertManager.cs @@ -27,7 +27,7 @@ public Base Convert(Type type, object obj) if (objectConverter == null) { - throw new NotSupportedException($"No conversion found for {type.Name}"); + throw new NotSupportedException($"No conversion found for {type.Name} with actual type of {obj.GetType()}"); } var convertedObject = objectConverter.Convert(obj); From 63d301645a81bb19c2e7d488932a1980c518cd97 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 20 Jun 2024 14:04:08 +0100 Subject: [PATCH 24/28] update host apis and lock files --- .../packages.lock.json | 8 +--- .../packages.lock.json | 8 +--- .../packages.lock.json | 17 ++++--- .../Speckle.Connectors.Rhino7.csproj | 4 +- .../packages.lock.json | 48 +++++++++++++++---- .../packages.lock.json | 8 +--- .../packages.lock.json | 8 +--- .../packages.lock.json | 8 +--- .../packages.lock.json | 8 +--- ...rters.Revit2023.DependencyInjection.csproj | 2 +- .../packages.lock.json | 17 ++++--- .../Speckle.Converters.Revit2023.Tests.csproj | 2 +- .../packages.lock.json | 8 ++-- .../Speckle.Converters.Revit2023.csproj | 2 +- .../packages.lock.json | 9 ++-- ...nverters.Rhino7.DependencyInjection.csproj | 2 +- .../packages.lock.json | 24 ++++------ .../Speckle.Converters.Rhino7.csproj | 2 +- .../packages.lock.json | 20 +++----- .../packages.lock.json | 8 +--- .../Speckle.Converters.Common.Tests.csproj | 2 +- .../packages.lock.json | 6 +-- .../packages.lock.json | 6 --- 23 files changed, 98 insertions(+), 129 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json index 3b14166e57..5306011fc3 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/packages.lock.json @@ -302,11 +302,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -431,8 +426,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json index b584dc45f9..ecbfc4fb09 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023/packages.lock.json @@ -279,11 +279,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -487,8 +482,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json index 9039fbd17b..ff2845ef02 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json @@ -315,18 +315,18 @@ }, "Speckle.Revit2023.Api": { "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "hPRXbyvgmealdPPWTxjHbpBRTsyt67DddoIs09M0n319eHh/eONnPC+SgBzJmmB834TtzzayMVk06S1cMT0Iow==", + "resolved": "0.1.1-preview.0.27", + "contentHash": "lYsz0dkPIHKJKbly8jyL4zGx7BNgYViw8hE3SKuP10InSF/zkcZoPJ3Zz9SEDTYVB4a7tm185a/z64Ti3IFReg==", "dependencies": { "Mapster": "7.3.0", "Speckle.Revit.API": "2023.0.0", - "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.24" + "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.27" } }, "Speckle.Revit2023.Interfaces": { "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "resolved": "0.1.1-preview.0.27", + "contentHash": "/tVBpS/NsqtQtA90X3zeW4grMaELS+i0J9PqZwdxYBMmB8rzoYCzbBME7KoxIXQK1FHILKeJv2AHGWkgg1c+rg==" }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", @@ -514,8 +514,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { @@ -529,7 +528,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.27, )" } }, "speckle.converters.revit2023.dependencyinjection": { @@ -538,7 +537,7 @@ "Speckle.Converters.Common": "[2.0.999-local, )", "Speckle.Converters.Common.DependencyInjection": "[2.0.999-local, )", "Speckle.Converters.Revit2023": "[2.0.999-local, )", - "Speckle.Revit2023.Api": "[0.1.1-preview.0.24, )" + "Speckle.Revit2023.Api": "[0.1.1-preview.0.27, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index 96a661406d..cd150b7ec2 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json index df37836fb8..2134f51b73 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json @@ -29,6 +29,24 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, + "Speckle.Rhino7.Api": { + "type": "Direct", + "requested": "[0.1.1-preview.0.27, )", + "resolved": "0.1.1-preview.0.27", + "contentHash": "UftvB7Q5FuORTyVe6+0uXyOPRhZjrdlIVQjXCI4KQUI0RPM15J4Vxgvl7FN1yjOjOs4CsVqOv6qsAsCPVoj/gQ==", + "dependencies": { + "Mapster": "7.3.0", + "RhinoCommon": "7.13.21348.13001", + "RhinoWindows": "7.13.21348.13001", + "Speckle.Rhino7.Interfaces": "0.1.1-preview.0.27" + } + }, + "Speckle.Rhino7.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.27, )", + "resolved": "0.1.1-preview.0.27", + "contentHash": "/W0fXXPDb97aV/6mBdUbPE+kvfqg4s7cdxqhVB3JhMmSzdf27RULslD7R/dYIYFuLnmAB3iQgdz53YMVtMrRfg==" + }, "System.Resources.Extensions": { "type": "Direct", "requested": "[7.0.0, )", @@ -70,6 +88,21 @@ "resolved": "6.0.0", "contentHash": "yg72rrYDapfsIUrul7aF6wwNnTJBOFvuA9VdDTQpPa8AlAriHbufeXYLBcodKjfUdkCnaiggX1U/nEP08Zb5GA==" }, + "Mapster": { + "type": "Transitive", + "resolved": "7.3.0", + "contentHash": "NrCUX/rJa5PTyo6iW4AL5dZLU9PDNlYnrJOVjgdpo5OQM9EtWH2CMHnC5sSuJWC0d0b0SnmeRrIviEem6WxtuQ==", + "dependencies": { + "Mapster.Core": "1.2.0", + "Microsoft.CSharp": "4.3.0", + "System.Reflection.Emit": "4.3.0" + } + }, + "Mapster.Core": { + "type": "Transitive", + "resolved": "1.2.0", + "contentHash": "TNdqZk2zAuBYfJF88D/3clQTOyOdqr1crU81yZQtlGa+e7FYWhJdK/buBWT+TpM3qQko9UzmzfOT4iq3JCs/ZA==" + }, "Microsoft.Bcl.AsyncInterfaces": { "type": "Transitive", "resolved": "7.0.0", @@ -288,11 +321,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -385,6 +413,11 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "System.Reflection.Emit": { + "type": "Transitive", + "resolved": "4.3.0", + "contentHash": "228FG0jLcIwTVJyz8CLFKueVqQK36ANazUManGaJHkO0icjiIypKW7YLWLIWahyIkdh5M7mV2dJepllLyA1SKg==" + }, "System.Reflection.Metadata": { "type": "Transitive", "resolved": "5.0.0", @@ -481,8 +514,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { @@ -495,7 +527,7 @@ "speckle.converters.rhino7.dependencyinjection": { "type": "Project", "dependencies": { - "RhinoCommon": "[7.13.21348.13001, )" + "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.27, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json index 308e61b7c6..acad1bb553 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3.DependencyInjection/packages.lock.json @@ -270,11 +270,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -366,8 +361,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json index 25847a4ec6..9c5d3fa603 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/packages.lock.json @@ -265,11 +265,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -354,8 +349,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json index a7f09e4723..57f50cdecb 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023.DependencyInjection/packages.lock.json @@ -213,11 +213,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -374,8 +369,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json index 66bbf8290c..2ea05d5e3f 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2023/packages.lock.json @@ -205,11 +205,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -359,8 +354,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index 293ddec6b5..cbe635b380 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json index 48eed8707b..247ad7b56e 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json @@ -16,13 +16,13 @@ }, "Speckle.Revit2023.Api": { "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "hPRXbyvgmealdPPWTxjHbpBRTsyt67DddoIs09M0n319eHh/eONnPC+SgBzJmmB834TtzzayMVk06S1cMT0Iow==", + "requested": "[0.1.1-preview.0.27, )", + "resolved": "0.1.1-preview.0.27", + "contentHash": "lYsz0dkPIHKJKbly8jyL4zGx7BNgYViw8hE3SKuP10InSF/zkcZoPJ3Zz9SEDTYVB4a7tm185a/z64Ti3IFReg==", "dependencies": { "Mapster": "7.3.0", "Speckle.Revit.API": "2023.0.0", - "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.24" + "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.27" } }, "GraphQL.Client": { @@ -232,8 +232,8 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "resolved": "0.1.1-preview.0.27", + "contentHash": "/tVBpS/NsqtQtA90X3zeW4grMaELS+i0J9PqZwdxYBMmB8rzoYCzbBME7KoxIXQK1FHILKeJv2AHGWkgg1c+rg==" }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", @@ -389,8 +389,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { @@ -404,7 +403,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.27, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj index 50117603c4..1f1823e415 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index 7bb3ee636d..c154849505 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.26, )", - "resolved": "0.1.1-preview.0.26", - "contentHash": "bh9v0aQYuy7jlvtiOAZCOFa1NxQHpQUUAeM/wM+imQeiMw/6xhlBx5yT/15N1CL6JJzchKRzTAnK4xDk9WKCmw==" + "requested": "[0.1.1-preview.0.27, )", + "resolved": "0.1.1-preview.0.27", + "contentHash": "/tVBpS/NsqtQtA90X3zeW4grMaELS+i0J9PqZwdxYBMmB8rzoYCzbBME7KoxIXQK1FHILKeJv2AHGWkgg1c+rg==" }, "Castle.Core": { "type": "Transitive", @@ -504,7 +504,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.26, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.27, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index 8ca235facc..fc0c051650 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json index b021d0f201..4ad9809c1a 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json @@ -16,9 +16,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" + "requested": "[0.1.1-preview.0.27, )", + "resolved": "0.1.1-preview.0.27", + "contentHash": "/tVBpS/NsqtQtA90X3zeW4grMaELS+i0J9PqZwdxYBMmB8rzoYCzbBME7KoxIXQK1FHILKeJv2AHGWkgg1c+rg==" }, "GraphQL.Client": { "type": "Transitive", @@ -354,8 +354,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index 48c45f8719..6f34ef2b29 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -11,6 +11,6 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json index 590b6f9e6c..edf9f6ea5d 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json @@ -8,18 +8,18 @@ "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, - "RhinoCommon": { - "type": "Direct", - "requested": "[7.13.21348.13001, )", - "resolved": "7.13.21348.13001", - "contentHash": "JQdaNw61ddBqIe08E9O4N/grwrN1hjDHcYW7tWylwCZyFR7SepoCD4NS+6LN6+oSQhNbhLi9Bf+hQOFYFdRAEA==" - }, "Speckle.InterfaceGenerator": { "type": "Direct", "requested": "[0.9.5, )", "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, + "Speckle.Rhino7.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.27, )", + "resolved": "0.1.1-preview.0.27", + "contentHash": "/W0fXXPDb97aV/6mBdUbPE+kvfqg4s7cdxqhVB3JhMmSzdf27RULslD7R/dYIYFuLnmAB3iQgdz53YMVtMrRfg==" + }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -205,11 +205,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -359,8 +354,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { @@ -373,8 +367,8 @@ "speckle.converters.rhino7": { "type": "Project", "dependencies": { - "RhinoCommon": "[7.13.21348.13001, )", - "Speckle.Converters.Common": "[2.0.999-local, )" + "Speckle.Converters.Common": "[2.0.999-local, )", + "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.27, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 547e5436f6..10e0d2d8cc 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -4,7 +4,7 @@ net48 - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json index 2512d2a6e6..e0fff47189 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json @@ -8,18 +8,18 @@ "resolved": "1.14.1", "contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" }, - "RhinoCommon": { - "type": "Direct", - "requested": "[7.13.21348.13001, )", - "resolved": "7.13.21348.13001", - "contentHash": "JQdaNw61ddBqIe08E9O4N/grwrN1hjDHcYW7tWylwCZyFR7SepoCD4NS+6LN6+oSQhNbhLi9Bf+hQOFYFdRAEA==" - }, "Speckle.InterfaceGenerator": { "type": "Direct", "requested": "[0.9.5, )", "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, + "Speckle.Rhino7.Interfaces": { + "type": "Direct", + "requested": "[0.1.1-preview.0.27, )", + "resolved": "0.1.1-preview.0.27", + "contentHash": "/W0fXXPDb97aV/6mBdUbPE+kvfqg4s7cdxqhVB3JhMmSzdf27RULslD7R/dYIYFuLnmAB3iQgdz53YMVtMrRfg==" + }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", @@ -205,11 +205,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -359,8 +354,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json index 326fdefd15..890db720a4 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.DependencyInjection/packages.lock.json @@ -302,11 +302,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -459,8 +454,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj index decdf77def..85a5aa17d0 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json index c5bc6b8f6d..48b9076d29 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.26, )", - "resolved": "0.1.1-preview.0.26", - "contentHash": "bh9v0aQYuy7jlvtiOAZCOFa1NxQHpQUUAeM/wM+imQeiMw/6xhlBx5yT/15N1CL6JJzchKRzTAnK4xDk9WKCmw==" + "requested": "[0.1.1-preview.0.27, )", + "resolved": "0.1.1-preview.0.27", + "contentHash": "/tVBpS/NsqtQtA90X3zeW4grMaELS+i0J9PqZwdxYBMmB8rzoYCzbBME7KoxIXQK1FHILKeJv2AHGWkgg1c+rg==" }, "Castle.Core": { "type": "Transitive", diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json index c3d43a1f8a..a9095c6e5b 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common/packages.lock.json @@ -23,12 +23,6 @@ "resolved": "0.9.5", "contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Direct", - "requested": "[0.1.1-preview.0.24, )", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "GraphQL.Client": { "type": "Transitive", "resolved": "6.0.0", From b6a191d2454ccb9dfb90d82bf7c583f44fbf5f25 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 20 Jun 2024 14:08:21 +0100 Subject: [PATCH 25/28] fmt --- .../Operations/Receive/DisableRedrawScope.cs | 3 +-- .../Operations/Receive/RhinoHostObjectBuilder.cs | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs index 4da1e8a4ef..621bfa45ed 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Operations/Receive/DisableRedrawScope.cs @@ -1,5 +1,4 @@ - -using Speckle.Rhino7.Interfaces; +using Speckle.Rhino7.Interfaces; namespace Speckle.Connectors.Rhino7.Operations.Receive; 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 25bf5921d1..6c73b9bd10 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 @@ -19,7 +19,9 @@ public class RhinoHostObjectBuilder : IHostObjectBuilder public RhinoHostObjectBuilder( IRootToHostConverter converter, IConversionContextStack contextStack, - GraphTraversal traverseFunction, IRhinoDocFactory rhinoDocFactory) + GraphTraversal traverseFunction, + IRhinoDocFactory rhinoDocFactory + ) { _converter = converter; _contextStack = contextStack; @@ -53,7 +55,11 @@ CancellationToken cancellationToken private HostObjectBuilderResult BakeObjects(IEnumerable objectsGraph, string baseLayerName) { var doc = _contextStack.Current.Document; - var rootLayerIndex = _contextStack.Current.Document.Layers.Find(Guid.Empty, baseLayerName, _rhinoDocFactory.UnsetIntIndex); + var rootLayerIndex = _contextStack.Current.Document.Layers.Find( + Guid.Empty, + baseLayerName, + _rhinoDocFactory.UnsetIntIndex + ); // POC: We could move this out into a separate service for testing and re-use. // Cleans up any previously received objects @@ -143,7 +149,7 @@ private IReadOnlyList HandleConversionResult(object conversionResult, Ba private IRhinoGroup BakeObjectsAsGroup(string groupName, IEnumerable list, int layerIndex) { var doc = _contextStack.Current.Document; - var objectIds = list.Select(obj => doc.Objects.Add(obj,_rhinoDocFactory.CreateAttributes(layerIndex))); + var objectIds = list.Select(obj => doc.Objects.Add(obj, _rhinoDocFactory.CreateAttributes(layerIndex))); var groupIndex = _contextStack.Current.Document.Groups.Add(groupName, objectIds); var group = _contextStack.Current.Document.Groups.FindIndex(groupIndex); return group; From 449b396adad3f2b96e94cda174cfe91c0a82864b Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 20 Jun 2024 16:06:43 +0100 Subject: [PATCH 26/28] fixes curves! --- .../ToSpeckle/Raw/NurbsCurveConverter.cs | 4 ---- .../ToSpeckle/Raw/PolylineToSpeckleConverter.cs | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) 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 e1d81c2a22..7c28b72c3d 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 @@ -40,10 +40,6 @@ IRhinoBoxFactory rhinoBoxFactory public SOG.Curve Convert(IRhinoNurbsCurve target) { target.ToPolyline(0, 1, 0, 0, 0, 0.1, 0, 0, true).TryGetPolyline(out var poly); - if (target.IsClosed) - { - poly.Add(poly[0]); - } SOG.Polyline displayValue = _polylineConverter.Convert(poly); 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 33d2d7807f..7682ceeb42 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 @@ -40,7 +40,7 @@ public SOG.Polyline Convert(IRhinoPolyline target) var box = _boxConverter.Convert(_rhinoBoxFactory.CreateBox(target.BoundingBox)); var points = target.Select(pt => _pointConverter.Convert(pt)).ToList(); - if (target.IsClosed) + if (points[0] == points[^1] && target.IsClosed) { points.RemoveAt(points.Count - 1); } From 83a4a61b95d88649bb2d7ef8b64c17bf2b77728d Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 21 Jun 2024 14:45:44 +0100 Subject: [PATCH 27/28] fmt --- .../Bindings/RhinoSelectionBinding.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs index 030bc6e20f..dcb7c57fcf 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Bindings/RhinoSelectionBinding.cs @@ -15,7 +15,11 @@ public class RhinoSelectionBinding : ISelectionBinding public string Name => "selectionBinding"; public IBridge Parent { get; } - public RhinoSelectionBinding(IRhinoIdleManager idleManager, IBridge parent, ITopLevelExceptionHandler topLevelExceptionHandler) + public RhinoSelectionBinding( + IRhinoIdleManager idleManager, + IBridge parent, + ITopLevelExceptionHandler topLevelExceptionHandler + ) { _idleManager = idleManager; _topLevelExceptionHandler = topLevelExceptionHandler; From 128345875be72a0248be14045ad0a8d4a92e9424 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 24 Jun 2024 13:51:06 +0100 Subject: [PATCH 28/28] vertexes aren't nullable --- .../packages.lock.json | 14 +++++++------- .../Speckle.Connectors.Rhino7.csproj | 4 ++-- .../Speckle.Connectors.Rhino7/packages.lock.json | 16 ++++++++-------- ...nverters.Revit2023.DependencyInjection.csproj | 2 +- .../packages.lock.json | 14 +++++++------- .../Speckle.Converters.Revit2023.Tests.csproj | 2 +- .../packages.lock.json | 8 ++++---- .../Speckle.Converters.Revit2023.csproj | 2 +- .../packages.lock.json | 6 +++--- ....Converters.Rhino7.DependencyInjection.csproj | 2 +- .../packages.lock.json | 8 ++++---- .../Speckle.Converters.Rhino7.csproj | 2 +- .../ToSpeckle/Raw/BrepToSpeckleConverter.cs | 8 ++++---- .../Speckle.Converters.Rhino7/packages.lock.json | 6 +++--- .../Speckle.Converters.Common.Tests.csproj | 2 +- .../packages.lock.json | 6 +++--- 16 files changed, 51 insertions(+), 51 deletions(-) diff --git a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json index ff2845ef02..27da03b1ba 100644 --- a/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json +++ b/DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023/packages.lock.json @@ -315,18 +315,18 @@ }, "Speckle.Revit2023.Api": { "type": "Transitive", - "resolved": "0.1.1-preview.0.27", - "contentHash": "lYsz0dkPIHKJKbly8jyL4zGx7BNgYViw8hE3SKuP10InSF/zkcZoPJ3Zz9SEDTYVB4a7tm185a/z64Ti3IFReg==", + "resolved": "0.1.1-preview.0.28", + "contentHash": "ejwYS/HI8yy0rJE4vgTr5aj8Fkg/E9JnMGjwyVS2fLtI4f7+FmwAY6inTUT2p/RAoRc2nQw+TerDpUtOhddzag==", "dependencies": { "Mapster": "7.3.0", "Speckle.Revit.API": "2023.0.0", - "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.27" + "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.28" } }, "Speckle.Revit2023.Interfaces": { "type": "Transitive", - "resolved": "0.1.1-preview.0.27", - "contentHash": "/tVBpS/NsqtQtA90X3zeW4grMaELS+i0J9PqZwdxYBMmB8rzoYCzbBME7KoxIXQK1FHILKeJv2AHGWkgg1c+rg==" + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", @@ -528,7 +528,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.27, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" } }, "speckle.converters.revit2023.dependencyinjection": { @@ -537,7 +537,7 @@ "Speckle.Converters.Common": "[2.0.999-local, )", "Speckle.Converters.Common.DependencyInjection": "[2.0.999-local, )", "Speckle.Converters.Revit2023": "[2.0.999-local, )", - "Speckle.Revit2023.Api": "[0.1.1-preview.0.27, )" + "Speckle.Revit2023.Api": "[0.1.1-preview.0.28, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj index cd150b7ec2..b64bd8b20b 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/Speckle.Connectors.Rhino7.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json index 2134f51b73..2b6b868bae 100644 --- a/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json +++ b/DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7/packages.lock.json @@ -31,21 +31,21 @@ }, "Speckle.Rhino7.Api": { "type": "Direct", - "requested": "[0.1.1-preview.0.27, )", - "resolved": "0.1.1-preview.0.27", - "contentHash": "UftvB7Q5FuORTyVe6+0uXyOPRhZjrdlIVQjXCI4KQUI0RPM15J4Vxgvl7FN1yjOjOs4CsVqOv6qsAsCPVoj/gQ==", + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "AE+1lMl+lzwEdNn6kvEWuCy6wRSFAIYP0KXeGI8fECNsCBj023c4IE/wSVn7wIHD+nM2ZHcST/62dmZXNqUt5A==", "dependencies": { "Mapster": "7.3.0", "RhinoCommon": "7.13.21348.13001", "RhinoWindows": "7.13.21348.13001", - "Speckle.Rhino7.Interfaces": "0.1.1-preview.0.27" + "Speckle.Rhino7.Interfaces": "0.1.1-preview.0.28" } }, "Speckle.Rhino7.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.27, )", - "resolved": "0.1.1-preview.0.27", - "contentHash": "/W0fXXPDb97aV/6mBdUbPE+kvfqg4s7cdxqhVB3JhMmSzdf27RULslD7R/dYIYFuLnmAB3iQgdz53YMVtMrRfg==" + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "TcbfXlRMnQRat1JodgW+YW5FflTYem1GGo9DtKA+6iAuVaYagN5dxsrM5LE6M3pCnEV9rkEQOjFo7sgnnbo4mw==" }, "System.Resources.Extensions": { "type": "Direct", @@ -527,7 +527,7 @@ "speckle.converters.rhino7.dependencyinjection": { "type": "Project", "dependencies": { - "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.27, )" + "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.28, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj index cbe635b380..b9b0735ffe 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/Speckle.Converters.Revit2023.DependencyInjection.csproj @@ -6,7 +6,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json index 247ad7b56e..a1b26cfcdc 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/packages.lock.json @@ -16,13 +16,13 @@ }, "Speckle.Revit2023.Api": { "type": "Direct", - "requested": "[0.1.1-preview.0.27, )", - "resolved": "0.1.1-preview.0.27", - "contentHash": "lYsz0dkPIHKJKbly8jyL4zGx7BNgYViw8hE3SKuP10InSF/zkcZoPJ3Zz9SEDTYVB4a7tm185a/z64Ti3IFReg==", + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "ejwYS/HI8yy0rJE4vgTr5aj8Fkg/E9JnMGjwyVS2fLtI4f7+FmwAY6inTUT2p/RAoRc2nQw+TerDpUtOhddzag==", "dependencies": { "Mapster": "7.3.0", "Speckle.Revit.API": "2023.0.0", - "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.27" + "Speckle.Revit2023.Interfaces": "0.1.1-preview.0.28" } }, "GraphQL.Client": { @@ -232,8 +232,8 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Transitive", - "resolved": "0.1.1-preview.0.27", - "contentHash": "/tVBpS/NsqtQtA90X3zeW4grMaELS+i0J9PqZwdxYBMmB8rzoYCzbBME7KoxIXQK1FHILKeJv2AHGWkgg1c+rg==" + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", @@ -403,7 +403,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.27, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj index 1f1823e415..4657d9e8ba 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/Speckle.Converters.Revit2023.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json index c154849505..2d40fe5534 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.27, )", - "resolved": "0.1.1-preview.0.27", - "contentHash": "/tVBpS/NsqtQtA90X3zeW4grMaELS+i0J9PqZwdxYBMmB8rzoYCzbBME7KoxIXQK1FHILKeJv2AHGWkgg1c+rg==" + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" }, "Castle.Core": { "type": "Transitive", @@ -504,7 +504,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.27, )" + "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj index fc0c051650..26aa7a8647 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/Speckle.Converters.Revit2023.csproj @@ -9,7 +9,7 @@ - + diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json index 4ad9809c1a..7c350fca98 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023/packages.lock.json @@ -16,9 +16,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.27, )", - "resolved": "0.1.1-preview.0.27", - "contentHash": "/tVBpS/NsqtQtA90X3zeW4grMaELS+i0J9PqZwdxYBMmB8rzoYCzbBME7KoxIXQK1FHILKeJv2AHGWkgg1c+rg==" + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" }, "GraphQL.Client": { "type": "Transitive", diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj index 6f34ef2b29..052b08bafc 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/Speckle.Converters.Rhino7.DependencyInjection.csproj @@ -11,6 +11,6 @@ - + diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json index edf9f6ea5d..0b5cd3165f 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7.DependencyInjection/packages.lock.json @@ -16,9 +16,9 @@ }, "Speckle.Rhino7.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.27, )", - "resolved": "0.1.1-preview.0.27", - "contentHash": "/W0fXXPDb97aV/6mBdUbPE+kvfqg4s7cdxqhVB3JhMmSzdf27RULslD7R/dYIYFuLnmAB3iQgdz53YMVtMrRfg==" + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "TcbfXlRMnQRat1JodgW+YW5FflTYem1GGo9DtKA+6iAuVaYagN5dxsrM5LE6M3pCnEV9rkEQOjFo7sgnnbo4mw==" }, "GraphQL.Client": { "type": "Transitive", @@ -368,7 +368,7 @@ "type": "Project", "dependencies": { "Speckle.Converters.Common": "[2.0.999-local, )", - "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.27, )" + "Speckle.Rhino7.Interfaces": "[0.1.1-preview.0.28, )" } }, "Speckle.Core": { diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj index 10e0d2d8cc..72c57460cd 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/Speckle.Converters.Rhino7.csproj @@ -4,7 +4,7 @@ net48 - + 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 4366f8a089..1ae05128f7 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 @@ -134,8 +134,8 @@ public SOG.Brep Convert(IRhinoBrep target) speckleParent, edge.EdgeCurveIndex, edge.TrimIndices(), - edge.StartVertex?.VertexIndex ?? -1, - edge.EndVertex?.VertexIndex ?? -1, + edge.StartVertex.VertexIndex, + edge.EndVertex.VertexIndex, edge.ProxyCurveIsReversed, _intervalConverter.Convert(edge.Domain) ) @@ -155,8 +155,8 @@ public SOG.Brep Convert(IRhinoBrep target) (int)trim.IsoStatus, (SOG.BrepTrimType)trim.TrimType, trim.IsReversed(), - trim.StartVertex?.VertexIndex ?? -1, - trim.EndVertex?.VertexIndex ?? -1 + trim.StartVertex.VertexIndex, + trim.EndVertex.VertexIndex ) { Domain = _intervalConverter.Convert(trim.Domain) diff --git a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json index e0fff47189..9a85ec5d77 100644 --- a/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json +++ b/DUI3-DX/Converters/Rhino/Speckle.Converters.Rhino7/packages.lock.json @@ -16,9 +16,9 @@ }, "Speckle.Rhino7.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.27, )", - "resolved": "0.1.1-preview.0.27", - "contentHash": "/W0fXXPDb97aV/6mBdUbPE+kvfqg4s7cdxqhVB3JhMmSzdf27RULslD7R/dYIYFuLnmAB3iQgdz53YMVtMrRfg==" + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "TcbfXlRMnQRat1JodgW+YW5FflTYem1GGo9DtKA+6iAuVaYagN5dxsrM5LE6M3pCnEV9rkEQOjFo7sgnnbo4mw==" }, "GraphQL.Client": { "type": "Transitive", diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj index 85a5aa17d0..f1e4c53353 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/Speckle.Converters.Common.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json index 48b9076d29..202e7670ff 100644 --- a/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json +++ b/DUI3-DX/Sdk/Speckle.Converters.Common.Tests/packages.lock.json @@ -65,9 +65,9 @@ }, "Speckle.Revit2023.Interfaces": { "type": "Direct", - "requested": "[0.1.1-preview.0.27, )", - "resolved": "0.1.1-preview.0.27", - "contentHash": "/tVBpS/NsqtQtA90X3zeW4grMaELS+i0J9PqZwdxYBMmB8rzoYCzbBME7KoxIXQK1FHILKeJv2AHGWkgg1c+rg==" + "requested": "[0.1.1-preview.0.28, )", + "resolved": "0.1.1-preview.0.28", + "contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA==" }, "Castle.Core": { "type": "Transitive",