Skip to content
Open
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
23 changes: 7 additions & 16 deletions Geometry_Engine/Modify/Extend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
[Input("tangentExtensions", "True - extends on tangent lines\nFalse - extends by curve's shape.")]
[Input("tolerance", "Tolerance value used for geometry processing.", typeof(Length))]
[Output("curve", "Extended curve.")]
public static Line Extend(this Line curve, double start = 0.0, double end = 0.0, bool tangentExtensions = false, double tolerance = Tolerance.Distance)

Check warning on line 47 in Geometry_Engine/Modify/Extend.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Geometry_Engine/Modify/Extend.cs#L47

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType

Check warning on line 47 in Geometry_Engine/Modify/Extend.cs

View workflow job for this annotation

GitHub Actions / ci-code-compliance

Geometry_Engine/Modify/Extend.cs#L47

Geometry_Engine/Modify/Extend.cs#L47: Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
{
if (start + end + curve.Length() < tolerance)
{
Expand All @@ -68,37 +68,28 @@
{
if (tangentExtensions)
return curve.ExtendTangent(start, end, tolerance);

if (curve.StartAngle != 0)
{
curve.CoordinateSystem = curve.CoordinateSystem.Rotate(curve.CoordinateSystem.Origin, curve.CoordinateSystem.Z, curve.StartAngle);
curve.EndAngle = -curve.StartAngle;
curve.StartAngle = 0;
}


double startAngleExt = start / curve.Radius;
double endAngleExt = end / curve.Radius;

if (startAngleExt + endAngleExt + curve.EndAngle < tolerance)
if (endAngleExt + startAngleExt - curve.StartAngle + curve.EndAngle < tolerance)
{
Base.Compute.RecordError("Negative extend values are smaller than curve length.");
return null;
}

if (startAngleExt + endAngleExt + curve.EndAngle - (2 * Math.PI) > tolerance)
if (Math.Abs(startAngleExt + endAngleExt + curve.EndAngle - curve.StartAngle) - (2 * Math.PI) > tolerance)
{
Base.Compute.RecordError("Extension values too great.");
return null;
}
Cartesian oldCS = curve.CoordinateSystem;
Cartesian newCS = oldCS.Rotate(oldCS.Origin, oldCS.Z, -startAngleExt);

return new Arc
{
CoordinateSystem = newCS,
CoordinateSystem = curve.CoordinateSystem,
Radius = curve.Radius,
StartAngle = 0,
EndAngle = curve.EndAngle + startAngleExt + endAngleExt
StartAngle = curve.StartAngle - startAngleExt,
EndAngle = curve.EndAngle + endAngleExt,
};
}

Expand All @@ -111,7 +102,7 @@
[Input("tangentExtensions", "True - extends on tangent lines\nFalse - extends by curve's shape.")]
[Input("tolerance", "Tolerance value used for geometry processing.", typeof(Length))]
[Output("curve", "Extended curve.")]
public static Circle Extend(this Circle curve, double start = 0.0, double end = 0.0, bool tangentExtensions = false, double tolerance = Tolerance.Distance)

Check warning on line 105 in Geometry_Engine/Modify/Extend.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Geometry_Engine/Modify/Extend.cs#L105

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType

Check warning on line 105 in Geometry_Engine/Modify/Extend.cs

View workflow job for this annotation

GitHub Actions / ci-code-compliance

Geometry_Engine/Modify/Extend.cs#L105

Geometry_Engine/Modify/Extend.cs#L105: Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
{
Base.Compute.RecordNote("Cannot Trim or Extend closed curves.");
return curve;
Expand All @@ -126,7 +117,7 @@
[Input("tangentExtensions", "True - extends on tangent lines\nFalse - extends by curve's shape.")]
[Input("tolerance", "Tolerance value used for geometry processing.", typeof(Length))]
[Output("curve", "Extended curve.")]
public static Ellipse Extend(this Ellipse curve, double start = 0.0, double end = 0.0, bool tangentExtensions = false, double tolerance = Tolerance.Distance)

Check warning on line 120 in Geometry_Engine/Modify/Extend.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Geometry_Engine/Modify/Extend.cs#L120

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType

Check warning on line 120 in Geometry_Engine/Modify/Extend.cs

View workflow job for this annotation

GitHub Actions / ci-code-compliance

Geometry_Engine/Modify/Extend.cs#L120

Geometry_Engine/Modify/Extend.cs#L120: Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
{
Base.Compute.RecordNote("Cannot Trim or Extend closed curves.");
return curve;
Expand All @@ -141,7 +132,7 @@
[Input("tangentExtensions", "True - extends on tangent lines\nFalse - extends by curve's shape.")]
[Input("tolerance", "Tolerance value used for geometry processing.", typeof(Length))]
[Output("curve", "Extended curve.")]
public static Polyline Extend(this Polyline curve, double start = 0.0, double end = 0.0, bool tangentExtensions = false, double tolerance = Tolerance.Distance)

Check warning on line 135 in Geometry_Engine/Modify/Extend.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Geometry_Engine/Modify/Extend.cs#L135

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType

Check warning on line 135 in Geometry_Engine/Modify/Extend.cs

View workflow job for this annotation

GitHub Actions / ci-code-compliance

Geometry_Engine/Modify/Extend.cs#L135

Geometry_Engine/Modify/Extend.cs#L135: Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
{
if (curve.IsClosed(tolerance))
{
Expand Down Expand Up @@ -209,7 +200,7 @@
[Input("tangentExtensions", "True - extends on tangent lines\nFalse - extends by curve's shape.")]
[Input("tolerance", "Tolerance value used for geometry processing.", typeof(Length))]
[Output("curve", "Extended curve.")]
public static PolyCurve Extend(this PolyCurve curve, double start = 0.0, double end = 0.0, bool tangentExtensions = false, double tolerance = Tolerance.Distance)

Check warning on line 203 in Geometry_Engine/Modify/Extend.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Geometry_Engine/Modify/Extend.cs#L203

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType

Check warning on line 203 in Geometry_Engine/Modify/Extend.cs

View workflow job for this annotation

GitHub Actions / ci-code-compliance

Geometry_Engine/Modify/Extend.cs#L203

Geometry_Engine/Modify/Extend.cs#L203: Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
{
if (tangentExtensions)
return curve.ExtendTangent(start, end, tolerance);
Expand Down Expand Up @@ -278,7 +269,7 @@
[Input("tangentExtensions", "True - extends on tangent lines\nFalse - extends by curve's shape.")]
[Input("tolerance", "Tolerance value used for geometry processing.", typeof(Length))]
[Output("curve", "Extended curve.")]
public static ICurve IExtend(this ICurve curve, double start = 0.0, double end = 0.0, bool tangentExtensions = false, double tolerance = Tolerance.Distance)

Check warning on line 272 in Geometry_Engine/Modify/Extend.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Geometry_Engine/Modify/Extend.cs#L272

Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType

Check warning on line 272 in Geometry_Engine/Modify/Extend.cs

View workflow job for this annotation

GitHub Actions / ci-code-compliance

Geometry_Engine/Modify/Extend.cs#L272

Geometry_Engine/Modify/Extend.cs#L272: Modify methods should return void, or their return type should be different to the input type of their first parameter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/ModifyReturnsDifferentType
{
return Extend(curve as dynamic, start, end, tangentExtensions, tolerance);
}
Expand Down
Loading