[Paraview] XYZ to VTK

Mike Jackson imikejackson at gmail.com
Tue Feb 19 12:36:06 EST 2008


Also,
Try removing the very first line:

# Example VTK file for general XYZ data

from the file. the vtk reader probably will not like that line,

Mike


On Feb 19, 2008, at 12:27 PM, Dr Patricia Lozano-Casal wrote:

> Hi Mike,
>
> it seems like I only have two different types of readers and when I  
> tried them both I get the same error. They both say XML so I am not  
> sure if I have a bug in the program. How could I get the right  
> reader to use on Windows?
>
> Thanks again.
>
> Patty
>
> Quoting Mike Jackson <imikejackson at gmail.com>:
>
>> Use the VTKUnstructuredGridReader and NOT the XML variant of the
>> reader. The file is just ASCII and NOT xml..
>>
>> Mike
>>
>> On Feb 19, 2008, at 12:06 PM, Dr Patricia Lozano-Casal wrote:
>>
>>> Hi Mike,
>>>
>>> thank you so much for the explanation. It did help me to  
>>> understand  how the file must be written. I tried using the test  
>>> file you sent  me but I get the following error message when  
>>> reading it with the  vtkXMLUnstructuredGridReader:
>>>
>>> ERROR: In C:\berk\ReleaseBuilds\ParaView3\VTK\IO 
>>> \vtkXMLReader.cxx, line 317
>>> vtkXMLUnstructuredGridReader (0DC4C4C8): Error parsing input  
>>> file.   ReadXMLInformation aborting.
>>>
>>>
>>> ERROR: In  C:\berk\ReleaseBuilds\ParaView3\VTK\Filtering 
>>> \vtkExecutive.cxx,  line 757
>>> vtkCompositeDataPipeline (0DC845A0): Algorithm   
>>> vtkXMLUnstructuredGridReader(0DC4C4C8) returned failure for   
>>> request: vtkInformation (0DCB6558)
>>>  Debug: Off
>>>  Modified Time: 96645
>>>  Reference Count: 1
>>>  Registered Events: (none)
>>>  Request: REQUEST_INFORMATION
>>>  ALGORITHM_AFTER_FORWARD: 1
>>>  KEYS_TO_COPY: COMPOSITE_DATA_INFORMATION
>>>  FORWARD_DIRECTION: 0
>>>
>>> Do you know why I am getting it? Should I use a different reader?
>>>
>>> Thank you so much for your help.
>>>
>>> Patty
>>>
>>>
>>> Quoting Mike Jackson <imikejackson at gmail.com>:
>>>
>>>> Patty,
>>>>  For each X value you will need one of these VTK files. For the
>>>> example below I am going to make up some values so that you can  
>>>> follow
>>>> along.
>>>>
>>>> Say we are at an x value of 3.44 and the XYZ are 32 bit floating  
>>>> point
>>>> numbers. Lets say the potential at each of those points are 1.0,  
>>>> 2.0,
>>>> 2.5, 3.5, so your data may look something like:
>>>>
>>>> Y     Z    Potential
>>>> 0.0  0.0     1.0
>>>> 1.0  0.0     2.0
>>>> 0.0  1.0     2.5
>>>> 1.0  1.0     3.5
>>>>
>>>> The below lines should be put into a data.vtk file.
>>>>
>>>> I will try to explain some of the important lines:
>>>> "POINTS 4 float" The type of data followed by the number of points,
>>>> followed by the type of data
>>>>
>>>> So, if you have 500 points then it would read
>>>> "POINTS 500 float"
>>>>
>>>> "CELLS 4 8"
>>>> This lists the number of cells and the total length of the cell  
>>>> list:
>>>> For your data, this would be (Number of Points) (Number of  
>>>> Points x 2)
>>>>
>>>> "CELL_TYPES 5"
>>>> This lists the types of cells and the number of cells. In your  
>>>> case we
>>>> are trying VTK_VERTEX, which has a value of 1, and there are  
>>>> (number of
>>>> Points) cells
>>>>
>>>> "POINT_DATA 4
>>>> SCALARS potential float 1"
>>>>
>>>> This is the value at each point. We have 4 points so 4 values. Each
>>>> value is simply a 32 bit floating point value, so that is the  
>>>> "1". I
>>>> have also named the Scalars "potential" so that name should also  
>>>> show
>>>> up in ParaView. Then you simply list the potential values in the  
>>>> same
>>>> order you listed your point coordinates from the DATASET section.
>>>>
>>>>
>>>> # Example VTK file for general XYZ data
>>>> # vtk DataFile Version 2.0
>>>> Unstructured Grid Example
>>>> ASCII
>>>> DATASET UNSTRUCTURED_GRID
>>>> POINTS 4 float
>>>> 3.44 0.0 0.0
>>>> 3.44 1.0 0.0
>>>> 3.44 0.0 1.0
>>>> 3.44 1.0 1.0
>>>>
>>>> CELLS 4 8
>>>> 1 0
>>>> 1 1
>>>> 1 2
>>>> 1 3
>>>>
>>>> CELL_TYPES 5
>>>> 1
>>>> 1
>>>> 1
>>>> 1
>>>> 1
>>>>
>>>> POINT_DATA 4
>>>> SCALARS potential float 1
>>>> LOOKUP_TABLE default
>>>> 1.0
>>>> 2.0
>>>> 2.5
>>>> 3.5
>>>>
>>>> Hope that helps
>>>> Mike Jackson
>>>>
>>>>
>>>> PS: You may want to write a short program to convert your data  
>>>> rather
>>>> than doing it by hand.
>>>>
>>>>
>>>> On Feb 19, 2008, at 5:45 AM, Dr Patricia Lozano-Casal wrote:
>>>>
>>>>> Hi Mike,
>>>>>
>>>>> first of all, thank you for your reply. I have three columns  
>>>>> of   data, two correspond to y and z coordinates in space and  
>>>>> the  third  one is the potential. The data corresponds to a  
>>>>> slice at a  certain  x value of a crystal structure. I would  
>>>>> like to  visualise the  potential in 3D. I saw the PDF file but  
>>>>> still  doesn't tell you how  to obtain the poligons and other   
>>>>> information needed so I am a bit  confused on what to write.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Patty
>>>>>
>>>>> Quoting Mike Jackson <imikejackson at gmail.com>:
>>>>>
>>>>>>
>>>>>> On Feb 18, 2008, at 11:24 AM, Dr Patricia Lozano-Casal wrote:
>>>>>>
>>>>>>> Hi everyone,
>>>>>>>
>>>>>>> I am finding some problems when trying to convert my three   
>>>>>>> column  ASCII data (XYZ) into vtk format. I know I have to   
>>>>>>> define  poligones  and normals but I don't really know how.  
>>>>>>> Is  there any  program that  converts general raw data files  
>>>>>>> to vtk  files? If  not, any advice on  how to get the  
>>>>>>> poligones and  normals would be  very appreciated.  Thank you  
>>>>>>> very much in  advance for your help.
>>>>>>>
>>>>>>> Patty
>>>>>>>
>>>>>>> -- 
>>>>>>> Dr Patricia Lozano-Casal
>>>>>>> Institute for Materials and Processes
>>>>>>> School of Engineering and Electronics
>>>>>>> University of Edinburgh
>>>>>>> Kenneth Denbigh Building
>>>>>>> The King's Buildings
>>>>>>> Mayfield Road
>>>>>>> Edinburgh, EH9 3JL, United Kingdom
>>>>>>> Phone: ++44 (0)131 650 4859
>>>>>>> Fax:   ++44 (0)131 650 6551
>>>>>>> E-mail: P.Lozano-Casal at ed.ac.uk
>>>>>>>
>>>>>>> -- 
>>>>>>> The University of Edinburgh is a charitable body, registered in
>>>>>>> Scotland, with registration number SC005336.
>>>>>>> --
>>>>>>
>>>>>> Is your data just points in space? And you want to show those  
>>>>>> points in
>>>>>> ParaView?
>>>>>>
>>>>>> I might be inclined to try an unstructured grid with only  
>>>>>> VTK_VERTEX as
>>>>>> cell types.
>>>>>>
>>>>>> <http://www.vtk.org/pdf/file-formats.pdf>  may help you figure  
>>>>>> out what
>>>>>> to write. Page 4 explains about the UnstructuredGrid format,  
>>>>>> while
>>>>>> there is an example starting at the bottom of page 8.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> # Example VTK file for general XYZ data
>>>>>> # vtk DataFile Version 2.0
>>>>>> Unstructured Grid Example
>>>>>> ASCII
>>>>>> DATASET UNSTRUCTURED_GRID
>>>>>> POINTS 5 float
>>>>>> 0.0 0.0 0.0
>>>>>> 1.0 0.0 0.0
>>>>>> 2.0 0.0 0.0
>>>>>> 0.0 1.0 0.0
>>>>>> 1.0 1.0 0.0
>>>>>> CELLS 5 10
>>>>>> 1 0
>>>>>> 1 1
>>>>>> 1 2
>>>>>> 1 3
>>>>>> 1 4
>>>>>> CELL_TYPES 5
>>>>>> 1
>>>>>> 1
>>>>>> 1
>>>>>> 1
>>>>>> 1
>>>>>>
>>>>>> # End VTK File
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Mike Jackson   Senior Research Engineer
>>>>>> Innovative Management & Technology Services
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> Dr Patricia Lozano-Casal
>>>>> Institute for Materials and Processes
>>>>> School of Engineering and Electronics
>>>>> University of Edinburgh
>>>>> Kenneth Denbigh Building
>>>>> The King's Buildings
>>>>> Mayfield Road
>>>>> Edinburgh, EH9 3JL, United Kingdom
>>>>> Phone: ++44 (0)131 650 4859
>>>>> Fax:   ++44 (0)131 650 6551
>>>>> E-mail: P.Lozano-Casal at ed.ac.uk
>>>>>
>>>>> -- 
>>>>> The University of Edinburgh is a charitable body, registered in
>>>>> Scotland, with registration number SC005336.
>>>>>
>>>>>
>>>>
>>>> -- 
>>>> Mike Jackson   Senior Research Engineer
>>>> Innovative Management & Technology Services
>>>
>>>
>>>
>>> -- 
>>> Dr Patricia Lozano-Casal
>>> Institute for Materials and Processes
>>> School of Engineering and Electronics
>>> University of Edinburgh
>>> Kenneth Denbigh Building
>>> The King's Buildings
>>> Mayfield Road
>>> Edinburgh, EH9 3JL, United Kingdom
>>> Phone: ++44 (0)131 650 4859
>>> Fax:   ++44 (0)131 650 6551
>>> E-mail: P.Lozano-Casal at ed.ac.uk
>>>
>>> -- 
>>> The University of Edinburgh is a charitable body, registered in
>>> Scotland, with registration number SC005336.
>>>
>>>
>
>
>
> -- 
> Dr Patricia Lozano-Casal
> Institute for Materials and Processes
> School of Engineering and Electronics
> University of Edinburgh
> Kenneth Denbigh Building
> The King's Buildings
> Mayfield Road
> Edinburgh, EH9 3JL, United Kingdom
> Phone: ++44 (0)131 650 4859
> Fax:   ++44 (0)131 650 6551
> E-mail: P.Lozano-Casal at ed.ac.uk
>
> -- 
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>

-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services




More information about the ParaView mailing list