コード例 #1
0
ファイル: DisplayVTKPlant.py プロジェクト: saulzar/PlantSimV3
    def InitRenderPasses(self):
        """Initiate and add realism passes to renderer"""
        cameraP = vtk.vtkCameraPass()
        opaque = vtk.vtkOpaquePass()
        peeling = vtk.vtkDepthPeelingPass()
        peeling.SetMaximumNumberOfPeels(1000)
        peeling.SetOcclusionRatio(0.1)

        translucent = vtk.vtkTranslucentPass()
        peeling.SetTranslucentPass(translucent)

        volume = vtk.vtkVolumetricPass()
        overlay = vtk.vtkOverlayPass()

        lights = vtk.vtkLightsPass()
        opaqueSequence = vtk.vtkSequencePass()

        passes2 = vtk.vtkRenderPassCollection()
        passes2.AddItem(lights)
        passes2.AddItem(opaque)
        opaqueSequence.SetPasses(passes2)

        opaqueCameraPass = vtk.vtkCameraPass()
        opaqueCameraPass.SetDelegatePass(opaqueSequence)

        shadowsBaker = vtk.vtkShadowMapBakerPass()
        shadowsBaker.SetOpaqueSequence(opaqueCameraPass)
        shadowsBaker.SetResolution(SHADOW_RENDER_RES)

        shadows = vtk.vtkShadowMapPass()
        shadows.SetShadowMapBakerPass(shadowsBaker)
        shadows.SetOpaqueSequence(opaqueSequence)

        seq = vtk.vtkSequencePass()
        passes = vtk.vtkRenderPassCollection()
        passes.AddItem(shadowsBaker)
        passes.AddItem(shadows)
        passes.AddItem(lights)
        passes.AddItem(peeling)
        passes.AddItem(volume)
        passes.AddItem(overlay)
        seq.SetPasses(passes)
        cameraP.SetDelegatePass(seq)

        self.renderer.SetPass(cameraP)
コード例 #2
0
ファイル: vtk_tms_widget.py プロジェクト: deherinu/TmsViewer
    def __init__(self, render_window_interactor, widget,config=None):

        # render_window_interactor.Initialize()
        # render_window_interactor.Start()
        self.configure(config)
        self.iren = render_window_interactor
        self.ren_win = render_window_interactor.GetRenderWindow()
        self.ren = vtk.vtkRenderer()
        self.ren.GradientBackgroundOn()
        self.ren.SetBackground2(self.BACKGROUND2)
        self.ren.SetBackground(self.BACKGROUND1)
        self.ren.SetUseDepthPeeling(1)
        self.ren_win.SetMultiSamples(0)
        self.ren_win.AlphaBitPlanesOn()
        self.ren.SetOcclusionRatio(0.1)
        self.ren_win.AddRenderer(self.ren)

        self.iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())

        self.light = vtk.vtkLight()
        self.ren.AddLight(self.light)
        self.light.SetLightTypeToSceneLight()
        self.light.SetPositional(0)


        self.light2 = vtk.vtkLight()
        self.ren.AddLight(self.light2)
        self.light2.SetLightTypeToSceneLight()
        self.light2.SetPositional(0)

        self.light3 = vtk.vtkLight()
        self.ren.AddLight(self.light3)
        self.light3.SetLightTypeToSceneLight()
        self.light3.SetPositional(0)

        self.picker = vtk.vtkCellPicker()
        self.picker.SetTolerance(0.0005)
        self.iren.SetPicker(self.picker)

        self.experiment = None
        self.__cylinder_actors = {}
        self.__line_actors = {}
        self.__cone_actors = {}
        self.__cone_sources = {}
        self.__error_triple = None
        self.__temp_sample = None
        self.__highlighted_actors = []

        #orientation axes
        axes_actor = vtk.vtkAnnotatedCubeActor()
        axes_actor.SetXPlusFaceText("R")
        axes_actor.SetXMinusFaceText("L")
        axes_actor.SetYPlusFaceText("P")
        axes_actor.SetYMinusFaceText("I ")
        axes_actor.SetZPlusFaceText("B")
        axes_actor.SetZMinusFaceText("F")

        axes_actor.GetTextEdgesProperty().SetColor(1, 1, 1)
        axes_actor.GetTextEdgesProperty().SetLineWidth(2)
        axes_actor.GetCubeProperty().SetColor(0.3, 0.3, 0.3)
        axes_actor.SetTextEdgesVisibility(1)
        axes_actor.SetFaceTextVisibility(0)

        axes_actor.SetZFaceTextRotation(90)
        axes_actor.SetXFaceTextRotation(-90)

        axes = vtk.vtkOrientationMarkerWidget()
        axes.SetOrientationMarker(axes_actor)
        axes.SetViewport(0.01, 0.01, 0.2, 0.2)

        self.axes = axes
        self.axes_actor = axes_actor


        self.axes.SetInteractor(self.iren)
        self.axes.EnabledOn()
        self.axes.InteractiveOff()

        self.__widget = widget

        if self.SHADOWS:
            opaque_sequence = vtk.vtkSequencePass()
            passes2 = vtk.vtkRenderPassCollection()
            opaque = vtk.vtkOpaquePass()
            lights = vtk.vtkLightsPass()
            peeling = vtk.vtkDepthPeelingPass()
            translucent = vtk.vtkTranslucentPass()
            peeling.SetTranslucentPass(translucent)
            passes2.AddItem(lights)
            passes2.AddItem(opaque)
            opaque_sequence.SetPasses(passes2)

            opaque_camera_pass = vtk.vtkCameraPass()
            opaque_camera_pass.SetDelegatePass(opaque_sequence)

            shadow_baker = vtk.vtkShadowMapBakerPass()
            shadow_baker.SetOpaquePass(opaque_camera_pass)

            shadow_baker.SetResolution(2**12)
            shadow_baker.SetPolygonOffsetFactor(3.1)
            shadow_baker.SetPolygonOffsetUnits(10.0)

            shadows = vtk.vtkShadowMapPass()
            shadows.SetShadowMapBakerPass(shadow_baker)

            shadows.SetOpaquePass(opaque_sequence)

            seq = vtk.vtkSequencePass()
            passes = vtk.vtkRenderPassCollection()
            seq.SetPasses(passes)
            passes.AddItem(shadow_baker)
            passes.AddItem(shadows)

            passes.AddItem(lights)
            passes.AddItem(peeling)
            passes.AddItem(vtk.vtkVolumetricPass())

            cameraP = vtk.vtkCameraPass()
            cameraP.SetDelegatePass(seq)
            self.ren.SetPass(cameraP)
コード例 #3
0
# passes.AddItem(vtk.vtkRenderStepsPass())
# seq = vtk.vtkSequencePass()
# seq.SetPasses(passes)
# ssao=vtk.vtkSSAOPass()
# ssao.SetDelegatePass(seq)
# ssao.SetRadius(0.035)
# ssao.SetKernelSize(128)
# ssao.BlurOff() # do not blur occlusion
# renderer.SetPass(ssao)



# #set tonemapping https://gitlab.kitware.com/vtk/vtk/-/blob/master/Rendering/OpenGL2/Testing/Cxx/TestToneMappingPass.cxx
cameraP=vtk.vtkCameraPass()
seq=vtk.vtkSequencePass()
opaque=vtk.vtkOpaquePass()
lights=vtk.vtkLightsPass()

passes=vtk.vtkRenderPassCollection()
passes.AddItem(lights)
passes.AddItem(opaque)
seq.SetPasses(passes)

#shadows  https://gitlab.kitware.com/vtk/vtk/-/blob/master/Rendering/OpenGL2/Testing/Cxx/TestShadowMapPass.cxx
shadows=vtk.vtkShadowMapPass()
shadows.GetShadowMapBakerPass().SetResolution(1024)
# to cancel self->shadowing
# shadows.GetShadowMapBakerPass().SetPolygonOffsetFactor(3.1)
# shadows.GetShadowMapBakerPass().SetPolygonOffsetUnits(10.0)
seq=vtk.vtkSequencePass()
passes=vtk.vtkRenderPassCollection()
コード例 #4
0
renderWindow.SetAlphaBitPlanes(1)
interactor.SetRenderWindow(renderWindow)

renderer = vtk.vtkRenderer()

renderWindow.AddRenderer(renderer)

supported = vtk.vtkFrameBufferObject.IsSupported(renderWindow)

if (not supported):
    print "returning"
    time.sleep(5)


cameraP = vtk.vtkCameraPass()
opaque = vtk.vtkOpaquePass()

peeling = vtk.vtkDepthPeelingPass()
peeling.SetMaximumNumberOfPeels(200)
peeling.SetOcclusionRatio(0.1)


translucent = vtk.vtkTranslucentPass()
peeling.SetTranslucentPass(translucent)


volume = vtk.vtkVolumetricPass()
overlay = vtk.vtkOverlayPass()
lights = vtk.vtkLightsPass()
opaqueSequence = vtk.vtkSequencePass()
pass2 = vtk.vtkRenderPassCollection()
コード例 #5
0
    def __init__(self):
       
        self.renderer = vtk.vtkRenderer()
        self.renderer.GradientBackgroundOn()

        self.ren_win = ren_win = vtk.vtkRenderWindow()
        
        ren_win.SetSize(512,512) 
        ren_win.SetMultiSamples(0)
        ren_win.SetAlphaBitPlanes(1)
        ren_win.SetOffScreenRendering(1) #default 1

        iren = self.iren = vtk.vtkRenderWindowInteractor()
        iren.SetRenderWindow(ren_win)
        ren_win.AddRenderer(self.renderer)
       
        camera_pass = vtk.vtkCameraPass()
        opaque = vtk.vtkOpaquePass()

        peeling=vtk.vtkDepthPeelingPass()
        peeling.SetMaximumNumberOfPeels(200)
        peeling.SetOcclusionRatio(0.1)

        translucent=vtk.vtkTranslucentPass()
        peeling.SetTranslucentPass(translucent)

        volume=vtk.vtkVolumetricPass()
        overlay=vtk.vtkOverlayPass()
        lights=vtk.vtkLightsPass()
        opaque_sequence=vtk.vtkSequencePass()

        passes2=vtk.vtkRenderPassCollection()
        passes2.AddItem(lights)
        passes2.AddItem(opaque)

        opaque_sequence.SetPasses(passes2)
        opaque_camera_pass=vtk.vtkCameraPass()
        opaque_camera_pass.SetDelegatePass(opaque_sequence)

        shadows_baker=vtk.vtkShadowMapBakerPass()
        shadows_baker.SetOpaquePass(opaque_camera_pass)
        shadows_baker.SetResolution(1024)

        #To cancel self-shadowing.
        shadows_baker.SetPolygonOffsetFactor(3.1)
        shadows_baker.SetPolygonOffsetUnits(10.0)

        shadows=vtk.vtkShadowMapPass()
        shadows.SetShadowMapBakerPass(shadows_baker)
        shadows.SetOpaquePass(opaque_sequence)

        seq=vtk.vtkSequencePass()
        passes=vtk.vtkRenderPassCollection()
        passes.AddItem(shadows_baker)
        passes.AddItem(shadows)
        passes.AddItem(lights)
        passes.AddItem(peeling)
        passes.AddItem(volume)
        passes.AddItem(overlay)

        seq.SetPasses(passes)
        camera_pass.SetDelegatePass(seq)
        self.renderer.SetPass(camera_pass)