From KitwarePublic
Revision as of 10:24, 11 August 2004 by Tfogal (talk | contribs) (spelling errors, link correction)
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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 ...

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.