Skip to content

Commit

Permalink
Fix VTK assembly render apply gp_Intrinsic_ZXY rotation (#1540)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzncode authored Mar 19, 2024
1 parent 153ed3f commit 00fdd71
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cadquery/occ_impl/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from OCP.TopTools import TopTools_ListOfShape
from OCP.BOPAlgo import BOPAlgo_GlueEnum, BOPAlgo_MakeConnected
from OCP.TopoDS import TopoDS_Shape
from OCP.gp import gp_EulerSequence

from vtkmodules.vtkRenderingCore import (
vtkActor,
Expand Down Expand Up @@ -259,7 +260,14 @@ def toVTK(
for shape, _, loc, col_ in assy:

col = col_.toTuple() if col_ else color
trans, rot = loc.toTuple()
T = loc.wrapped.Transformation()
trans = T.TranslationPart().Coord()
rot = tuple(
map(
degrees,
T.GetRotation().GetEulerAngles(gp_EulerSequence.gp_Intrinsic_ZXY),
)
)

data = shape.toVtkPolyData(tolerance, angularTolerance)

Expand Down Expand Up @@ -290,7 +298,7 @@ def toVTK(
actor = vtkActor()
actor.SetMapper(mapper)
actor.SetPosition(*trans)
actor.SetOrientation(*map(degrees, rot))
actor.SetOrientation(rot[1], rot[2], rot[0])
actor.GetProperty().SetColor(*col[:3])
actor.GetProperty().SetOpacity(col[3])

Expand All @@ -302,7 +310,7 @@ def toVTK(
actor = vtkActor()
actor.SetMapper(mapper)
actor.SetPosition(*trans)
actor.SetOrientation(*map(degrees, rot))
actor.SetOrientation(rot[1], rot[2], rot[0])
actor.GetProperty().SetColor(0, 0, 0)
actor.GetProperty().SetLineWidth(2)

Expand Down

0 comments on commit 00fdd71

Please sign in to comment.