[vtkusers] why doesn't my glyph scale?

Akiko Campbell adcampbell at shaw.ca
Tue Apr 19 19:44:28 EDT 2005


Thank you very much for all your suggestions!

Akiko

-----Original Message-----
From: David.Pont at ForestResearch.co.nz
[mailto:David.Pont at ForestResearch.co.nz] 
Sent: Tuesday, April 19, 2005 2:30 PM
To: John Platt
Cc: 'Akiko Campbell'; vtkusers at vtk.org; vtkusers-bounces at vtk.org
Subject: RE: [vtkusers] why doesn't my glyph scale?





Just a couple of tips about glyphs from my experiences...

Very small values make glyphs so small they disappear. To remedy this I
have used a second mapper+actor with SetRepresentationToPoints on the
actors property. This gives a visible fixed sized point at the locations
where the glyphs are too small. I have also used SetPointSize on the
actors
property to control point size. I have used this with scalar data, not
sure
how it would go with vectors?

Negative values turn the glyphs inside out and they disappear too. Pass
the
glyphs through vtkPolyDataNormals to see them.

   regards, Dave P

"John Platt" <jcplatt at lineone.net> wrote on 20/04/2005 04:49:47:

> Hi Akiko,
>
> Assuming your eigenvectors are not normalized, divide each component
> by the norm of the vector, then multiply each component by the
> required magnitude. VTK_SCALE_BY_VECTOR will calculate the scale
factors
as
>
>       vMag = vtkMath::Norm(vector);
>       scalex = scaley = scalez = vMag;
>
> and then apply the ScaleFactor.
>
> The only check on the scales is for 0.0 in which case they are resetto
1e-10.
>
> HTH
>
> John.
>
> -----Original Message-----
> From: Akiko Campbell [mailto:adcampbell at shaw.ca]
> Sent: 19 April 2005 16:21
> To: 'John Platt'
> Cc: vtkusers at vtk.org
> Subject: RE: [vtkusers] why doesn't my glyph scale?
>
> 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
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.
> org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-- 
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
 




More information about the vtkusers mailing list