diff --git a/docs/examples/brep_explorer.py b/docs/examples/brep_explorer.py index b66faa2dc..50a3288c9 100644 --- a/docs/examples/brep_explorer.py +++ b/docs/examples/brep_explorer.py @@ -1,12 +1,12 @@ +# type: ignore + from compas.geometry import Box from compas.colors import Color -from compas.geometry import Brep +from compas.brep import Brep from compas_view2.app import App box = Box.from_width_height_depth(1, 1, 1) A = Brep.from_box(box) -A.sew() -A.fix() vertex = A.vertices[0] @@ -21,7 +21,7 @@ viewer = App() -viewer.add(A, linewidth=1, linecolor=Color(0.2, 0.2, 0.2)) +viewer.add(A, linewidth=2, linecolor=Color(0.2, 0.2, 0.2)) viewer.add(vertex.point, pointcolor=Color.red(), pointsize=20) @@ -31,9 +31,9 @@ for edge in edges: viewer.add(edge.to_line(), linewidth=5, linecolor=Color(0.2, 0.2, 0.2)) -for face in faces: - brep = Brep() - brep.native_brep = face.occ_face - viewer.add(brep, show_lines=False, opacity=0.5) +# for face in faces: +# brep = Brep.from_brepfaces() +# brep.occ_shape = face.occ_face +# viewer.add(brep.to_viewmesh()[0], show_lines=False, opacity=0.5) viewer.show() diff --git a/docs/examples/brep_from_booleans.py b/docs/examples/brep_from_booleans.py index 9f59f4789..fd031ce58 100644 --- a/docs/examples/brep_from_booleans.py +++ b/docs/examples/brep_from_booleans.py @@ -1,29 +1,20 @@ -from compas.geometry import Point, Vector, Plane +# type: ignore + +from compas.geometry import Frame from compas.geometry import Box, Cylinder -from compas.geometry import Brep from compas_view2.app import App -from compas_view2.objects import Collection R = 1.4 -P = Point(0, 0, 0) -X = Vector(1, 0, 0) -Y = Vector(0, 1, 0) -Z = Vector(0, 0, 1) -YZ = Plane(P, X) -ZX = Plane(P, Y) -XY = Plane(P, Z) - -box = Box.from_width_height_depth(2 * R, 2 * R, 2 * R) -cx = Cylinder((YZ, 0.7 * R), 4 * R) -cy = Cylinder((ZX, 0.7 * R), 4 * R) -cz = Cylinder((XY, 0.7 * R), 4 * R) - -A = Brep.from_box(box) -B1 = Brep.from_cylinder(cx) -B2 = Brep.from_cylinder(cy) -B3 = Brep.from_cylinder(cz) - -C = A - (B1 + B2 + B3) +YZ = Frame.worldYZ() +ZX = Frame.worldZX() +XY = Frame.worldXY() + +box = Box(2 * R).to_brep() +cx = Cylinder(0.7 * R, 4 * R, frame=YZ).to_brep() +cy = Cylinder(0.7 * R, 4 * R, frame=ZX).to_brep() +cz = Cylinder(0.7 * R, 4 * R, frame=XY).to_brep() + +result = box - (cx + cy + cz) # ============================================================================== # Visualisation @@ -34,6 +25,6 @@ viewer.view.camera.rx = -75 viewer.view.camera.distance = 7 -viewer.add(C) +viewer.add(result, linewidth=2) viewer.run() diff --git a/docs/examples/brep_from_mesh.py b/docs/examples/brep_from_mesh.py index 3b5861a63..563891cc0 100644 --- a/docs/examples/brep_from_mesh.py +++ b/docs/examples/brep_from_mesh.py @@ -1,12 +1,17 @@ +# type: ignore + import compas from compas.geometry import Vector, Translation, Scale -from compas.geometry import Polyline from compas.datastructures import Mesh -from compas_occ.brep import BRep +from compas.brep import Brep from compas_view2.app import App -mesh = Mesh.from_obj(compas.get("tubemesh.obj")) +mesh: Mesh = Mesh.from_obj(compas.get("tubemesh.obj")) + +# move the mesh closer to the origin +# place it on the XY plane +# and scale it down centroid = mesh.centroid() zmin = min(mesh.vertices_attribute("z")) @@ -19,22 +24,13 @@ mesh.transform(S * T) -brep = BRep.from_mesh(mesh) -brep.check() +# convert to a brep -lines = [] -curves = [] +brep = Brep.from_mesh(mesh) -for edge in brep.edges: - if edge.is_line: - lines.append(edge.to_line()) - elif edge.is_bspline: - curves.append(Polyline(edge.curve.locus())) +# visualize viewer = App(viewmode="ghosted") -viewer.add(brep, show_lines=False) - -for curve in curves: - viewer.add(curve, linewidth=2) +viewer.add(brep, linewidth=2) viewer.run() diff --git a/docs/examples/brep_overlap.py b/docs/examples/brep_overlap.py index bf23e7270..de0a0b942 100644 --- a/docs/examples/brep_overlap.py +++ b/docs/examples/brep_overlap.py @@ -1,9 +1,11 @@ +# type: ignore + from compas.geometry import Translation from compas.geometry import Box from compas.geometry import Brep from compas.colors import Color +from compas.brep import Brep from compas_view2.app import App -from compas_view2.objects import Collection box = Box.from_width_height_depth(1, 1, 1) A = Brep.from_box(box) @@ -16,12 +18,25 @@ viewer = App() -viewer.add(Collection(items=[A, B]), show_lines=False, opacity=0.5) - -brep = Brep.from_native(FA[0].occ_face) -viewer.add(brep, show_lines=False, facecolor=Color.red().lightened(50)) - -brep = Brep.from_native(FB[0].occ_face) -viewer.add(brep, show_lines=False, facecolor=Color.blue().lightened(50)) +viewer.add(A, opacity=0.5, linewidth=3) +viewer.add(B, opacity=0.5, linewidth=3) + +for face in FA[:1]: + brep = Brep.from_brepfaces([face]) + viewer.add( + brep, + facecolor=Color.red().lightened(50), + linewidth=3, + linecolor=Color.red(), + ) + +for face in FB[:1]: + brep = Brep.from_brepfaces([face]) + viewer.add( + brep, + facecolor=Color.blue().lightened(50), + linewidth=3, + linecolor=Color.blue(), + ) viewer.show() diff --git a/docs/examples/brepface_with_hole.py b/docs/examples/brepface_with_hole.py index 7719cc196..c9e910f1b 100644 --- a/docs/examples/brepface_with_hole.py +++ b/docs/examples/brepface_with_hole.py @@ -1,6 +1,9 @@ -from compas.geometry import Point, Vector, Plane, Circle -from compas_occ.brep import BRepEdge, BRepLoop, BRepFace, BRep -from compas_occ.geometry import OCCNurbsCurve, OCCNurbsSurface +# type: ignore + +from compas.geometry import Point, Vector, Frame, Circle +from compas_occ.brep import OCCBrepEdge, OCCBrepLoop, OCCBrepFace +from compas.brep import Brep +from compas.geometry import NurbsCurve, NurbsSurface from compas_view2.app import App points = [ @@ -10,27 +13,35 @@ [Point(0, 3, 0), Point(1, 3, 0), Point(2, 3, 0), Point(3, 3, 0)], ] -surface = OCCNurbsSurface.from_points(points=points) +surface = NurbsSurface.from_points(points=points) + +circle = Circle( + 0.5, + frame=Frame( + Point(1.5, 1.5, 1.5), + Vector(1, 0, 0), + Vector(0, 1, 0), + ), +) -circle = Circle(Plane(Point(1.5, 1.5, 1.5), Vector(0, 0, 1)), 0.5) -curve = OCCNurbsCurve.from_circle(circle).projected(surface).embedded(surface) +# projected is still 3D +# embedded is 2D +# and the 2D curve should keep track of the embedding surface +curve = NurbsCurve.from_circle(circle) -edge = BRepEdge.from_curve(curve, surface) -loop = BRepLoop.from_edges([edge]) +edge = OCCBrepEdge.from_curve(curve=curve, surface=surface) +loop = OCCBrepLoop.from_edges([edge]) -face = BRepFace.from_surface(surface) +# perhaps this should be: +# face = OCCBrepFace() +# face.set_surface(surface) +# face.add_boundary(loop) => if the loop edges are not embedded in the surface, they should be +# face.add_hole(loop) => if the loop edges ... +face = OCCBrepFace.from_surface(surface) face.add_loop(loop) -brep = BRep.from_faces([face]) -mesh = brep.to_tesselation() +brep = Brep.from_brepfaces([face]) viewer = App() -viewer.add(mesh, show_lines=False) -for edge in brep.edges: - if edge.is_line: - viewer.add(edge.to_line(), linewidth=2) - elif edge.is_circle: - viewer.add(edge.curve.to_polyline(), linewidth=2) - elif edge.is_bspline: - viewer.add(edge.curve.to_polyline(), linewidth=2) +viewer.add(brep, linewidth=2) viewer.show() diff --git a/docs/examples/brepface_with_holes.py b/docs/examples/brepface_with_holes.py index 88657912e..b8d42189f 100644 --- a/docs/examples/brepface_with_holes.py +++ b/docs/examples/brepface_with_holes.py @@ -1,29 +1,23 @@ -from compas.geometry import Plane, Circle -from compas_occ.brep import BRepEdge, BRepLoop, BRepFace, BRep -from compas_view2.app import App +# type: ignore -plane = Plane.worldXY() +from compas.geometry import Frame, Plane, Circle +from compas_occ.brep import OCCBrepEdge, OCCBrepLoop, OCCBrepFace +from compas.brep import Brep +from compas_view2.app import App -circle1 = Circle(Plane([2, 2, 0], [0, 0, 1]), 1.0) -circle2 = Circle(Plane([-2, -2, 0], [0, 0, 1]), 2.0) -circle3 = Circle(Plane([2, -2, 0], [0, 0, 1]), 0.5) +circle1 = Circle(1.0, frame=Frame([2, 2, 0])) +circle2 = Circle(2.0, frame=Frame([-2, -2, 0])) +circle3 = Circle(0.5, frame=Frame([2, -2, 0])) -loop1 = BRepLoop.from_edges([BRepEdge.from_circle(circle1)]) -loop2 = BRepLoop.from_edges([BRepEdge.from_circle(circle2)]) -loop3 = BRepLoop.from_edges([BRepEdge.from_circle(circle3)]) +loop1 = OCCBrepLoop.from_edges([OCCBrepEdge.from_circle(circle1)]) +loop2 = OCCBrepLoop.from_edges([OCCBrepEdge.from_circle(circle2)]) +loop3 = OCCBrepLoop.from_edges([OCCBrepEdge.from_circle(circle3)]) -face = BRepFace.from_plane(plane, udomain=(-5, 5), vdomain=(-5, 5)) +face = OCCBrepFace.from_plane(Plane.worldXY(), udomain=(-5, 5), vdomain=(-5, 5)) face.add_loops([loop1, loop2, loop3], reverse=True) -brep = BRep.from_faces([face]) +brep = Brep.from_brepfaces([face]) viewer = App() -viewer.add(brep, show_lines=False) - -for edge in brep.edges: - if edge.is_line: - viewer.add(edge.to_line(), linewidth=2) - elif edge.is_circle: - viewer.add(edge.curve.to_polyline(), linewidth=2) - +viewer.add(brep, linewidth=2) viewer.show() diff --git a/docs/examples/curve_closest_parameters_curve.py b/docs/examples/curve_closest_parameters_curve.py index ee20fa304..f554cc5c8 100644 --- a/docs/examples/curve_closest_parameters_curve.py +++ b/docs/examples/curve_closest_parameters_curve.py @@ -1,27 +1,25 @@ +# type: ignore + 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 - points0 = [Point(0, 0, 0), Point(3, 6, 0), Point(6, -3, 3), Point(10, 0, 0)] -curve0 = OCCNurbsCurve.from_points(points0) +curve0 = NurbsCurve.from_points(points0) points1 = [Point(6, -3, 0), Point(3, 1, 0), Point(6, 6, 3), Point(3, 12, 0)] -curve1 = OCCNurbsCurve.from_points(points1) +curve1 = NurbsCurve.from_points(points1) +# 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) -# ============================================================================== -# Visualisation -# ============================================================================== - view = App() -view.add(Polyline(curve0.locus()), linewidth=3) -view.add(Polyline(curve1.locus()), linewidth=3) +view.add(curve0.to_polyline(), linewidth=3) +view.add(curve1.to_polyline(), linewidth=3) view.add(points[0], pointcolor=(1, 0, 0)) view.add(points[1], pointcolor=(1, 0, 0)) diff --git a/docs/examples/curve_closest_point.py b/docs/examples/curve_closest_point.py index 4b6b6d678..42b0dffde 100644 --- a/docs/examples/curve_closest_point.py +++ b/docs/examples/curve_closest_point.py @@ -1,20 +1,19 @@ +# type: ignore + 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, 0, 2), Point(6, 0, -3), Point(8, 0, 0)] -curve = OCCNurbsCurve.from_interpolation(points) +curve = NurbsCurve.from_interpolation(points) point = Point(2, -1, 0) closest, t = curve.closest_point(point, return_parameter=True) -print(curve.point_at(t) == closest) - view = App() -view.add(Polyline(curve.locus()), linewidth=3) +view.add(curve.to_polyline(), linewidth=3) view.add(point, pointcolor=(0, 0, 1)) view.add(closest, pointcolor=(1, 0, 0)) diff --git a/docs/examples/curve_comparison1.py b/docs/examples/curve_comparison1.py index 28c116302..41dda5dad 100644 --- a/docs/examples/curve_comparison1.py +++ b/docs/examples/curve_comparison1.py @@ -1,6 +1,8 @@ +# type: ignore + from compas.geometry import Point from compas.geometry import Polyline, Bezier -from compas_occ.geometry import OCCNurbsCurve +from compas.geometry import NurbsCurve from compas_view2.app import App @@ -9,7 +11,7 @@ points = [Point(3, 0, 0), Point(4, 3, 0), Point(5, 0, 0)] -curve1 = OCCNurbsCurve.from_parameters( +curve1 = NurbsCurve.from_parameters( points=points, weights=[1.0, 1.0, 1.0], knots=[0.0, 1.0], @@ -17,7 +19,7 @@ degree=2, ) -curve2 = OCCNurbsCurve.from_parameters( +curve2 = NurbsCurve.from_parameters( points=points, weights=[1.0, 2.0, 1.0], knots=[0.0, 1.0], @@ -25,7 +27,7 @@ degree=2, ) -curve3 = OCCNurbsCurve.from_parameters( +curve3 = NurbsCurve.from_parameters( points=points, weights=[1.0, 1.0, 1.0], knots=[0.0, 1.0, 2.0, 3.0, 4.0, 5.0], @@ -47,7 +49,7 @@ linewidth=1, linecolor=(0.3, 0.3, 0.3), ) -view.add(Polyline(bezier.locus()), linewidth=5, linecolor=(0, 0, 0)) +view.add(bezier.to_polyline(), linewidth=5, linecolor=(0, 0, 0)) view.add( Polyline(curve1.points), @@ -57,8 +59,8 @@ linewidth=1, linecolor=(0.3, 0.3, 0.3), ) -view.add(Polyline(curve1.locus()), linewidth=5, linecolor=(0, 0, 0)) -view.add(Polyline(curve2.locus()), linewidth=5, linecolor=(0, 1, 1)) -view.add(Polyline(curve3.locus()), linewidth=5, linecolor=(0, 0, 1)) +view.add(curve1.to_polyline(), linewidth=5, linecolor=(0, 0, 0)) +view.add(curve2.to_polyline(), linewidth=5, linecolor=(0, 1, 1)) +view.add(curve3.to_polyline(), linewidth=5, linecolor=(0, 0, 1)) view.run() diff --git a/docs/examples/curve_comparison2.py b/docs/examples/curve_comparison2.py index 55493ad62..1aff33ae9 100644 --- a/docs/examples/curve_comparison2.py +++ b/docs/examples/curve_comparison2.py @@ -1,3 +1,5 @@ +# type: ignore + from compas.geometry import Point from compas.geometry import Polyline, Bezier from compas_occ.geometry import OCCNurbsCurve @@ -71,7 +73,7 @@ linewidth=1, linecolor=(0.3, 0.3, 0.3), ) -view.add(Polyline(bezier.locus()), linewidth=5, linecolor=(0, 0, 0)) +view.add(bezier.to_polyline(), linewidth=5, linecolor=(0, 0, 0)) view.add( Polyline(curve1.points), @@ -81,11 +83,11 @@ linewidth=1, linecolor=(0.3, 0.3, 0.3), ) -view.add(Polyline(curve1.locus()), linewidth=5, linecolor=(0, 0, 0)) -view.add(Polyline(curve2.locus()), linewidth=3, linecolor=(0, 0, 1)) -view.add(Polyline(curve3.locus()), linewidth=3, linecolor=(0.2, 0.2, 1)) -view.add(Polyline(curve4.locus()), linewidth=3, linecolor=(0.4, 0.4, 1)) -view.add(Polyline(curve5.locus()), linewidth=3, linecolor=(0.6, 0.6, 1)) -view.add(Polyline(curve6.locus()), linewidth=3, linecolor=(0.8, 0.8, 1)) +view.add(curve1.to_polyline(), linewidth=5, linecolor=(0, 0, 0)) +view.add(curve2.to_polyline(), linewidth=3, linecolor=(0, 0, 1)) +view.add(curve3.to_polyline(), linewidth=3, linecolor=(0.2, 0.2, 1)) +view.add(curve4.to_polyline(), linewidth=3, linecolor=(0.4, 0.4, 1)) +view.add(curve5.to_polyline(), linewidth=3, linecolor=(0.6, 0.6, 1)) +view.add(curve6.to_polyline(), linewidth=3, linecolor=(0.8, 0.8, 1)) view.run() diff --git a/docs/examples/curve_divide.py b/docs/examples/curve_divide.py index 175913b6a..6656b2d15 100644 --- a/docs/examples/curve_divide.py +++ b/docs/examples/curve_divide.py @@ -1,3 +1,5 @@ +# type: ignore + from compas.utilities import pairwise from compas.geometry import Point from compas_occ.geometry import OCCNurbsCurve diff --git a/docs/examples/curve_from_circle.py b/docs/examples/curve_from_circle.py index 7588296b6..bb57f1f10 100644 --- a/docs/examples/curve_from_circle.py +++ b/docs/examples/curve_from_circle.py @@ -1,11 +1,12 @@ -from compas.geometry import Vector, Point, Plane +# type: ignore + from compas.geometry import Polyline from compas.geometry import Circle from compas_occ.geometry import OCCNurbsCurve from compas_view2.app import App -circle = Circle(Plane(Point(0, 0, 0), Vector(0, 0, 1)), 1.0) +circle = Circle(1.0) curve = OCCNurbsCurve.from_circle(circle) # ============================================================================== @@ -14,7 +15,7 @@ view = App() -view.add(Polyline(curve.locus()), linewidth=3) +view.add(curve.to_polyline(), linewidth=3) view.add( Polyline(curve.points), show_points=True, diff --git a/docs/examples/curve_from_data.py b/docs/examples/curve_from_data.py new file mode 100644 index 000000000..becc6acc7 --- /dev/null +++ b/docs/examples/curve_from_data.py @@ -0,0 +1,32 @@ +from compas.geometry import Point +from compas.geometry import Polyline +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 = NurbsCurve.from_points(points) + +data = curve.data + +print(data) + +# # ============================================================================== +# # Visualisation +# # ============================================================================== + +# view = App() + +# view.add(curve.to_polyline(), linewidth=3) # type: ignore + +# view.add( +# Polyline(curve.points), +# show_points=True, +# pointsize=20, +# pointcolor=(1, 0, 0), # type: ignore +# linewidth=1, +# linecolor=(0.3, 0.3, 0.3), # type: ignore +# ) # type: ignore + +# view.run() diff --git a/docs/examples/curve_from_ellipse.py b/docs/examples/curve_from_ellipse.py index 95b6bb1df..b27009aa9 100644 --- a/docs/examples/curve_from_ellipse.py +++ b/docs/examples/curve_from_ellipse.py @@ -1,5 +1,6 @@ -from compas.geometry import Vector, Point, Plane -from compas.geometry import Line, Polyline +# type: ignore + +from compas.geometry import Line from compas.geometry import Ellipse from compas.utilities import pairwise from compas_occ.geometry import OCCNurbsCurve @@ -7,7 +8,7 @@ from compas_view2.objects import Collection -ellipse = Ellipse(Plane(Point(0, 0, 0), Vector(0, 0, 1)), 2.0, 1.0) +ellipse = Ellipse(2.0, 1.0) curve = OCCNurbsCurve.from_ellipse(ellipse) # ============================================================================== @@ -16,7 +17,7 @@ view = App() -view.add(Polyline(curve.locus()), linewidth=3) +view.add(curve.to_polyline(), linewidth=3) view.add(Collection(curve.points), pointsize=20, pointcolor=(1, 0, 0)) for a, b in pairwise(curve.points): diff --git a/docs/examples/curve_from_interpolation.py b/docs/examples/curve_from_interpolation.py index 4e52d773b..8d4591281 100644 --- a/docs/examples/curve_from_interpolation.py +++ b/docs/examples/curve_from_interpolation.py @@ -1,5 +1,7 @@ +# type: ignore + from compas.geometry import Point -from compas.geometry import Polyline, Bezier +from compas.geometry import Bezier from compas_occ.geometry import OCCNurbsCurve from compas_view2.app import App from compas_view2.objects import Collection @@ -7,7 +9,7 @@ points = [Point(0, 0, 0), Point(3, 6, 0), Point(6, -3, 3), Point(10, 0, 0)] bezier = Bezier(points) -points = bezier.locus(10) +points = bezier.to_points(10) curve = OCCNurbsCurve.from_interpolation(points) @@ -17,7 +19,7 @@ view = App() -view.add(Polyline(curve.locus()), linewidth=3) +view.add(curve.to_polyline(), linewidth=3) view.add(Collection(points)) view.run() diff --git a/docs/examples/curve_from_line.py b/docs/examples/curve_from_line.py index 5df3a3915..78284e87b 100644 --- a/docs/examples/curve_from_line.py +++ b/docs/examples/curve_from_line.py @@ -1,5 +1,7 @@ +# type: ignore + from compas.geometry import Point -from compas.geometry import Line, Polyline +from compas.geometry import Line from compas_occ.geometry import OCCNurbsCurve from compas_view2.app import App from compas_view2.objects import Collection @@ -14,7 +16,7 @@ view = App() -view.add(Polyline(curve.locus()), linewidth=3) +view.add(curve.to_polyline(), linewidth=3) view.add(Collection(curve.points), pointsize=20, pointcolor=(1, 0, 0)) view.run() diff --git a/docs/examples/curve_from_parameters.py b/docs/examples/curve_from_parameters.py index 67722619e..b2bc6aaf9 100644 --- a/docs/examples/curve_from_parameters.py +++ b/docs/examples/curve_from_parameters.py @@ -1,3 +1,5 @@ +# type: ignore + from compas.geometry import Point from compas.geometry import Polyline from compas_occ.geometry import OCCNurbsCurve @@ -20,7 +22,7 @@ view = App() -view.add(Polyline(curve.locus()), linewidth=3) +view.add(curve.to_polyline(), linewidth=3) view.add( Polyline(curve.points), show_points=True, diff --git a/docs/examples/curve_from_points.py b/docs/examples/curve_from_points.py index 1c4fc9f00..b1c078f8c 100644 --- a/docs/examples/curve_from_points.py +++ b/docs/examples/curve_from_points.py @@ -1,12 +1,14 @@ +# type: ignore + 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_points(points) +curve = NurbsCurve.from_points(points) # ============================================================================== # Visualisation @@ -14,7 +16,8 @@ view = App() -view.add(Polyline(curve.locus()), linewidth=3) +view.add(curve.to_polyline(), linewidth=3) + view.add( Polyline(curve.points), show_points=True, diff --git a/docs/examples/curve_joining.py b/docs/examples/curve_joining.py index 5c6d1f905..0248c59d4 100644 --- a/docs/examples/curve_joining.py +++ b/docs/examples/curve_joining.py @@ -1,5 +1,6 @@ +# type: ignore + from compas.geometry import Point -from compas.geometry import Polyline from compas_occ.geometry import OCCNurbsCurve from compas_view2.app import App @@ -18,8 +19,8 @@ view = App() -view.add(Polyline(curve1.locus()), linewidth=3, linecolor=(1, 0, 0)) -view.add(Polyline(curve2.locus()), linewidth=3, linecolor=(0, 1, 0)) -view.add(Polyline(joined.locus()), linewidth=3, linecolor=(0, 0, 1)) +view.add(curve1.to_polyline(), linewidth=3, linecolor=(1, 0, 0)) +view.add(curve2.to_polyline(), linewidth=3, linecolor=(0, 1, 0)) +view.add(joined.to_polyline(), linewidth=3, linecolor=(0, 0, 1)) view.run() diff --git a/docs/examples/curve_segmentation.py b/docs/examples/curve_segmentation.py index 7d92998a8..d569b95de 100644 --- a/docs/examples/curve_segmentation.py +++ b/docs/examples/curve_segmentation.py @@ -1,5 +1,6 @@ +# type: ignore + from compas.geometry import Point -from compas.geometry import Polyline from compas_occ.geometry import OCCNurbsCurve from compas_view2.app import App @@ -25,9 +26,8 @@ view = App() -view.add(Polyline(curveA.locus()), linewidth=4, linecolor=(1, 0, 0)) - -view.add(Polyline(curveB.locus()), linewidth=1, linecolor=(0, 0, 0)) -view.add(Polyline(segment.locus()), linewidth=4, linecolor=(0, 1, 0)) +view.add(curveA.to_polyline(), linewidth=4, linecolor=(1, 0, 0)) +view.add(curveB.to_polyline(), linewidth=1, linecolor=(0, 0, 0)) +view.add(segment.to_polyline(), linewidth=4, linecolor=(0, 1, 0)) view.run() diff --git a/docs/examples/surface_aabb.py b/docs/examples/surface_aabb.py index 663e4e796..28cfdabcc 100644 --- a/docs/examples/surface_aabb.py +++ b/docs/examples/surface_aabb.py @@ -1,3 +1,5 @@ +# type: ignore + from math import radians from compas.geometry import Point, Translation, Rotation from compas.geometry import Polyline @@ -44,7 +46,7 @@ for col in zip(*surface.points): view.add(Polyline(col), linewidth=2, linecolor=(0, 1.0, 0)) -view.add(surface.to_mesh(), show_lines=False) +view.add(surface, show_lines=False) view.add(box, show_faces=False) view.run() diff --git a/docs/examples/surface_frames.py b/docs/examples/surface_frames.py index 1df49bb63..e07248130 100644 --- a/docs/examples/surface_frames.py +++ b/docs/examples/surface_frames.py @@ -1,3 +1,5 @@ +# type: ignore + from compas.geometry import Point from compas.utilities import meshgrid, flatten from compas_occ.geometry import OCCNurbsSurface @@ -26,9 +28,9 @@ view = App() -view.add(surface.to_mesh(), show_lines=False) +view.add(surface, show_lines=False) for frame in frames: - view.add(frame, pointsize=0.25) + view.add(frame, size=0.3, pointsize=0.25) view.run() diff --git a/docs/examples/surface_from_extrusion-1.py b/docs/examples/surface_from_extrusion-1.py index 4ca08974f..594139bc7 100644 --- a/docs/examples/surface_from_extrusion-1.py +++ b/docs/examples/surface_from_extrusion-1.py @@ -1,11 +1,12 @@ +# type: ignore + from compas.geometry import Vector from compas.geometry import Circle -from compas.geometry import Plane from compas_occ.geometry import OCCNurbsCurve from compas_occ.geometry import OCCNurbsSurface from compas_view2.app import App -curve = OCCNurbsCurve.from_circle(Circle(Plane.worldXY(), 2.0)) +curve = OCCNurbsCurve.from_circle(Circle(2.0)) surface = OCCNurbsSurface.from_extrusion(curve, Vector(0, 0, 5)) @@ -14,5 +15,5 @@ viewer.view.camera.target = [0, 0, 2] viewer.add(curve.to_polyline(), linewidth=5, linecolor=(1, 0, 0)) -viewer.add(surface.to_mesh()) +viewer.add(surface) viewer.show() diff --git a/docs/examples/surface_from_extrusion-2.py b/docs/examples/surface_from_extrusion-2.py index 1fa43f661..5d8f85027 100644 --- a/docs/examples/surface_from_extrusion-2.py +++ b/docs/examples/surface_from_extrusion-2.py @@ -1,3 +1,5 @@ +# type: ignore + from compas.geometry import Point from compas.geometry import Vector from compas_occ.geometry import OCCNurbsCurve @@ -15,5 +17,5 @@ viewer.view.camera.target = [2, 0, 5] viewer.add(curve.to_polyline(), linewidth=5, linecolor=(1, 0, 0)) -viewer.add(surface.to_mesh()) +viewer.add(surface) viewer.show() diff --git a/docs/examples/surface_from_fill.py b/docs/examples/surface_from_fill.py index 5641a1764..7cbba640a 100644 --- a/docs/examples/surface_from_fill.py +++ b/docs/examples/surface_from_fill.py @@ -1,9 +1,8 @@ +# type: ignore + from compas.geometry import NurbsCurve from compas.geometry import NurbsSurface - - from compas.geometry import Point -from compas.geometry import Polyline from compas_view2.app import App @@ -26,7 +25,11 @@ nurbscurve6 = NurbsCurve.from_interpolation(points6) nurbssurface_4curves = NurbsSurface.from_fill( - nurbscurve3, nurbscurve4, nurbscurve5, nurbscurve6, style="curved" + nurbscurve3, + nurbscurve4, + nurbscurve5, + nurbscurve6, + style="curved", ) @@ -36,15 +39,15 @@ view = App() -view.add(Polyline(nurbscurve1.locus()), linewidth=3, linecolor=(1, 0, 0)) -view.add(Polyline(nurbscurve2.locus()), linewidth=3, linecolor=(0, 1, 0)) +view.add(nurbscurve1.to_polyline(), linewidth=3, linecolor=(1, 0, 0)) +view.add(nurbscurve2.to_polyline(), linewidth=3, linecolor=(0, 1, 0)) -view.add(Polyline(nurbscurve3.locus()), linewidth=3, linecolor=(1, 0, 0)) -view.add(Polyline(nurbscurve4.locus()), linewidth=3, linecolor=(0, 1, 0)) -view.add(Polyline(nurbscurve5.locus()), linewidth=3, linecolor=(1, 0, 1)) -view.add(Polyline(nurbscurve6.locus()), linewidth=3, linecolor=(0, 0, 1)) +view.add(nurbscurve3.to_polyline(), linewidth=3, linecolor=(1, 0, 0)) +view.add(nurbscurve4.to_polyline(), linewidth=3, linecolor=(0, 1, 0)) +view.add(nurbscurve5.to_polyline(), linewidth=3, linecolor=(1, 0, 1)) +view.add(nurbscurve6.to_polyline(), linewidth=3, linecolor=(0, 0, 1)) -view.add(nurbssurface_2curves.to_mesh(nu=10)) -view.add(nurbssurface_4curves.to_mesh(nu=10)) +view.add(nurbssurface_2curves) +view.add(nurbssurface_4curves) view.run() diff --git a/docs/examples/surface_from_meshgrid.py b/docs/examples/surface_from_meshgrid.py index 5ee82dd2a..142ba2970 100644 --- a/docs/examples/surface_from_meshgrid.py +++ b/docs/examples/surface_from_meshgrid.py @@ -1,3 +1,5 @@ +# type: ignore + from compas.geometry import Point from compas.geometry import Polyline from compas.utilities import meshgrid, linspace diff --git a/docs/examples/surface_from_parameters.py b/docs/examples/surface_from_parameters.py index c220e0aec..dca3d6b87 100644 --- a/docs/examples/surface_from_parameters.py +++ b/docs/examples/surface_from_parameters.py @@ -1,9 +1,10 @@ +# type: ignore + from compas.geometry import Point from compas.geometry import Polyline from compas_occ.geometry import OCCNurbsSurface from compas_view2.app import App - points = [ [ Point(0, 0, 0), @@ -67,7 +68,7 @@ surface = OCCNurbsSurface.from_parameters( points=points, weights=weights, - u_knots=[ + knots_u=[ 1.0, 1 + 1 / 9, 1 + 2 / 9, @@ -79,11 +80,11 @@ 1 + 8 / 9, 2.0, ], - v_knots=[0.0, 1 / 9, 2 / 9, 3 / 9, 4 / 9, 5 / 9, 6 / 9, 7 / 9, 8 / 9, 1.0], - u_mults=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - v_mults=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - u_degree=3, - v_degree=3, + knots_v=[0.0, 1 / 9, 2 / 9, 3 / 9, 4 / 9, 5 / 9, 6 / 9, 7 / 9, 8 / 9, 1.0], + mults_u=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + mults_v=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + degree_u=3, + degree_v=3, ) # ============================================================================== @@ -112,6 +113,6 @@ linecolor=(0.3, 0.3, 0.3), ) -view.add(surface) +view.add(surface.to_mesh()) view.run() diff --git a/docs/examples/surface_from_parameters_rhino.py b/docs/examples/surface_from_parameters_rhino.py deleted file mode 100644 index 3e427ac8c..000000000 --- a/docs/examples/surface_from_parameters_rhino.py +++ /dev/null @@ -1,95 +0,0 @@ -from compas.geometry import Point -from compas.geometry import Polyline -from compas.geometry import NurbsSurface -from compas.artists import Artist - - -points = [ - [ - Point(0, 0, 0), - Point(1, 0, +0), - Point(2, 0, +0), - Point(3, 0, +0), - Point(4, 0, +0), - Point(5, 0, 0), - ], - [ - Point(0, 1, 0), - Point(1, 1, -1), - Point(2, 1, -1), - Point(3, 1, -1), - Point(4, 1, -1), - Point(5, 1, 0), - ], - [ - Point(0, 2, 0), - Point(1, 2, -1), - Point(2, 2, +2), - Point(3, 2, +2), - Point(4, 2, -1), - Point(5, 2, 0), - ], - [ - Point(0, 3, 0), - Point(1, 3, -1), - Point(2, 3, +2), - Point(3, 3, +2), - Point(4, 3, -1), - Point(5, 3, 0), - ], - [ - Point(0, 4, 0), - Point(1, 4, -1), - Point(2, 4, -1), - Point(3, 4, -1), - Point(4, 4, -1), - Point(5, 4, 0), - ], - [ - Point(0, 5, 0), - Point(1, 5, +0), - Point(2, 5, +0), - Point(3, 5, +0), - Point(4, 5, +0), - Point(5, 5, 0), - ], -] - -weights = [ - [1.0, 1.0, 1.0, 1.0, 1.0, 1.0], - [1.0, 1.0, 1.0, 1.0, 1.0, 1.0], - [1.0, 1.0, 1.0, 1.0, 1.0, 1.0], - [1.0, 1.0, 1.0, 1.0, 1.0, 1.0], - [1.0, 1.0, 1.0, 1.0, 1.0, 1.0], - [1.0, 1.0, 1.0, 1.0, 1.0, 1.0], -] - -surface = NurbsSurface.from_parameters( - points=points, - weights=weights, - u_knots=[ - 1.0, - 1 + 1 / 9, - 1 + 2 / 9, - 1 + 3 / 9, - 1 + 4 / 9, - 1 + 5 / 9, - 1 + 6 / 9, - 1 + 7 / 9, - 1 + 8 / 9, - 2.0, - ], - v_knots=[0.0, 1 / 9, 2 / 9, 3 / 9, 4 / 9, 5 / 9, 6 / 9, 7 / 9, 8 / 9, 1.0], - u_mults=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - v_mults=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - u_degree=3, - v_degree=3, -) - -# ============================================================================== -# Visualisation -# ============================================================================== - -artist = Artist(surface) -artist.draw() - diff --git a/docs/examples/surface_from_points.py b/docs/examples/surface_from_points.py index 2df203121..d33735860 100644 --- a/docs/examples/surface_from_points.py +++ b/docs/examples/surface_from_points.py @@ -1,9 +1,10 @@ +# type: ignore + from compas.geometry import Point from compas.geometry import Polyline from compas_occ.geometry import OCCNurbsSurface from compas_view2.app import App - points = [ [Point(0, 0, 0), Point(1, 0, 0), Point(2, 0, 0), Point(3, 0, 0)], [Point(0, 1, 0), Point(1, 1, 2), Point(2, 1, 2), Point(3, 1, 0)], diff --git a/docs/examples/surface_intersections_with_line.py b/docs/examples/surface_intersections_with_line.py index 1ffec6db8..3282e8749 100644 --- a/docs/examples/surface_intersections_with_line.py +++ b/docs/examples/surface_intersections_with_line.py @@ -1,3 +1,5 @@ +# type: ignore + from math import radians from compas.geometry import Point, Vector, Line, Polyline from compas.geometry import Rotation @@ -71,6 +73,6 @@ Line(base, base + (x - base).scaled(1.2)), linewidth=1, linecolor=(0, 0, 1) ) -view.add(surface.to_mesh(), show_lines=False) +view.add(surface) view.run() diff --git a/docs/examples/surface_isocurves.py b/docs/examples/surface_isocurves.py index e1d70c626..82693354e 100644 --- a/docs/examples/surface_isocurves.py +++ b/docs/examples/surface_isocurves.py @@ -1,5 +1,6 @@ +# type: ignore + from compas.geometry import Point -from compas.geometry import Polyline from compas_occ.geometry import OCCNurbsSurface from compas_view2.app import App @@ -18,12 +19,12 @@ # ============================================================================== u_curves = [] -for u in surface.u_space(5): - u_curves.append(surface.u_isocurve(u)) +for u in surface.space_u(5): + u_curves.append(surface.isocurve_u(u)) v_curves = [] -for v in surface.v_space(10): - v_curves.append(surface.v_isocurve(v)) +for v in surface.space_v(10): + v_curves.append(surface.isocurve_v(v)) # ============================================================================== # Visualisation @@ -32,9 +33,9 @@ view = App() for curve in u_curves: - view.add(Polyline(curve.locus()), linecolor=(1, 0, 0), linewidth=2) + view.add(curve.to_polyline(), linecolor=(1, 0, 0), linewidth=2) for curve in v_curves: - view.add(Polyline(curve.locus()), linecolor=(0, 1, 0), linewidth=2) + view.add(curve.to_polyline(), linecolor=(0, 1, 0), linewidth=2) view.run() diff --git a/docs/examples/surface_jsondata.py b/docs/examples/surface_jsondata.py index 6fa351dfc..bdfd8e4a6 100644 --- a/docs/examples/surface_jsondata.py +++ b/docs/examples/surface_jsondata.py @@ -38,7 +38,7 @@ view.add(Polyline(v.locus()), linewidth=1, linecolor=(0.3, 0.3, 0.3)) for curve in surface.boundary(): - view.add(Polyline(curve.locus()), linewidth=2, linecolor=(0, 0, 0)) + view.add(curve.to_polyline(), linewidth=2, linecolor=(0, 0, 0)) view.add(other.to_mesh(), show_lines=False) diff --git a/docs/examples/surface_obb.py b/docs/examples/surface_obb.py index 935e96429..e482fadae 100644 --- a/docs/examples/surface_obb.py +++ b/docs/examples/surface_obb.py @@ -1,3 +1,5 @@ +# type: ignore + from math import radians from compas.geometry import Point, Translation, Rotation from compas.geometry import Polyline diff --git a/docs/examples/surface_random.py b/docs/examples/surface_random.py index 3683592af..396f8de8c 100644 --- a/docs/examples/surface_random.py +++ b/docs/examples/surface_random.py @@ -1,9 +1,10 @@ +# type: ignore + import random from compas.geometry import Polyline from compas_occ.geometry import OCCNurbsSurface from compas_view2.app import App - U = 10 V = 20 diff --git a/docs/examples/surface_viewobject.py b/docs/examples/surface_viewobject.py index fbb85f797..2bd736860 100644 --- a/docs/examples/surface_viewobject.py +++ b/docs/examples/surface_viewobject.py @@ -1,3 +1,5 @@ +# type: ignore + from compas.geometry import Point from compas_occ.geometry import OCCNurbsSurface from compas_view2.app import App