Skip to content

Commit

Permalink
update curve examples to use plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Jan 16, 2024
1 parent 7aa7e0b commit c32a0a5
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 29 deletions.
5 changes: 4 additions & 1 deletion docs/examples/curves/curve_closest_parameters_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
# this doesn't make much sense from an API pov
# should be like with intersections
parameters, distance = curve0.closest_parameters_curve(curve1, return_distance=True)

points = curve0.closest_points_curve(curve1, return_distance=False)

# =============================================================================
# Visualization
# =============================================================================

view = App()

view.add(curve0.to_polyline(), linewidth=3)
Expand Down
5 changes: 4 additions & 1 deletion docs/examples/curves/curve_closest_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
from compas.geometry import NurbsCurve
from compas_view2.app import App


points = [Point(0, 0, 0), Point(3, 0, 2), Point(6, 0, -3), Point(8, 0, 0)]
curve = NurbsCurve.from_interpolation(points)

point = Point(2, -1, 0)
closest, t = curve.closest_point(point, return_parameter=True)

# =============================================================================
# Visualization
# =============================================================================

view = App()

view.add(curve.to_polyline(), linewidth=3)
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/curves/curve_comparison1.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# type: ignore

from compas.geometry import Point
from compas.geometry import Polyline, Bezier
from compas.geometry import Point, Polyline, Bezier
from compas.geometry import NurbsCurve
from compas_view2.app import App

Expand Down Expand Up @@ -36,7 +35,7 @@
)

# ==============================================================================
# Visualisation
# Visualization
# ==============================================================================

view = App()
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/curves/curve_comparison2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# type: ignore

from compas.geometry import Point
from compas.geometry import Polyline, Bezier
from compas.geometry import Point, Polyline, Bezier
from compas_occ.geometry import OCCNurbsCurve
from compas_view2.app import App

Expand Down Expand Up @@ -60,7 +59,7 @@
)

# ==============================================================================
# Visualisation
# Visualization
# ==============================================================================

view = App()
Expand Down
9 changes: 7 additions & 2 deletions docs/examples/curves/curve_divide.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from compas.utilities import pairwise
from compas.geometry import Point
from compas_occ.geometry import OCCNurbsCurve
from compas.geometry import NurbsCurve
from compas_view2.app import App

points = [Point(0, 0, 0), Point(3, -6, 0), Point(6, 2, 0), Point(9, -2, 0)]
curve = OCCNurbsCurve.from_points(points)
curve = NurbsCurve.from_points(points)

N = 10
params, points = curve.divide(N, return_points=True)
Expand All @@ -15,7 +15,12 @@
segment = curve.segmented(u, v)
print(segment.length())

# =============================================================================
# Visualization
# =============================================================================

viewer = App()

viewer.add(curve.to_polyline())
for point in points:
viewer.add(point)
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/curves/curve_from_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

from compas.geometry import Polyline
from compas.geometry import Circle
from compas_occ.geometry import OCCNurbsCurve
from compas.geometry import NurbsCurve
from compas_view2.app import App


circle = Circle(1.0)
curve = OCCNurbsCurve.from_circle(circle)
curve = NurbsCurve.from_circle(circle)

# ==============================================================================
# Visualisation
Expand Down
5 changes: 3 additions & 2 deletions docs/examples/curves/curve_from_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from compas.geometry import Point
from compas.geometry import Polyline
from compas.geometry import NurbsCurve
from compas_view2.app import App

# from compas.geometry import Polyline
# from compas_view2.app import App


points = [Point(0, 0, 0), Point(3, 6, 0), Point(6, -3, 3), Point(10, 0, 0)]
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/curves/curve_from_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from compas.geometry import Line
from compas.geometry import Ellipse
from compas.utilities import pairwise
from compas_occ.geometry import OCCNurbsCurve
from compas.geometry import NurbsCurve
from compas_view2.app import App
from compas_view2.objects import Collection


ellipse = Ellipse(2.0, 1.0)
curve = OCCNurbsCurve.from_ellipse(ellipse)
curve = NurbsCurve.from_ellipse(ellipse)

# ==============================================================================
# Visualisation
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/curves/curve_from_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from compas.geometry import Point
from compas.geometry import Bezier
from compas_occ.geometry import OCCNurbsCurve
from compas.geometry import NurbsCurve
from compas_view2.app import App
from compas_view2.objects import Collection

Expand All @@ -11,7 +11,7 @@
bezier = Bezier(points)
points = bezier.to_points(10)

curve = OCCNurbsCurve.from_interpolation(points)
curve = NurbsCurve.from_interpolation(points)

# ==============================================================================
# Visualisation
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/curves/curve_from_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from compas.geometry import Point
from compas.geometry import Line
from compas_occ.geometry import OCCNurbsCurve
from compas.geometry import NurbsCurve
from compas_view2.app import App
from compas_view2.objects import Collection


line = Line(Point(0, 0, 0), Point(3, 3, 0))
curve = OCCNurbsCurve.from_line(line)
curve = NurbsCurve.from_line(line)

# ==============================================================================
# Visualisation
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/curves/curve_from_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from compas.geometry import Point
from compas.geometry import Polyline
from compas_occ.geometry import OCCNurbsCurve
from compas.geometry import NurbsCurve
from compas_view2.app import App


points = [Point(0, 0, 0), Point(3, 6, 0), Point(6, -3, 3), Point(10, 0, 0)]

curve = OCCNurbsCurve.from_parameters(
curve = NurbsCurve.from_parameters(
points=points,
weights=[1.0, 1.0, 1.0, 1.0],
knots=[0.0, 1.0],
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/curves/curve_joining.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# type: ignore

from compas.geometry import Point
from compas_occ.geometry import OCCNurbsCurve
from compas.geometry import NurbsCurve
from compas_view2.app import App

points1 = [Point(0, 0, 0), Point(1, 1, 0), Point(3, 0, 0)]
points2 = [Point(3, 0, 0), Point(4, -2, 0), Point(5, 0, 0)]

curve1 = OCCNurbsCurve.from_interpolation(points1)
curve2 = OCCNurbsCurve.from_interpolation(points2)
curve1 = NurbsCurve.from_interpolation(points1)
curve2 = NurbsCurve.from_interpolation(points2)

joined = curve1.joined(curve2)
curve1.join(curve2)
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/curves/curve_segmentation.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# type: ignore

from compas.geometry import Point
from compas_occ.geometry import OCCNurbsCurve
from compas.geometry import NurbsCurve
from compas_view2.app import App


pointsA = [Point(0, 0, 0), Point(3, 6, 0), Point(6, -3, 3), Point(10, 0, 0)]
curveA = OCCNurbsCurve.from_points(pointsA)
curveA = NurbsCurve.from_points(pointsA)

curveA.segment(u=0.2, v=0.5)

print(curveA.domain)

pointsB = [Point(0, -1, 0), Point(3, 5, 0), Point(6, -4, 3), Point(10, -1, 0)]
curveB = OCCNurbsCurve.from_points(pointsB)
curveB = NurbsCurve.from_points(pointsB)

segment = curveB.segmented(u=0.2, v=0.5)

Expand Down

0 comments on commit c32a0a5

Please sign in to comment.