mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 22:43:41 +00:00
Backwards pyocc compatibility in occ_utils
This commit is contained in:
@@ -29,8 +29,10 @@ from collections import namedtuple, Iterable
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from OCC.Core import V3d, TopoDS, gp, AIS, Quantity, BRepTools, Graphic3d
|
from OCC.Core import V3d, TopoDS, gp, AIS, Quantity, BRepTools, Graphic3d
|
||||||
|
USE_OCCT_HANDLE = False
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from OCC import V3d, TopoDS, gp, AIS, Quantity, BRepTools, Graphic3d
|
from OCC import V3d, TopoDS, gp, AIS, Quantity, BRepTools, Graphic3d
|
||||||
|
USE_OCCT_HANDLE = True
|
||||||
|
|
||||||
shape_tuple = namedtuple('shape_tuple', ('data', 'geometry', 'styles'))
|
shape_tuple = namedtuple('shape_tuple', ('data', 'geometry', 'styles'))
|
||||||
|
|
||||||
@@ -76,10 +78,15 @@ def initialize_display():
|
|||||||
for l in lights:
|
for l in lights:
|
||||||
viewer.DelLight(l)
|
viewer.DelLight(l)
|
||||||
|
|
||||||
for dir in [V3d.V3d_TypeOfOrientation_Yup_AxoRight, V3d.V3d_TypeOfOrientation_Zup_AxoRight]:
|
if hasattr(V3d, 'V3d_TypeOfOrientation_Yup_AxoRight'):
|
||||||
|
dirs = [[V3d.V3d_TypeOfOrientation_Yup_AxoRight], [V3d.V3d_TypeOfOrientation_Zup_AxoRight]]
|
||||||
|
else:
|
||||||
|
dirs = [(3, 2, 1), (-1, -2, -3)]
|
||||||
|
|
||||||
|
for dir in dirs:
|
||||||
light = V3d.V3d_DirectionalLight(viewer_handle)
|
light = V3d.V3d_DirectionalLight(viewer_handle)
|
||||||
light.SetDirection(dir)
|
light.SetDirection(*dir)
|
||||||
viewer.SetLightOn(light)
|
viewer.SetLightOn(light.GetHandle() if USE_OCCT_HANDLE else light)
|
||||||
|
|
||||||
setup()
|
setup()
|
||||||
return handle
|
return handle
|
||||||
@@ -177,14 +184,14 @@ def display_shape(shape, clr=None, viewer_handle=None):
|
|||||||
clr = Quantity.Quantity_Color(r(), r(), r(), Quantity.Quantity_TOC_RGB)
|
clr = Quantity.Quantity_Color(r(), r(), r(), Quantity.Quantity_TOC_RGB)
|
||||||
ais.SetColor(clr)
|
ais.SetColor(clr)
|
||||||
|
|
||||||
ais_handle = ais
|
ais_handle = ais.GetHandle() if USE_OCCT_HANDLE else ais
|
||||||
viewer_handle.Context.Display(ais_handle, False)
|
viewer_handle.Context.Display(ais_handle, False)
|
||||||
|
|
||||||
return ais_handle
|
return ais_handle
|
||||||
|
|
||||||
|
|
||||||
def set_shape_transparency(ais, t, update_viewer=True):
|
def set_shape_transparency(ais, t):
|
||||||
handle.Context.SetTransparency(ais, t, update_viewer)
|
handle.Context.SetTransparency(ais, t)
|
||||||
|
|
||||||
|
|
||||||
def get_bounding_box_center(bbox):
|
def get_bounding_box_center(bbox):
|
||||||
|
|||||||
Reference in New Issue
Block a user