[vtkusers] API

Jens Fisseler fisseler at rob.uni-luebeck.de
Thu Jan 13 09:11:14 EST 2005

Hi Jens,

> I've a little question. On my work with vtk I've always the same 
> problem. On many classes the parameters from the methods are not 
> documented. For example the class vtkColorTransferFunction. The class 
> has the method AddRGBPoint(double x, double r, double, g, double b). I 
> don't know what is x or r or g. Why are the parameters no documented 
> please and anybody improve this.

I think the lack of documentation is something you have to live with
using open source software. I don't know if closed source libraries are
better documented.

At least you can to some extent remedy this by reading the source code,
which also gives you some knowledge of what is going on under the hood.
And when you have some good working knowledge, you can help others by
documenting the code, for example.

So, in order to help you a little bit, here is my best guess regarding
the 'AddRGBPoint' function (someone please correct me if I'm wrong!). I
have not used the class 'vtkColorTransferFunction' myself, but it
defines a mapping from R (the real numbers) to R^3, a color space,
either RGB or HSV. This mapping must be defined somehow, and one way to
define such a mapping is by defining a piecewise linear function.

Given n real values x_i, with x_1 < x_2 < ... < x_n, a color (either RGB
or HSV) c_i is associated with every x_i. Now, if you want to map a new
value x using this piecewise linear function, you can find two values x'
and x'' with x' < x < x''. The color x is mapped to is given by a linear
combination of c' and c'', the colors associated with x' and x'':

c = (x - x')/(x''-x') * c' + (x'' - x)/(x''-x') * c''

Of course you also have to take into account the case x == x_i for some
i and x < x_1 or x > x_2, i.e. boundary conditions. But I guess this
should give you some idea about how 'vtkColorTransferFunction' works.
And if you want to know more: read the source.

And now back to your question about 'AddRGBPoint(x, r, g, b)'. It just
add a new point x, associated with the RGB color (r, g, b), given that
the color space used is RGB (you can change this with 'SetColorSpace').



More information about the vtkusers mailing list