[vtkusers] Fwd: Re: Glyph coloring by vector magnitud

Sebastian Gatzka sebastian.gatzka at stud.tu-darmstadt.de
Fri Feb 26 07:19:37 EST 2010


I’m using a structuredGrid:

 

    vtkStructuredGrid *sGrid = vtkStructuredGrid::New();



The vector array is this:

 

     vtkFloatArray *v = vtkFloatArray::New();
  v->SetNumberOfComponents(3);

 

which is filled with data like this:

 

    v->InsertNextTuple3(ix,iy,iz);

 

and is set tot he field:

 

   sGrid->GetCellData()->SetVectors(v);



The rest is history:


            vtkArrowSource *arrow = vtkArrowSource::New();

    vtkGlyph3D *glyph = vtkGlyph3D::New();
    glyph->SetInput(gridCellCenters->GetOutput());        
    glyph->SetSourceConnection(arrow->GetOutputPort());
    glyph->SetScaleModeToScaleByVector();
    glyph->SetColorModeToColorByVector();
    glyph->SetScaleFactor(0.1);
    glyph->Update();

     vtkPolyDataMapper *glyphMapper = vtkPolyDataMapper::New();
    glyphMapper->SetInputConnection(glyph->GetOutputPort());


    vtkActor *glyphActor = vtkActor::New();
    glyphActor->SetMapper(glyphMapper);

 

This is producing uniform colored (blue) glyphs, scaled by their magnitude.

So what may be wrong?



 

Von: Rakesh Patil [mailto:rakeshthp at in.com] 
Gesendet: Freitag, 26. Februar 2010 13:08
An: Sebastian Gatzka
Cc: vtkusers
Betreff: Re:[vtkusers] Fwd: Re: Glyph coloring by vector magnitud

 


It should set the colors.. Tell me what type of grid are you using..?? And what is the vector array that you are setting to this Grid??


---------- Original message ----------
From:Sebastian Gatzka< sebastian.gatzka at stud.tu-darmstadt.de >
Date: 26 Feb 10 15:23:25
Subject: [vtkusers] Fwd: Re:Glyph coloring by vector magnitud
To: vtkusers at vtk.org



Unfortunately this does not work for me.
Despite turning off the data scaling I can scale the glyphs from their magnitude, but not color them by their magnitude.

vtkArrowSource *arrow = vtkArrowSource::New();

vtkGlyph3D *glyph = vtkGlyph3D::New();
glyph->SetInput(gridCellCenters->GetOutput()); 
glyph->SetSourceConnection(arrow->GetOutputPort());
glyph->SetScaleMode(VTK_SCALE_BY_VECTOR);
glyph->SetColorMode(VTK_COLOR_BY_VECTOR);
glyph->SetScaleFactor(0.1);

This code generates scaled but uniform colored vectors.


Am 22.02.2010 16:33, schrieb Rakesh Patil: 

Its because you have turned of the scaling mode. When you say, SetScaleModeToDataScalingOff(), all glyphs are rendered of equal length.

In the next step, you are saying,

SetColorModeToColorByScale();

you'll see that all the glyphs are of same scale. Thus, all glyphs are rendered with same color. I think, Once you comment or remove 

SetScaleModeToDataScalingOff()

then, it should work fine..

Seniors please correct me if i'm wrong..

Good luck

Regards
Rakesh Patil





---------- Original message ----------
From:Sebastian Gatzka< sebastian.gatzka at stud.tu-darmstadt.de >
Date: 22 Feb 10 19:37:52
Subject: [vtkusers] Glyph coloring by vector magnitud
To: vtkusers at vtk.org

Hello World.

Meanwhile I made some nice glyphs, but am stuck with the coloring.
I switched on SetColorModeToColorByVector() which may be the coloring by vector magnitude?

vtkGlyph3D *glyph vtkGlyph3D::New();
glyph->SetInput(gridCellCenters->GetOutput()); 
glyph->SetSourceConnection(arrow->GetOutputPort());
glyph->SetScaleModeToDataScalingOff();
glyph->SetColorModeToColorByScale();
glyph->SetScaleFactor(0.3);

Unfortunately all glyphs are colored the same (blue).
Do I have to do anything further to get propper coloring? Maybe with the mapper?

See you. Sebastian

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100226/b833aa1c/attachment.htm>


More information about the vtkusers mailing list