|
| 1 | +# type: ignore |
| 2 | +from compas_viewer import Viewer |
| 3 | + |
| 4 | +from compas.geometry import NurbsSurface |
| 5 | +from compas.geometry import Point |
| 6 | +from compas.geometry import Sphere |
| 7 | +from compas_occ.brep import OCCBrep |
| 8 | + |
| 9 | +points = [ |
| 10 | + [Point(0, 0, 0), Point(1, 0, 0), Point(2, 0, 0), Point(3, 0, 0)], |
| 11 | + [Point(0, 1, 0), Point(1, 1, 2), Point(2, 1, 2), Point(3, 1, 0)], |
| 12 | + [Point(0, 2, 0), Point(1, 2, 2), Point(2, 2, 2), Point(3, 2, 0)], |
| 13 | + [Point(0, 3, 0), Point(1, 3, 0), Point(2, 3, 0), Point(3, 3, 0)], |
| 14 | +] |
| 15 | + |
| 16 | +surface = OCCBrep.from_surface(NurbsSurface.from_points(points=points)) |
| 17 | +sphere = OCCBrep.from_sphere(Sphere(radius=1)) |
| 18 | + |
| 19 | +x = surface.intersect(sphere) |
| 20 | +assert x, "..." |
| 21 | + |
| 22 | +curves = [] |
| 23 | +for edge in x.edges: |
| 24 | + curves.append(edge.curve) |
| 25 | + |
| 26 | +# ============================================================================= |
| 27 | +# Visualization |
| 28 | +# ============================================================================= |
| 29 | + |
| 30 | +viewer = Viewer() |
| 31 | +viewer.scene.add(surface, linewidth=2, show_points=False, opacity=0.5) |
| 32 | +viewer.scene.add(sphere, linewidth=2, show_points=False, opacity=0.5) |
| 33 | +viewer.scene.add(curves, linewidth=2) |
| 34 | +viewer.show() |
0 commit comments