[vtkusers] vtkXMLReader, map scalars to color

Mirelle Mellqvist mirelle_mellqvist at hotmail.com
Fri Sep 10 05:58:25 EDT 2004


Hi all,
I am using VS .NET and VTK. I have made a XML file with a unstructured grid 
and this works fine to map up. I have now added som scalarvalues to every 
point in the file. I would like to see the different scalar values in each 
point and to see how they are interpolated over the element. I think that 
there might be something wrong in my pipeline, but I not sure what.

I do see colors on the grid when I map it, but not the way I want it to 
look. The way it looks right now is that it contains 36 points with 25 
quads. These together make a big quad. The lower left corner is yellow (this 
is where the first point is located) and then the rest of the grid is blue.
Can somebody tell me why this is? I have looked around in the ML and on 
Kitware and on Google to find out what is wrong. But I can't find anything. 
I have also read the fileformat paper on vtk and XML, but that doesn't help 
me either.
Looking forward to hear from you!
I have appended my code:
#include "vtkXMLUnstructuredGridReader.h"
#include "vtkUnstructuredGrid.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkCamera.h"
#include "vtkDataSet.h"


int main(){
	vtkXMLUnstructuredGridReader *reader=vtkXMLUnstructuredGridReader::New();
		reader->SetFileName("test_v02.vtu");

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

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

	vtkCamera *camera=vtkCamera::New();
		camera->SetFocalPoint(0, 0, 0);

	vtkRenderer *ren=vtkRenderer::New();
		ren->AddActor(actor);
		ren->SetBackground(1,1,1);
		ren->SetActiveCamera(camera);
		ren->ResetCamera();

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

	vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
		iren->SetRenderWindow(renWin);

	renWin->Render();
	iren->Start();
	reader->Delete();
	mapper->Delete();
	actor->Delete();
	ren->Delete();
	renWin->Delete();
	system("PAUSE");
	return 0;

}

<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
	<UnstructuredGrid>
		<Piece NumberOfPoints="36" NumberOfCells="25">
			<PointData Scalars="Temperature">
				<DataArray type="Float32" Name="Temperature" format="ascii">
					0.0 21.0 11.0 16.0 1.0 22.0 10.0 12.0 2.0 4.0 23.0 13.0 3.0 24.0 14.0 
4.0 25.0 15.0 5.0 26.0
					16.0 6.0 27.0 12.0 17.0 7.0 28.0 5.0 18.0 8.0 29.0 19.0 9.0 30.0 20.0 
10.0
				</DataArray>
			</PointData>
			<Points>
				<DataArray type="Float32" NumberOfComponents="3" format="ascii">
					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 -100.0 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
					100.0 -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 100.0 -400.0 0.0
					200.0 -400.0 0.0 300.0 -400.0 0.0
					400.0 -400.0 0.0
				</DataArray>
			</Points>
			<Cells>
				<DataArray type="Int32" Name="connectivity" format="ascii">
					2 3 24 23
					3 4 26 24
					22 23 24 25
					21 22 25 28
					25 24 26 27
					4 5 6 26
					28 25 27 29
					6 7 27 26
					20 21 28 30
					12 13 20 30
					7 8 29 27
					29 31 30 28
					8 9 31 29
					11 12 30 31
					9 10 11 31
					19 0 1 32
					18 19 32 33
					2 23 32 1
					17 18 33 34
					23 22 33 32
					22 21 34 33
					16 17 34 35
					14 15 16 35
					21 20 35 34
					20 13 14 35
				</DataArray>
				<DataArray type="UInt8" Name="offsets" Format="ascii">
					4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 
100
				</DataArray>
				<DataArray type="UInt8" Name="types" Format="ascii">
					 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
				</DataArray>
			</Cells>
		</Piece>
	</UnstructuredGrid>
</VTKFile>

_________________________________________________________________
Auktioner: Tjäna en hacka på gamla prylar http://tradera.msn.se




More information about the vtkusers mailing list