Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Python WX从VTK构造和提取阴影信息?_Python_Shadow_Vtk_Wxwidgets - Fatal编程技术网

如何使用Python WX从VTK构造和提取阴影信息?

如何使用Python WX从VTK构造和提取阴影信息?,python,shadow,vtk,wxwidgets,Python,Shadow,Vtk,Wxwidgets,我正试图从卫星的3D模型中评估太阳能电池板上的阴影,该模型在VTK和wxpython中可视化。为此,我建立了面板位置的模型,并放置了一个光源来创建一个不同的阴影,以评估从特定方向的阴影。最后,我希望根据该区域的阴影部分提取功率估计值 我遇到了一个挑战,我非常感谢社区的意见,即如何最好地实现和提取必须由图形引擎生成的阴影信息,即为每个多边形或参与者提取亮区和未亮区的点 下面是一个简化的示例,我使用光源高亮显示两个立方体(基于此)。首先,我没有看到立方体1在立方体2上的任何阴影(我希望如此),其次,

我正试图从卫星的3D模型中评估太阳能电池板上的阴影,该模型在VTK和wxpython中可视化。为此,我建立了面板位置的模型,并放置了一个光源来创建一个不同的阴影,以评估从特定方向的阴影。最后,我希望根据该区域的阴影部分提取功率估计值

我遇到了一个挑战,我非常感谢社区的意见,即如何最好地实现和提取必须由图形引擎生成的阴影信息,即为每个多边形或参与者提取亮区和未亮区的点

下面是一个简化的示例,我使用光源高亮显示两个立方体(基于此)。首先,我没有看到立方体1在立方体2上的任何阴影(我希望如此),其次,如果可以的话,我无法想象如何提取这些信息

import wx
import vtk
from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor

class p1(wx.Panel):

    def __init__(self,parent):
        wx.Panel.__init__(self, parent)

        #to interact with the scene using the mouse use an instance of vtkRenderWindowInteractor.
        self.widget = wxVTKRenderWindowInteractor(self, -1)
        self.widget.Enable(1)
        self.widget.AddObserver("ExitEvent", lambda o,e,f=self: f.Close())
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.widget, 1, wx.EXPAND)
        self.SetSizer(self.sizer)
        self.Layout()
        self.isploted = False

    def renderthis(self):
            # open a window and create a renderer
            self.ren = vtk.vtkRenderer()
            self.widget.GetRenderWindow().AddRenderer(self.ren)

            #Create a cube (to shadow)
            cube1 =vtk.vtkCubeSource()
            cube1.SetCenter(0.0, 0.0, 2)
            cube1Mapper = vtk.vtkPolyDataMapper()
            cube1Mapper.SetInput(cube1.GetOutput())
            cube1Actor = vtk.vtkActor()
            cube1Actor.SetMapper(cube1Mapper)
            self.ren.AddActor(cube1Actor)

            #Create a second cube (to be shadowed)
            cube2 =vtk.vtkCubeSource()
            cube2.SetCenter(0.0, 0.0, 0.5)
            cube2.SetXLength(2)
            cube2.SetYLength(2)
            cube2Mapper = vtk.vtkPolyDataMapper()
            cube2Mapper.SetInput(cube2.GetOutput())
            cube2Actor = vtk.vtkActor()
            cube2Actor.SetMapper(cube2Mapper)
            self.ren.AddActor(cube2Actor)

            # add axes and view point
            axes = vtk.vtkAxesActor()
            self.marker = vtk.vtkOrientationMarkerWidget()
            self.marker.SetInteractor( self.widget._Iren )
            self.marker.SetOrientationMarker( axes )
            self.marker.SetViewport(0.75,0,1,0.25)
            self.marker.SetEnabled(1)

            # add distant light source
            self.light = vtk.vtkLight()
            self.light.SetPosition(0, 0, 100)
            self.light.SetColor(1.0, 1.0, 1.0)
            self.ren.AddLight(self.light)

            # may need to add something for vtkShadowPass() here?

            # then would extract the resultant filter?

            self.ren.ResetCamera()
            self.ren.ResetCameraClippingRange()
            self.ren.SetBackground(1,0,0)
            cam = self.ren.GetActiveCamera()
            cam.Elevation(10)
            cam.Azimuth(70)
            self.isploted = True


class Frame(wx.Frame):
    def __init__(self,parent,title):
        wx.Frame.__init__(self,parent,title=title,size=(650,600), style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU|
                  wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN)
        self.sp = wx.SplitterWindow(self)
        self.p1 = p1(self.sp)
        self.p2 = wx.Panel(self.sp,style=wx.SUNKEN_BORDER)

        self.sp.SplitHorizontally(self.p1,self.p2,470)

        self.statusbar = self.CreateStatusBar()
        self.statusbar.SetStatusText("Click on the Plot Button")

        self.plotbut = wx.Button(self.p2,-1,"plot", size=(40,20),pos=(10,10))
        self.plotbut.Bind(wx.EVT_BUTTON,self.plot)

    def plot(self,event):
        if not self.p1.isploted:
            self.p1.renderthis()
            self.statusbar.SetStatusText("Use your mouse to interact with the model")


app = wx.App(redirect=False)
frame = Frame(None,"Lights, Cameras, Action")
frame.Show()
app.MainLoop()
<> Pc>在C++中似乎有一个有用的例子:但是我很难理解注释,怕编程不是我的背景。
非常感谢您提供的任何指导或提示,即使告诉我这根本不可能,我也需要重新思考该方法。

基于本课程的类参考,我相信应该有一种方法可以使用以下方法激活阴影:“self.ren.UseShadowsOn()'但是在使用5.10或更新到6.3的python中,这似乎在VTK中不起作用