[vtkusers] Reading vtk file format?

Marie Anderson marie_anderson_1 at hotmail.com
Tue Aug 31 07:23:08 EDT 2004


Hello
I am a newbie at VTK and I am having a bit of problems. I have made a VTK 
file where I have put some data. Se below:
# vtk DataFile Version 4.2
Test data
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 53 float
  0.0 -500.000 0.0
  0.0 -400.000 0.0
  0.0 -300.000 0.0
  0.0 -200.000 0.0
  0.0 -99.9999 0.0
  0.0 0.0 0.0
  100.0 0.0 0.0
  200.0 0.0 0.0
  300.0 0.0 0.0
  400.0 0.0 0.0
  500.0 0.0 0.0
  500.0 -100.0 0.0
  500.0 -200.0 0.0
  500.0 -300.0 0.0
  500.0 -400.0 0.0
  500.0 -500.0 0.0
  400.0 -500.0 0.0
  300.0 -500.0 0.0
  200.0 -500.0 0.0
  99.99 -500.0 0.0
  400.0 -300.0 0.0
  300.0 -300.0 0.0
  200.0 -300.0 0.0
  100.0 -300.0 0.0
  100.0 -200.0 0.0
  200.0 -200.0 0.0
  100.0 -100.0 0.0
  200.0 -100.0 0.0
  300.0 -200.0 0.0
  300.0 -100.0 0.0
  400.0 -200.0 0.0
  400.0 -100.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  0.0 0.0 0.0
  99.99 -400.0 0.0
  200.0 -400.0 0.0
  300.0 -400.0 0.0
  400.0 -400.0 0.0

CELLS 25 100
3 4 25 24
4 5 27 25
23 24 25 26
22 23 26 29
26 25 27 28
5 6 7 27
29 26 28 30
7 8 28 27
21 22 29 31
13 14 21 31
8 9 30 28
30 32 31 29
9 10 32 30
12 13 31 32
10 11 12 32
20 1 2 50
19 20 50 51
3 24 50 2
18 19 51 52
24 23 51 50
23 22 52 51
17 18 52 53
15 16 17 53
22 21 53 52
21 14 15 53

CELL_TYPE 25
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9

POINT_DATA 53
SCALARS scalars float 1
LOOKUP_TABLE default
0.0	1.0	2.0	3.0	4.0	5.0	6.0	7.0	8.0	9.0
10.0	11.0	12.0	13.0	14.0	15.0	16.0	17.0	18.0	19.0
20.0	21.0	22.0	23.0	24.0	25.0	26.0	27.0	28.0	29.0
30.0	31.0	32.0	33.0	34.0	35.0	36.0	37.0	38.0	39.0
40.0	41.0	42.0	43.0	44.0	45.0	46.0	47.0	48.0	49.0
50.0	51.0	52.0	53.0


I think that it is the right format. Can anyone tell me how sensitive it is 
to whitespaces? I have looked in the VTK fileformat article and it doesn't 
say much about sensitivty to that.

I just want to be able to see my data and I have made a C++ file that looks 
like this:

#include "vtkUnstructuredGridReader.h"
#include "vtkUnstructuredGrid.h"
#include "vtkWarpVector.h"
#include "vtkConnectivityFilter.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"

int main(){


	vtkUnstructuredGridReader *reader = vtkUnstructuredGridReader::New();
	reader->SetFileName("filereader.vtk");
	reader->IsFileUnstructuredGrid();

	vtkDataSetMapper *dataMapper=vtkDataSetMapper::New();
	dataMapper->SetInput(reader->GetOutput());

	/*vtkWarpVector *warp=vtkWarpVector::New();
		warp->SetInput(reader->GetOutput());


	vtkConnectivityFilter *connect=vtkConnectivityFilter::New();
		connect->SetInput(warp-GetOutput());

*/
	vtkActor *actor=vtkActor::New();
	actor->SetMapper(dataMapper);

	vtkRenderer *ren=vtkRenderer::New();
	ren->AddActor(actor);
	ren->SetBackground(0.1,0.2,0.4);

	vtkRenderWindow *renWin=vtkRenderWindow::New();
	renWin->AddRenderer(ren);
	renWin->SetSize(1000,1000);

	int i;
  for (i = 0; i < 360; ++i)
    {
    // render the image
    renWin->Render();
    // rotate the active camera by one degree
    ren->GetActiveCamera()->Azimuth( 1 );
    }
	reader->Delete();
	dataMapper->Delete();
	actor->Delete();
	ren->Delete();
	renWin->Delete();
	system("PAUSE");
	return 0;
}


When I try to run this file a renderWindow opens up but then I get warnings. 
The warning says this: "The instruction at "0x77fcc024" referenced memory at 
"0x0000000". The memory could not be written." Then after that I get another 
warning saying kind of the same thing.
Does anybody know what might be wrong!!
Thanks for all of your help!!
Kind regards,
Marie

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus




More information about the vtkusers mailing list