[vtkusers] Problem with vtkWriter functions in python - commas instead of periods

Adrien Marion adrien.marion at creatis.insa-lyon.fr
Wed Jan 12 05:03:13 EST 2011


Hi everybody,

I have a problem with vtkUnstructuredGridWriter fonction used with Python.
Indeed, when I execute this code (that generates 10 points with 3 
coordinates, creates a vtkUnstructuredGrid and then writes it):

/#!/usr/bin/env python

from pylab import *
import vtk
from random import *

N=10;
posx=zeros(N);
posy=zeros(N);
posz=zeros(N);

for i in range(N):
     posx[i]=random();
     posy[i]=random();
     posz[i]=random();

# Create unstructured grid each containing a cell of a
# different type.

polyVertexPoints = vtk.vtkPoints()
polyVertexPoints.SetNumberOfPoints(N)
for i in range(N):
     polyVertexPoints.InsertPoint(i, posx[i], posy[i], posz[i])

aPolyVertex = vtk.vtkPolyVertex()
aPolyVertex.GetPointIds().SetNumberOfIds(N)
for i in range(N):
     aPolyVertex.GetPointIds().SetId(i, i)

aPolyVertexGrid = vtk.vtkUnstructuredGrid()
aPolyVertexGrid.Allocate(1, 1)
aPolyVertexGrid.InsertNextCell(aPolyVertex.GetCellType(),
                                aPolyVertex.GetPointIds())
aPolyVertexGrid.SetPoints(polyVertexPoints)

# Save the unstructured grid containing scatterers
writer=vtk.vtkUnstructuredGridWriter()
writer.SetFileName('bugCommas.vtk');
writer.SetInput(aPolyVertexGrid);
writer.Write();/

the file bigCommas.vtk is written with commas instead of periods for 
decimal values. Consequently, It cannot be interpreted correctly and 
notably with Paraview.

Generic Warning: In 
/builddir/build/BUILD/ParaView-3.8.1/VTK/IO/vtkDataReader.cxx, line 1382
Error reading ascii data. Possible mismatch of datasize with declaration.

In the same way, I encountered this problem with vtkPolyDataWriter 
function, again with Python.

Does someone know why periods were replaced by commas ?

Adrien

-- 
Adrien MARION, Docteur/PhD
Chercheur post-doctorant (ANR VIP)
Laboratoire CREATIS, INSA de Lyon
CNRS UMR 5220, INSERM U630
Bâtiment Blaise Pascal, 4ème étage
7, avenue Jean Capelle
69621 Villeurbanne cedex FRANCE
Tel : (+33) 4 72 43 87 86
Fax:  (+33) 4 72 43 85 26
e-mail : adrien.marion at creatis.insa-lyon.fr
http://www.creatis.insa-lyon.fr/~amarion

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110112/7edfa44d/attachment.htm>


More information about the vtkusers mailing list