Skip to content

Commit

Permalink
fix(autocad): arc to host conversions fixed to remove dependency on i…
Browse files Browse the repository at this point in the history
…ncoming arc plane and angle props (#325)

* removes dependencies on incoming arc plane and angle props

* fixes incorrect root to speckle naming

* Update Speckle.Converters.AutocadShared.projitems
  • Loading branch information
clairekuang authored Oct 24, 2024
1 parent 08bf19f commit 900427a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

namespace Speckle.Converters.Autocad;

public class AutocadRootToHostConverter : IRootToSpeckleConverter
public class AutocadRootToSpeckleConverter : IRootToSpeckleConverter
{
private readonly IConverterManager<IToSpeckleTopLevelConverter> _toSpeckle;
private readonly IConverterSettingsStore<AutocadConversionSettings> _settingsStore;

public AutocadRootToHostConverter(
public AutocadRootToSpeckleConverter(
IConverterManager<IToSpeckleTopLevelConverter> toSpeckle,
IConverterSettingsStore<AutocadConversionSettings> settingsStore
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Speckle.Converters.Common;
using Speckle.Converters.Common.Registration;
Expand All @@ -14,7 +14,7 @@ public static void AddAutocadConverters(this IServiceCollection serviceCollectio
//register types by default
serviceCollection.AddMatchingInterfacesAsTransient(converterAssembly);
// add single root converter
serviceCollection.AddRootCommon<AutocadRootToHostConverter>(converterAssembly);
serviceCollection.AddRootCommon<AutocadRootToSpeckleConverter>(converterAssembly);

// add application converters and context stack
serviceCollection.AddApplicationConverters<AutocadToSpeckleUnitConverter, ADB.UnitsValue>(converterAssembly);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)AutocadConversionSettings.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AutocadConversionSettingsFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AutocadRootToHostConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AutocadRootToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AutocadConversionContextStack.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AutocadToSpeckleUnitConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\EntityExtensions.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public ADB.Arc Convert(SOG.Arc target)
AG.CircularArc3d circularArc = _arcConverter.Convert(target);

// calculate adjusted start and end angles from circularArc reference
AG.Plane plane = _planeConverter.Convert(target.plane);
double angle = circularArc.ReferenceVector.AngleOnPlane(plane);
double startAngle = circularArc.StartAngle + angle;
double endAngle = circularArc.EndAngle + angle;
// for some reason, if just the circular arc start and end angle props are used, this moves the endpoints of the created arc
// so we need to calculate the adjusted start and end angles from the circularArc reference vector.
AG.Plane plane = new(circularArc.Center, circularArc.Normal);
double angleOnPlane = circularArc.ReferenceVector.AngleOnPlane(plane);
double adjustedStartAngle = circularArc.StartAngle + angleOnPlane;
double adjustEndAngle = circularArc.EndAngle + angleOnPlane;

return new(circularArc.Center, circularArc.Normal, circularArc.Radius, startAngle, endAngle);
return new(circularArc.Center, circularArc.Normal, circularArc.Radius, adjustedStartAngle, adjustEndAngle);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ public AG.CircularArc3d Convert(SOG.Arc target)
AG.Point3d end = _pointConverter.Convert(target.endPoint);
AG.Point3d mid = _pointConverter.Convert(target.midPoint);
AG.CircularArc3d arc = new(start, mid, end);

AG.Vector3d normal = _vectorConverter.Convert(target.plane.normal);
AG.Vector3d xdir = _vectorConverter.Convert(target.plane.xdir);
arc.SetAxes(normal, xdir);

if (target.startAngle is double startAngle && target.endAngle is double endAngle)
{
arc.SetAngles(startAngle, endAngle);
}

return arc;
}
}

0 comments on commit 900427a

Please sign in to comment.