[vtkusers] How to get data out of a .vtk file??

Mirelle Mellqvist mirelle_mellqvist at hotmail.com
Mon Aug 30 07:21:04 EDT 2004


Hi
I am a newbie at Vtk. I am doing a project where I have FEM-elements. I have 
put in all of my data into a .vtk file. My problem now is that I don't know 
what I have to do to see the graphics.
This is what my VTK-file looks like:# vtk DataFile Version 4.2
Test data
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 53 float
0.    -500.000 0.0
0.    -400.000 0.0
0.    -300.000 0.0
0.    -200.000 0.0
0.    -99.9999 0.0
0.    0.       0.0
100.0 0.       0.0
200.0 0.       0.0
300.0 0.       0.0
400.0 0.       0.0
500.0 0.       0.0
500.0 -100.000 0.0
500.0 -200.000 0.0
500.0 -300.000 0.0
500.0 -400.000 0.0
500.0 -500.000 0.0
400.0 -500.000 0.0
300.0 -500.000 0.0
200.0 -500.000 0.0
99.99 -500.000 0.0
400.0 -300.000 0.0
300.0 -300.000 0.0
200.0 -300.000 0.0
100.0 -300.000 0.0
100.0 -200.000 0.0
200.0 -200.000 0.0
100.0 -100.000 0.0
200.0 -100.000 0.0
300.0 -200.000 0.0
300.0 -100.000 0.0
400.0 -200.000 0.0
400.0 -100.000 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.000 0.0
200.0 -400.000 0.0
300.0 -400.000 0.0
400.0 -400.000 0.0

CELLS 25 100 //(n är antal celler, size är styoleken av cellist)
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

//celltyp data är ett enda värde som specificerar celltypen
CELL_TYPE 25 //(n är antalet celler, detta värde ska matcha det värde som 
specificeras av CELLS keyword )
9
9
9
9
9
9
9
9
9
9
9
9
9

and I think that this should look ok. My c++ file looks like this:

#include "vtkUnstructuredGridReader.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"

int main(){


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

	vtkDataSetMapper *dataMapper=vtkDataSetMapper::New();
	dataMapper->SetInput(reader->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(500,500);

	dataMapper->Delete();
	actor->Delete();
	ren->Delete();
	renWin->Delete();
	return 0;
}

and I get an error that says:
H:\Exjobb\20040830\test_20040830\test_20040830.cpp(14) : error C2664: 
'SetInput' : cannot convert parameter 1 from 'class vtkUnstructuredGrid *' 
to 'class vtkDataSet *'
        Types pointed to are unrelated; conversion requires 
reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

What is wrong? How to a get the points out? And the celltypes? I guess I 
don't quite know how it is related.
Looking forward to hear from you all!
Kind regards,
Mirelle

_________________________________________________________________
Hitta rätt på nätet med MSN Sök http://search.msn.se/




More information about the vtkusers mailing list