[Insight-users] VRML Importer Example Problem
Dora Szasz
dora.szasz at yahoo.com
Fri Aug 17 08:25:36 EDT 2012
I was able to solve this problem. So, the example http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/VRML is quite wrong, because it shrinks the volume.
I attached here the code, but it has some lights options, also, because I need them.
#include <vtkVersion.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkVRMLImporter.h>
#include <vtkDataSet.h>
#include <vtkActorCollection.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkPolyDataNormals.h>
#include <vtkActor.h>
#include <vtkSmartPointer.h>
#include <vtkRendererCollection.h>
#include <vtkLight.h>
int main ( int argc, char *argv[])
{
if(argc != 2)
{
std::cout << "Required arguments: Filename" << std::endl;
return EXIT_FAILURE;
}
std::string filename = argv[1];
std::cout << "Reading " << filename << std::endl;
vtkSmartPointer<vtkRenderer> ren1= vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(ren1);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
// VRML Import
vtkSmartPointer<vtkVRMLImporter> importer = vtkSmartPointer<vtkVRMLImporter>::New();
importer->SetFileName ( filename.c_str() );
importer->Read();
importer->SetRenderWindow(renderWindow);
importer->Update();
ren1=importer->GetRenderer();
vtkRendererCollection *renCollection=vtkRendererCollection::New();
renCollection = renderWindow->GetRenderers();
renCollection->InitTraversal();
vtkRenderer *ren= vtkRenderer::New();
ren = renCollection->GetNextItem();
ren->ResetCamera();
vtkLight *light1=vtkLight::New();
light1->SetLightTypeToCameraLight ();
ren->AddLight(light1);
vtkActorCollection *actorcol=vtkActorCollection::New();
actorcol=ren->GetActors();
vtkActor *actor=vtkActor::New();
actor=actorcol->GetLastActor();
vtkMapper *map=actor->GetMapper();
vtkDataSet *PolyData=map->GetInput();
ren->AddActor(actor);
renderWindow->Render();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
________________________________
From: Dora Szasz <dora.szasz at yahoo.com>
To: "insight-users at itk.org" <insight-users at itk.org>
Cc: "vtkusers at vtk.org" <vtkusers at vtk.org>
Sent: Friday, August 17, 2012 1:19 PM
Subject: VRML Importer Example Problem
Hello all,
I have tried to load a .wrl volume using vtkVRMLImporter.
Everything works fine, but the volume is shrinked. Can you tell me why? The other problem is that the color of the volume is not loaded.
I have attached here 2 pictures: one with the volume loaded with a WRLViewer and the other with the volume loaded with VTK.
Thank you,
Dora
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120817/2d016bed/attachment.htm>
More information about the Insight-users
mailing list