<div><div class="gmail_quote">On Wed, Feb 10, 2010 at 12:33 AM, Shahid Rauf <span dir="ltr"><<a href="mailto:srauf106326@gmail.com">srauf106326@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><font face="arial, helvetica, sans-serif">I am new to VTK and would greatly appreciate help with the following question.<br><br>I have an XML Unstructured Grid data file (.vtu) which has multiple scalar DataArrays within the PointData block:<br>
<br> <font face="'courier new', monospace"><font color="#3333ff"><PointData Scalars="var_1"><br> <DataArray type="Float32" Name="var_1" format="ascii"><br>
...<br> </DataArray><br> <DataArray type="Float32" Name="var_2" format="ascii"><br> ...<br> </DataArray><br> <DataArray type="Float32" Name="var_3" format="ascii"><br>
...<br> </DataArray><br> </PointData></font></font><br><br>I can visualize the data in this file using Paraview and look at the different variables easily. I am now trying to visualize using a C++ VTK program, but the program is only displaying the first variable ("var_1"). So far I have not been able to figure out how to make VTK plot the other variables ("var_2", "var_3"). Can somebody let me know which class and function to use to change the scalar variable that is plotted. I am including portions of my C++ code to help explain what I am doing.<br>
<br> </font><font face="'courier new', monospace"><font color="#ff0000">vtkRenderer *renderer = vtkRenderer::New();<br> vtkRenderWindow *renWin = vtkRenderWindow::New();<br> renWin->AddRenderer(renderer);<br>
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
iren->SetRenderWindow(renWin);<br><br> vtkXMLUnstructuredGridReader *reader = vtkXMLUnstructuredGridReader::New();<br> char *cfname = "vtk.vtu";<br> reader->SetFileName( cfname );<br> delete[] cfname;<br>
reader->Update();<br><br> vtkExtractUnstructuredGrid *usplane=vtkExtractUnstructuredGrid::New();<br> usplane->SetInput(reader->GetOutput());<br> usplane->SetExtent(-10,10,-10,10,-10,10);<br><br> vtkPlane *planefunction=vtkPlane::New();<br>
planefunction->SetOrigin(0.0,0.0,0.05);<br> planefunction->SetNormal(0,0,1);<br><br> vtkCutter *cutter=vtkCutter::New();<br> cutter->SetInput(usplane->GetOutput());<br> cutter->SetCutFunction(planefunction);<br>
<br> vtkPolyDataMapper *planeMapper=vtkPolyDataMapper::New();<br> planeMapper->SetInputConnection(cutter->GetOutputPort());<br> planeMapper->SetScalarModeToUsePointData();<br> planeMapper->SetScalarRange(0.0,100.0);<br>
vtkActor *planeActor=vtkActor::New();<br> planeActor->SetMapper(planeMapper);<br><br> renderer->AddActor(planeActor);<br> <br> renWin->Render();<br> iren->Start();</font></font>
<div><font face="'courier new', monospace"><font color="#ff0000"><br></font></font></div>
<div><font face="arial, helvetica, sans-serif">Thanks a lot for your help,</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div>
<div><font face="arial, helvetica, sans-serif">Shahid Rauf.</font></div>
<div><font color="#ff0000" face="'courier new', monospace"></font></div></div></blockquote></div><br></div><div>I believe you can use</div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; font-size: 13px; border-collapse: collapse; color: rgb(255, 0, 0); ">usplane->GetPointData()->SetActiveScalars("var_2");</span></div>
<div><font class="Apple-style-span" color="#FF0000" face="'courier new', monospace"><span class="Apple-style-span" style="border-collapse: collapse;"><br><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: arial; ">Please let us know if that does the trick.</span><br>
</span></font><div><font class="Apple-style-span" color="#FF0000" face="'courier new', monospace"><span class="Apple-style-span" style="border-collapse: collapse; "><br clear="all"></span></font>Thanks,<br><br>David</div>
</div>