[vtkusers] A bug of vtk4.0 ??

Berk Geveci berk.geveci at kitware.com
Thu Sep 5 09:13:53 EDT 2002


Nope, not a bug, a feature :-) To avoid excessive memory
usage, vtkStreamLine deletes the stream array when it
is done. I am surprised you can even make the call, the
pointer should be NULL. You should not be using it anyway, 
it is not designed to be accessible by anything outside. 
It was public because of technical reasons related to threaded
integration. If you REALLY want to use it, sub-class vtkStreamer 
and write your own Execute(). 

By the way, I am slowly deprecating vtkStreamer and it's 
sub-classes. They will eventually be replaced by vtkStreamTracer 
(not by next release but most probably after that). I would
recommend taking a look at it if you are using a nightly 
release.

-Berk

On Wed, 2002-09-04 at 18:15, Song Li wrote:
> Hi, there,
> 
> 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
> ?????
> --------------------------------------------------------------------------------
> 
> #include "vtkUnstructuredGridReader.h"
> #include "vtkStreamLine.h"
> #include "vtkRungeKutta4.h"
> #include "vtkTubeFilter.h"
> #include "vtkGeometryFilter.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkActor.h"
> #include "vtkLookupTable.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include <iostream.h>
> 
> 
> class strm : public vtkStreamLine
> {
>  public:
>  void init(vtkUnstructuredGrid* in);
>  vtkPolyData* getoutput(){return this->GetOutput();}
> };
> 
> void strm::init(vtkUnstructuredGrid* in)
> {
>  vtkRungeKutta4* integ = vtkRungeKutta4::New();
> 
>  SetInput( in );
>  SetStartPosition( 1.4f, 2.0f, 1.2f );
>  SetMaximumPropagationTime( 5.67517 );
>  SetIntegrationStepLength( 0.0348257);
>  SetStepLength( 0.0348257 );
>  SetIntegrationDirectionToIntegrateBothDirections( );
>  SetNumberOfThreads( 1 );
>  SetIntegrator( integ );
>  Update();
> 
>  cout<<this->GetStreamers()->GetNumberOfPoints()<<endl; //output number
> of points to terminal scrren
> }
> 
> int main( int argc, char *argv[] )
> {
>   vtkUnstructuredGridReader* reader = vtkUnstructuredGridReader::New( );
> 
>   vtkTubeFilter* tubeFilter = vtkTubeFilter::New();
>   vtkGeometryFilter* filter = vtkGeometryFilter::New( );
>   vtkPolyDataMapper* mapper = vtkPolyDataMapper::New( );
>   vtkActor* actor = vtkActor::New( );
> 
>   reader->SetFileName("flowdata.vtk"); //a dataset with the type of
> "vtkUnstructuredGrid"
>   reader->Update();
> 
>   strm* s = new strm;
>   s->init(reader->GetOutput());
> 
> //the visualization routines are not important for this problem
>   vtkLookupTable* lut = vtkLookupTable::New();
>   lut->SetHueRange( 0.66667, 0.0);
>   lut->SetNumberOfColors(64);
> 
>   tubeFilter->SetInput( s->getoutput( ) );
>   tubeFilter->SetRadius( 0.0174128 );
> 
>   filter->SetInput( tubeFilter->GetOutput( ) );
>   mapper->SetInput( filter->GetOutput( ) );
>   mapper->SetColorModeToMapScalars( );
>   mapper->SetScalarRange( 0.0,200.0 );
>   mapper->SetLookupTable( lut );
>   actor->SetMapper( mapper );
>   actor->GetProperty( )->SetSpecularPower( 20.0f );
> 
>   vtkCamera *camera = vtkCamera::New();
>       camera->SetPosition(1,1,1);
>       camera->SetFocalPoint(0,0,0);
> 
>   // Create the rendering objects.
>   vtkRenderer* ren = vtkRenderer::New();
>   ren->AddActor(actor);
>   vtkRenderWindow* renWin = vtkRenderWindow::New();
>   renWin->AddRenderer(ren);
>   vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
>   iren->SetRenderWindow(renWin);
>   ren->SetActiveCamera(camera);
>   ren->ResetCamera();
>   ren->SetBackground(1,1,1);
>   renWin->Render();
>   iren->Start();
> 
>   reader->Delete();
>   filter->Delete();
>   lut->Delete();
>   delete s;
>   tubeFilter->Delete();
>   mapper->Delete();
>   actor->Delete();
>   ren->Delete();
>   renWin->Delete();
>   iren->Delete();
>   return 0;
> }
> -----------------------------------------------------------------------------------
> 
> 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......
> 
> 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 !!!!!
> 
> Is this indicates a bug of vtk4.0 ??  I don't have any more ideas......I
> am working on SGI's platform. Anyone can give me more informations ??
> Thank a lot!!!
> 
> --
> Song Li
> VRAC(Virtual Reality Application Center),Iowa State University
> Email: lisong at vrac.iastate.edu
> Homepage: http://www.vrac.iastate.edu/~lisong
> 
> 





More information about the vtkusers mailing list