[vtkusers] Change Objects in active vtkRenderWindow (using QT)

Fabian fabian-richter at gmx.de
Mon Oct 29 09:29:49 EDT 2012


Hello Arnaud BARRE,

thanks for Your answer.

My code looks like this (my pointcloud is a list already processed in the
vector called 'Data'):

My Code wrote
> void PCV_VTKOps::PCV_Visualize(std::vector
> <STRUCT_7Values>
>  Data)
> {	
> 	int i;
> 	PickedPoints.clear();
> 	
> 	//general vtk declarations
> 	vtkSmartPointer
> <vtkRenderer>
> 				PointCloudRenderer					= vtkSmartPointer
> <vtkRenderer>
> ::New();
> 	vtkSmartPointer
> <vtkRenderWindow>
> 			PointCloudRenderWindow				= vtkSmartPointer
> <vtkRenderWindow>
> ::New();
> 	vtkSmartPointer
> <vtkRenderWindowInteractor>
> 	PointCloudrenderWindowInteractor	= vtkSmartPointer
> <vtkRenderWindowInteractor>
> ::New();
> 	vtkSmartPointer
> <PCV_VTKPickPoints>
> 			style								= vtkSmartPointer
> <PCV_VTKPickPoints>
> ::New();
> 	vtkSmartPointer
> <vtkBMPReader>
> 				BackgroundTextureReader				= vtkSmartPointer
> <vtkBMPReader>
> ::New();
> 	vtkSmartPointer
> <vtkTexture>
> 					BackgroundTexture					= vtkSmartPointer
> <vtkTexture>
> ::New();
> 	vtkSmartPointer
> <vtkInteractorStyleTrackballCamera>
>  style2						= vtkSmartPointer
> <vtkInteractorStyleTrackballCamera>
> ::New();
> 	vtkSmartPointer
> <vtkWindowToImageFilter>
> 		PointCloudToImageFilter				= vtkSmartPointer
> <vtkWindowToImageFilter>
> ::New();
> 	vtkSmartPointer
> <vtkBMPWriter>
> 				PointCloudToImageWriter				= vtkSmartPointer
> <vtkBMPWriter>
> ::New();
> 	
> 	vtkCamera									*PointCloudRendererCamera;
> 
> 	//vtkDeclarations PointCloud
> 	vtkSmartPointer
> <vtkUnsignedCharArray>
> 		PointCloudColors					= vtkSmartPointer
> <vtkUnsignedCharArray>
> ::New();
> 	vtkSmartPointer
> <vtkPoints>
> 					PointCloudPoints					= vtkSmartPointer
> <vtkPoints>
> ::New();
> 	vtkSmartPointer
> <vtkPolyData>
> 				PointsPolydata						= vtkSmartPointer
> <vtkPolyData>
> ::New();
> 	vtkSmartPointer
> <vtkPolyData>
> 				PointCloudPolyData					= vtkSmartPointer
> <vtkPolyData>
> ::New();
> 	vtkSmartPointer
> <vtkVertexGlyphFilter>
> 		PointCloudVertexFilter				= vtkSmartPointer
> <vtkVertexGlyphFilter>
> ::New();
> 	vtkSmartPointer
> <vtkPolyDataMapper>
> 			PointCloudMapper					= vtkSmartPointer
> <vtkPolyDataMapper>
> ::New();
> 	vtkSmartPointer
> <vtkActor>
> 					PointCloudActor						= vtkSmartPointer
> <vtkActor>
> ::New();
> 
> 	PointCloudColors					-> SetNumberOfComponents(3);
> 	unsigned char Color[3] = {0, 0, 0};
> 			
> 
> 		
> 		for (i = 0; i < (int) Data.size(); i++)
> 		{
> 			if(VTKPARMS.ColorMode == 1)
> 			{
> 				Color[0] = Data[i].R;
> 				Color[1] = Data[i].G;
> 				Color[2] = Data[i].B;
> 			}
> 			PointCloudColors				-> InsertNextTupleValue(Color);
> 			PointCloudPoints				-> InsertNextPoint(Data[i].x,Data[i].y,Data[i].z);
> 		}
> 		
> 	PointsPolydata							-> SetPoints(PointCloudPoints);
> 	PointCloudVertexFilter					->
> SetInputConnection(PointsPolydata->GetProducerPort());
> 	PointCloudVertexFilter					-> Update();
> 	PointCloudPolyData						->
> ShallowCopy(PointCloudVertexFilter->GetOutput());
> 	PointCloudPolyData						-> GetPointData()->SetScalars(PointCloudColors);
>  
> 	 //Visualization
> 	PointCloudMapper						->
> SetInputConnection(PointCloudPolyData->GetProducerPort());
> 	PointCloudActor							-> SetMapper(PointCloudMapper);
> 	PointCloudActor							-> GetProperty()->SetPointSize(VTKPARMS.PointSize);
> 	
> 	PointCloudRenderer						-> AddActor(PointCloudActor);
> 
> 	BackgroundTextureReader					-> SetFileName
> ("C:\\PunktWolkenTest\\VTKBACKGROUND.bmp");
> 	BackgroundTexture						->
> SetInputConnection(BackgroundTextureReader->GetOutputPort());
> 	
> 	PointCloudRenderer->SetBackgroundTexture(BackgroundTexture);
> 	PointCloudRenderer->TexturedBackgroundOn();
> 	
> 	PointCloudRenderWindow					-> AddRenderer(PointCloudRenderer);
> 			
> 	
> 	PointCloudrenderWindowInteractor			->
> SetRenderWindow(PointCloudRenderWindow);
> 	
> VTKPARMS.QTRenderer = PointCloudRenderer;
> VTKPARMS.QTRenderWindow = PointCloudRenderWindow;					
> 
> 
> 	PointCloudRenderWindow					-> Render();
> 	PointCloudrenderWindowInteractor			-> Start();
> 	PointCloudRenderWindow					-> Finalize();
> 		
> }

But I am not sure if my question is more about structure. What this function
does is basically take the points, process the pipeline and put the Renderer
and RenderWindow somewhere where I can put it into a QVTKWidget.

Now I am afraid, that 'sorting points out' (because they have a special
color value) would mean that I need to walk through the whole pipeline
again. I know how to connect the QTSlider, but I dont know, if my function
allows to interact with it after it run through. 

I thought about reorganising the function in case it needs to be called
every time when the slider is moved. In that case I would save the VTKcamera
somehow, filter the pointcloud before it gets visualized and swap the
RenderWindows in the QVTKWidget (if possible).

Would You think this to be better?

THANKS ALOT,
Fabian





--
View this message in context: http://vtk.1045678.n5.nabble.com/Change-Objects-in-active-vtkRenderWindow-using-QT-tp5716830p5716869.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list