Esempio n. 1
0
def render3DS(fName):
    importer = vtk.vtk3DSImporter()
    importer.ComputeNormalsOn()
    importer.SetFileName(fName)
    importer.Read()
    renWin = importer.GetRenderWindow()
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)
    renWin.SetSize(500,500)
    ren = importer.GetRenderer()
    ren.SetBackground(0.1,0.2,0.4)
    iren.Initialize()
    renWin.Render()
    iren.Start()
Esempio n. 2
0
 def show3DS(self, fileName):
     vtk = self.vtk
     importer = vtk.vtk3DSImporter()
     importer.ComputeNormalsOn()
     importer.SetFileName(fileName)
     importer.Read()
     ren = importer.GetRenderer()
     ren.SetBackground(0.1, 0.2, 0.4)
     ren.ResetCamera()
     w = self.winManager.newWindow(fileName)
     importer.SetRenderWindow(w.vtkWidget.GetRenderWindow())
     w.vtkWidget.GetRenderWindow().AddRenderer(ren)
     w.show()
     w.vtkWidget.Initialize()
     w.vtkWidget.Start()
     return w
Esempio n. 3
0
def load3DS(filename, legend=None):
    renderer = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(renderer)

    importer = vtk.vtk3DSImporter()
    importer.SetFileName(filename)
    importer.ComputeNormalsOn()
    importer.SetRenderWindow(renWin)
    importer.Update()

    actors = renderer.GetActors()  # vtkActorCollection
    acts = []
    for i in range(actors.GetNumberOfItems()):
        a = actors.GetItemAsObject(i)
        acts.append(a)
    del renWin
    return Assembly(acts, legend=legend)
Esempio n. 4
0
def load3DS(filename):
    """Load ``3DS`` file format from file. Return an ``Assembly(vtkAssembly)`` object."""
    renderer = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(renderer)

    importer = vtk.vtk3DSImporter()
    importer.SetFileName(filename)
    importer.ComputeNormalsOn()
    importer.SetRenderWindow(renWin)
    importer.Update()

    actors = renderer.GetActors()  # vtkActorCollection
    acts = []
    for i in range(actors.GetNumberOfItems()):
        a = actors.GetItemAsObject(i)
        acts.append(a)
    del renWin
    return Assembly(acts)
Esempio n. 5
0
def main():
    fileName = get_program_parameters()

    importer = vtk.vtk3DSImporter()
    importer.SetFileName(fileName)
    importer.ComputeNormalsOn()

    colors = vtk.vtkNamedColors()

    renderer = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    iren = vtk.vtkRenderWindowInteractor()

    renWin.AddRenderer(renderer)
    renderer.SetBackground2(colors.GetColor3d('Gold'))
    renderer.SetBackground(colors.GetColor3d('Wheat'))
    renderer.GradientBackgroundOn()

    iren.SetRenderWindow(renWin)
    importer.SetRenderWindow(renWin)
    importer.Update()

    # actors = vtk.vtkActorCollection()
    actors = renderer.GetActors()
    print('There are', actors.GetNumberOfItems(), 'actors.')

    renWin.SetWindowName('3DSImporter')
    renWin.Render()
    camera = vtk.vtkCamera()
    camera.SetPosition(0, -1, 0)
    camera.SetFocalPoint(0, 0, 0)
    camera.SetViewUp(0, 0, 1)
    camera.Azimuth(150)
    camera.Elevation(30)

    renderer.SetActiveCamera(camera)
    renderer.ResetCamera()
    renderer.ResetCameraClippingRange()

    renWin.Render()
    iren.Start()
Esempio n. 6
0
    def __init__ (self, renwin, file_name):        
        """Initializes the class given a vtkRenderWindow and a
        file_name."""
        debug ("In mv3DSImporter::__init__ ()")
        self.file_name = file_name
        self.renwin = renwin
        orig_actors = self._get_actors (self.renwin)
        
        self.imp = vtk.vtk3DSImporter ()
        self.imp.SetFileName (file_name)
        self.imp.SetRenderWindow (self.renwin)
        try:
            self.imp.ComputeNormalsOn ()
        except AttributeError:
            pass
        self.imp.Read ()
        self.renwin.Render ()
        final_actors = self._get_actors (self.renwin)

        self.actors = []
        for act in final_actors:
            if act not in orig_actors:
                self.actors.append (act)        
Esempio n. 7
0
#!/usr/bin/env python
import vtk
from vtk.util.misc import vtkGetDataRoot

VTK_DATA_ROOT = vtkGetDataRoot()

ren1 = vtk.vtkRenderer()
renWin1 = vtk.vtkRenderWindow()
renWin1.AddRenderer(ren1)

importer = vtk.vtk3DSImporter()
importer.SetRenderWindow(renWin1)
importer.ComputeNormalsOn()
importer.SetFileName(VTK_DATA_ROOT + "/Data/iflamigm.3ds")
importer.Read()

importer.GetRenderer().SetBackground(0.1, 0.2, 0.4)
importer.GetRenderWindow().SetSize(150, 150)

#
# the importer created the renderer
renCollection = renWin1.GetRenderers()
renCollection.InitTraversal()

ren = renCollection.GetNextItem()

#
# change view up to +z
#
ren.GetActiveCamera().SetWindowCenter(-0.2, 0.3)
ren.GetActiveCamera().SetPosition(0, 1, 0)
Esempio n. 8
0
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

ren1 = vtk.vtkRenderer()
renWin1 = vtk.vtkRenderWindow()
renWin1.AddRenderer(ren1)

importer = vtk.vtk3DSImporter()
importer.SetRenderWindow(renWin1)
importer.ComputeNormalsOn()
importer.SetFileName(VTK_DATA_ROOT + "/Data/iflamigm.3ds")
importer.Read()

importer.GetRenderer().SetBackground(0.1, 0.2, 0.4)
importer.GetRenderWindow().SetSize(150, 150)

#
# the importer created the renderer
renCollection = renWin1.GetRenderers()
renCollection.InitTraversal()

ren = renCollection.GetNextItem()

#
# change view up to +z
#
ren.GetActiveCamera().ParallelProjectionOn()
ren.GetActiveCamera().SetPosition(0, 1, 0)