OCC.Display.OCCViewer module

class OffscreenRenderer(screen_size=(640, 480))

Bases: OCC.Display.OCCViewer.Viewer3d

The offscreen renderer is inherited from Viewer3d. The DisplayShape method is overriden to export to image each time it is called.

DisplayShape(shapes, material=None, texture=None, color=None, transparency=None, update=False)
class Viewer3d(window_handle)

Bases: OCC.Visualization.Display3d

Create(create_default_lights=True, draw_face_boundaries=True, phong_shading=True)
DisableAntiAliasing()
DisableTextureEnv()
DisplayColoredShape(shapes, color='YELLOW', update=False)
DisplayMessage(point, text_to_write, height=None, message_color=None, update=False)
Point:a gp_Pnt or gp_Pnt2d instance
Text_to_write:a string
Message_color:triple with the range 0-1
DisplayShape(shapes, material=None, texture=None, color=None, transparency=None, update=False)

display one or a set of displayable objects

DisplayVector(vec, pnt, update=False)

displays a vector as an arrow

DynamicZoom(X1, Y1, X2, Y2)
EnableAntiAliasing()
EnableTextureEnv(name_of_texture=0)

enable environment mapping. Possible modes are Graphic3d_NOT_ENV_CLOUDS Graphic3d_NOT_ENV_CV Graphic3d_NOT_ENV_MEDIT Graphic3d_NOT_ENV_PEARL Graphic3d_NOT_ENV_SKY1 Graphic3d_NOT_ENV_SKY2 Graphic3d_NOT_ENV_LINES Graphic3d_NOT_ENV_ROAD Graphic3d_NOT_ENV_UNKNOWN

EraseAll()
ExportToImage(image_filename)
FitAll()
GetOverLayer()

returns an handle to the current overlayer

GetSelectedShape()

Returns the current selected shape

GetSelectedShapes()
MoveTo(X, Y)
OnResize()
Pan(dx, dy)
Repaint()
ResetView()
Rotation(X, Y)
Select(X, Y)
SelectArea(Xmin, Ymin, Xmax, Ymax)
SetBackgroundImage(image_filename, stretch=True)

displays a background image (jpg, png etc.)

SetModeHLR()
SetModeShaded()
SetModeWireFrame()
SetOrthographicProjection()
SetPerspectiveProjection()
SetRasterizationMode()

to enable rasterization mode, just call the SetRenderingParams with default values

SetRaytracingMode(depth=3)

enables the raytracing mode

SetRenderingParams(Method=0, RaytracingDepth=3, IsShadowEnabled=True, IsReflectionEnabled=False, IsAntialiasingEnabled=False, IsTransparentShadowEnabled=False, StereoMode=0, AnaglyphFilter=1, ToReverseStereo=False)

Default values are : Method=Graphic3d_RM_RASTERIZATION, RaytracingDepth=3, IsShadowEnabled=True, IsReflectionEnabled=False, IsAntialiasingEnabled=False, IsTransparentShadowEnabled=False, StereoMode=Graphic3d_StereoMode_QuadBuffer, AnaglyphFilter=Graphic3d_RenderingParams.Anaglyph_RedCyan_Optimized, ToReverseStereo=False)

SetSelectionMode(mode=None)
SetSelectionModeEdge()
SetSelectionModeFace()
SetSelectionModeNeutral()
SetSelectionModeShape()
SetSelectionModeVertex()
ShiftSelect(X, Y)
StartRotation(X, Y)
Tumble(num_images, animation=True)
View_Bottom()
View_Front()
View_Iso()
View_Left()
View_Rear()
View_Right()
View_Top()
Zoom(X, Y)
ZoomArea(X1, Y1, X2, Y2)
ZoomFactor(zoom_factor)
display_graduated_trihedron()
display_trihedron()

Show a black trihedron in lower right corner

register_overlay_item(overlay_item)
register_select_callback(callback)

Adds a callback that will be called each time a shape s selected

set_bg_gradient_color(R1, G1, B1, R2, G2, B2)

set a bg vertical gradient color. R, G and B are floats.

unregister_callback(callback)

Remove a callback from the callback list

get_color_from_name(color_name)

from the string ‘WHITE’, returns Quantity_Color WHITE. color_name is the color name, case insensitive.

rgb_color(r, g, b)
to_string(_string)