[vtkusers] Coloring HedgeHog vectors
K.R.Subramanian
krs at cs.uncc.edu
Sat Aug 24 10:23:08 EDT 2002
Philip Cook wrote:
> On Saturday 24 August 2002 11:37, vtkusers-request at public.kitware.com wrote:
> > I am using vtkHedgehog to visualize vector data from a
> > structured grid data set. I would like the color of the
> > vector line to be scaled to the length of the vector, and
> > not a particular scalar component of the vector. How do I pull this
> > off? Various combinations of inputs to the vtkHedgehog or the
> > polydatamapper have given solid colors, but not a color
> > scale.
It sounds like he wants the magnitude of the vector to control the color, but this
is what vtkHedgehog does by default, from the docs. You have to work harder to get
a component of the vector to be the scalars that are used to control the color.
-- krs
>
> >
> > Jess Neri
>
> I'm not sure if you want each line to have multiple colours (I don't know how
> to do that).
>
> If you want to colour each line with one colour that is determined by its
> vector magnitude, you can use vtkGlyph3D. This class will place an oriented
> glyph (in our case a line, but it can be any polygonal shape) at each point
> in an input dataset. You can scale and colour by vector, normal, or scalar
> values.
>
> // make a line for our glyph
> vtkLineSource *line = vtkLineSource::New();
>
> line->SetPoint1(0.0f, 0.0f, 0.0f);
> line->SetPoint2(1.0f, 0.0f, 0.0f);
>
> line->Update();
>
> vtkGlyph3D *glyph = vtkGlyph3D::New();
>
> // Set vectors for points in structured points
> // vectors should be a vtkDataArray containing the vectors for each point
> spoints->GetPointData()->SetVectors(vectors);
>
> // Tell the glyph what we want to use as input
> glyph->SetInput(spoints);
>
> // Tell the glyph what shape we want placed at each point of input
> glyph->SetSource(line->GetOutput());
>
> // Tell the glyph to orient all source objects
> glyph->OrientOn();
>
> //Tell the glyph to orient by vector
> glyph->SetVectorModeToUseVector();
>
> // Tell the glyph to scale by vector
> // can alternatively call ScalingOff() to make all lines the same length
> glyph->SetScaleModeToScaleByVector();
>
> // And also to colour by vector
> glyph->SetColorModeToColorByVector();
>
> // Make sure all those orders took effect
> glyph->Update();
>
> // Now make an LUT
> vtkLookupTable *lut = vtkLookupTable::New();
> lut->SetHueRange(0.667, 0.0);
>
> // map to graphics library
> vtkPolyDataMapper *map = vtkPolyDataMapper::New();
> map->SetInput(glyph->GetOutput());
>
> // minScalar, maxScalar should correspond to min and max vector magnitude in
> // input vector data
> map->SetScalarRange(minScalar, maxScalar);
> lut->SetRange(minScalar, maxScalar);
> map->SetLookupTable(lut);
>
> // actor coordinates geometry, properties, transformation
> vtkActor *aGlyph = vtkActor::New();
> aGlyph->SetMapper(map);
>
> And so on.
>
> Phil
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
--
K.R.Subramanian Phone: (704) 687-4872
Department of Computer Science FAX: (704) 687-4893
UNC Charlotte, CARC 311 Email: krs at cs.uncc.edu
Charlotte, NC 28223-0001 Web: http://www.cs.uncc.edu/~krs
More information about the vtkusers
mailing list