if __name__ == '__main__':
mgs = []
poly = vtkCylinderSource()
poly.SetResolution(20)
poly.SetRadius(12)
poly.SetHeight(2)
poly.CappingOn()
poly.Update()
mgs.append(poly.GetOutput())
transformMatrix = [0, 1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1, 2, 3, 1]
# transformMatrix = [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1]
mtxRot = np.array(transformMatrix).reshape(4, 4, order='F').reshape(-1).tolist()
mtxTr2 = vtkMatrix4x4()
mtxTr2.DeepCopy(mtxRot)
transform = vtkTransform()
transform.SetMatrix(mtxTr2)
transform_filter = vtkTransformPolyDataFilter() # vtkTransformFilter()
transform_filter.SetTransform(transform)
transform_filter.SetInputData(poly.GetOutput())
transform_filter.Update()
mgs.append(transform_filter.GetOutput())
renderer = vtkRenderer()
renderWindow = vtkRenderWindow()
renderWindow.SetWindowName("ConvexPointSet")
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
for num, mg in enumerate(mgs):
cubeActor = vtkActor()
cubeActor.GetProperty().SetColor(num, num + 1, 1)
cubeActor.VisibilityOn()
mapper = vtkPolyDataMapper()
mapper.SetInputData(mg)
# mapper.SetLookupTable(lut)
mapper.ScalarVisibilityOff()
cubeActor.SetMapper(mapper)
# Add the actors to the scene
renderer.AddActor(cubeActor)
renderer.ResetCamera()
renderer.GetActiveCamera().Azimuth(210)
renderer.GetActiveCamera().Elevation(30)
renderer.ResetCameraClippingRange()
renderer.SetBackground2(colors.GetColor3d('Black'))
renderer.SetBackground(colors.GetColor3d('Silver'))
renderer.SetGradientBackground(True)
camera = vtkCamera()
camera.SetPosition(0, 0, 0)
camera.SetFocalPoint(0, 0, 0)
# Render and interact
renderWindow.SetSize(640, 480)
renderWindow.Render()
renderWindowInteractor.Start()
After matrix transformation.
The run result shows a black shadow.
I don’t know what the problem is?
log1 = transform.GetOrientationWXYZ()
log2 = transform.GetPosition()
log3 = transform.GetOrientation()
log4 = transform.GetScale()
Print:
log1 (119.99999999999999, 0.5773502691896257, 0.577350269189626, 0.5773502691896256)
log2 (1.0, 2.0, 3.0)
log3 (90.0, -0.0, 90.0)
log4 (-1.0, -1.0, -1.0)
Scale minus?Whether the result is correct?
Any help you can give me would be greatly appreciated!