Skip to content

Commit

Permalink
0.14.0 update
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Mar 3, 2022
1 parent 8fada2f commit c72087e
Show file tree
Hide file tree
Showing 18 changed files with 832 additions and 141 deletions.
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Robert McNeel & Associates
Copyright (c) 2022 Robert McNeel & Associates

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
32 changes: 28 additions & 4 deletions compute_rhino3d/AreaMassProperties.py
Expand Up @@ -140,7 +140,31 @@ def Compute6(brep, area, firstMoments, secondMoments, productMoments, multiple=F
return response


def Compute7(surface, multiple=False):
def Compute7(brep, area, firstMoments, secondMoments, productMoments, relativeTolerance, absoluteTolerance, multiple=False):
"""
Compute the AreaMassProperties for a single Brep.
Args:
brep (Brep): Brep to measure.
area (bool): True to calculate area.
firstMoments (bool): True to calculate area first moments, area, and area centroid.
secondMoments (bool): True to calculate area second moments.
productMoments (bool): True to calculate area product moments.
relativeTolerance (double): The relative tolerance used for the calculation. In overloads of this function where tolerances are not specified, 1.0e-6 is used.
absoluteTolerance (double): The absolute tolerancwe used for the calculation. In overloads of this function where tolerances are not specified, 1.0e-6 is used.
Returns:
AreaMassProperties: The AreaMassProperties for the given Brep or None on failure.
"""
url = "rhino/geometry/areamassproperties/compute-brep_bool_bool_bool_bool_double_double"
if multiple: url += "?multiple=true"
args = [brep, area, firstMoments, secondMoments, productMoments, relativeTolerance, absoluteTolerance]
if multiple: args = list(zip(brep, area, firstMoments, secondMoments, productMoments, relativeTolerance, absoluteTolerance))
response = Util.ComputeFetch(url, args)
return response


def Compute8(surface, multiple=False):
"""
Computes an AreaMassProperties for a surface.
Expand All @@ -158,7 +182,7 @@ def Compute7(surface, multiple=False):
return response


def Compute8(surface, area, firstMoments, secondMoments, productMoments, multiple=False):
def Compute9(surface, area, firstMoments, secondMoments, productMoments, multiple=False):
"""
Compute the AreaMassProperties for a single Surface.
Expand All @@ -180,7 +204,7 @@ def Compute8(surface, area, firstMoments, secondMoments, productMoments, multipl
return response


def Compute9(geometry, multiple=False):
def Compute10(geometry, multiple=False):
"""
Computes the Area properties for a collection of geometric objects.
At present only Breps, Surfaces, Meshes and Planar Closed Curves are supported.
Expand All @@ -199,7 +223,7 @@ def Compute9(geometry, multiple=False):
return response


def Compute10(geometry, area, firstMoments, secondMoments, productMoments, multiple=False):
def Compute11(geometry, area, firstMoments, secondMoments, productMoments, multiple=False):
"""
Computes the AreaMassProperties for a collection of geometric objects.
At present only Breps, Surfaces, Meshes and Planar Closed Curves are supported.
Expand Down
79 changes: 79 additions & 0 deletions compute_rhino3d/Brep.py
Expand Up @@ -5,6 +5,39 @@
pass # python 3


def IsBox(thisBrep, multiple=False):
"""
Verifies a Brep is in the form of a solid box.
Returns:
bool: True if the Brep is a solid box, False otherwise.
"""
url = "rhino/geometry/brep/isbox-brep"
if multiple: url += "?multiple=true"
args = [thisBrep]
if multiple: args = [[item] for item in thisBrep]
response = Util.ComputeFetch(url, args)
return response


def IsBox1(thisBrep, tolerance, multiple=False):
"""
Verifies a Brep is in the form of a solid box.
Args:
tolerance (double): The tolerance used to determine if faces are planar and to compare face normals.
Returns:
bool: True if the Brep is a solid box, False otherwise.
"""
url = "rhino/geometry/brep/isbox-brep_double"
if multiple: url += "?multiple=true"
args = [thisBrep, tolerance]
if multiple: args = list(zip(thisBrep, tolerance))
response = Util.ComputeFetch(url, args)
return response


def ChangeSeam(face, direction, parameter, tolerance, multiple=False):
"""
Change the seam of a closed trimmed surface.
Expand Down Expand Up @@ -1220,6 +1253,40 @@ def CreateOffsetBrep(brep, distance, solid, extend, tolerance, multiple=False):
return response


def CreateOffsetBrep1(brep, distance, solid, extend, shrink, tolerance, multiple=False):
"""
Offsets a Brep.
Args:
brep (Brep): The Brep to offset.
distance (double): The distance to offset. This is a signed distance value with respect to
face normals and flipped faces.
solid (bool): If true, then the function makes a closed solid from the input and offset
surfaces by lofting a ruled surface between all of the matching edges.
extend (bool): If true, then the function maintains the sharp corners when the original
surfaces have sharps corner. If False, then the function creates fillets
at sharp corners in the original surfaces.
shrink (bool): If true, then the function shrinks the underlying surfaces to their face's outer boundary loop.
tolerance (double): The offset tolerance.
Returns:
Brep[]: Array of Breps if successful. If the function succeeds in offsetting, a
single Brep will be returned. Otherwise, the array will contain the
offset surfaces, outBlends will contain the set of blends used to fill
in gaps (if extend is false), and outWalls will contain the set of wall
surfaces that was supposed to join the offset to the original (if solid
is true).
outBlends (Brep[]): The results of the calculation.
outWalls (Brep[]): The results of the calculation.
"""
url = "rhino/geometry/brep/createoffsetbrep-brep_double_bool_bool_bool_double_breparray_breparray"
if multiple: url += "?multiple=true"
args = [brep, distance, solid, extend, shrink, tolerance]
if multiple: args = list(zip(brep, distance, solid, extend, shrink, tolerance))
response = Util.ComputeFetch(url, args)
return response


def RemoveFins(thisBrep, multiple=False):
"""
Recursively removes any Brep face with a naked edge. This function is only useful for non-manifold Breps.
Expand Down Expand Up @@ -1852,6 +1919,18 @@ def CreateCurvatureAnalysisMesh(brep, state, multiple=False):
return response


def DestroyRegionTopology(thisBrep, multiple=False):
"""
Destroys a Brep's region topology information.
"""
url = "rhino/geometry/brep/destroyregiontopology-brep"
if multiple: url += "?multiple=true"
args = [thisBrep]
if multiple: args = [[item] for item in thisBrep]
response = Util.ComputeFetch(url, args)
return response


def GetRegions(thisBrep, multiple=False):
"""
Gets an array containing all regions in this brep.
Expand Down
159 changes: 95 additions & 64 deletions compute_rhino3d/Curve.py
Expand Up @@ -132,6 +132,54 @@ def CreateFilletCornersCurve(curve, radius, tolerance, angleTolerance, multiple=
return response


def JoinCurves(inputCurves, joinTolerance, preserveDirection, multiple=False):
"""
Joins a collection of curve segments together.
Args:
inputCurves (IEnumerable<Curve>): An array, a list or any enumerable set of curve segments to join.
joinTolerance (double): Joining tolerance,
i.e. the distance between segment end-points that is allowed.
preserveDirection (bool): If true, curve endpoints will be compared to curve start points.If false, all start and endpoints will be compared and copies of input curves may be reversed in output.
Returns:
Curve[]: An array of joint curves. This array can be empty.
"""
url = "rhino/geometry/curve/joincurves-curvearray_double_bool"
if multiple: url += "?multiple=true"
args = [inputCurves, joinTolerance, preserveDirection]
if multiple: args = list(zip(inputCurves, joinTolerance, preserveDirection))
response = Util.ComputeFetch(url, args)
response = Util.DecodeToCommonObject(response)
return response


def CreateArcLineArcBlend(startPt, startDir, endPt, endDir, radius, multiple=False):
"""
Creates an arc-line-arc blend curve between two curves.
The output is generally a PolyCurve with three segments: arc, line, arc.
In some cases, one or more of those segments will be absent because they would have 0 length.
If there is only a single segment, the result will either be an ArcCurve or a LineCurve.
Args:
startPt (Point3d): Start of the blend curve.
startDir (Vector3d): Start direction of the blend curve.
endPt (Point3d): End of the blend curve.
endDir (Vector3d): End direction of the arc blend curve.
radius (double): The radius of the arc segments.
Returns:
Curve: The blend curve if successful, False otherwise.
"""
url = "rhino/geometry/curve/createarclinearcblend-point3d_vector3d_point3d_vector3d_double"
if multiple: url += "?multiple=true"
args = [startPt, startDir, endPt, endDir, radius]
if multiple: args = list(zip(startPt, startDir, endPt, endDir, radius))
response = Util.ComputeFetch(url, args)
response = Util.DecodeToCommonObject(response)
return response


def CreateArcBlend(startPt, startDir, endPt, endDir, controlPointLengthRatio, multiple=False):
"""
Creates a polycurve consisting of two tangent arc segments that connect two points and two directions.
Expand Down Expand Up @@ -273,6 +321,31 @@ def CreateBlendCurve2(curve0, t0, reverse0, continuity0, curve1, t1, reverse1, c
return response


def CreateMatchCurve(curve0, reverse0, continuity, curve1, reverse1, preserve, average, multiple=False):
"""
Changes a curve end to meet a specified curve with a specified continuity.
Args:
curve0 (Curve): The open curve to change.
reverse0 (bool): Reverse the directon of the curve to change before matching.
continuity (BlendContinuity): The continuity at the curve end.
curve1 (Curve): The open curve to match.
reverse1 (bool): Reverse the directon of the curve to match before matching.
preserve (PreserveEnd): Prevent modification of the curvature at the end opposite the match for curves with fewer than six control points.
average (bool): Adjust both curves to match each other.
Returns:
Curve[]: The results of the curve matching, if successful, otherwise an empty array.
"""
url = "rhino/geometry/curve/creatematchcurve-curve_bool_blendcontinuity_curve_bool_preserveend_bool"
if multiple: url += "?multiple=true"
args = [curve0, reverse0, continuity, curve1, reverse1, preserve, average]
if multiple: args = list(zip(curve0, reverse0, continuity, curve1, reverse1, preserve, average))
response = Util.ComputeFetch(url, args)
response = Util.DecodeToCommonObject(response)
return response


def CreateTweenCurves(curve0, curve1, numCurves, multiple=False):
"""
Creates curves between two open or closed input curves. Uses the control points of the curves for finding tween curves.
Expand Down Expand Up @@ -417,68 +490,6 @@ def CreateTweenCurvesWithSampling1(curve0, curve1, numCurves, numSamples, tolera
return response


def JoinCurves(inputCurves, multiple=False):
"""
Joins a collection of curve segments together.
Args:
inputCurves (IEnumerable<Curve>): Curve segments to join.
Returns:
Curve[]: An array of curves which contains.
"""
url = "rhino/geometry/curve/joincurves-curvearray"
if multiple: url += "?multiple=true"
args = [inputCurves]
if multiple: args = [[item] for item in inputCurves]
response = Util.ComputeFetch(url, args)
response = Util.DecodeToCommonObject(response)
return response


def JoinCurves1(inputCurves, joinTolerance, multiple=False):
"""
Joins a collection of curve segments together.
Args:
inputCurves (IEnumerable<Curve>): An array, a list or any enumerable set of curve segments to join.
joinTolerance (double): Joining tolerance,
i.e. the distance between segment end-points that is allowed.
Returns:
Curve[]: An array of joint curves. This array can be empty.
"""
url = "rhino/geometry/curve/joincurves-curvearray_double"
if multiple: url += "?multiple=true"
args = [inputCurves, joinTolerance]
if multiple: args = list(zip(inputCurves, joinTolerance))
response = Util.ComputeFetch(url, args)
response = Util.DecodeToCommonObject(response)
return response


def JoinCurves2(inputCurves, joinTolerance, preserveDirection, multiple=False):
"""
Joins a collection of curve segments together.
Args:
inputCurves (IEnumerable<Curve>): An array, a list or any enumerable set of curve segments to join.
joinTolerance (double): Joining tolerance,
i.e. the distance between segment end-points that is allowed.
preserveDirection (bool): If true, curve endpoints will be compared to curve start points.If false, all start and endpoints will be compared and copies of input curves may be reversed in output.
Returns:
Curve[]: An array of joint curves. This array can be empty.
"""
url = "rhino/geometry/curve/joincurves-curvearray_double_bool"
if multiple: url += "?multiple=true"
args = [inputCurves, joinTolerance, preserveDirection]
if multiple: args = list(zip(inputCurves, joinTolerance, preserveDirection))
response = Util.ComputeFetch(url, args)
response = Util.DecodeToCommonObject(response)
return response


def MakeEndsMeet(curveA, adjustStartCurveA, curveB, adjustStartCurveB, multiple=False):
"""
Makes adjustments to the ends of one or both input curves so that they meet at a point.
Expand Down Expand Up @@ -1107,8 +1118,9 @@ def PlanarCurveCollision(curveA, curveB, testPlane, tolerance, multiple=False):

def DuplicateSegments(thisCurve, multiple=False):
"""
Polylines will be exploded into line segments. ExplodeCurves will
return the curves in topological order.
Duplicates curve segments.
Explodes polylines, polycurves and G1 discontinuous NURBS curves.
Single segment curves, such as lines, arcs, unkinked NURBS curves, are duplicated.
Returns:
Curve[]: An array of all the segments that make up this curve.
Expand Down Expand Up @@ -1310,6 +1322,25 @@ def MakeClosed(thisCurve, tolerance, multiple=False):
return response


def CombineShortSegments(thisCurve, tolerance, multiple=False):
"""
Looks for segments that are shorter than tolerance that can be combined.
For NURBS of degree greater than 1, spans are combined by removing
knots. Similarly for NURBS segments of polycurves. Otherwise,
RemoveShortSegments() is called. Does not change the domain, but it will
change the relative parameterization.
Returns:
bool: True if short segments were combined or removed. False otherwise.
"""
url = "rhino/geometry/curve/combineshortsegments-curve_double"
if multiple: url += "?multiple=true"
args = [thisCurve, tolerance]
if multiple: args = list(zip(thisCurve, tolerance))
response = Util.ComputeFetch(url, args)
return response


def LcoalClosestPoint(thisCurve, testPoint, seed, multiple=False):
"""
Find parameter of the point on a curve that is locally closest to
Expand Down

0 comments on commit c72087e

Please sign in to comment.