| 702 | |
| 703 | === Prikaz izdelave kocke in uporaba funkcije krožnega izvleka === |
| 704 | {{{ |
| 705 | #!python |
| 706 | ##Prikaz izdelave kocke in uporaba funkcije krožnega izvleka |
| 707 | ##S.Kulovec, 2011 |
| 708 | |
| 709 | from OCC.gp import * |
| 710 | from OCC.BRepPrimAPI import * |
| 711 | from OCC.TopExp import * |
| 712 | from OCC.TopAbs import * |
| 713 | import OCC.TopoDS |
| 714 | from OCC.BRep import * |
| 715 | from OCC.Geom import * |
| 716 | from OCC.GCE2d import * |
| 717 | from OCC.Geom2d import * |
| 718 | from OCC.BRepLib import * |
| 719 | from OCC.BRepFeat import * |
| 720 | |
| 721 | from OCC.Utils.Topology import Topo |
| 722 | from OCC.BRepBuilderAPI import * |
| 723 | |
| 724 | import sys, time |
| 725 | from OCC.Display.SimpleGui import * |
| 726 | display, start_display, add_menu, add_function_to_menu = init_display() |
| 727 | |
| 728 | S = BRepPrimAPI_MakeBox(400.,250.,300.).Shape() |
| 729 | faces = list(Topo(S).faces()) |
| 730 | F1 = faces[2] |
| 731 | surf = BRep_Tool_Surface(F1) |
| 732 | Pl = Handle_Geom_Plane_DownCast(surf) |
| 733 | |
| 734 | D = gp.gp_OX() |
| 735 | |
| 736 | MW1 = BRepBuilderAPI_MakeWire() |
| 737 | p1 = gp_Pnt2d(100.,100.) |
| 738 | p2 = gp_Pnt2d(200.,100.) |
| 739 | aline = GCE2d_MakeLine(p1,p2).Value() |
| 740 | MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)).Edge()) |
| 741 | |
| 742 | p1 = gp_Pnt2d(200.,100.) |
| 743 | p2 = gp_Pnt2d(150.,200.) |
| 744 | aline = GCE2d_MakeLine(p1,p2).Value() |
| 745 | MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)).Edge()) |
| 746 | |
| 747 | p1 = gp_Pnt2d(150.,200.) |
| 748 | p2 = gp_Pnt2d(100.,100.) |
| 749 | aline = GCE2d_MakeLine(p1,p2).Value() |
| 750 | MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)).Edge()) |
| 751 | |
| 752 | MKF1 = BRepBuilderAPI_MakeFace() |
| 753 | MKF1.Init(surf,False) |
| 754 | MKF1.Add(MW1.Wire()) |
| 755 | FP = MKF1.Face() |
| 756 | BRepLib_BuildCurves3d(FP) |
| 757 | MKrev = BRepFeat_MakeRevol(S,FP,F1,D,1,True) |
| 758 | F2 = faces[4] |
| 759 | MKrev.Perform(F2) |
| 760 | display.EraseAll() |
| 761 | display.DisplayShape(MKrev.Shape()) |
| 762 | |
| 763 | start_display() |
| 764 | |
| 765 | }}} |