[vtkusers] A bug of vtk4.0 ??

Song Li lisong at vrac.iastate.edu
Wed Sep 4 18:15:57 EDT 2002


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020904/6ea2ca72/attachment.htm>


More information about the vtkusers mailing list