[vtkusers] Why don't my Glyphs scale?

Mdl mdl78 at libero.it
Mon Nov 18 06:43:18 EST 2002


Hi everybody,

I'm getting very frustrated about this simple VTK code that doesn't seem to
work.. I have to display n spheres arranged on a circle that scale according
to some values changing in time...

Here's some code:

disco = vtkDiskSource::New();
disco->SetInnerRadius (1.0);
disco->SetOuterRadius (1.0);
disco->SetCircumferentialResolution (n);

vtkFloatArray *fa = vtkFloatArray::New();
fa->SetNumberOfComponents (1);
fa->SetNumberOfTuples(n);
for (int i = 0; i < n; i++)
    fa->SetTuple1 ((vtkIdType) i,  value[i]);
(disco->GetOutput())->GetPointData()->SetScalars(fa);

petali = vtkGlyph3D::New();
sfera = vtkSphereSource::New();
petali->SetSource (sfera->GetOutput());
petali->SetInput (disco->GetOutput());
petali->SetScaleModeToScaleByScalar();
petali->SetScaleFactor (1.5);
petali->ScalingOn();
petali->SetColorModeToColorByScalar();
petali->SetRange(0.0, 250.0);

mPetali = vtkPolyDataMapper::New();
mPetali->SetInput(petali->GetOutput());
aPetali = vtkActor::New();
aPetali->SetMapper(mPetali);
ren1->AddActor (aPetali);


....then, in the animation function:

[..]
fa = vtkFloatArray::New();
fa->SetNumberOfTuples (n);
fa->SetNumberOfComponents (1);
for (int i = 0; i < n; i++)
    fa->SetTuple1((vtkIdType) i, newValue[i]);
(disco->GetOutput())->GetPointData()->SetScalars(fa);
petali->Update();
renWindow->Render();
[..]


..and it doesn't work. The spheres are displayed, in the correct positions,
but they don't grow and shrink according to the data I feed the Glyph3D
filter with... they don't grow and shrink at all! Where am I wrong?
Please notice that in the very same render window I also have a 2D text that
I change in every cycle of the animation function, and it changes perfectly!
So it is not a global problem, it is just a Glyph3D problem.

Thanks to everyone who wants to help me!
Marco





More information about the vtkusers mailing list