简体   繁体   English

VTK,两个磁盘的大小相同,尽管半径不同?

[英]VTK, two disks are same size despite different radius?

Attempting to overlay two disks in VTK using the following code: 尝试使用以下代码在VTK中覆盖两个磁盘:

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. 这是因为您设置了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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尽管代码不同,但两个不同的文件仍提供相同的输出-PyQT5和Python - Two different files giving same output despite having different codes - PyQT5 and Python 尽管具有相同的锚点/句柄(manim),为什么这会生成两条不同的贝塞尔曲线? - Why does this generate two different Bezier curves despite having the same anchors/handles (manim)? 尽管 Big-O 相同,为什么这两个函数的性能差异如此之大? - Why is the performance of these two functions so drastically different despite the same Big-O? 如何将两个不同的Dataframe列均等化为相同大小 - How to equalise two different Dataframe column into same size 具有特定半径的球体的 VTK/Paraview 可编程源 - VTK/Paraview Programmable source for spheres with specific radius 为什么结果不同,尽管代码完全相同? - Why is the result different ,despite the code is exactly the same? 如何合并具有不同行大小和相同列大小的两个矩阵(DataFrame)? - How to merge two matrix(DataFrame) with different row size and same column size? Python matlibplot:用圆圈(相同的半径,不同的颜色)可视化整数矩阵(-1,0或1) - Python matlibplot: visualizing a matrix of integers (-1, 0 or 1) with circles (same radius, different color) 使用openCV-python将两个轮廓分割为两个相同大小的不同图像 - Segmenting two contours into two different images of same size using openCV-python pygame 表面在中间被切断,尽管与屏幕尺寸相同 - pygame surface is cutting off in the middle despite being the same size as the screen
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM