<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi, there,
<p>I am implementing moving sphere on the streamline, which need to access
the data in the vtkStreamArray. Unfortunately, vtk4.0 seems does not support
this. Below is a testing program to output the number of all points on
the streamline onto terminal screen, it is very simple, any gurus want
to take a look at it and help me to find out what's wrong ?????
<br>--------------------------------------------------------------------------------
<p>#include "vtkUnstructuredGridReader.h"
<br>#include "vtkStreamLine.h"
<br>#include "vtkRungeKutta4.h"
<br>#include "vtkTubeFilter.h"
<br>#include "vtkGeometryFilter.h"
<br>#include "vtkPolyDataMapper.h"
<br>#include "vtkActor.h"
<br>#include "vtkLookupTable.h"
<br>#include "vtkPolyDataMapper.h"
<br>#include "vtkRenderWindow.h"
<br>#include "vtkRenderWindowInteractor.h"
<br>#include &lt;iostream.h>
<br>&nbsp;
<p>class strm : public vtkStreamLine
<br>{
<br>&nbsp;public:
<br>&nbsp;void init(vtkUnstructuredGrid* in);
<br>&nbsp;vtkPolyData* getoutput(){return this->GetOutput();}
<br>};
<p>void strm::init(vtkUnstructuredGrid* in)
<br>{
<br>&nbsp;vtkRungeKutta4* integ = vtkRungeKutta4::New();
<p>&nbsp;SetInput( in );
<br>&nbsp;SetStartPosition( 1.4f, 2.0f, 1.2f );
<br>&nbsp;SetMaximumPropagationTime( 5.67517 );
<br>&nbsp;SetIntegrationStepLength( 0.0348257);
<br>&nbsp;SetStepLength( 0.0348257 );
<br>&nbsp;SetIntegrationDirectionToIntegrateBothDirections( );
<br>&nbsp;SetNumberOfThreads( 1 );
<br>&nbsp;SetIntegrator( integ );
<br>&nbsp;Update();
<p>&nbsp;cout&lt;&lt;this->GetStreamers()->GetNumberOfPoints()&lt;&lt;endl;
//output number of points to terminal scrren
<br>}
<p>int main( int argc, char *argv[] )
<br>{
<br>&nbsp; vtkUnstructuredGridReader* reader = vtkUnstructuredGridReader::New(
);
<br>&nbsp; vtkTubeFilter* tubeFilter = vtkTubeFilter::New();
<br>&nbsp; vtkGeometryFilter* filter = vtkGeometryFilter::New( );
<br>&nbsp; vtkPolyDataMapper* mapper = vtkPolyDataMapper::New( );
<br>&nbsp; vtkActor* actor = vtkActor::New( );
<p>&nbsp; reader->SetFileName("flowdata.vtk"); //a dataset with the type
of "vtkUnstructuredGrid"
<br>&nbsp; reader->Update();
<p>&nbsp; strm* s = new strm;
<br>&nbsp; s->init(reader->GetOutput());
<p>//the visualization routines are not important for this problem
<br>&nbsp; vtkLookupTable* lut = vtkLookupTable::New();
<br>&nbsp; lut->SetHueRange( 0.66667, 0.0);
<br>&nbsp; lut->SetNumberOfColors(64);
<p>&nbsp; tubeFilter->SetInput( s->getoutput( ) );
<br>&nbsp; tubeFilter->SetRadius( 0.0174128 );
<p>&nbsp; filter->SetInput( tubeFilter->GetOutput( ) );
<br>&nbsp; mapper->SetInput( filter->GetOutput( ) );
<br>&nbsp; mapper->SetColorModeToMapScalars( );
<br>&nbsp; mapper->SetScalarRange( 0.0,200.0 );
<br>&nbsp; mapper->SetLookupTable( lut );
<br>&nbsp; actor->SetMapper( mapper );
<br>&nbsp; actor->GetProperty( )->SetSpecularPower( 20.0f );
<p>&nbsp; vtkCamera *camera = vtkCamera::New();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; camera->SetPosition(1,1,1);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; camera->SetFocalPoint(0,0,0);
<p>&nbsp; // Create the rendering objects.
<br>&nbsp; vtkRenderer* ren = vtkRenderer::New();
<br>&nbsp; ren->AddActor(actor);
<br>&nbsp; vtkRenderWindow* renWin = vtkRenderWindow::New();
<br>&nbsp; renWin->AddRenderer(ren);
<br>&nbsp; vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
<br>&nbsp; iren->SetRenderWindow(renWin);
<br>&nbsp; ren->SetActiveCamera(camera);
<br>&nbsp; ren->ResetCamera();
<br>&nbsp; ren->SetBackground(1,1,1);
<br>&nbsp; renWin->Render();
<br>&nbsp; iren->Start();
<p>&nbsp; reader->Delete();
<br>&nbsp; filter->Delete();
<br>&nbsp; lut->Delete();
<br>&nbsp; delete s;
<br>&nbsp; tubeFilter->Delete();
<br>&nbsp; mapper->Delete();
<br>&nbsp; actor->Delete();
<br>&nbsp; ren->Delete();
<br>&nbsp; renWin->Delete();
<br>&nbsp; iren->Delete();
<br>&nbsp; return 0;
<br>}
<br>-----------------------------------------------------------------------------------
<p>I don't know why in vtk4.0 the method "vtkStreamer::GetStreamers()"
is changed to protected(in vtk3.2 it is public) which make a little more
trouble to write the program......
<p>I can see a streamline in the rendering window when running this program.
If compile it using vtk3.2, the terminal output is 72, which is very reasonable,
if compile the same program using vtk4.0, the output is 1 !!!!!
<p>Is this indicates a bug of vtk4.0 ??&nbsp; I don't have any more ideas......I
am working on SGI's platform. Anyone can give me more informations ?? Thank
a lot!!!
<pre>--&nbsp;
Song Li
VRAC(Virtual Reality Application Center),Iowa State University
Email: lisong@vrac.iastate.edu
Homepage: <A HREF="http://www.vrac.iastate.edu/~lisong">http://www.vrac.iastate.edu/~lisong</A></pre>
&nbsp;</html>