[vtk-developers] Manual conversion of some Tcl to Python tests.

Marcus D. Hanwell marcus.hanwell at kitware.com
Sun Sep 2 13:17:10 EDT 2012


On Fri, Aug 31, 2012 at 6:10 PM, David Thompson
<david.thompson at kitware.com> wrote:
> Hi Marcus,
>
>>> ... How about the following for SetColor()?
>>>
>>>   void InsertColor( std::string name, double* rgba, int swatch = 0 );
>>>   void InsertColor( std::string name, double r, double g, double b, double a=1., int swatch = 0 );
>>>   void RemoveColor( std::string name );
>>>   int  GetNumberOfSwatches( std::string name );
>>>
>>> That seems wrappable and the vector could just be increased in size to accommodate whatever swatch number was provided (hence the name change from SetXXX to InsertXXX).
>>>
>> The vtkColor4d is just a double[4] in memory, and an
>> std::vector<vtkColor4d> colors would be laid out as 4*N doubles. The
>> color classes can also convert between different representations and
>> you don't need to guess the size. I personally prefer the compactness
>> of the vtkColor4ub, and the representation is easy to send to GL (as
>> is the vtkColor4d but it does use more space).
>
> My problem with vtkColor4ub is that if you want to use VTK to generate or process high dynamic range images, it could be a problem to standardize on this as internal storage for base classes.

Why not specialize at that level for the high dynamic range images, it
seems odd to pay the price in the base classes for something not being
used there too.
>
>> ... I would love to see us move towards using actual types to represent
>> things like color, with accessors that can give the pointers for
>> older/C function calls.
>
> I have conflicting feelings about that. I really enjoy the convenience of actual types but it seems like VTK, as a library instead of an application, should be capable of accepting data in whatever form it is provided.

That is why I wrote the vtkColor* classes to be POD, you can actually
use GetData to get at the underlying data, initialize them from
pointers to their underlying types or if efficiency is a concern you
can cast, e.g.

double myColors[4 * n];
...do something with the colors...
vtk*Class->SetColor(*(static_cast<vtkColor4d *>(myColors[4 * 1])));

You can also perform conversions if desired (although I feel this is
way off topic for the thread)
>
>> My $0.02, there is another color table class in the charts modules
>> that lets us pass around color sequences for plot colors too.
>
> Argh! I was looking for that the other day and missed it. Would you object to me performing a little surgery on it to reconcile it with vtkBrewerColors?
>
It depends what the surgery is, I would be happy to take a look at
what you want to do/review it. It would be great to get more colors in
there (I would like to retain the current ones for the tests at least
even if you add nicer ones), but it has been in for quite some time so
we should retain the API.

Marcus



More information about the vtk-developers mailing list