Build a surface plot from java (point by point)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Build a surface plot from java (point by point)

jason@optimalcomputing
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

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();
Reply | Threaded
Open this post in threaded view
|

Re: Build a surface plot from java (point by point)

louiskoo
do you use vtk 32bit or 64 bit?
Reply | Threaded
Open this post in threaded view
|

Re: Build a surface plot from java (point by point)

jason@optimalcomputing
vtk 32 bits