Skip to content

Instantly share code, notes, and snippets.

@theTonyHo
Last active August 29, 2015 14:05
Show Gist options
  • Save theTonyHo/e0296ad61e22f26558d6 to your computer and use it in GitHub Desktop.
Save theTonyHo/e0296ad61e22f26558d6 to your computer and use it in GitHub Desktop.
PlanarClosedCurveContainment with Curve Geometries
def PlanarClosedCurveContainment(curve_a, curve_b, plane=None, tolerance=None):
"""Determines the relationship between the regions bounded by two coplanar
simple closed curves
Parameters:
curve_a, curve_b = identifiers of two planar, closed curves
plane[opt] = test plane. If omitted, the currently active construction
plane is used
tolerance[opt] = if omitted, the document absolute tolerance is used
Returns:
a number identifying the relationship if successful
0 = the regions bounded by the curves are disjoint
1 = the two curves intersect
2 = the region bounded by curve_a is inside of curve_b
3 = the region bounded by curve_b is inside of curve_a
None if not successful
"""
if tolerance is None or tolerance<=0:
tolerance = scriptcontext.doc.ModelAbsoluteTolerance
if plane:
plane = rhutil.coerceplane(plane)
else:
plane = scriptcontext.doc.Views.ActiveView.ActiveViewport.ConstructionPlane()
rc = Rhino.Geometry.Curve.PlanarClosedCurveRelationship(curve_a, curve_b, plane, tolerance)
return int(rc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment