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