|
1 | 1 | from compas.geometry import Point, Vector, Plane |
2 | | -from compas.geometry import Box |
3 | | -from compas.geometry import Cylinder |
| 2 | +from compas.geometry import Polyline |
| 3 | +from compas.geometry import Box, Cylinder |
4 | 4 | from compas_occ.brep import BRep |
5 | | - |
6 | 5 | from compas_view2.app import App |
7 | 6 |
|
| 7 | + |
8 | 8 | R = 1.4 |
9 | 9 | P = Point(0, 0, 0) |
10 | 10 | X = Vector(1, 0, 0) |
|
25 | 25 | B3 = BRep.from_cylinder(cz) |
26 | 26 | C = BRep.from_boolean_difference(A, BRep.from_boolean_union(BRep.from_boolean_union(B1, B2), B3)) |
27 | 27 |
|
| 28 | +# ============================================================================== |
| 29 | +# Visualisation |
| 30 | +# ============================================================================== |
| 31 | + |
| 32 | +# Currently, the viewer does not suppport BRep shapes. |
| 33 | +# Therefore we have to convert the components of the BRep to something the viewer does understand. |
| 34 | + |
| 35 | +mesh = C.to_tesselation() |
| 36 | + |
28 | 37 | lines = [] |
29 | 38 | circles = [] |
30 | 39 | ellipses = [] |
|
33 | 42 | if edge.is_line: |
34 | 43 | lines.append(edge.to_line()) |
35 | 44 | elif edge.is_circle: |
36 | | - circles.append(edge.to_circle()) |
| 45 | + circles.append(Polyline(edge.curve.locus())) |
37 | 46 | elif edge.is_ellipse: |
38 | | - ellipses.append(edge.to_ellipse()) |
| 47 | + ellipses.append(Polyline(edge.curve.locus())) |
39 | 48 | else: |
40 | 49 | raise NotImplementedError |
41 | 50 |
|
42 | | -# ============================================================================== |
43 | | -# Visualisation |
44 | | -# ============================================================================== |
45 | | - |
46 | | -viewer = App() |
| 51 | +viewer = App(viewmode='ghosted', width=1600, height=900) |
| 52 | +viewer.view.camera.rz = -30 |
| 53 | +viewer.view.camera.rx = -75 |
| 54 | +viewer.view.camera.distance = 7 |
47 | 55 |
|
48 | | -viewer.add(C.to_tesselation(), show_edges=False) |
| 56 | +viewer.add(mesh, show_edges=False) |
49 | 57 |
|
50 | 58 | for line in lines: |
51 | 59 | viewer.add(line, linewidth=2) |
52 | 60 |
|
53 | 61 | for circle in circles: |
54 | | - viewer.add(circle, linewidth=2, u=64) |
| 62 | + viewer.add(circle, linewidth=2) |
55 | 63 |
|
56 | 64 | for ellipse in ellipses: |
57 | | - viewer.add(ellipse, linewidth=2, u=64) |
| 65 | + viewer.add(ellipse, linewidth=2) |
58 | 66 |
|
59 | 67 | viewer.run() |
0 commit comments