简体   繁体   中英

VTK, two disks are same size despite different radius?

Attempting to overlay two disks in VTK using the following code:

source = vtk.vtkDiskSource()
source.SetInnerRadius(0)
source.SetOuterRadius(100)
source.SetCircumferentialResolution(300)
source.SetRadialResolution(300)
source.Update()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)

source2 = vtk.vtkDiskSource()
source2.SetInnerRadius(0)
source2.SetOuterRadius(5)
source2.SetCircumferentialResolution(300)
source2.SetRadialResolution(300)
source2.Update()
mapper2 = vtk.vtkPolyDataMapper()
mapper2.SetInputConnection(source2.GetOutputPort())
actor2 = vtk.vtkActor()
actor2.SetMapper(mapper2)
actor2.GetProperty().SetColor(1.0,0.0,0.0)
actor2.SetPosition(0,0,1)

ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

ren.AddActor(actor)
ren.AddActor(actor2)

renWin.Render()
iren.Start()

This should put one large white disk and a smaller red disk in front of it. However what it does is render two disks, one white and one red slightly in front of it. However both disks are the exact same size. ie I have to rotate it to see the white one. Any idea why this is happening? I feel the answers probably very obvious!

Many thanks

It´s because of your position setting of the actor2. The 2nd disc is closer to the camera and appears larger.

Decrease the distance or remove it.

eg

actor2.SetPosition(0,0,0.1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM