Changes between Version 4 and Version 5 of PythonOcc


Ignore:
Timestamp:
Dec 5, 2011, 11:56:47 AM (12 years ago)
Author:
skulovec
Comment:

izdelava prizme + mirror

Legend:

Unmodified
Added
Removed
Modified
  • PythonOcc

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