[vtkusers] contour plot

tomasz_garstka tomasz.garstka at lmat-uk.com
Tue Jan 7 02:51:17 EST 2014


layered_cube.out.m0.1.vtu
<http://vtk.1045678.n5.nabble.com/file/n5725247/layered_cube.out.m0.1.vtu>  

Hi I am using c# and I am trying to plot a contour plot and a legend of the
displacement vector field over acube. The input file is the attached
file.layered_cube.out.m0.1.vtu.  

I managed to plot the cube itself using the following code and I need some
help with contouring:

      private void renderWindowControl1_Load(object sender, EventArgs e) {
         try {
             string filePath =
@"C:\tomasz\LMAT_FEA\layered_cube.out.m0.1.vtu";
 
            // reader
            vtkXMLUnstructuredGridReader reader =
vtkXMLUnstructuredGridReader.New();
            if(reader.CanReadFile(filePath) == 0) {
               MessageBox.Show("Cannot read file \"" + filePath + "\"",
"Error", MessageBoxButtons.OK);
               return;
            }
            reader.SetFileName(filePath);
            reader.Update(); // here we read the file actually
 
            // mapper
            vtkDataSetMapper gridMapper = vtkDataSetMapper.New();
            gridMapper.SetInputConnection(reader.GetOutputPort());
 
            // actor
            vtkActor gridActor = vtkActor.New();
            gridActor.SetMapper(gridMapper);
 
            // get a reference to the renderwindow of our
renderWindowControl1
            vtkRenderWindow renderWindow =
renderWindowControl1.RenderWindow;
 
            // renderer
            vtkRenderer renderer =
renderWindow.GetRenderers().GetFirstRenderer();
            // set background color
            renderer.SetBackground(0.2, 0.3, 0.4);
 
            // add our actor to the renderer
            renderer.AddActor(gridActor);
 
            // reposition the camera, so that actor can be fully seen
            renderer.ResetCamera();
         }
         catch(Exception ex) {
            MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK);
         }
      }


Many thanks,

Tomasz






--
View this message in context: http://vtk.1045678.n5.nabble.com/contour-plot-tp5725247.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list