VtkStreamTracer: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(ReasonForTermination usage)
 
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 3: Line 3:
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:
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:


----
<blockquote style="padding: 1em border: 1px striped blue">
 
<pre>
vtkStreamTracer::ReasonForTermination RFT;
vtkStreamTracer::ReasonForTermination RFT;
vtkStreamTracer *ST = vtkStreamTracer::New();
vtkStreamTracer *ST = vtkStreamTracer::New();
Line 23: Line 23:
   ....
   ....
}
}
</pre>
</blockquote>


----


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.


Note the frequent 'vtkStreamTracer::' qualifier. The ReasonForTermination is defined within the StreamTracer class, so all references to it muts 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 [http://public.kitware.com/pipermail/vtkusers/2004-April/073493.html this Mailing list thread].


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 [http://public.kitware.com/pipermail/vtkusers/2004-April/073493.html link ST Mailing list thread].
{{VTK/Template/Footer}}

Latest revision as of 13:46, 20 December 2005

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]