[vtkusers] VRML objects

Parvaneh Saeedi parvanes at ece.ubc.ca
Tue Jun 4 22:48:02 EDT 2002


Hi everyone,

I am trying to import a VRML object into vtk. One of the users advised me to read the VRML and save it into vtk format. This way I have access to the actors. Through hi help I wrote the following code:

int main( int argc, char *argv[] )
{
 
vtkRenderer *ren1= vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1); 


vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);


vtkVRMLImporter *importer=vtkVRMLImporter::New();
importer->SetRenderWindow(renWin);
importer->SetFileName("woman.wrl");
importer->Read();

ren1=importer->GetRenderer();
ren1->SetBackground(0.1, 0.2, 0.4);
renWin->SetSize(300,300);


vtkRendererCollection *renCollection=vtkRendererCollection::New();
renCollection = renWin->GetRenderers();
renCollection->InitTraversal();
vtkRenderer *ren= vtkRenderer::New();
ren = renCollection->GetNextItem();

ren->ResetCamera();
ren->GetActiveCamera()->Dolly(1.75);
ren1->ResetCameraClippingRange();

vtkActorCollection *actorcol=vtkActorCollection::New();
actorcol=ren->GetActors();

vtkActor *actor=vtkActor::New();
actor=actorcol->GetLastActor();

vtkMapper *map=actor->GetMapper();
vtkDataSet *PolyData=map->GetInput();

//vtkDataSet *PolyData=ren->GetActors()->GetLastActor()->GetMapper()->GetInput();
 
vtkDataSetWriter *writer=vtkDataSetWriter::New();
writer->SetInput(PolyData);
writer->SetFileName("woman.vtk");
writer->Write();
}


The woman.vtk file is created successfully! However when I read it later and try to scale it only one  item of my VRML object, hair piece, is there.

Either I am not transforming  the VRML into vtk completely or I have problem later when I read the vtk.

Could anyone who has worked with VRML objects provide me with some guidance?


Thanks very much. 
Parvaneh Saeedi
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020604/7b06dd48/attachment.htm>


More information about the vtkusers mailing list