[vtkusers] Multiple vtk3DSImporter importers in a render window
Bill Lorensen
bill.lorensen at gmail.com
Sat May 12 08:55:53 EDT 2012
You are correct. Importer's do not behave as readers. This is because
they often include camera and or light information as well as actors
with properties. Importers have a method SetRenderWindow that you can
use to control where they appear.
>From vtkImporter.h:
// Description
// Set the vtkRenderWindow to contain the imported actors, cameras and
// lights, If no vtkRenderWindow is set, one will be created and can be
// obtained with the GetRenderWindow method. If the vtkRenderWindow has been
// specified, the first vtkRenderer it has will be used to import the
// objects. If the vtkRenderWindow has no Renderer, one will be created and
// can be accessed using GetRenderer.
virtual void SetRenderWindow(vtkRenderWindow*);
vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
In your example try setting
importer SetRenderWindow renWin
importer2 SetRenderWindow renWin
If you need to manipulate the individual actors it is a bit more
complicated since the importers may have multiple actors.
On Sat, May 12, 2012 at 7:04 AM, Dora Szasz <dora.szasz at yahoo.com> wrote:
> Hello vtk users,
>
> How can I integrate in a render window multiple vtk3DS importers?
> I have tried the following code in Tcl, but I have received the following
> error: "Object named importer could not find requested method:
> GetOutputPort", so the importer is not behaving like a reader.
>
> How can I do this?
>
>
> Thank you a lot,
> Dora Szasz
>
> package require vtk
> package require vtkinteraction
>
> # Create the importer and read a file
> vtk3DSImporter importer
> importer ComputeNormalsOn
> importer SetFileName "204_c_01_v14a_body_3.3ds"
> importer Read
>
> vtk3DSImporter importer2
> importer2 ComputeNormalsOff
> importer2 SetFileName "216_03_v6f_corp-ns3.3ds"
> importer2 Read
>
> vtkPolyDataNormals normals
> normals SetInputConnection [importer GetOutputPort]
> normals FlipNormalsOn
> vtkPolyDataMapper importerMapper
> importerMapper SetInputConnection [normals GetOutputPort]
> vtkActor importerActor
> importerActor SetMapper importerMapper
> importerActor SetOrigin 2 1 3
> importerActor SetPosition 2.25 0 0
> [importerActor GetProperty] SetColor 1 0 1
> vtkPolyDataNormals normals2
> normals2 SetInputConnection [importer2 GetOutputPort]
> normals2 FlipNormalsOn
> vtkPolyDataMapper importer2Mapper
> importer2Mapper2 SetInputConnection [normals2 GetOutputPort]
> vtkActor importer2Actor
> importer2Actor SetMapper importer2Mapper
> importer2Actor SetPosition 0 0 0.25
> [importer2Actor GetProperty] SetColor 0 1 0
> vtkRenderer ren1
> vtkRendererWindow renWin
> renWin AddRenderer ren1
> vtkRendererWindowInteractor iren
> iren SetRenderWindow renWin
> ren1 AddActor importerActor
> ren1 AddActor importer2Actor
> ren1 SetBackground 0.1 0.2 0.4
> renWin SetSize 200 200
>
> # Set up the camera to get a particular view of the scene
> vtkCamera camera
> camera SetClippingRange 21.9464 30.0179
> camera SetFocalPoint 3.49221 2.28844 -0.970866
> camera SetPosition 3.49221 2.28844 24.5216
> camera SetViewAngle 30
> camera SetViewUp 0 1 0
> ren1 SetActiveCamera camera
>
> # Set the user method (bound to key 'u')
> #
> iren AddObserver UserEvent {wm deiconify .vtkInteract}
> renWin Render
>
> # Withdraw the default tk window
> wm withdraw .
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
Unpaid intern in BillsBasement at noware dot com
More information about the vtkusers
mailing list