<!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 use vtkUnstructureGridReader to load the data: "blow.vtk" (in
VTKData/Data), and try to</DIV>
<DIV>"switch" different scalar in my program by setting different active scalar,
here </DIV>
<DIV>is the code fragment:</DIV>
<DIV> </DIV>
<DIV>// Initial all object</DIV>
<DIV>unstrGridReader = vtkUnstructuredGridReader::New();</DIV>
<DIV>dataSetMapper = vtkDataSetMapper::New();</DIV>
<DIV>m_MainRoleActor = vtkActor::New();</DIV>
<DIV> </DIV>
<DIV>// Load data</DIV>
<DIV>unstrGridReader->SetFileName(DataSourceFile.c_str());</DIV>
<DIV>dataSetMapper->SetInput(reinterpret_cast<vtkDataSet*>(unstrGridReader->GetOutput()));</DIV>
<DIV>m_MainRoleActor->SetMapper(dataSetMapper);</DIV>
<DIV> </DIV>
<DIV>// Get all scalars string in the file</DIV>
<DIV>vector<string> m_ScalarsList;</DIV>
<DIV>size_t nosS = unstrGridReader->GetNumberOfScalarsInFile();<BR>for(size_t
t=0;t<nosS;t++)<BR>{</DIV>
<DIV> string sn =
unstrGridReader->GetScalarsNameInFile(t);<BR>
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 = 2)</DIV>
<DIV>void SetColorByIndex(int idx)</DIV>
<DIV>{</DIV>
<DIV>
m_MainRoleActor->GetMapper()->GetInput()->GetPointData()->SetActiveScalars(m_ScalarsList[idx].c_str());</DIV>
<DIV> m_MainRoleActor->GetMapper()->Update();</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>My questions are: </DIV>
<DIV>1. Does
"dataSetMapper->SetInput(reinterpret_cast<vtkDataSet*>(unstrGridReader->GetOutput()));"
load all</DIV>
<DIV> scalars and vectors in the file at a time ? If
not, what is the best way to handle multiple scalars in my program ?</DIV>
<DIV>2. When I use "SetActiveScalars", it returns "-1" to me, what's wrong
with my code ?</DIV>
<DIV>3. What's the standard flowchart to perform "switch" scalars
operation? Is the following procedure right ?</DIV>
<DIV> 1. Load all data </DIV>
<DIV> 2. Setup All Mappers</DIV>
<DIV> 3. Set Active Scalars</DIV>
<DIV> 4. Setup All Actors</DIV>
<DIV> 5. ...rendering things....</DIV>
<DIV> </DIV>
<DIV>Thx~</DIV>
<DIV> </DIV>
<DIV> </DIV></DIV></BODY></HTML>