[vtkusers] why doesn't my glyph scale?

Akiko Campbell adcampbell at shaw.ca
Tue Apr 19 11:20:54 EDT 2005


Hi John and Malcolm,
 
Thank you very much for your quick and helpful replies!  I’ve tried all
the suggestions but still my glyphs don’t scale.  It seems my problem is
due to the way I built the vector.  It’s a silly question but how do you
build magnitude information into your vectors in VTK so that they can be
used with VTK_SCALE_BY_VECTOR (i.e. scale by point vector magnitude in
John’s email below)?  Another question is…my vector (both direction and
magnitude) values are very small and many of them are negative numbers.
I tried to set a huge value to ScaleFactor but still nothing happens.
Is there a value range I need to be aware of?   Thank you again.
 
Akiko
 
-----Original Message-----
From: John Platt [mailto:jcplatt at lineone.net] 
Sent: Tuesday, April 19, 2005 2:27 AM
To: 'Akiko Campbell'
Subject: RE: [vtkusers] why doesn't my glyph scale?
 
Hi Akiko,
 
Try replacing
 
points->GetCellData()->SetScalars( eigenValue_1 );
with
points->GetPointData()->SetScalars( eigenValue_1 );
 
Below is an extract of some glyph code - the comments may be helpful.
  
      // The glyphs can be oriented along the input DataSet vectors or
normals.
      // Since spheres have no preferred orientation, switch orientation
off.
 
      m_vtkGlyphs->OrientOff();
 
      // The glyphs must be scaled otherwise each glyph will be drawn in
      // World coordinates. Note that scaling is ON by default.
 
      m_vtkGlyphs->ScalingOn();  
 
      // Scaling is controlled by the composite factor ScaleFactor *
DataScale
      // where the data scale is either
      //
      //          - point scalars (VTK_SCALE_BY_SCALAR)
      //          - point vector magnitude (VTK_SCALE_BY_VECTOR)
      //          - point vector components
(VTK_SCALE_BY_VECTORCOMPONENTS)
      //
      // Scaling due to data (scalars, vectors, or normals can be
disabled
      // using SetScaleModeToDataScalingOff()). The glyph scale can also
be
      // controlled by mapping the data scale to a specified range, then
      // multiplying by the scale factor.
 
John.
 
-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
Behalf Of Akiko Campbell
Sent: 19 April 2005 00:32
To: vtkusers at vtk.org
Subject: [vtkusers] why doesn't my glyph scale?
 
Hello,
 
I have a set of points I’d like to visualize with glyphs but glyphs
don’t seem to scale at all. I read in point’s vector components into a
float array (eigenVector_1) and corresponding magnitude data into
another float array (eigenValue_1).  Since magnitude information is
stored in a separate array as scalars, I would like to use
SetScaleModeToScaleByScalar() to scale glyphs but all glyphs are exactly
the same shape and are directed in the same direction.  I am wondering
if something I’m doing is wrong here.  Could someone give me an insight?
Thank you!
 
vtkPolyData *points = reader->GetOutput();
const unsigned int numberOfPoints = vpoints->GetNumberOfPoints();
vtkFloatArray *eigenVector_1 = vtkFloatArray::New();
eigenVector_1->SetNumberOfComponents( 3 );
eigenVector_1->SetNumberOfTuples( numberOfPoints );
vtkFloatArray *eigenValue_1 = vtkFloatArray::New();
eigenValue_1->SetNumberOfTuples( numberOfPoints );
//************************************************
A brief version of loop to populate the arrays:
 
for (unsigned int ctr=0; ctr < numberOfPoints; ctr++){
 eigenVector_1->SetComponent( ctr, 0, voxelValue_1_X[X] );
 eigenVector_1->SetComponent( ctr, 1, voxelValue_1_Y[Y] );
 eigenVector_1->SetComponent( ctr, 2, voxelValue_1_Z[Z] );
 
 eigenValue_1->SetValue( ctr, pixelValue[X] );
}
//************************************************
 
//Set the vectors and scalars 
points->GetPointData()->SetVectors( eigenVector_1 ); 
points->GetCellData()->SetScalars( eigenValue_1 );
 
vtkSphereSource *source = vtkSphereSource::New();
source->SetThetaResolution( 6 );
source->SetPhiResolution( 5 );
source->SetRadius( 0.5 );
vtkGlyph3D *glyph = vtkGlyph3D::New();
glyph->SetInput(points);
glyph->SetSource(source->GetOutput());
glyph->ScalingOff(); // I read somewhere I need to set this off…even
with ScalingOn(), no scaling happens. 
glyph->OrientOn();
glyph->SetVectorModeToUseVector();
glyph->SetScaleModeToScaleByScalar();
glyph->SetColorModeToColorByScalar();
glyph->Update();

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.16 - Release Date: 2005-04-18


--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.16 - Release Date: 2005-04-18


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.16 - Release Date: 2005-04-18
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050419/e8dcc5d7/attachment.htm>


More information about the vtkusers mailing list