[vtkusers] vectors: problem of scaling

nrsilva at inf.pucrs.br nrsilva at inf.pucrs.br
Sat Jul 9 20:05:44 EDT 2005


Hi

I am reading vectors components (x, y, z) of velocity and I am trying to display them using vtkGlyph3D. Since they are very small, they seem to disappear. The SetScaleFactor() doesn't cause any effect.

 Another doubt that I have is about the vector. Since I read the components, that are the velocity in x, y and z, and try to display using the glyphs, it shows the resulting vector? That is the way we get the orientation of the vector? 

The folowing code is:

I read the vector components (x, y, z) and associate that with vtkStructuredGrid. I have two actors: onde for the grid and another for the glyphs. The code after reading the vector components and associate that with vtkStructuredGrid.  is:

vtkConeSource *cone = vtkConeSource::New();
	cone->SetResolution(3);
	cone->SetHeight(1);
	cone->SetRadius(0.25);

vtkGlyph3D *cones = vtkGlyph3D::New();
	cones->SetInput(rgrid);    //the vtkStructuredGrid
	cones->SetSource(cone->GetOutput());
	cones->ScalingOff();
	cones->SetScaleFactor(10);
	cones->SetScaleModeToScaleByVectorComponents();

	cones->SetVectorModeToUseNormal();
	cones->OrientOn();
	cones->Update();

  vtkPolyDataMapper *rgridMapper = vtkPolyDataMapper::New();
      rgridMapper->SetInput(cones->GetOutput());
 
vtkDataSetMapper *rgridMapper2 = vtkDataSetMapper::New();
      rgridMapper2->SetInput(rgrid);	
  

  vtkActor *wireActor = vtkActor::New();
     wireActor->SetMapper(rgridMapper);
     wireActor->GetProperty()->SetRepresentationToSurface();
     wireActor->GetProperty()->SetColor(1,0,1);
     wireActor->GetProperty()->SetPointSize(10);

  vtkActor *wireActor2 = vtkActor::New();
     wireActor2->SetMapper(rgridMapper2);
     wireActor2->GetProperty()->SetRepresentationToSurface();
     wireActor2->GetProperty()->SetColor(0,0,0);
     wireActor2->GetProperty()->SetPointSize(10);

  
 // Create the usual rendering stuff.
  vtkRenderer *renderer = vtkRenderer::New();
  vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(renderer);
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

  renderer->AddActor(wireActor);
  renderer->AddActor(wireActor2);
  renderer->SetBackground(1,1,1);
  renderer->GetActiveCamera()->Elevation(1.0);
  renderer->GetActiveCamera()->Azimuth(30.0);
  renderer->GetActiveCamera()->Zoom(2);



More information about the vtkusers mailing list