Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(autocad): arc to host conversions fixed to remove dependency on incoming arc plane and angle props #325

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading