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

unpack parameters as Dictionary #344

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
aee97d2
updates constructors and deprecates any unused code & functionality
clairekuang Oct 28, 2024
114356c
updates arcs and polycurves
clairekuang Oct 29, 2024
a400494
removes set only circle props
clairekuang Oct 29, 2024
47be734
updates box conversions
clairekuang Oct 30, 2024
eee9d17
Merge branch 'dev' into claire/cnx-687-purge-unused-classes-from-objects
clairekuang Oct 30, 2024
129395d
Merge branch 'dev' into claire/cnx-687-purge-unused-classes-from-objects
clairekuang Oct 30, 2024
6706def
fixes model curves and transforms
clairekuang Oct 31, 2024
232d859
Update ModelCurveToSpeckleTopLevelConverter.cs
clairekuang Nov 1, 2024
ff221a5
unpack parameters as Dictionnary
KatKatKateryna Nov 3, 2024
4595e35
Merge branch 'dev' into claire/cnx-687-purge-unused-classes-from-objects
clairekuang Nov 4, 2024
2d47837
Merge branch 'dev' into claire/cnx-687-purge-unused-classes-from-objects
clairekuang Nov 5, 2024
ad74743
bumps nugets
clairekuang Nov 5, 2024
a43332e
Merge branch 'claire/cnx-687-purge-unused-classes-from-objects' of ht…
clairekuang Nov 5, 2024
d65d53a
fixes package locks and arc
clairekuang Nov 5, 2024
ae08faa
updates rhino arc test
clairekuang Nov 5, 2024
bfc8807
Merge branch 'claire/cnx-687-purge-unused-classes-from-objects' into …
KatKatKateryna Nov 5, 2024
e8fede2
Merge branch 'dev' into claire_classes_ArcGIS_parameters
KatKatKateryna Nov 5, 2024
7d12302
add lists
KatKatKateryna Nov 5, 2024
9faedac
Merge branch 'dev' into claire_classes_ArcGIS_parameters
KatKatKateryna Nov 5, 2024
5343efc
refactor
KatKatKateryna Nov 6, 2024
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
Prev Previous commit
Next Next commit
updates arcs and polycurves
clairekuang committed Oct 29, 2024
commit 114356ca21ac9e05dd4b5757ef178289f6fde9c1
Original file line number Diff line number Diff line change
@@ -46,14 +46,13 @@ public ADB.Polyline Convert(SOG.Polycurve target)
break;
case SOG.Arc arc:
// POC: possibly endAngle and startAngle null?
double? angle = arc.endAngle - arc.startAngle;
angle = angle < 0 ? angle + 2 * Math.PI : angle;
if (angle is null)
double measure = arc.measure;
if (measure <= 0 || measure >= 2 * Math.PI)
{
throw new ArgumentNullException(nameof(target), "Cannot convert arc without angle value.");
throw new ArgumentOutOfRangeException(nameof(target), "Cannot convert arc with measure <= 0 or >= 2 pi");
}

var bulge = Math.Tan((double)angle / 4) * BulgeDirection(arc.startPoint, arc.midPoint, arc.endPoint);
var bulge = Math.Tan(measure / 4) * BulgeDirection(arc.startPoint, arc.midPoint, arc.endPoint);
polyline.AddVertexAt(count, _pointConverter.Convert(arc.startPoint).Convert2d(plane), bulge, 0, 0);
if (!target.closed && count == target.segments.Count - 1)
{
Original file line number Diff line number Diff line change
@@ -120,6 +120,9 @@ public SOG.Autocad.AutocadPolycurve Convert(ADB.Polyline3d target)
new()
{
segments = segments,
bulges = null,
tangents = null,
normal = null,
value = value,
polyType = polyType,
closed = target.Closed,
Original file line number Diff line number Diff line change
@@ -80,6 +80,7 @@ public SOG.Autocad.AutocadPolycurve Convert(ADB.Polyline target)
value = value,
bulges = bulges,
normal = normal,
tangents = null,
elevation = target.Elevation,
polyType = SOG.Autocad.AutocadPolyType.Light,
closed = target.Closed,
Original file line number Diff line number Diff line change
@@ -21,17 +21,12 @@ public SOG.Arc Convert(AG.CircularArc2d target)
{
string units = _settingsStore.Current.SpeckleUnits;

// find arc plane (normal is in clockwise dir)
// find arc plane (normal is in counterclockwise dir)
var center3 = new AG.Point3d(target.Center.X, target.Center.Y, 0);
AG.Plane plane = target.IsClockWise
? new AG.Plane(center3, AG.Vector3d.ZAxis.MultiplyBy(-1))
: new AG.Plane(center3, AG.Vector3d.ZAxis);

// calculate total angle. TODO: This needs to be validated across all possible arc orientations
var totalAngle = target.IsClockWise
? Math.Abs(target.EndAngle - target.StartAngle)
: Math.Abs(target.EndAngle - target.StartAngle);

double startParam = target.GetParameterOf(target.StartPoint);
double endParam = target.GetParameterOf(target.EndPoint);
AG.Point2d midPoint = target.EvaluatePoint(target.StartAngle + (target.EndAngle - target.StartAngle) / 2);
@@ -40,7 +35,6 @@ public SOG.Arc Convert(AG.CircularArc2d target)
var arc = new SOG.Arc()
{
plane = _planeConverter.Convert(plane),
radius = target.Radius,
startPoint = new()
{
x = target.StartPoint.X,
@@ -62,11 +56,7 @@ public SOG.Arc Convert(AG.CircularArc2d target)
z = 0,
units = units
},
startAngle = target.StartAngle,
endAngle = target.EndAngle,
angleRadians = totalAngle,
domain = new SOP.Interval { start = startParam, end = endParam },
length = target.GetLength(0, 1),
units = units
};

Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ IConverterSettingsStore<AutocadConversionSettings> settingsStore

public SOG.Arc Convert(AG.CircularArc3d target)
{
SOG.Plane plane = _planeConverter.Convert(target.GetPlane());
SOG.Plane plane = _planeConverter.Convert(new(target.Center, target.Normal));
SOG.Point start = _pointConverter.Convert(target.StartPoint);
SOG.Point end = _pointConverter.Convert(target.EndPoint);
double startParam = target.GetParameterOf(target.StartPoint);
@@ -31,20 +31,14 @@ public SOG.Arc Convert(AG.CircularArc3d target)
SOG.Point mid = _pointConverter.Convert(midPoint);

SOG.Arc arc =
new(
plane,
target.Radius,
target.StartAngle,
target.EndAngle,
target.EndAngle - target.StartAngle, // POC: testing, unsure
_settingsStore.Current.SpeckleUnits
)
new()
{
plane = plane,
startPoint = start,
endPoint = end,
midPoint = mid,
domain = new SOP.Interval { start = startParam, end = endParam },
length = target.GetLength(0, 1, 0.000)
units = _settingsStore.Current.SpeckleUnits,
};

return arc;
Original file line number Diff line number Diff line change
@@ -28,29 +28,23 @@ IConverterSettingsStore<AutocadConversionSettings> settingsStore

public SOG.Arc Convert(ADB.Arc target)
{
SOG.Plane plane = _planeConverter.Convert(target.GetPlane());
SOG.Plane plane = _planeConverter.Convert(new(target.Center, target.Normal));
SOG.Point start = _pointConverter.Convert(target.StartPoint);
SOG.Point end = _pointConverter.Convert(target.EndPoint);
SOG.Point mid = _pointConverter.Convert(target.GetPointAtDist(target.Length / 2.0));
SOP.Interval domain = new() { start = target.StartParam, end = target.EndParam };
SOG.Box bbox = _boxConverter.Convert(target.GeometricExtents);

SOG.Arc arc =
new(
plane,
target.Radius,
target.StartAngle,
target.EndAngle,
target.TotalAngle,
_settingsStore.Current.SpeckleUnits
)
new()
{
plane = plane,
startPoint = start,
endPoint = end,
midPoint = mid,
domain = domain,
length = target.Length,
bbox = bbox
bbox = bbox,
units = _settingsStore.Current.SpeckleUnits
};

return arc;
Original file line number Diff line number Diff line change
@@ -42,9 +42,11 @@ public SOG.Arc Convert(CDB.AlignmentSubEntityArc target)
double midPointX = target.CenterPoint.X + midScalingVectorX;
double midPointY = target.CenterPoint.Y + midScalingVectorY;

// find arc plane (normal is in clockwise dir)
// find arc plane (normal is in counterclockwise dir)
var center3 = new AG.Point3d(target.CenterPoint.X, target.CenterPoint.Y, 0);
AG.Plane plane = new AG.Plane(center3, AG.Vector3d.ZAxis);
AG.Plane plane = target.Clockwise
? new AG.Plane(center3, AG.Vector3d.ZAxis.MultiplyBy(-1))
: new AG.Plane(center3, AG.Vector3d.ZAxis);

// create arc
SOG.Arc arc =
@@ -72,9 +74,6 @@ public SOG.Arc Convert(CDB.AlignmentSubEntityArc target)
units = units
},
plane = _planeConverter.Convert(plane),
radius = target.Radius,
angleRadians = target.Delta,
length = target.Length,
units = units,

// additional alignment subentity props
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Speckle.Converters.Common.Objects;
using Speckle.Converters.RevitShared.Services;
using Speckle.Sdk.Common;

namespace Speckle.Converters.RevitShared.ToHost.Raw.Geometry;

@@ -23,31 +22,12 @@ public ArcConverterToHost(

public DB.Arc Convert(SOG.Arc target)
{
double startAngle;
double endAngle;

if (target.startAngle > target.endAngle)
{
startAngle = (double)target.endAngle;
endAngle = (double)target.startAngle;
}
else
{
startAngle = (double)target.startAngle.NotNull();
endAngle = (double)target.endAngle.NotNull();
}

var plane = _planeConverter.Convert(target.plane);

if (SOG.Point.Distance(target.startPoint, target.endPoint) < 1E-6)
{
// Endpoints coincide, it's a circle.
return DB.Arc.Create(
plane,
_scalingService.ScaleToNative(target.radius ?? 0, target.units),
startAngle,
endAngle
);
return DB.Arc.Create(plane, _scalingService.ScaleToNative(target.radius, target.units), 0, Math.PI * 2);
}

return DB.Arc.Create(
Original file line number Diff line number Diff line change
@@ -28,32 +28,20 @@ ScalingServiceToSpeckle scalingService

public SOG.Arc Convert(DB.Arc target)
{
// see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128
// Revit arcs are always counterclockwise in the arc normal direction. This aligns with Speckle arc plane convention.
var arcPlane = DB.Plane.CreateByOriginAndBasis(target.Center, target.XDirection, target.YDirection);
DB.XYZ center = target.Center;

DB.XYZ dir0 = target.GetEndPoint(0).Subtract(center).Normalize();
DB.XYZ dir1 = target.GetEndPoint(1).Subtract(center).Normalize();

DB.XYZ start = target.Evaluate(0, true);
DB.XYZ end = target.Evaluate(1, true);
DB.XYZ mid = target.Evaluate(0.5, true);

double startAngle = target.XDirection.AngleOnPlaneTo(dir0, target.Normal);
double endAngle = target.XDirection.AngleOnPlaneTo(dir1, target.Normal);

return new SOG.Arc()
{
plane = _planeConverter.Convert(arcPlane),
radius = _scalingService.ScaleLength(target.Radius),
startAngle = startAngle,
endAngle = endAngle,
angleRadians = endAngle - startAngle,
units = _converterSettings.Current.SpeckleUnits,
endPoint = _xyzToPointConverter.Convert(end),
startPoint = _xyzToPointConverter.Convert(start),
midPoint = _xyzToPointConverter.Convert(mid),
length = _scalingService.ScaleLength(target.Length),
domain = new Interval { start = target.GetEndParameter(0), end = target.GetEndParameter(1) }
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Speckle.Converters.Common;
using Speckle.Converters.Common;
using Speckle.Converters.Common.Objects;

namespace Speckle.Converters.Rhino.ToSpeckle.Raw;
@@ -9,7 +9,6 @@ public class ArcToSpeckleConverter : ITypedConverter<RG.Arc, SOG.Arc>
private readonly ITypedConverter<RG.Plane, SOG.Plane> _planeConverter;
private readonly ITypedConverter<RG.Box, SOG.Box> _boxConverter;
private readonly IConverterSettingsStore<RhinoConversionSettings> _settingsStore;

private readonly IBoxFactory _boxFactory;

public ArcToSpeckleConverter(
@@ -36,20 +35,14 @@ IBoxFactory boxFactory
/// 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.
/// </remarks>
public SOG.Arc Convert(RG.Arc target) =>
new(
_planeConverter.Convert(target.Plane),
target.Radius,
target.StartAngle,
target.EndAngle,
target.Angle,
_settingsStore.Current.SpeckleUnits
)
new()
{
plane = _planeConverter.Convert(target.Plane), // POC: need to validate if this follows the Speckle arc plane handedness convention
startPoint = _pointConverter.Convert(target.StartPoint),
midPoint = _pointConverter.Convert(target.MidPoint),
endPoint = _pointConverter.Convert(target.EndPoint),
domain = SOP.Interval.UnitInterval,
length = target.Length,
bbox = _boxConverter.Convert(_boxFactory.Create(target.BoundingBox()))
bbox = _boxConverter.Convert(_boxFactory.Create(target.BoundingBox())),
units = _settingsStore.Current.SpeckleUnits,
};
}