VtkStreamTracer

From KitwarePublic
Jump to navigationJump to search

vtkStreamTracer is the new 'preferred' method for tracing stream lines. The old method used 'vtkStreamLine', which may or may not contain bugs / issues / undocumented caveats.

StreamTracer has some of its own caveats, but hopefully they are all documented. Recently I encountered the issue of determining where a particular stream line ends. Conveniently the object includes an enum for describing this, aptly named ReasonForTermination. To access this information, you will need to grab it out of a vtkCellData array of the same name. Code might look like the following:

vtkStreamTracer::ReasonForTermination RFT;
vtkStreamTracer *ST = vtkStreamTracer::New();
vtkIntArray *Int;

... setup ST inputs, settings, outputs, etc ...

ST->Update();
Int = ST->GetOutput()->GetCellData()->GetArray("ReasonForTermination");
if(Int) {
   RFT = Int->GetValue(0);
} else {
   std::cerr << "Error getting streamline properties!\n";
}
switch(RFT) {
   case vtkStreamTracer::OUT_OF_DOMAIN:   /* something */; break;
   case vtkStreamTracer::NOT_INITIALIZED: /* something */; break;
   ....
}


Note the frequent 'vtkStreamTracer::' qualifier. The ReasonForTermination is defined within the StreamTracer class, so all references to it must be fully qualified with the object. Also note the 'Update()' before trying to access the CellData array -- this is very important! Without it the filter will not have executed and the array you get back from GetArray() would not be what you are expecting. Finally, note that the output of GetArray() is tested before we dereference it - it can return NULL in certain circumstances.

This interface may seem counterintuitive (it did for me, at least...) but there is supposedly a good reason for this design. The mailing list thread that justified this design is archived at this Mailing list thread.



VTK: [Welcome | Site Map]