| | 365 | |
| | 366 | === Izris CAD prizme === |
| | 367 | {{{ |
| | 368 | #!python |
| | 369 | ## Izdelava prizme --primer bottle |
| | 370 | |
| | 371 | from OCC.Display.SimpleGui import * |
| | 372 | from OCC.BRepPrimAPI import * |
| | 373 | from OCC.gp import * |
| | 374 | from OCC.GC import * |
| | 375 | from OCC.BRepBuilderAPI import * |
| | 376 | from OCC.TopoDS import * |
| | 377 | |
| | 378 | display, start_display, add_menu, add_function_to_menu = init_display() |
| | 379 | |
| | 380 | myWidth = 50.0 |
| | 381 | myThickness = 30.0 |
| | 382 | myHeight = 70.0 |
| | 383 | |
| | 384 | #Definiranje začetnih točk |
| | 385 | aPnt1 = gp_Pnt(-myWidth / 2. , 0 , 0) |
| | 386 | aPnt2 = gp_Pnt(-myWidth / 2. , -myThickness / 4. , 0) |
| | 387 | aPnt3 = gp_Pnt(0 , -myThickness / 2. , 0) |
| | 388 | aPnt4 = gp_Pnt(myWidth / 2. , -myThickness / 4. , 0) |
| | 389 | aPnt5 = gp_Pnt(myWidth / 2. , 0 , 0) |
| | 390 | |
| | 391 | #Izdelava segmentov--definiranje geometrije |
| | 392 | aArcOfCircle = GC_MakeArcOfCircle(aPnt2,aPnt3 ,aPnt4) |
| | 393 | aSegment1 = GC_MakeSegment(aPnt1 , aPnt2) |
| | 394 | aSegment2 = GC_MakeSegment(aPnt4 , aPnt5) |
| | 395 | |
| | 396 | #Izdelava robov -- definiranje topologije |
| | 397 | aEdge1 = BRepBuilderAPI_MakeEdge(aSegment1.Value()) |
| | 398 | aEdge2 = BRepBuilderAPI_MakeEdge(aArcOfCircle.Value()) |
| | 399 | aEdge3 = BRepBuilderAPI_MakeEdge(aSegment2.Value()) |
| | 400 | |
| | 401 | #Povezovanje robov v mrežo |
| | 402 | aWire = BRepBuilderAPI_MakeWire(aEdge1.Edge() , aEdge2.Edge() ,\ |
| | 403 | aEdge3.Edge()) |
| | 404 | |
| | 405 | #Izdelava celotnega profila - mirror |
| | 406 | xAxis = gp_OX() |
| | 407 | aTrsf = gp_Trsf() |
| | 408 | aTrsf.SetMirror(xAxis) |
| | 409 | aBRepTrsf = BRepBuilderAPI_Transform(aWire.Shape() , aTrsf) |
| | 410 | aMirroredShape = aBRepTrsf.Shape() |
| | 411 | aMirroredWire = TopoDS_wire(aMirroredShape) |
| | 412 | mkWire = BRepBuilderAPI_MakeWire() |
| | 413 | mkWire.Add(aWire.Wire()) |
| | 414 | mkWire.Add(aMirroredWire) |
| | 415 | myWireProfile = mkWire.Wire() |
| | 416 | |
| | 417 | #Telo: Iz profila se izdela telo |
| | 418 | myFaceProfile = BRepBuilderAPI_MakeFace(myWireProfile) |
| | 419 | aPrismVec = gp_Vec(0 , 0 , myHeight) |
| | 420 | myBody = BRepPrimAPI_MakePrism(myFaceProfile.Face() , aPrismVec).Shape() |
| | 421 | |
| | 422 | display.DisplayShape(myBody) |
| | 423 | start_display() |
| | 424 | }}} |