2010/5/13 Patrick Janssen <patr...@janssen.name>

> I am just getting started, and have been looking at some of the exampls
> etc... So to draw a line, you would do this:
>
> def test5():
>     ''' Test creating a line segment''
>     display, start_display, add_menu, add_function_to_menu = init_display()
>
>     from OCC.gp import gp_Pnt, gp_Dir
>     from OCC.Geom import Geom_Line
>     from OCC.BRepBuilderAPI import BRepBuilderAPI_MakeEdge
>     p1 = gp_Pnt(0,0,0)
>     line_dir = gp_Dir(1,1,0)
>     my_line = Geom_Line(p1, line_dir).Lin()
>     my_line = BRepBuilderAPI_MakeEdge(my_line)
>     my_line.Build()
>     my_line = my_line.Shape()
>     display.DisplayShape(my_line)
>
>     display.View_Iso()
>     display.FitAll()
>     start_display()
>
>
> Is there a simpler way?
> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> Patrick
>
>
Hi Patrick,

In only 14 lines of python code, you manage to display a line in a 3D
window. I think it's not bad! What do you mean exactly with 'simpler'? Do
you mean 'less lines'? Whatever the alternative solution could be, you will
always have to :
* import python modules/packages,
* define two points (or a point and a direction),
* create the line from these two points,
* send the line to the renderer.

You can use for instance high level wrappers to generate the edges from the
line:

from OCC.Display.SimpleGui import *
display, start_display, add_menu, add_function_to_menu = init_display()
from OCC.gp import gp_Pnt, gp_Dir
from OCC.Geom import Geom_Line
from OCC.Utils.Construct import make_edge

p1 = gp_Pnt(0,0,0)
line_dir = gp_Dir(1,1,0)
my_line = Geom_Line(p1, line_dir).Lin()

display.DisplayShape(make_edge(my_line))

start_display()

This sample is 11 lines, I would not say it's simpler but smaller.

Thomas
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to