Skip to content

Commit 00fdd71

Browse files
authored
Fix VTK assembly render apply gp_Intrinsic_ZXY rotation (#1540)
1 parent 153ed3f commit 00fdd71

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

cadquery/occ_impl/assembly.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from OCP.TopTools import TopTools_ListOfShape
2626
from OCP.BOPAlgo import BOPAlgo_GlueEnum, BOPAlgo_MakeConnected
2727
from OCP.TopoDS import TopoDS_Shape
28+
from OCP.gp import gp_EulerSequence
2829

2930
from vtkmodules.vtkRenderingCore import (
3031
vtkActor,
@@ -259,7 +260,14 @@ def toVTK(
259260
for shape, _, loc, col_ in assy:
260261

261262
col = col_.toTuple() if col_ else color
262-
trans, rot = loc.toTuple()
263+
T = loc.wrapped.Transformation()
264+
trans = T.TranslationPart().Coord()
265+
rot = tuple(
266+
map(
267+
degrees,
268+
T.GetRotation().GetEulerAngles(gp_EulerSequence.gp_Intrinsic_ZXY),
269+
)
270+
)
263271

264272
data = shape.toVtkPolyData(tolerance, angularTolerance)
265273

@@ -290,7 +298,7 @@ def toVTK(
290298
actor = vtkActor()
291299
actor.SetMapper(mapper)
292300
actor.SetPosition(*trans)
293-
actor.SetOrientation(*map(degrees, rot))
301+
actor.SetOrientation(rot[1], rot[2], rot[0])
294302
actor.GetProperty().SetColor(*col[:3])
295303
actor.GetProperty().SetOpacity(col[3])
296304

@@ -302,7 +310,7 @@ def toVTK(
302310
actor = vtkActor()
303311
actor.SetMapper(mapper)
304312
actor.SetPosition(*trans)
305-
actor.SetOrientation(*map(degrees, rot))
313+
actor.SetOrientation(rot[1], rot[2], rot[0])
306314
actor.GetProperty().SetColor(0, 0, 0)
307315
actor.GetProperty().SetLineWidth(2)
308316

0 commit comments

Comments
 (0)