[vtkusers] How to offscreen-render a specific field in VTK?

Daniel WEI lakeat at gmail.com
Thu Jul 3 10:37:04 EDT 2014


Dear List,


I have a .VTK file, having UnstructuredGrid data, containing velocity field
and a scalar pressure field. Now I want to do the offscreen rendering.

Following the reader->mapper->actor->renderer pattern, I am able to render
the grid and export it to an image (using SetRepresentationToWireframe). (I
am using C++.)

Now I want to render, say the pressure field (p), google shows me that I
should use vtkLookupTable, and then SetLookupTable in the mapper. (Please
correct me if I am wrong.) But I have no success, the result image is white
blank. My questions are:

   1. Which reader should I use? Should I continue to use the
   vtkUnstructuredGridReader?
   2. How to get the specific scalar/vector variable in lookuptable?

Here is the part of the code related to my question.

// ------------// Create a reader: Read the file// ------------
vtkSmartPointer<vtkUnstructuredGridReader> reader =
    vtkSmartPointer<vtkUnstructuredGridReader>::New();//
vtkSmartPointer<vtkPolyDataReader> reader =//
vtkSmartPointer<vtkPolyDataReader>::New();//
vtkSmartPointer<vtkDataSetReader> reader =//
vtkSmartPointer<vtkDataSetReader>::New();
reader->SetFileName(inputFilename.c_str());
reader->Update();

vtkSmartPointer<vtkLookupTable> lut =
    vtkSmartPointer<vtkLookupTable>::New();
lut->SetNumberOfTableValues(1);
lut->Build();
// ------------// Create a mapper// ------------//
vtkSmartPointer<vtkPolyDataMapper> mapper = //
vtkSmartPointer<vtkPolyDataMapper>::New();
vtkSmartPointer<vtkDataSetMapper> mapper =
    vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInputConnection(reader->GetOutputPort());//
mapper->SetScalarRange(scalarRange[0], scalarRange[1]);
mapper->SetScalarModeToUseCellData();
mapper->SetLookupTable(lut);
// ------------// Create a actor// ------------
vtkSmartPointer<vtkActor> actor =
    vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(0,0,0);
actor->GetProperty()->SetRepresentationToWireframe();//
actor->GetProperty()->SetRepresentationToSurface();

PS: Any insight from python or TCL is also welcome.


Thanks




​Daniel
 Wei
----------------------
*University of Notre Dame*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140703/9c25e5da/attachment.html>


More information about the vtkusers mailing list