[vtkusers] how to plot 2d field data?

Matthias Specht specht at ifi.unizh.ch
Mon Jun 21 14:04:30 EDT 2004


hello,
I try to use vtkXYPlotActor to draw a couple of (x, y) - pairs as points.
however I do not understand how to tell vtkXYPlotActor which component is the x- and which 
  one is the y-coordinate.
In the simple example below (java) I try to draw 4 points - however, 6 points get drawn 
and not at the positions I would expect....
I guess I missunderstood something about how vtkXYPlotActor is used to draw field-data. if 
anybody would have simple example I would be very pleased...

thanx a lot

matthias


-------------------------------------------------------------------
.................
	vtkFloatArray[] pcScores = new vtkFloatArray[nSamples];
	vtkFieldData[] fd = new vtkFieldData[nSamples];
	vtkDataObject[] dob = new vtkDataObject[nSamples];
	vtkXYPlotActor plotAct = new vtkXYPlotActor();

	for(int i=0; i<nSamples; i++) {	
	    pcScores[i] = new vtkFloatArray();

	    // x component
	    pcScores[i].InsertComponent(0, 0, (float) i * 0.5);
             // y component
	    pcScores[i].InsertComponent(0, 1, (float) i * 2.0);


	    fd[i] = new vtkFieldData();
	    fd[i].AddArray(pcScores[i]);

	    dob[i] = new vtkDataObject();
	    dob[i].SetFieldData(fd[i]);	
	    plotAct.AddDataObjectInput(dob[i]);

	    System.out.println("PCScores of shape " + i + "= " +
			       pcScores[i].GetComponent(0, 0) + ", " + 			 

			       pcScores[i].GetComponent(0, 1));
	}
	
	plotAct.SetXValuesToValue();

	plotAct.PlotLinesOff();
	plotAct.PlotPointsOn();



	vtkRenderer ren1 = new vtkRenderer();
	ren1.AddActor2D(plotAct);
	
	vtkRenderWindow renWin = new vtkRenderWindow();
	renWin.AddRenderer( ren1 );
	renWin.SetSize( 600, 600 );

	vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
	iren.SetRenderWindow(renWin);

	iren.Initialize();
	iren.Start();
......................
-------------------------------------------------------------------------


-- 
matthias specht
| mailto:specht at ifi.unizh.ch  http://www.ifi.unizh.ch/staff/specht
office
| multimedia lab, computer science department, university of zurich
| winterthurerstr. 190, 8057 zurich, switzerland
| phone +41-1-635-4565 fax +41-1-635-6809




More information about the vtkusers mailing list