[vtkusers] vtkVRMLImporter

Chandran Ramu chandran.ramu at quest-global.com
Fri Jun 20 07:07:21 EDT 2003


Hi All,

I am Using vtkVrmlImporter to load the vrml ,but i find that the vrml does
not get loaded fully.
I have tried all ways but invain. Can any one please help me

Thank in advance

Code Snippet (First method)

	vtkVRMLImporter importer=new vtkVRMLImporter();
	importer.SetRenderWindow(renWin.GetRenderWindow());
	importer.SetFileName(filePath);
	importer.Read();
	renWin.Render();

I have even tried the other approach which is as follows

	vtkVRMLImporter importer=new vtkVRMLImporter();
	importer.SetRenderWindow(renWin.GetRenderWindow());
	importer.SetFileName(filePath);
	importer.Read();
	vtkAppendPolyData appendData=new vtkAppendPolyData();
	vtkActorCollection collection=renWin.GetRenderer().GetActors();
	int count =collection.GetNumberOfItems();
	collection.InitTraversal();
	vtkProperty prop=null;
	for(int i=0;i< count ;i++){
		vtkActor actor=collection.GetNextActor();
		actor.InitPartTraversal();
		int count1=actor.GetNumberOfParts();
		for(int j=0;j< count1 ;j++){
			vtkActor actorNew=actor.GetNextPart();
			prop=actor.GetProperty();
			vtkPolyData data=(vtkPolyData) actorNew.GetMapper
().GetInputAsDataSet();
			appendData.AddInput(data);
		}
	}
	vtkPolyDataNormals normals=new vtkPolyDataNormals();
	normals.SetInput(appendData.GetInput());
	normals.ConsistencyOn();
	normals.SplittingOff();
	vtkActorCollection collection1=renWin.GetRenderer().GetActors();
	int count1 =collection.GetNumberOfItems();
	ollection.InitTraversal();
	for(int i=0;i< count ;i++){
		vtkActor actor=collection.GetNextActor();
		renWin.GetRenderer().RemoveActor(actor);
	}
	vtkPolyDataMapper clipMapper = new vtk.vtkPolyDataMapper();
	clipMapper.SetInput(normals.GetOutput());
	clipMapper.ScalarVisibilityOff();
	vtkActor clipActor = new vtk.vtkActor();
	clipActor.SetMapper(clipMapper);
	prop.SetDiffuse(0.7);
	clipActor.SetProperty(prop);
	renWin.GetRenderer().AddActor(clipActor);
	renWin.setBackground(Color.yellow);
	renWin.GetRenderer().SetBackground(30,30,30);
	renWin.GetRenderer().ResetCameraClippingRange();
	renWin.Render();


Any suggestions to improve on the code is greatly appreciated

Thanks in advance

Chandran Ramu




More information about the vtkusers mailing list