1 | # -*- coding: utf-8 -*- |
---|
2 | from OCC.Display.SimpleGui import * |
---|
3 | from math import pi |
---|
4 | |
---|
5 | from OCC.gp import * |
---|
6 | from OCC.BRepBuilderAPI import * |
---|
7 | from OCC.BRepPrimAPI import * |
---|
8 | from OCC.BRepFilletAPI import * # izdelava zaokrožitev |
---|
9 | from OCC.BRepAlgoAPI import * # Boolova algebra |
---|
10 | |
---|
11 | from OCC.TopExp import * |
---|
12 | from OCC.TopAbs import * |
---|
13 | from OCC.TopTools import * |
---|
14 | from OCC.TopoDS import * |
---|
15 | from OCC. TColgp import * |
---|
16 | |
---|
17 | display, start_display, add_menu, add_function_to_menu = init_display() |
---|
18 | |
---|
19 | def kocka(a = 100): |
---|
20 | global cube |
---|
21 | global b |
---|
22 | b = a |
---|
23 | cube = BRepPrimAPI_MakeBox(a,a,a).Shape() |
---|
24 | |
---|
25 | def prikaz_kocke(event=None): |
---|
26 | display.EraseAll() |
---|
27 | display.DisplayShape(cube, update=True) |
---|
28 | |
---|
29 | def zaokrozeno_vse(event=None): |
---|
30 | zaokrozitev = BRepFilletAPI_MakeFillet(cube) |
---|
31 | anEdgeExplorer = TopExp_Explorer(cube, TopAbs_EDGE) |
---|
32 | |
---|
33 | while anEdgeExplorer.More(): |
---|
34 | anEdge = topods.Edge(anEdgeExplorer.Current()) |
---|
35 | zaokrozitev.Add(R, anEdge) |
---|
36 | anEdgeExplorer.Next() |
---|
37 | zaokrozitev.Build() |
---|
38 | kocka_zaokrozitev_vse = zaokrozitev.Shape() |
---|
39 | display.EraseAll() |
---|
40 | display.DisplayShape(kocka_zaokrozitev_vse, update=True) |
---|
41 | |
---|
42 | #Zakrozevanje s seznamom robom |
---|
43 | def zaokrozitev_seznam(event=None): |
---|
44 | zaokrozitev = BRepFilletAPI_MakeFillet(cube) |
---|
45 | anEdgeExplorer = TopExp_Explorer(cube, TopAbs_EDGE) |
---|
46 | seznam_robov = [] |
---|
47 | while anEdgeExplorer.More(): |
---|
48 | anEdge = topods.Edge(anEdgeExplorer.Current()) |
---|
49 | seznam_robov.append(anEdge) |
---|
50 | anEdgeExplorer.Next() |
---|
51 | zaokrozitev.Add(R, seznam_robov[0]) |
---|
52 | zaokrozitev.Add(R, seznam_robov[1]) |
---|
53 | zaokrozitev.Add(R, seznam_robov[5]) |
---|
54 | zaokrozitev.Add(R, seznam_robov[10]) |
---|
55 | |
---|
56 | zaokrozitev.Build() |
---|
57 | kocka_zaokrozitev_seznam = zaokrozitev.Shape() |
---|
58 | display.EraseAll() |
---|
59 | display.DisplayShape(kocka_zaokrozitev_seznam, update=True) |
---|
60 | |
---|
61 | def spremeni_radij(event=None): |
---|
62 | global R |
---|
63 | R = int(input("Vnesi nov radij:")) |
---|
64 | |
---|
65 | kocka(200) |
---|
66 | |
---|
67 | R = b/5 |
---|
68 | |
---|
69 | add_menu("Kocka") |
---|
70 | add_function_to_menu("Kocka", prikaz_kocke) |
---|
71 | add_menu("Zaokrozevanja") |
---|
72 | add_function_to_menu("Zaokrozevanja", zaokrozeno_vse) |
---|
73 | add_function_to_menu("Zaokrozevanja", zaokrozitev_seznam) |
---|
74 | |
---|
75 | add_menu("Funkcije") |
---|
76 | add_function_to_menu("Funkcije", spremeni_radij) |
---|
77 | |
---|
78 | display.View_Iso() |
---|
79 | start_display() |
---|