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

Geometry_Engine: Expose tolerances #1170

Merged
merged 2 commits into from
Sep 6, 2019
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
33 changes: 22 additions & 11 deletions Geometry_Engine/Query/Centroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,31 @@ public static partial class Query
/***************************************************/
/**** Public Methods - Curves ****/
/***************************************************/

[Deprecated("2.4", "Deprecated to expose tolerance as optional parameter for greater control", null, "Centroid(this Polyline curve, double tolerance = Tolerance.Distance)")]
public static Point Centroid(this Polyline curve)
{
if (!curve.IsPlanar())
return curve.Centroid(Tolerance.Distance);
}

[Deprecated("2.4", "Deprecated to expose tolerance as optional parameter for greater control", null, "Centroid(this PolyCurve curve, double tolerance = Tolerance.Distance)")]
public static Point Centroid(this PolyCurve curve)
{
return curve.Centroid(Tolerance.Distance);
}

public static Point Centroid(this Polyline curve, double tolerance = Tolerance.Distance)
{
if (!curve.IsPlanar(tolerance))
{
Reflection.Compute.RecordError("Input must be planar.");
return null;
}
else if (!curve.IsClosed())
else if (!curve.IsClosed(tolerance))
{
Reflection.Compute.RecordError("Curve is not closed. Input must be a polygon");
return null;
}
else if (curve.IsSelfIntersecting())
else if (curve.IsSelfIntersecting(tolerance))
{
Reflection.Compute.RecordWarning("Curve is self intersecting");
return null;
Expand Down Expand Up @@ -112,19 +123,19 @@ public static Point Centroid(this Polyline curve)

/***************************************************/

public static Point Centroid(this PolyCurve curve)
public static Point Centroid(this PolyCurve curve, double tolerance = Tolerance.Distance)
{
if (!curve.IsPlanar())
if (!curve.IsPlanar(tolerance))
{
Reflection.Compute.RecordError("Input must be planar.");
return null;
}
else if (!curve.IsClosed())
else if (!curve.IsClosed(tolerance))
{
Reflection.Compute.RecordError("Curve is not closed.");
return null;
}
else if (curve.IsSelfIntersecting())
else if (curve.IsSelfIntersecting(tolerance))
{
Reflection.Compute.RecordWarning("Curve is self intersecting");
return null;
Expand Down Expand Up @@ -288,9 +299,9 @@ private static Point CircularSegmentCentroid(this Arc arc)
/***************************************************/

public static Point ICentroid(this ICurve curve)
{
return Centroid(curve as dynamic);
}
{
return Centroid(curve as dynamic);
}

/***************************************************/
}
Expand Down
28 changes: 20 additions & 8 deletions Geometry_Engine/Query/Normal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,33 @@ public static List<Vector> Normals(this Mesh mesh)
/***************************************************/
/**** Public Methods - Curves ****/
/***************************************************/


[Deprecated("2.4", "Deprecated to expose tolerance as optional parameter for greater control", null, "Normal(this Polyline curve, double tolerance = Tolerance.Distance)")]
public static Vector Normal(this Polyline curve)
{
return curve.Normal(Tolerance.Distance);
}

[Deprecated("2.4", "Deprecated to expose tolerance as optional parameter for greater control", null, "Normal(this PolyCurve curve, double tolerance = Tolerance.Distance)")]
public static Vector Normal(this PolyCurve curve)
{
return curve.Normal(Tolerance.Distance);
}

if (!curve.IsPlanar())
public static Vector Normal(this Polyline curve, double tolerance = Tolerance.Distance)
{

if (!curve.IsPlanar(tolerance))
{
Reflection.Compute.RecordError("Input must be planar.");
return null;
}
else if (!curve.IsClosed())
else if (!curve.IsClosed(tolerance))
{
Reflection.Compute.RecordError("Curve is not closed. Input must be a polygon");
return null;
}
else if (curve.IsSelfIntersecting())
else if (curve.IsSelfIntersecting(tolerance))
{
Reflection.Compute.RecordWarning("Curve is self intersecting");
return null;
Expand All @@ -124,20 +136,20 @@ public static Vector Normal(this Polyline curve)

/***************************************************/

public static Vector Normal(this PolyCurve curve)
public static Vector Normal(this PolyCurve curve, double tolerance = Tolerance.Distance)
{

if (!curve.IsPlanar())
if (!curve.IsPlanar(tolerance))
{
Reflection.Compute.RecordError("Input must be planar.");
return null;
}
else if (!curve.IsClosed())
else if (!curve.IsClosed(tolerance))
{
Reflection.Compute.RecordError("Curve is not closed. Input must be a polygon");
return null;
}
else if (curve.IsSelfIntersecting())
else if (curve.IsSelfIntersecting(tolerance))
{
Reflection.Compute.RecordWarning("Curve is self intersecting");
return null;
Expand Down