简体   繁体   English

Activiz(C#)VTK与Python VTK渲染质量

[英]Activiz (C#) VTK vs Python VTK render quality

I have created a small tool in Python that shows a couple of STLs and creates a number of screenshots of them. 我已经在Python中创建了一个小工具,该工具显示了两个STL,并为其创建了许多屏幕截图。 Recently, I have converted this tool to C# using the Activiz VTK wrapper (both VTK implementations are version 5.8.0). 最近,我已使用Activiz VTK包装器将此工具转换为C#(两个VTK实现均为5.8.0版)。 The quality of the screenshots created in the C# implementation is similar to that of the Python screenshots, except where STLs overlap with eachother. C#实现中创建的屏幕截图的质量与Python屏幕快照的质量相似,不同之处在于STL相互重叠。

This is a Python VTK screenshot 这是Python VTK屏幕截图

And this is the corresponding Activiz VTK screenshot 这是对应的Activiz VTK屏幕截图

As you can see, the red objects show through the beige one in Activiz VTK, the orange (and red) objects also show through the blue object on the left. 如您所见,红色对象通过Activiz VTK中的米色显示,橙色(和红色)对象也通过左侧的蓝色对象显示。

This is the Activiz render setup: 这是Activiz渲染设置:

vtkOpenGLRenderer renderer = new vtkOpenGLRenderer();            
renderer.SetBackground(1, 1, 1);
vtkWin32OpenGLRenderWindow window = new vtkWin32OpenGLRenderWindow();
window.SetSize(1000, 1000);
window.AddRenderer(renderer);

STLs are added like this 这样添加STL

vtkPolyDataMappermapper = vtkPolyDataMapper.New();
mapper.SetInput(_polydata);
vtkActor actor = vtkActor.New();
actor.SetMapper(mapper);
actor.GetProperty().SetColor((double)color.R / 255, (double)color.G / 255, (double)color.B / 255);
actor.GetProperty().SetOpacity(alpha);
actor.GetProperty().SetInterpolationToPhong();
renderer.AddActor(actor);

This is the original Python render setup 这是原始的Python渲染设置

renderer = vtkOpenGLRenderer()
renderer.SetBackground(1,1,1)
window = vtkWin32OpenGLRenderWindow()
window.SetSize(1000,1000)
window.AddRenderer(renderer)

And STLs are added like this in Python 然后在Python中像这样添加STL

mapper = vtkPolyDataMapper()
mapper.SetInputData(polydata)
actor = vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(color)
actor.GetProperty().SetOpacity(alpha)
actor.GetProperty().SetInterpolationToPhong()
renderer.AddActor(actor)

Has anyone had a similar experience, or does anyone know what causes this difference in quality? 有没有人有过类似的经历,或者有谁知道是什么原因造成了这种质量差异?

Kind regards 亲切的问候

Maybe the cameras clipping planes (see "Perspective Projection") are set to different values. 也许相机的裁剪平面 (请参见“透视投影”)设置为不同的值。 If the clipping range is too large such rendering errors can occur. 如果裁剪范围太大,则会发生渲染错误。 Try to set it small enough so that all your objects are displayed. 尝试将其设置得足够小,以便显示所有对象。 Haven't tried it but something like this: 还没有尝试过,但是像这样:

renderer.GetActiveCamera().SetClippingRange(0.1, 100);

where the two arguments are the distances of the near and far clipping plane from the camera. 其中两个参数是近摄剪辑和远摄剪辑与相机的距离。

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

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