[vtkusers] How to plot points in vtkTable when using vtkChartXYZ

madz madaramh at gmail.com
Fri Mar 21 01:11:01 EDT 2014


I have been taking a look at  TestSurfacePlot.cxx
<http://vtk.org/gitweb?p=VTK.git;a=blob;f=Charts/Core/Testing/Cxx/TestSurfacePlot.cxx>  
so that I can plot a 3D plot in VTK. However I cannot understand how
vtkTable is used when plotting the 3D points. 

The example uses 4900 (numPoints *numPoints ) points to draw the graph, as
shown below.

   // Create a surface
   vtkNew<vtkTable> table;
   float numPoints = 70;
   float inc = 9.424778 / (numPoints - 1);
   for (float i = 0; i < numPoints; ++i)
     {
     vtkNew<vtkFloatArray> arr;
     table->AddColumn(arr.GetPointer());
     }
   table->SetNumberOfRows(numPoints);
   for (float i = 0; i < numPoints; ++i)
     {
     float x = i * inc;
     for (float j = 0; j < numPoints; ++j)
       {
       float y  = j * inc;
       table->SetValue(i, j, sin(sqrt(x*x + y*y)));
       }
     }

I have the following points which I want to plot.


vtkSmartPointer<vtkPoints> points = 
		vtkSmartPointer<vtkPoints>::New();

	points->InsertNextPoint(1 , 1.5, -8.99186);
	points->InsertNextPoint(1, 1.6, -8.85449);
	points->InsertNextPoint(1, 1.7, -8.68152);
	points->InsertNextPoint(1, 1.8, -8.49732);
	points->InsertNextPoint(1, 1.9, -8.32522);
	points->InsertNextPoint(1, 2, -8.17228);
	points->InsertNextPoint(1, 2.2, -7.8841);
	points->InsertNextPoint(1.2, 1.5, -9.12484);
	points->InsertNextPoint(1.2, 1.6, -9.09976);
	points->InsertNextPoint(1.2, 1.7, -9.05809);
	points->InsertNextPoint(1.2, 1.8, -9.01267);
	points->InsertNextPoint(1.2, 1.9, -8.96422);
	points->InsertNextPoint(1.2, 2, -8.915);
	points->InsertNextPoint(1.2, 2.1, -8.86868);
	points->InsertNextPoint(1.2, 2.2, -8.82868);
	points->InsertNextPoint(1.4, 1.5, -9.13137);
	points->InsertNextPoint(1.4, 1.6, -9.14205);
	points->InsertNextPoint(1.4, 1.7, -9.13732);
	points->InsertNextPoint(1.4, 1.8, -9.12582);
	points->InsertNextPoint(1.4, 1.9, -9.11241);
	points->InsertNextPoint(1.4, 2, -9.09979);
	points->InsertNextPoint(1.4, 2.1, -9.08681);
	points->InsertNextPoint(1.4, 2.2, -9.07625);
	points->InsertNextPoint(1.6, 1.5, -9.07156);
	points->InsertNextPoint(1.6, 1.6, -9.11704);
	points->InsertNextPoint(1.6, 1.7, -9.13725);
	points->InsertNextPoint(1.6, 1.8, -9.14542);
	points->InsertNextPoint(1.6, 1.9, -9.14749);
	points->InsertNextPoint(1.6, 2, -9.14697);
	points->InsertNextPoint(1.6, 2.1, -9.14576);
	points->InsertNextPoint(1.6, 2.2, -9.14469);
	points->InsertNextPoint(1.8, 1.5, -8.9309);
	points->InsertNextPoint(1.8, 1.6, -9.02638);
 	points->InsertNextPoint(1.8, 1.7, -9.08083);
	points->InsertNextPoint(1.8, 1.8, -9.11085);
	points->InsertNextPoint(1.8, 1.9, -9.12813);
	points->InsertNextPoint(1.8, 2, -9.13914);
	points->InsertNextPoint(1.8, 2.1, -9.14687);
	points->InsertNextPoint(1.8, 2.2, -9.15265);
  	points->InsertNextPoint(2, 1.5, -8.71458);
	points->InsertNextPoint(2, 1.6, -8.86802);
	points->InsertNextPoint(2, 1.7, -8.95806);
	points->InsertNextPoint(2, 1.8, -9.01556);
	points->InsertNextPoint(2, 1.9, -9.05421);
	points->InsertNextPoint(2, 2, -9.08177);
	points->InsertNextPoint(2, 2.1, -9.10174);
	points->InsertNextPoint(2, 2.2, -9.11662);

	for (float i = 0; i < points->GetNumberOfPoints(); i++)
	{
		double p1[3];
		points->GetPoint(i,p1);
		table->SetValue(p1[0], p1[1], p1[2]);
	}

The above didn't render the correct results. How can I plot these correctly
with vtkTable?




--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-plot-points-in-vtkTable-when-using-vtkChartXYZ-tp5726438.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list