Structured Grid Help

Hello. I am trying to draw a sphere. I have managed to animate a surface using DATASET STRUCTURED_GRID and multiple vtk files which shows a diffusion process over time. So far, so good. Now I want to draw a sphere and deform it. I can produce points for a radius = 1 sphere with theta from 0 to 2 pi and phi from 0 to pi. There are 5000 points. Of course, r is constant and equal to 1, but that is going to vary. So I have 5000 points on a sphere in float format. I was trying to use the following:

vtk DataFile Version 2.0

Sphere example
ASCII
DATASET STRUCTURED_POINTS
POINT_DATA 5000 float
0.477142 0.649450 0.592073
0.552779 0.752401 -0.358230
0.120193 0.163598 -0.979178
-0.422898 -0.575616 -0.699874 etc for 5000 points

I keep getting the error that the number of points don’t match the matadata.

After this, I’ll be putting data to represent stresses and strains at each point. I’ve tried looking at examples but nothing works and I would like to use C if that is possible. I am way too old school for Python.

Any assistance regarding how to set out the data would be very appreciated. I really don’t understand the difference between structured and unstructured. I believe the lookup table can be used to enter stress and strain data???

Thank you for your time.

Bit of a correction. I had an error in producing points. Here is the beginning of the dataset:

vtk DataFile Version 2.0

Sphere example
ASCII
DATASET STRUCTURED_POINTS
POINT_DATA 5000 float
0.000000 0.000000 1.000000
0.062791 0.000000 0.998027
0.125333 0.000000 0.992115
0.187381 0.000000 0.982287

etc

I guess I should put in the error messages

Warning: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/IO/Legacy/vtkStructuredPointsReader.cxx, line 282
vtkStructuredPointsReader (0x184eef00): Not all meta data was read from the file.

Warning: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/IO/Legacy/vtkStructuredPointsReader.cxx, line 282
vtkStructuredPointsReader (0x17a1c730): Not all meta data was read from the file.

Warning: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/IO/Legacy/vtkStructuredPointsReader.cxx, line 282
vtkStructuredPointsReader (0x17a1c730): Not all meta data was read from the file.

ERROR: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/IO/Legacy/vtkStructuredPointsReader.cxx, line 455
vtkStructuredPointsReader (0x17a1c730): Number of points don’t match data values!

Warning: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/IO/Legacy/vtkStructuredPointsReader.cxx, line 282
vtkStructuredPointsReader (0x1a554840): Not all meta data was read from the file.

Warning: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/IO/Legacy/vtkStructuredPointsReader.cxx, line 282
vtkStructuredPointsReader (0x1a543d30): Not all meta data was read from the file.

Warning: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/IO/Legacy/vtkStructuredPointsReader.cxx, line 282
vtkStructuredPointsReader (0x1a543d30): Not all meta data was read from the file.

ERROR: In /builds/gitlab-kitware-sciviz-ci/build/superbuild/paraview/src/VTK/IO/Legacy/vtkStructuredPointsReader.cxx, line 455
vtkStructuredPointsReader (0x1a543d30): Number of points don’t match data values!

Structured Points requires origin, spacing and dimension to be set for the point which will implicitly define the coordinates of the points. Check the file format documentation https://kitware.github.io/vtk-examples/site/VTKFileFormats/#dataset-format

I have read the documentation, many times. I have put in the information as you and the documentation says. It doesn’t work.

The origin is 0 0 0

Dimensions nx ny nz are 5000 5000 5000

Did you read the error messages I posted?

Also, what is meant by spacing? That is not in the documentation. Is it the distance between coordinate points?

Also what do you mean by the point that will implicitly define the points?

Furthermore, thank you for your response and help. I am sincerely grateful.

Also, what is meant by spacing? That is not in the documentation. Is it the distance between coordinate points?

Yes

Also what do you mean by the point that will implicitly define the points?

I meant that origin, spacing and dimension will define implicitly the points.
For example the file below defines a structured grid of 3*4*6 = 72 points, the first point is located at (0,0,0) the distance between the points at each direction is (1,1,1) so the points are :
(0,0,0), (1,0,0),(2,0,0),
(0,1,0), (1,1,0),(2,1,0), …

Finally, the list of values at the end defines the value at each point.

You may want to view the file in the Spreadsheet View in ParaView to explore the structure of the file better.

# vtk DataFile Version 3.0
Volume example
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 3 4 6
SPACING 1 1 1
ORIGIN 0 0 0
POINT_DATA 72
SCALARS volume_scalars char 1
LOOKUP_TABLE default
0 0 0 0 0 0 0 0 0 0 0 0
0 5 10 15 20 25 25 20 15 10 5 0
0 10 20 30 40 50 50 40 30 20 10 0
0 10 20 30 40 50 50 40 30 20 10 0
0 5 10 15 20 25 25 20 15 10 5 0
0 0 0 0 0 0 0 0 0 0 0 

There is an example of a STRUCTURED_POINTS dataset (and other structured datasets) in the ParaView’s included Examples. They are found with File/ Open/ Examples. Structured points is VTK/ legacy/ structuredVolume.vtk.

This email didn’t go through from my email account. So I’m repeating it here.

Ohhhh, the origin is the location of the first point!!! It’s not the location of the origin of the coordinate system. That’s huge. Thank you!

Walter, the problem is not with the examples, it’s getting them to work. I’ll keep trying different approaches to see if I can get anything. I have found that structured just means a curvilinear coordinate system. Non-structured is non-curvilinear. It may be I should not be using structured points, so I will try others after trying suggestions from Christos. Thank you so much for your help.

FINALLY!!!

You use a structured grid.
r is constant =1.0
theta is in 20 steps from 0 to 2*pi
phi is in 10 steps from 0 to pi

therefore:

DIMENSIONS 1 20 10
POINTS 200 float
put in the points here…

and voila!! BTW, make dtheta = 2 pi/(ntheta-1) and dphi = pi/(phi-1) and all will be well. It is all in the DIMENSIONS tab. I am going to change r to having varying values to create a stretched or convoluted spheroid, but I am on my way. There may be many values of r but I will keep the first DIMENSION to 1 and go from there. So, in reality, it is kind of already in spherical coordinates only DIMENSION is not what is nx ny nz but nr ntheta and nphi. Kewl.

Thanks a lot for your help. Now to put in stresses, etc.

MASSIVE shout out to Libby for going the extra distance. She was a huge help.

Posting this a second time to check my send email address is correct:

Bruce Rout <brucerout@gmail.com>

8:33 PM (17 minutes ago)


to ParaView

FINALLY!!!

Huge shout out to Libby for her help. It’s in the DIMENSIONS section. Basically, it’s kinda already in spherical coordinates. r is a constant so number of r measurements is 1, theta is 20 in this case and nphi is 10. So there are 200 points.

This works:

vtk DataFile Version 2.0

Sphere example
ASCII
DATASET STRUCTURED_GRID
DIMENSIONS 1 20 10
POINTS 200 float
0.000000 0.000000 1.000000
0.342020 0.000000 0.939693
0.642788 0.000000 0.766044
0.866025 0.000000 0.500000
0.984808 0.000000 0.173648
0.984808 0.000 …

I now need to toss in a lookup table to colour various points on the spherical surface. In the near future, r will have varying values as the sphere becomes convoluted. So I may be back with all these silly questions, or it may all work just fine. Thank you all for your help and for hanging in there with me.

For reference: theta goes from 0 to 2pi and phi goes from 0 to pi. dtheta = 2pi/(ntheta-1) and dphi = (nphi-1).

Once again, thanks for your patience with me and your guidance.

Yours,

Bruce

Hi, I’m just staring out and have had some success. I have a nice picture of a sphere that rotates. I would like to throw a brick at it. Do I need a separate .vtk datafile for the brick, or is there a way to put both brick and sphere into the same .vtk legacy file? I am using STRUCTURED_GRID for the sphere. I’d probably use the same for the brick. Unfortunately, I cannot find an answer in the documentation or user guide.

Thank you for your time and help.