Skip to content

Commit 5639038

Browse files
committed
fillet tests
1 parent cb1b7fe commit 5639038

File tree

2 files changed

+71
-8
lines changed

2 files changed

+71
-8
lines changed

scripts/fillet1.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
11
import os
22

33
from compas.geometry import Frame
4-
from compas_occ.conversions.shapes import Box
5-
from compas_occ.brep.datastructures import BRepShape
4+
from compas.geometry import Box, Cylinder
5+
from compas_occ.brep import BRep
6+
7+
from compas_view2.app import App
8+
from compas_view2.objects import Collection
69

710
from OCC.Core.BRepFilletAPI import BRepFilletAPI_MakeFillet
811

912
HERE = os.path.dirname(__file__)
10-
FILE = os.path.join(HERE, '__fillet.stp')
13+
FILE = os.path.join(HERE, "fillet.stp")
14+
15+
box = Box(Frame.worldXY(), 1.8, 1.8, 2)
16+
box.frame.point.z += 0.2
17+
box = BRep.from_box(box)
1118

12-
box = BRepShape(Box(Frame.worldXY(), 1, 1, 1).to_occ_shape())
1319
fillet = BRepFilletAPI_MakeFillet(box.occ_shape)
20+
for edge in box.edges:
21+
fillet.Add(0.1, edge.occ_edge)
22+
fillet.Build()
23+
24+
void = BRep()
25+
void.occ_shape = fillet.Shape()
26+
27+
shape = BRep.from_box(Box(Frame.worldXY(), 2, 2, 2))
28+
shape = shape - void
29+
30+
cylinder = Cylinder((([1, 1, 0], [0, 0, 1]), 0.4), 3)
31+
cylinder = BRep.from_cylinder(cylinder)
32+
33+
shape = shape + cylinder
34+
35+
viewer = App()
1436

15-
for edge in box.edges():
16-
fillet.Add(0.1, edge)
37+
viewmesh = shape.to_viewmesh()
38+
viewer.add(viewmesh[0], show_edges=False)
39+
viewer.add(Collection(viewmesh[1]), linewidth=2)
1740

18-
shape = BRepShape(fillet.Shape())
19-
shape.to_step(FILE)
41+
viewer.run()

scripts/fillet2.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import os
2+
3+
from compas.geometry import Frame
4+
from compas.geometry import Box, Cylinder
5+
from compas_occ.brep import BRep
6+
7+
from compas_view2.app import App
8+
from compas_view2.objects import Collection
9+
10+
from OCC.Core.BRepFilletAPI import BRepFilletAPI_MakeChamfer
11+
12+
HERE = os.path.dirname(__file__)
13+
FILE = os.path.join(HERE, "fillet.stp")
14+
15+
box = Box(Frame.worldXY(), 1.8, 1.8, 2)
16+
box.frame.point.z += 0.2
17+
box = BRep.from_box(box)
18+
19+
fillet = BRepFilletAPI_MakeChamfer(box.occ_shape)
20+
for edge in box.edges:
21+
fillet.Add(0.1, edge.occ_edge)
22+
fillet.Build()
23+
24+
void = BRep()
25+
void.occ_shape = fillet.Shape()
26+
27+
shape = BRep.from_box(Box(Frame.worldXY(), 2, 2, 2))
28+
shape = shape - void
29+
30+
cylinder = Cylinder((([1, 1, 0], [0, 0, 1]), 0.4), 3)
31+
cylinder = BRep.from_cylinder(cylinder)
32+
33+
shape = shape + cylinder
34+
35+
viewer = App()
36+
37+
viewmesh = shape.to_viewmesh()
38+
viewer.add(viewmesh[0], show_edges=False)
39+
viewer.add(Collection(viewmesh[1]), linewidth=2)
40+
41+
viewer.run()

0 commit comments

Comments
 (0)