[vtkusers] scalars etc

Asad A. Abu-Tarif tarifa at rpi.edu
Mon Jun 17 14:14:40 EDT 2002


Hi Jim,
I attached the email below that was sent to the vtk list before
and I kept for my future reference.
I think you'll find it useful.

Asad
&&&&&&&&&&&&&&&&&
*  Asad A. Abu-Tarif
*  Computer Engineering.
*  PhD Candidate, Rensselaer Polytechnic Institute (RPI).
*  Web-site: http://asad.ods.org/Professional/
*  Registration Toolkit: http://asad.ods.org/RegMagicTKDoc/
*  tarifa at rpi.edu
&&&&&&&&&&&&&&&&&&


Hello vtkusers!

I've just ported my medium-sized (40K lines) application from vtk3.2 to
vtk4.x. I thought I would share my experiences with you, in case there were
people out there contemplating it but a bit scared.

The documentation in

http://public.kitware.com/VTK/files/misc/Upgrading.zip

and the FAQ entry 6.7 at

http://public.kitware.com/cgi-bin/vtkfaq?req=show&file=faq06.007.htp

are both useful but don't have enough concrete examples. Hopefully this
email will help a little, though it is by no means complete. I'm using
VC++6 + MFC on Win2K and was unable/unwilling to run the script in the zip
file.

So,

I switched all my include directories to the new VTK ones and recompiled.
337 errors, not unexpectedly. Most concerned vtkScalars and vtkTCoords
which have both been removed. Where I was using single value scalars, like
this:

vtkScalars *scalars = vtkScalars::New();
scalars->SetNumberOfScalars(N_POINTS);
...
polydata->GetPointData()->SetScalars(scalars);
...
scalars->SetScalar(i,2.3);
...

I replaced with:

vtkFloatArray *scalars = vtkFloatArray::New();
scalars->SetNumberOfComponents(1);
scalars->SetNumberOfTuples(N_POINTS);
...
polydata->GetPointData()->SetScalars(scalars);
...
scalars->SetTuple1(i,2.3);
...

OK so far, far fewer errors.

Where I had 2D texture coordinates:

vtkTCoords *tcoords = vtkTCoords::New();
tcoords->SetNumberOfTCoords(N);
...
float p[3];
p[0]=x; p[1]=y;
tcoords->SetTCoord(i,p);
...

I replaced with:

vtkFloatArray *tcoords = vtkTCoords::New();
tcoords->SetNumberOfComponents(2);
tcoords->SetNumberOfTuples(N);
...
float p[2];
p[0]=x; p[1]=y;
tcoords->SetTuple(i,p);
....

All well and good, still fewer errors. Make sure you call
SetNumberOfComponents *before* SetNumberOfTuples else you'll get problems
(I did!).

Where I was creating 0-255 image data and had been using:

vtkScalars* scalars = vtkScalars::New();
scalars->SetDataTypeToUnsignedChar();
...

I replaced with:

vtkUnsignedCharArray *scalars = vtkUnsignedCharArray::New()
...

Going well!

When creating RGB images, I had been using:

vtkScalars *scalars = vtkScalars::New();
scalars->SetDataTypeToUnsignedChar();
scalars->SetNumberOfComponents(3);
scalars->SetNumberOfScalars(X*Y);
...
scalars->SetActiveComponent(0);
scalars->SetScalar(i,val1);
scalars->SetActiveComponent(1);
scalars->SetScalar(i,val2);
scalars->SetActiveComponent(2);
scalars->SetScalar(i,val3);
...

I replaced with:

vtkUnsignedCharArray *scalars = vtkUnsignedCharArray::New()
scalars->SetNumberOfComponents(3);
scalars->SetNumberOfScalars(X*Y);
...
scalars->SetComponent(i,0,val1);
scalars->SetComponent(i,1,val2);
scalars->SetComponent(i,2,val3);
...

My remaining errors concerned vtkWin32OffscreenRenderWindow that has been
removed. Where I had been using:

vtkWin32OffscreenRenderWindow *offscreen =
vtkWin32OffscreenRenderWindow::New();
...

I replaced with:

vtkWin32OpenGLRenderWindow *offscreen = vtkWin32OpenGLRenderWindow::New();
offscreen->SetOffScreenRendering(1);
...

All done. I'd had to throw in some #include "vtkFloatArray.h" and things
like that of course. Zero compile errors.

Had to remember to link against the new vtk lib files, so I removed

vtkdll.lib

and added

vtkCommon.lib
vtkGraphics.lib
etc.

Zero link errors. My program is up and running again, no apparant problems.
Plus now I can use all the new features of vtk4. (And I'm sure it's faster
but maybe that's my imagination.)

Bye!

Tim.


----- Original Message -----
From: "James C. Robinson" <j.robinson at kepler.ie>
To: "Vtkusers at Public. Kitware. Com" <vtkusers at public.kitware.com>
Sent: Monday, June 17, 2002 2:11 PM
Subject: [vtkusers] scalars etc


>
> Dear All,
>
> It continues - I have a very specific query. The following code no longer
> works (as vtkScalar no longer seems to exist). Any ideas:
>
>    vtkScalars *pPressures =
pUnstructuredGrid->GetPointData()->GetScalars()
> ;
>
> I have quickly gone thru the new doc and it seems that I should be
accessing
> a vtkDataArray where I either have a tuple of value 1 or 3 (for accessing
> vector in a similar manner).
>
> Regards,
>
> Jim
> ______________________
>
> Dr. James C. Robinson, BE,MEngSc,PhD,CEng,MIEI,
> Kepler Engineering Software Ltd.,
> 42 Rivergrove,
> Glanmire, Co. Cork,
> Eire
>
> Tel:         +353-21-4822028
> Tel:         +353-87-2393010
> Fax:        +353-21-4822721
> E-mail:     j.robinson at kepler.ie
> ______________________
>
>
> _______________________________________________
> 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
>




More information about the vtkusers mailing list