[vtkusers] Contour Plot in Rectilinear Grid

Michel Cancelliere michel.cancelliere at polito.it
Mon Nov 16 04:50:02 EST 2009


Hi VTK users,

I'm trying to represent a contour plot from a plane in a Rectilinear grid
but i can't. I'm wondering if some of you can help me with this. I'm doing
this:


           rgrid = new vtkRectilinearGrid();
            vtkFloatArray xcoords = new vtkFloatArray();
            vtkFloatArray ycoords = new vtkFloatArray();
            vtkFloatArray zcoords = new vtkFloatArray();
            vtkFloatArray field_data = new vtkFloatArray();


            read_file(r_file, xcoords); // This function reads from a file
and put its content in the xcoords variable
            read_file(t_file, ycoords);
            read_file(z_file, zcoords);
            read_file(field_file, field_data);


            Nx = xcoords.GetNumberOfTuples();
            Ny = ycoords.GetNumberOfTuples();
            Nz = zcoords.GetNumberOfTuples();
            rgrid.SetDimensions(Nx, Ny, Nz);
            rgrid.SetXCoordinates(xcoords);
            rgrid.SetYCoordinates(ycoords);
            rgrid.SetZCoordinates(zcoords);
            rgrid.GetCellData().SetScalars(field_data);



            vtkRectilinearGridGeometryFilter plane = new
vtkRectilinearGridGeometryFilter();
            plane.SetInput(rgrid);
            plane.SetExtent(0, Nx-1, Ny-1, Ny-1, 0, Nz-1);


          vtkRectilinearGridGeometryFilter top = new
vtkRectilinearGridGeometryFilter();
            top.SetInput(rgrid);
            top.SetExtent(0, Nx-1, 0, Ny-1, 0, 0);

//// CONTOUR PLOT ////////////////
            vtkContourFilter contour = new vtkContourFilter();
            contour.SetInputConnection(top.GetOutputPort());
            contour.ComputeNormalsOn();
            contour.GenerateValues(32, 0.2, 0.9);

            vtkPolyDataMapper contourMapper = new vtkPolyDataMapper();
            contourMapper.SetInput(contour.GetOutput());

            vtkActor contourActor = new vtkActor();
            contourActor.SetMapper(contourMapper);
            //////////////////////////////////
            ren.AddActor(contourActor);


After that i got nothing but a black screen.

Thank you in advance for your help

Michel Cancelliere
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091116/7c22d087/attachment.htm>


More information about the vtkusers mailing list