tvtk中关于SetViewPlaneNorm的AttributeError

2024-10-02 08:20:29 发布

您现在位置:Python中文网/ 问答频道 /正文

注意:找到了一个临时解决方案:打开camera.py,使用pass并对函数_view_plane_normal_changed中的内容进行注释,然后重新编译它。在

我用的是python(x,y)2.7.5.1。当我使用像mayavi这样的tvtk的包时,它会引发一个AttributeError:SetViewPlaneNormal. 我知道这是因为vtk不赞成这种方法。 有人知道怎么解决吗? vtk的版本是5.10.1-3. 完整的trackback包含如下一些块:

ERROR:traits:Exception occurred in traits notification handler for object:     vtkOpenGLCamera (06F89078)
    Debug: Off
    ...#There are too many lines here


Traceback (most recent call last):
    File "D:\Python27\lib\site-packages\traits\trait_notifiers.py", line 381, in call_3
        self.handler( object, old, new )
    File "D:\Python27\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\camera.py", line 82, in _view_plane_normal_changed
        self._do_change(self._vtk_obj.SetViewPlaneNormal,
AttributeError: SetViewPlaneNormal
Exception occurred in traits notification handler.

Tags: inpyselfviewexceptioncamerahandlerattributeerror
2条回答

我也面临着同样的问题。任何mayavi代码都会导致AttributeError:SetViewPlaneNormal错误。在

我的平台是win7prox64,有python2.7.5,vtk5.10.1,Mayavi 4.3.0。在

请注意,即使是官方的python示例也会导致错误,但是尽管在控制台中不断地打印错误,图形还是正确地显示出来的。在

以下是完整的堆栈跟踪:

, trait: view_plane_normal, old value: [ 0.57735027  0.57735027  0.57735027], new value: [     0.57735027  0.57735027  0.57735027]
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\traits\trait_notifiers.py", line 381, in call_3
    self.handler( object, old, new )
  File "C:\Python27\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\camera.py", line 82, in     _view_plane_normal_changed
    self._do_change(self._vtk_obj.SetViewPlaneNormal,
AttributeError: SetViewPlaneNormal
Exception occurred in traits notification handler for object: vtkOpenGLCamera (092BF010)
  Debug: Off
  Modified Time: 890617
  Reference Count: 2
  Registered Events: 
    Registered Observers:
      vtkObserver (0A1AA3C8)
        Event: 33
        EventName: ModifiedEvent
        Command: 0A867210
        Priority: 0
        Tag: 1
  ClippingRange: (1.56289, 5.47286)
  DirectionOfProjection: (-0.57735, -0.57735, -0.57735)
  Distance: 3.29037
  EyeAngle: 2
  FocalDisk: 1
  FocalPoint: (1, 1, 1)
  ViewShear: (0, 0, 1)
  ParallelProjection: Off
  ParallelScale: 0.851612
  Position: (2.8997, 2.8997, 2.8997)
  Stereo: Off
  Left Eye: 1
  Thickness: 3.90998
  ViewAngle: 30
  UseHorizontalViewAngle: 0
  UserTransform: (none)
(none)
  ViewPlaneNormal: (0.57735, 0.57735, 0.57735)
  ViewUp: (0, 0, 1)
  WindowCenter: (0, 0)
  UseOffAxisProjection: (0)
  ScreenBottomLeft: (-0.5, -0.5, -0.5)
  ScreenBottomRight: (0.5, -0.5, -0.5)
  ScreenTopRight: (0.5, 0.5, -0.5)
  EyeSeparation: (0.06)
  WorldToScreenMatrix: (03996300
    Debug: Off
    Modified Time: 881548
    Reference Count: 1
    Registered Events: (none)
    Elements:
        1 0 0 0 
        0 1 0 0 
        0 0 1 0 
        0 0 0 1 
  )
  EyeTransformMatrix: (039954F0
    Debug: Off
    Modified Time: 881550
    Reference Count: 1
    Registered Events: (none)
    Elements:
        1 0 0 0 
        0 1 0 0 
        0 0 1 0 
        0 0 0 1 
  )
  ModelTransformMatrix: (039955E0
    Debug: Off
    Modified Time: 881552
    Reference Count: 1
    Registered Events: (none)
    Elements:
        1 0 0 0 
        0 1 0 0 
        0 0 1 0 
        0 0 0 1 
  )

, trait: view_plane_normal, old value: [ 0.57735027  0.57735027  0.57735027], new value: [     0.57735027  0.57735027  0.57735027]
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\traits\trait_notifiers.py", line 381, in call_3
    self.handler( object, old, new )
  File "C:\Python27\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\camera.py", line 82, in     _view_plane_normal_changed
    self._do_change(self._vtk_obj.SetViewPlaneNormal,
AttributeError: SetViewPlaneNormal    

上面的堆栈跟踪在每次渲染中打印多次。如果我们移动摄像机导致FPS的大幅度下降,就会继续发生。在

导致此错误的最简单代码示例:

^{pr2}$

我在使用python(x,y)(2.7.5.2)时也遇到过这个问题,但是在Anaconda(1.8.0)发行版下,代码可以正常工作。在

# code comes from mayavi docs shipped with python(x,y) 2.7.5.2
# Create the data.
from numpy import pi, sin, cos, mgrid
dphi, dtheta = pi/250.0, pi/250.0
[phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta]
m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4;
r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7
x = r*sin(phi)*cos(theta)
y = r*cos(phi)
z = r*sin(phi)*sin(theta)

# View it.
from mayavi import mlab
s = mlab.mesh(x, y, z)
mlab.show()

相关问题 更多 >

    热门问题