FW: [vtkusers] why doesn't my glyph scale?
John Platt
jcplatt at lineone.net
Tue Apr 19 05:28:30 EDT 2005
-----Original Message-----
From: John Platt [mailto:jcplatt at lineone.net]
Sent: 19 April 2005 10:27
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050419/1fe6468e/attachment.htm>
More information about the vtkusers
mailing list