Skip to content

Commit 5fda913

Browse files
committed
examples
1 parent 2e128b1 commit 5fda913

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from compas_viewer import Viewer
2+
3+
from compas.geometry import Circle
4+
from compas.geometry import Frame
5+
from compas.tolerance import TOL
6+
from compas_occ.brep import OCCBrep
7+
from compas_occ.geometry import OCCNurbsCurve
8+
9+
frame = Frame.worldYZ()
10+
c1 = Circle(1.0, frame=frame)
11+
12+
frame = Frame.worldYZ()
13+
frame.point = [3, 0, 0]
14+
c2 = Circle(3.0, frame=frame)
15+
16+
frame = Frame.worldYZ()
17+
frame.point = [6, 0, 0]
18+
c3 = Circle(0.5, frame=frame)
19+
20+
frame = Frame.worldYZ()
21+
frame.point = [9, 0, 0]
22+
c4 = Circle(3.0, frame=frame)
23+
24+
curves = [
25+
OCCNurbsCurve.from_circle(c1),
26+
OCCNurbsCurve.from_circle(c2),
27+
OCCNurbsCurve.from_circle(c3),
28+
OCCNurbsCurve.from_circle(c4),
29+
]
30+
31+
brep = OCCBrep.from_loft(curves) # type: ignore
32+
33+
TOL.lineardeflection = 1
34+
35+
viewer = Viewer()
36+
viewer.scene.add(brep, linewidth=2)
37+
viewer.show()
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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

Comments
 (0)