本文整理汇总了Python中OCC.Display.SimpleGui.init_display函数的典型用法代码示例。如果您正苦于以下问题:Python init_display函数的具体用法?Python init_display怎么用?Python init_display使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init_display函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main(argv):
step_reader = STEPControl_Reader()
status = step_reader.ReadFile(argv[0])
if status == IFSelect_RetDone: # check status
failsonly = False
step_reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity)
step_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity)
number_of_roots = step_reader.NbRootsForTransfer()
ok = False
i = 1
while not ok and i <= number_of_roots:
ok = step_reader.TransferRoot(i)
i += 1
_nbs = step_reader.NbShapes()
aResShape = step_reader.Shape(1)
else:
print("Error: can't read file.")
sys.exit(0)
display, start_display, add_menu, add_function_to_menu = init_display()
display.DisplayShape(aResShape, update=True)
start_display()
示例2: display_terrain
def display_terrain(self):
"""
Try to display terrain
"""
display, start_display, add_menu, add_function_to_menu = init_display()
display.EraseAll()
display.DisplayShape(self.surface, update=True)
for river in self.rivers.values():
display.DisplayShape(river, update=True)
start_display()
示例3: update_display
def update_display(self):
if self.display_list == None:
# returns: display, start_display, add_menu, add_function_to_menu
from OCC.Display.SimpleGui import init_display
self.display_list = init_display(self.display_driver)
# ask all modules to add shapes to display
display = self.display_list[0]
display.EraseAll()
for m in self.modules:
self.modules[m].add_shapes(display = display)
示例4: display_configuration
def display_configuration(tigl_handle):
"""
This is an example how to use the internal tigl/pyocc API
to display all wing and fuselage segments
"""
from OCC.Display.SimpleGui import init_display
# get the configuration manager
mgr = tigl.configuration.CCPACSConfigurationManager_get_instance()
# get the CPACS configuration, defined by the tigl handle
# we need to access the underlying tigl handle (that is used in the C/C++ API)
config = mgr.get_configuration(tigl_handle._handle.value)
display, start_display, add_menu, add_function_to_menu = init_display()
for ifuse in range(1, config.get_fuselage_count() + 1):
fuselage = config.get_fuselage(ifuse)
for isegment in range(1, fuselage.get_segment_count() + 1):
segment = fuselage.get_segment(isegment)
display.DisplayShape(segment.get_loft().shape(), update=True)
mirrored_shape = segment.get_mirrored_loft()
if mirrored_shape is not None:
display.DisplayShape(mirrored_shape.shape(), update=True)
for iwing in range(1, config.get_wing_count() + 1):
wing = config.get_wing(iwing)
for isegment in range(1, wing.get_segment_count() + 1):
segment = wing.get_segment(isegment)
display.DisplayShape(segment.get_loft().shape(), update=True)
mirrored_shape = segment.get_mirrored_loft()
if mirrored_shape is not None:
display.DisplayShape(mirrored_shape.shape(), update=True)
for iobj in range(1, config.get_external_object_count()+1):
obj = config.get_external_object(iobj)
shape = obj.get_loft()
if shape is not None:
display.DisplayShape(shape.shape(), update=True)
mirrored_shape = obj.get_mirrored_loft()
if mirrored_shape is not None:
display.DisplayShape(mirrored_shape.shape(), update=True)
display.FitAll()
start_display()
示例5: solid_compound
def solid_compound(filename=None):
"""
Generate and display solid object created from bspline surface.
"""
# Create Builder first
builder = BRep_Builder()
# Base box
points_1 = [
gp_Pnt(0.0, 0.0, 0.0),
gp_Pnt(1.0, 0.0, 0.0),
gp_Pnt(1.0, 1.0, 0.0),
gp_Pnt(0.0, 1.0, 0.0),
gp_Pnt(0.0, 0.0, 1.0),
gp_Pnt(1.0, 0.0, 1.0),
gp_Pnt(1.0, 1.0, 1.0),
gp_Pnt(0.0, 1.0, 1.0)
]
solid_box1 = make_box(builder, points_1)
compound = TopoDS_Compound()
builder.MakeCompound(compound)
builder.Add(compound, solid_box1)
base_primitives = brep_explorer.shape_disassembly(solid_box1)
# Get some testing elements
face = base_primitives[4].values()[0]
wire = wires_of_face(face)[0]
edges = edges_of_wire(wire)
for ed_id, edge in enumerate(edges):
print('edge', ed_id, edge.Orientation())
verts = verts_of_edge(edge)
for vert in verts:
coo = coords_from_vert(vert)
print(coo, vert.Orientation())
print('Final compound')
stat = brep_explorer.create_shape_stat(compound)
brep_explorer.print_stat(stat)
if filename is not None:
breptools_Write(compound, filename)
display, start_display, add_menu, add_function_to_menu = init_display()
display.EraseAll()
display.DisplayShape(solid_box1, color='red', update=True)
start_display()
示例6: test_with_viewer_after
def test_with_viewer_after():
# create parameters
p = Parameters()
c = ParametricModelingContext(p)
# create simple box
p.X1, p.Y1, p.Z1, p.X2, p.Y2, p.Z2, p.RADIUS = 12,70,12,30,30,30,4
my_pnt1 = c.basic_operations.MakePointXYZ(p.X1,p.Y1,p.Z1, name="Pnt1", show=True)
my_pnt2 = c.basic_operations.MakePointXYZ(p.X2,p.Y2,p.Z2, name="Pnt2", show=True) # Create the second point
my_box = c.prim_operations.MakeBoxTwoPnt(my_pnt1,my_pnt2,name="Box1", show=True)
#Init display after geometry is created
from OCC.Display.SimpleGui import init_display
display, start_display, add_menu, add_function_to_menu = init_display()
c.set_display(display)
start_display()
示例7: display_result
def display_result(shapes):
"""
Display results
"""
display, start_display, add_menu, add_function_to_menu = init_display()
display.EraseAll()
# Display results
colors = ['red', 'green', 'blue', 'yellow', 'orange']
col_len = len(colors)
for color_id, shape in enumerate(shapes):
_color_id = color_id % col_len
ais_shell = display.DisplayShape(shape, color=colors[_color_id], update=True)
# display.Context.SetTransparency(ais_shell, 0.7)
start_display()
示例8: test_with_viewer
def test_with_viewer():
# init viewer
from OCC.Display.SimpleGui import init_display
display, start_display, add_menu, add_function_to_menu = init_display()
# create parameters
p = Parameters()
# create parametric modeling context
c = ParametricModelingContext(p)
# set graphics
c.set_display(display)
# create simple box
p.X1, p.Y1, p.Z1, p.X2, p.Y2, p.Z2, p.RADIUS = 12, 70, 12, 30, 30, 30, 4
my_pnt1 = c.basic_operations.MakePointXYZ(p.X1, p.Y1, p.Z1, name="Pnt1", show=True)
my_pnt2 = c.basic_operations.MakePointXYZ(p.X2, p.Y2, p.Z2, name="Pnt2", show=True)
my_box = c.prim_operations.MakeBoxTwoPnt(my_pnt1, my_pnt2, name="Box1", show=True)
示例9: show
def show(self, show_file=None):
"""
Method to show a file. If `show_file` is not given it plots `self.shape`.
:param string show_file: the filename you want to show.
"""
if show_file is None:
shape = self.shape
else:
shape = self.load_shape_from_file(show_file)
display, start_display, __, __ = init_display()
display.FitAll()
display.DisplayShape(shape, update=True)
# Show the plot to the screen
start_display()
示例10: visualise
def visualise(occtopo_2dlist, colour_list = None, backend = "qt-pyqt5"):
"""
This function visualise a 3D model using the PythonOCC viewer.
Parameters
----------
occtopo_2dlist : 2d list of OCCtopologies
Geometries to be visualised together with the results.
OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
colour_list : list of str, optional
The colours of the occtopo_2dlist, Default = None. If None all the geometries are displayed in white.
The colour strings include: "WHITE", "BLUE", "RED", "GREEN", "YELLOW", "CYAN", "BLACK", "ORANGE".
The number of colours must correspond to the number of list in the other_topo2dlist.
backend : str, optional
The graphic interface to use for visualisation, Default = qt-pyqt5. Other options include:"qt-pyqt4", "qt-pyside", "wx"
Returns
-------
None : None
A qt window pops up displaying the geometries.
"""
display, start_display, add_menu, add_function_to_menu = init_display(backend_str = backend)
if colour_list == None:
colour_list = []
for _ in range(len(occtopo_2dlist)):
colour_list.append("WHITE")
sc_cnt = 0
for shape_list in occtopo_2dlist:
compound = construct.make_compound(shape_list)
colour = colour_list[sc_cnt]
display.DisplayColoredShape(compound, color = colour, update=True)
sc_cnt+=1
display.set_bg_gradient_color(250, 250, 250, 250, 250, 250)
display.View_Iso()
display.FitAll()
start_display()
示例11: display_results
def display_results(occ_bspline, points):
"""
Try to display OCC
:param occ_bspline:
:param points:
:return:
"""
# Initialize displaying
from OCC.Display.SimpleGui import init_display
display, start_display, add_menu, add_function_to_menu = init_display()
display.EraseAll()
# Draw b-spline surfaces
display.DisplayShape(occ_bspline.GetHandle(), update=True)
# # Draw points of B-Spline
import OCC.Prs3d
import OCC.Quantity
import OCC.Graphic3d
import OCC.Aspect
import OCC.gp
a_presentation = OCC.Prs3d.Prs3d_Presentation(display._struc_mgr)
group = OCC.Prs3d.Prs3d_Root_CurrentGroup(a_presentation.GetHandle()).GetObject()
black = OCC.Quantity.Quantity_Color(OCC.Quantity.Quantity_NOC_BLACK)
asp = OCC.Graphic3d.Graphic3d_AspectLine3d(black, OCC.Aspect.Aspect_TOL_SOLID, 1)
gg = OCC.Graphic3d.Graphic3d_ArrayOfPoints(len(points),
False, # hasVColors
)
for point in points:
pnt = OCC.gp.gp_Pnt(point[0], point[1], point[2])
gg.AddVertex(pnt)
group.SetPrimitivesAspect(asp.GetHandle())
group.AddPrimitiveArray(gg.GetHandle())
a_presentation.Display()
start_display()
示例12: split_shape
def split_shape(event=None):
"""
Example of spliting shape
"""
display, start_display, add_menu, add_function_to_menu = init_display()
S = BRepPrimAPI_MakeBox(gp_Pnt(-100, -60, -80), 150, 200, 170).Shape()
asect = BRepAlgoAPI_Section(S, gp_Pln(1, 2, 1, -15), False)
asect.ComputePCurveOn1(True)
asect.Approximation(True)
asect.Build()
R = asect.Shape()
asplit = BRepFeat_SplitShape(S)
wire1 = BRepBuilderAPI_MakeWire()
i = 0
for edg in Topo(R).edges():
print(edg)
face = TopoDS_Face()
if asect.HasAncestorFaceOn1(edg, face):
print('Adding edge on face and wire: ', face, i)
asplit.Add(edg, face)
# Add edge to wire
if i > 0:
wire1.Add(edg)
i += 1
asplit.Build()
wire1.Build()
display.EraseAll()
display.DisplayShape(asplit.Shape())
display.DisplayShape(wire1.Shape(), color='blue')
# display.FitAll()
start_display()
breptools_Write(asplit.Shape(), "split1.brep")
示例13: show
def show(self, show_file=None):
"""
Method to show an iges file. If `show_file` is not given it plots `self.infile`.
:param string show_file: the iges filename you want to show.
"""
if show_file is None:
show_file = self.infile
else:
self._check_filename_type(show_file)
# read in the IGES file
reader = IGESControl_Reader()
reader.ReadFile(show_file)
reader.TransferRoots()
shape = reader.Shape()
display, start_display, __, __ = init_display()
display.FitAll()
display.DisplayShape(shape, update=True)
# Show the plot to the screen
start_display()
示例14: print
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import sys
print(sys.path)
# required by travis to find SimpleGui module
# both on py2 and py3
sys.path.append('/home/travis/virtualenv/python2.7.8/lib/python2.7/site-packages')
sys.path.append('/home/travis/virtualenv/python3.3.5/lib/python3.3/site-packages')
from OCC.Display.SimpleGui import init_display
from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox
# pyside test
print('pyside test')
pyside_display, start_display, add_menu, add_function_to_menu = init_display('qt-pyside')
my_box_1 = BRepPrimAPI_MakeBox(10., 20., 30.).Shape()
pyside_display.DisplayShape(my_box_1, update=True)
# pyqt4 test
print('pyqt4 test')
pyqt4_display, start_display, add_menu, add_function_to_menu = init_display('qt-pyqt4')
my_box_2 = BRepPrimAPI_MakeBox(10., 20., 30.).Shape()
pyqt4_display.DisplayShape(my_box_2, update=True)
# wx test
print('wx test')
wx_display, start_display, add_menu, add_function_to_menu = init_display('wx')
my_box_3 = BRepPrimAPI_MakeBox(10., 20., 30.).Shape()
wx_display.DisplayShape(my_box_3, update=True)
示例15: __init__
def __init__(self):
self.display, self.start_display, self.add_menu, self.add_function_to_menu = init_display()