<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=big5">
<META content="MSHTML 6.00.2900.2523" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>
<DIV>Hi~ I have some questions about the mechanism of vtkDataReader.</DIV>
<DIV>I&nbsp;use vtkUnstructureGridReader to load the data: "blow.vtk" (in 
VTKData/Data), and try&nbsp;to</DIV>
<DIV>"switch" different scalar in my program by setting different active scalar, 
here </DIV>
<DIV>is the code fragment:</DIV>
<DIV>&nbsp;</DIV>
<DIV>// Initial all object</DIV>
<DIV>unstrGridReader = vtkUnstructuredGridReader::New();</DIV>
<DIV>dataSetMapper = vtkDataSetMapper::New();</DIV>
<DIV>m_MainRoleActor = vtkActor::New();</DIV>
<DIV>&nbsp;</DIV>
<DIV>// Load data</DIV>
<DIV>unstrGridReader-&gt;SetFileName(DataSourceFile.c_str());</DIV>
<DIV>dataSetMapper-&gt;SetInput(reinterpret_cast&lt;vtkDataSet*&gt;(unstrGridReader-&gt;GetOutput()));</DIV>
<DIV>m_MainRoleActor-&gt;SetMapper(dataSetMapper);</DIV>
<DIV>&nbsp;</DIV>
<DIV>// Get all scalars string in the file</DIV>
<DIV>vector&lt;string&gt; m_ScalarsList;</DIV>
<DIV>size_t nosS = unstrGridReader-&gt;GetNumberOfScalarsInFile();<BR>for(size_t 
t=0;t&lt;nosS;t++)<BR>{</DIV>
<DIV>&nbsp;&nbsp;&nbsp; string sn = 
unstrGridReader-&gt;GetScalarsNameInFile(t);<BR>&nbsp;&nbsp;&nbsp; 
m_ScalarsList.push_back(sn);<BR>}</DIV>
<DIV>....</DIV>
<DIV>// switch different active scalar from GUI (for example, user want to see 
the second scalars in the file, idx&nbsp;= 2)</DIV>
<DIV>void SetColorByIndex(int idx)</DIV>
<DIV>{</DIV>
<DIV>&nbsp;&nbsp;&nbsp; 
m_MainRoleActor-&gt;GetMapper()-&gt;GetInput()-&gt;GetPointData()-&gt;SetActiveScalars(m_ScalarsList[idx].c_str());</DIV>
<DIV>&nbsp;&nbsp;&nbsp; m_MainRoleActor-&gt;GetMapper()-&gt;Update();</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>My questions are: </DIV>
<DIV>1. Does 
"dataSetMapper-&gt;SetInput(reinterpret_cast&lt;vtkDataSet*&gt;(unstrGridReader-&gt;GetOutput()));"&nbsp; 
load all</DIV>
<DIV>&nbsp;&nbsp;&nbsp; scalars and vectors in the file at a time ?&nbsp; If 
not, what is the best way to handle multiple scalars in my program ?</DIV>
<DIV>2. When I use "SetActiveScalars", it returns&nbsp;"-1" to me, what's wrong 
with my code ?</DIV>
<DIV>3. What's the standard flowchart to perform "switch" scalars 
operation?&nbsp; Is the following procedure right ?</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;1. Load all data&nbsp;&nbsp;&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; 2. Setup All Mappers</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;3. Set Active Scalars</DIV>
<DIV>&nbsp;&nbsp;&nbsp; 4. Setup All Actors</DIV>
<DIV>&nbsp;&nbsp;&nbsp; 5. ...rendering things....</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thx~</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV></DIV></BODY></HTML>