| 92 | |
| 93 | Primer kode 3D modela:[[BR]] |
| 94 | {{{ |
| 95 | #!python |
| 96 | ## Izdelava kocke |
| 97 | |
| 98 | from OCC.Display.SimpleGui import * |
| 99 | from OCC.BRepPrimAPI import * |
| 100 | from OCC.gp import * |
| 101 | from OCC.GC import * |
| 102 | from OCC.BRepBuilderAPI import * |
| 103 | #from OCC.TopoDS import * |
| 104 | |
| 105 | display, start_display, add_menu, add_function_to_menu = init_display() |
| 106 | |
| 107 | #Definiranje točk v prostoru |
| 108 | aPnt1 = gp_Pnt(0 , 0 , 0) |
| 109 | aPnt2 = gp_Pnt(10 , 0, 0) |
| 110 | aPnt3 = gp_Pnt(10 , 10 , 0) |
| 111 | aPnt4 = gp_Pnt(0, 10 , 0) |
| 112 | |
| 113 | #Izdelava segmentov--definiranje geometrije |
| 114 | aSegment1 = GC_MakeSegment(aPnt1 , aPnt2) |
| 115 | aSegment2 = GC_MakeSegment(aPnt2 , aPnt3) |
| 116 | aSegment3 = GC_MakeSegment(aPnt3 , aPnt4) |
| 117 | aSegment4 = GC_MakeSegment(aPnt4 , aPnt1) |
| 118 | |
| 119 | #Izdelava robov -- definiranje topologije |
| 120 | aEdge1 = BRepBuilderAPI_MakeEdge(aSegment1.Value()) |
| 121 | aEdge2 = BRepBuilderAPI_MakeEdge(aSegment2.Value()) |
| 122 | aEdge3 = BRepBuilderAPI_MakeEdge(aSegment3.Value()) |
| 123 | aEdge4 = BRepBuilderAPI_MakeEdge(aSegment4.Value()) |
| 124 | |
| 125 | #Povezovanje robov v mrežo |
| 126 | aWire = BRepBuilderAPI_MakeWire(aEdge1.Edge() , aEdge2.Edge() ,\ |
| 127 | aEdge3.Edge(), aEdge4.Edge()) |
| 128 | |
| 129 | #Telo: Iz profila se izdela telo |
| 130 | myFaceProfile = BRepBuilderAPI_MakeFace(aWire.Wire()) |
| 131 | |
| 132 | aPrismVec = gp_Vec(0 , 0 , 10) |
| 133 | |
| 134 | myBody = BRepPrimAPI_MakePrism(myFaceProfile.Face() , aPrismVec).Shape() |
| 135 | |
| 136 | display.DisplayShape(myBody) |
| 137 | start_display() |
| 138 | }}} |
409 | | === Izris CAD kocke === |
410 | | {{{ |
411 | | #!python |
412 | | ## Izdelava kocke |
413 | | |
414 | | from OCC.Display.SimpleGui import * |
415 | | from OCC.BRepPrimAPI import * |
416 | | from OCC.gp import * |
417 | | from OCC.GC import * |
418 | | from OCC.BRepBuilderAPI import * |
419 | | #from OCC.TopoDS import * |
420 | | |
421 | | display, start_display, add_menu, add_function_to_menu = init_display() |
422 | | |
423 | | #Definiranje točk v prostoru |
424 | | aPnt1 = gp_Pnt(0 , 0 , 0) |
425 | | aPnt2 = gp_Pnt(10 , 0, 0) |
426 | | aPnt3 = gp_Pnt(10 , 10 , 0) |
427 | | aPnt4 = gp_Pnt(0, 10 , 0) |
428 | | |
429 | | #Izdelava segmentov--definiranje geometrije |
430 | | aSegment1 = GC_MakeSegment(aPnt1 , aPnt2) |
431 | | aSegment2 = GC_MakeSegment(aPnt2 , aPnt3) |
432 | | aSegment3 = GC_MakeSegment(aPnt3 , aPnt4) |
433 | | aSegment4 = GC_MakeSegment(aPnt4 , aPnt1) |
434 | | |
435 | | #Izdelava robov -- definiranje topologije |
436 | | aEdge1 = BRepBuilderAPI_MakeEdge(aSegment1.Value()) |
437 | | aEdge2 = BRepBuilderAPI_MakeEdge(aSegment2.Value()) |
438 | | aEdge3 = BRepBuilderAPI_MakeEdge(aSegment3.Value()) |
439 | | aEdge4 = BRepBuilderAPI_MakeEdge(aSegment4.Value()) |
440 | | |
441 | | #Povezovanje robov v mrežo |
442 | | aWire = BRepBuilderAPI_MakeWire(aEdge1.Edge() , aEdge2.Edge() ,\ |
443 | | aEdge3.Edge(), aEdge4.Edge()) |
444 | | |
445 | | #Telo: Iz profila se izdela telo |
446 | | myFaceProfile = BRepBuilderAPI_MakeFace(aWire.Wire()) |
447 | | |
448 | | aPrismVec = gp_Vec(0 , 0 , 10) |
449 | | |
450 | | myBody = BRepPrimAPI_MakePrism(myFaceProfile.Face() , aPrismVec).Shape() |
451 | | |
452 | | display.DisplayShape(myBody) |
453 | | start_display() |
454 | | }}} |