Changes between Version 61 and Version 62 of PythonOcc


Ignore:
Timestamp:
Oct 5, 2016, 9:42:33 AM (8 years ago)
Author:
mtelenta
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PythonOcc

    v61 v62  
    304304start_display()
    305305}}}
     306
     307Risanje različnih tipov robov.
     308[[Image(bottle.png, width=480px, right)]]
     309{{{
     310##Copyright 2009-2015 Thomas Paviot (tpaviot@gmail.com)
     311##
     312##This file is part of pythonOCC.
     313##
     314##pythonOCC is free software: you can redistribute it and/or modify
     315##it under the terms of the GNU Lesser General Public License as published by
     316##the Free Software Foundation, either version 3 of the License, or
     317##(at your option) any later version.
     318##
     319##pythonOCC is distributed in the hope that it will be useful,
     320##but WITHOUT ANY WARRANTY; without even the implied warranty of
     321##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     322##GNU Lesser General Public License for more details.
     323##
     324##You should have received a copy of the GNU Lesser General Public License
     325##along with pythonOCC.  If not, see <http://www.gnu.org/licenses/>.
     326
     327import math
     328
     329from OCC.gp import gp_Pnt, gp_Lin, gp_Ax1, gp_Dir, gp_Elips, gp_Ax2
     330from OCC.BRepBuilderAPI import (BRepBuilderAPI_MakeEdge,
     331                                BRepBuilderAPI_MakeVertex)
     332from OCC.TColgp import TColgp_Array1OfPnt
     333from OCC.Geom import Geom_BezierCurve
     334
     335from OCC.Display.SimpleGui import init_display
     336display, start_display, add_menu, add_function_to_menu = init_display()
     337
     338
     339def edge(event=None):
     340    # The blue edge
     341    BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80, -50, -20),
     342                                       gp_Pnt(-30, -60, -60))
     343    V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20, 10, -30))
     344    V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10, 7, -25))
     345    YellowEdge = BRepBuilderAPI_MakeEdge(V1.Vertex(), V2.Vertex())
     346
     347    #The white edge
     348    line = gp_Lin(gp_Ax1(gp_Pnt(10, 10, 10), gp_Dir(1, 0, 0)))
     349    WhiteEdge = BRepBuilderAPI_MakeEdge(line, -20, 10)
     350
     351    #The red edge
     352    Elips = gp_Elips(gp_Ax2(gp_Pnt(10, 0, 0), gp_Dir(1, 1, 1)), 60, 30)
     353    RedEdge = BRepBuilderAPI_MakeEdge(Elips, 0, math.pi/2)
     354
     355    # The green edge and the both extreme vertex
     356    P1 = gp_Pnt(-15, 200, 10)
     357    P2 = gp_Pnt(5, 204, 0)
     358    P3 = gp_Pnt(15, 200, 0)
     359    P4 = gp_Pnt(-15, 20, 15)
     360    P5 = gp_Pnt(-5, 20, 0)
     361    P6 = gp_Pnt(15, 20, 0)
     362    P7 = gp_Pnt(24, 120, 0)
     363    P8 = gp_Pnt(-24, 120, 12.5)
     364    array = TColgp_Array1OfPnt(1, 8)
     365    array.SetValue(1, P1)
     366    array.SetValue(2, P2)
     367    array.SetValue(3, P3)
     368    array.SetValue(4, P4)
     369    array.SetValue(5, P5)
     370    array.SetValue(6, P6)
     371    array.SetValue(7, P7)
     372    array.SetValue(8, P8)
     373    curve = Geom_BezierCurve(array)
     374    ME = BRepBuilderAPI_MakeEdge(curve.GetHandle())
     375    GreenEdge = ME
     376    V3 = ME.Vertex1()
     377    V4 = ME.Vertex2()
     378
     379    display.DisplayColoredShape(BlueEdge.Edge(), 'BLUE')
     380    display.DisplayShape(V1.Vertex())
     381    display.DisplayShape(V2.Vertex())
     382    display.DisplayColoredShape(WhiteEdge.Edge(), 'WHITE')
     383    display.DisplayColoredShape(YellowEdge.Edge(), 'YELLOW')
     384    display.DisplayColoredShape(RedEdge.Edge(), 'RED')
     385    display.DisplayColoredShape(GreenEdge.Edge(), 'GREEN')
     386    display.DisplayShape(V3)
     387    display.DisplayShape(V4, update=True)
     388
     389if __name__ == '__main__':
     390    edge()
     391    start_display()
     392
     393}}}
    306394=== Izdelava primera Bottle z uporabo programskega jezika Python in knjižnice OCC ===
    307395Naslednji primer prikazuje izdelavo primera BottleCAD. Podrobnejši razdelek posameznih delov programske kode dobimo na [[http://trac.lecad.si/vaje/wiki/OpenCascade|MakeBottleCAD(C++)]].