[vtkusers] vtkDataReader problems...

ckchen@CIS ckchen.cis89g at nctu.edu.tw
Fri Dec 10 02:13:08 EST 2004

Hi~ I have some questions about the mechanism of vtkDataReader.
I use vtkUnstructureGridReader to load the data: "blow.vtk" (in VTKData/Data), and try to
"switch" different scalar in my program by setting different active scalar, here 
is the code fragment:

// Initial all object
unstrGridReader = vtkUnstructuredGridReader::New();
dataSetMapper = vtkDataSetMapper::New();
m_MainRoleActor = vtkActor::New();

// Load data

// Get all scalars string in the file
vector<string> m_ScalarsList;
size_t nosS = unstrGridReader->GetNumberOfScalarsInFile();
for(size_t t=0;t<nosS;t++)
    string sn = unstrGridReader->GetScalarsNameInFile(t);
// switch different active scalar from GUI (for example, user want to see the second scalars in the file, idx = 2)
void SetColorByIndex(int idx)

My questions are: 
1. Does "dataSetMapper->SetInput(reinterpret_cast<vtkDataSet*>(unstrGridReader->GetOutput()));"  load all
    scalars and vectors in the file at a time ?  If not, what is the best way to handle multiple scalars in my program ?
2. When I use "SetActiveScalars", it returns "-1" to me, what's wrong with my code ?
3. What's the standard flowchart to perform "switch" scalars operation?  Is the following procedure right ?
    1. Load all data   
    2. Setup All Mappers
    3. Set Active Scalars
    4. Setup All Actors
    5. ...rendering things....


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20041210/41176217/attachment.htm>

More information about the vtkusers mailing list