[vtkusers] Build a surface plot from java (point by point)
jason@optimalcomputing
jason.cardinal at optimalcomputing.be
Tue Aug 11 03:10:23 EDT 2015
I would like to build a surface plot by manually adding points to my graphic
(I'm developping in Java).
This should be rendered to something like this :
http://www.vtk.org/pipermail/vtkusers/attachments/20101029/63dfcd6c/attachment-0001.jpeg
<http://www.vtk.org/pipermail/vtkusers/attachments/20101029/63dfcd6c/attachment-0001.jpeg>
Could you please help me get a working code ?
Here is what I tried (and that isn't actually working) ...
// xResults, yResults and zResults are Double[][] parameters
vtkPolyData datas = new vtkPolyData();
for(int i=0; i<xResults.length; i++)
for(int j=0; j<xResults[i].length; j++)
{
double x = xResults[i][i], y = yResults[i][j], z = zResults[i][j];
datas.GetPoints().InsertNextPoint(x, y, z);
}
vtkPolyDataMapper mapper = new vtkPolyDataMapper();
mapper.SetInputData(datas);
vtkActor actor2 = new vtkActor();
actor2.SetMapper(mapper);
vtkRenderer renderer = new vtkRenderer();
vtkRenderWindow renderWindow = new vtkRenderWindow();
renderWindow.AddRenderer(renderer);
vtkRenderWindowInteractor renderWindowInteractor = new
vtkRenderWindowInteractor();
renderWindowInteractor.SetRenderWindow(renderWindow);
vtkCubeAxesActor2D axes = new vtkCubeAxesActor2D();
axes.SetInputData(mapper.GetInputAsDataSet());
axes.SetFlyModeToOuterEdges();
axes.SetCamera(renderWindowPanel.GetRenderer().GetActiveCamera());
axes.SetLabelFormat("%6.4g");
axes.SetScaling(3);
renderer.AddViewProp(axes);
// Add the actor to the scene
renderer.AddActor(actor2);
renderer.SetBackground(.3, .6, .3); // Background color green
// Render and interact
renderWindow.Render();
renderWindowInteractor.Start();
--
View this message in context: http://vtk.1045678.n5.nabble.com/Build-a-surface-plot-from-java-point-by-point-tp5733413.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list