[vtkusers] Contour Plot in Rectilinear Grid

Bill Lorensen bill.lorensen at gmail.com
Mon Nov 16 07:53:00 EST 2009


For contouring, you want to set the point data, not the cell data:
 rgrid.GetPointData().SetScalars(field_data);


On Mon, Nov 16, 2009 at 4:50 AM, Michel Cancelliere
<michel.cancelliere at polito.it> wrote:
> 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
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list