[vtkusers] Two renderer in One window
Min-Su KIM
minsu.kim at yumail.ac.kr
Thu Aug 21 01:52:46 EDT 2003
Enjoy THIS in c++ code :)
----
vtkPolyDataReader *Reader = vtkPolyDataReader::New();
Reader->SetFileName("Model1.vtk");
Reader->Update();
vtkPolyDataReader *Reader2 = vtkPolyDataReader::New();
Reader->SetFileName("Model2.vtk");
Reader->Update();
//vtkTransform
vtkTransform *Transform = vtkTransform::New();
Transform->Identity(); Transform->RotateX(-90);
Transform->RotateY(0); Transform->RotateZ(90);
//vtkTransformPolyDataFilter for Original
vtkTransformPolyDataFilter *RotationSource =
vtkTransformPolyDataFilter::New();
RotationSource->SetTransform(Transform);
RotationSource->SetInput(Reader->GetOutput());
RotationSource->Update();
//vtkTransformPolyDataFilter for Target
vtkTransformPolyDataFilter *RotationTarget =
vtkTransformPolyDataFilter::New();
RotationTarget->SetTransform(Transform);
RotationTarget->SetInput(Reader2->GetOutput());
RotationTarget->Update();
//Mapper for Source
vtkPolyDataMapper *MapperSource = vtkPolyDataMapper::New();
MapperSource->SetInput(RotationSource->GetOutput());
MapperSource->Update();
//Mapper for Target
vtkPolyDataMapper *MapperTarget = vtkPolyDataMapper::New();
MapperTarget->SetInput(RotationTarget->GetOutput());
MapperTarget->Update();
//Actor for Source
vtkActor *ActorSource =vtkActor::New();
ActorSource->SetMapper(MapperSource);
ActorSource->GetProperty()->SetColor(0.6,0.4,0.7);
//Actor for Target
vtkActor *ActorTarget =vtkActor::New();
ActorTarget->SetMapper(MapperTarget);
ActorTarget->GetProperty()->SetColor(0.89, 0.81, 0.34);
//Renderer for Source
vtkRenderer *RendererSource = vtkRenderer::New();
RendererSource->SetViewport(0.0,0.0,0.5,1.0);
RendererSource->AddActor(ActorSource);
RendererSource->SetBackground(0,0,0);
//Renderer for Target
vtkRenderer *RendererTarget = vtkRenderer::New();
RendererTarget->SetViewport(0.5,0.0,1.0,1.0);
RendererTarget->AddActor(ActorTarget);
RendererTarget->SetBackground(0,0,0);
//Camera for synchronization between two renderers
vtkCamera *Camera = vtkCamera::New();
RendererTarget->SetActiveCamera(RendererSource->GetActiveCamera());
//RenderWindow
vtkRenderWindow *renWindow = vtkRenderWindow::New();
renWindow->AddRenderer(RendererSource);
renWindow->AddRenderer(RendererTarget);
renWindow->SetSize(600,300);
//User's (keyboard and mouse) interactor
vtkRenderWindowInteractor *WindowInteractor =
vtkRenderWindowInteractor::New();
WindowInteractor->SetRenderWindow(renWindow);
cout << "Keyboard and Mouse Interaction ... ON " << endl;
//Visualization Starts
renWindow->Render();
cout << "Visualization ... Start" << endl;
//Description for RenderWindowInterator
cout << " S : Surface " << endl << " W : Wireframe" << endl;
cout << " Left Mouse : Rotation" << endl;
cout << " Right Mouse : Zoom" << endl;
cout << " Shift + Mouse : Translation" << endl;
cout << " E or Q : QUIT the Visualization" << endl;
WindowInteractor->Start();
//Destructor after visualization
WindowInteractor->Delete();
renWindow->Delete();
RendererSource->Delete(); RendererTarget->Delete();
ActorSource->Delete(); ActorTarget->Delete();
MapperSource->Delete(); MapperTarget->Delete();
RotationSource->Delete(); RotationTarget->Delete();
----
============================================
Min-Su Kim
min-su.kim at creatis.insa-lyon.fr
minsu.kim at yumail.ac.kr
Tel (33) 4 72 43 64 69
(33) 6 61 23 74 44
Fax (33) 4 72 43 85 26
CREATIS INSA Batiment Blaise Pascal
20 Avenue Einstein 69621 Villeurbanne cedex FRANCE
URL http://www-creatis.insa-lyon.fr
MSN kmsrefugee at hotmail.com
============================================
----- Original Message -----
From: "Xin Zhao" <zxem at my169.com>
To: <vtkusers at public.kitware.com>
Sent: Saturday, August 23, 2003 12:54 PM
Subject: [vtkusers] Two renderer in One window
> Dear VTKall,
>
> I try to put two renderer object in one render window.
> I use Java and vtkPanel class. How can I change the vtkPanel to
achieve it.
> And whether I can add more renderer object into render window at run
time?
>
> Thanks!
>
> Xin Zhao
> zxem at my169.com
> 2003-08-15
>
> --
> X Zhao
> Department of Computer Science, University of Sheffield,
> Regent Court, 211 Portobello Street, Sheffield S1 4DP
> Telephone +44 (0)114 278 9436
> Email acp02xz at sheffield.ac.uk
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
>
More information about the vtkusers
mailing list