Skip to content

Commit

Permalink
adds vtkhdf and updates ve #29
Browse files Browse the repository at this point in the history
  • Loading branch information
mxochicale committed Dec 2, 2023
1 parent de424ca commit 2d648b1
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pyVEs/bareVE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ name: bareVE
channels:
- conda-forge #pyside6
dependencies:
- python=3.10
#- python=3.11
#- python=3.8
#- python=3.9
#- python=3.10
- python=3.11
- pip
- pip:
### VERSIONS of pyside6: https://pypi.org/project/PySide6/#history
- pyside6>=6.4.2
### VERSIONS of VTK https://gitlab.kitware.com/vtk/vtk/-/tags
#- vtk>=9.0.3
#- vtk>=9.2.0
#- vtk>=9.2.5
- vtk>=9.3.0
### VERSIONS of opencv-contrib-python-headless https://pypi.org/project/opencv-contrib-python-headless/#history
- opencv-contrib-python-headless>=4.7.0.68
#
- h5py
#- pyvista #https://pypi.org/project/pyvista/#history #https://github.com/pyvista/pyvista/tags
#- qimage2ndarray
#- notebook
#- pandas
Expand Down
28 changes: 28 additions & 0 deletions vtk/vtkhdf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# VTKHDF files
https://www.kitware.com/how-to-write-time-dependent-data-in-vtkhdf-files/
> October 27, 2023; Lucas Givord and Julien Fausty
> It can be read into VTK or ParaView master at the moment and will be available in the next release of both : VTK 9.3.0 and ParaView 5.12.0.
## Application
python vtkpython.py

## issues
* python=3.10 with vtk>=9.3.0 in bareVE.yaml;
* python=3.11 with vtk>=9.3.0 in bareVE.yaml;
* python=3.9 with vtk>=9.3.0 in bareVE.yaml;
* python=3.9 with - vtk>=9.2.5 in bareVE.yaml;
* python=3.9 with - vtk>=9.2.0 in bareVE.yaml;
* python=3.8 with - vtk>=9.2.0 in bareVE.yaml;


```
Traceback (most recent call last):
File "/home/mxochicale/repositories/mxochicale/code/vtk/vtkhdf/vtkpython.py", line 3, in <module>
from vtkmodules.vtkFiltersGeneral import (vtkGroupDataSetsFilter,
ImportError: cannot import name 'vtkSpatioTemporalHarmonicsAttribute' from 'vtkmodules.vtkFiltersGeneral' (/home/mxochicale/mambaforge/envs/bareVE/lib/python3.10/site-packages/vtkmodules/vtkFiltersGeneral.cpython-310-x86_64-linux-gnu.so)
ImportError: cannot import name 'vtkSpatioTemporalHarmonicsAttribute' from 'vtkmodules.vtkFiltersGeneral' (/home/mxochicale/mambaforge/envs/bareVE/lib/python3.9/site-packages/vtkmodules/vtkFiltersGeneral.cpython-39-x86_64-linux-gnu.so)
ImportError: cannot import name 'vtkSpatioTemporalHarmonicsAttribute' from 'vtkmodules.vtkFiltersGeneral' (/home/mxochicale/mambaforge/envs/bareVE/lib/python3.9/site-packages/vtkmodules/vtkFiltersGeneral.cpython-39-x86_64-linux-gnu.so)
ImportError: cannot import name 'vtkSpatioTemporalHarmonicsAttribute' from 'vtkmodules.vtkFiltersGeneral' (/home/mxochicale/mambaforge/envs/bareVE/lib/python3.11/site-packages/vtkmodules/vtkFiltersGeneral.cpython-311-x86_64-linux-gnu.so)
```


68 changes: 68 additions & 0 deletions vtk/vtkhdf/vtkpython.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import numpy as np
import h5py as h5

from vtkmodules.vtkCommonDataModel import (vtkDataObject,
vtkPartitionedDataSet,
vtkPolyData)
from vtkmodules.vtkFiltersGeneral import vtkGroupDataSetsFilter
from vtkmodules.vtkFiltersGeneral import vtkWarpScalar

from vtkmodules.vtkFiltersGeneral import vtkSpatioTemporalHarmonicsAttribute
#https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/General/vtkSpatioTemporalHarmonicsAttribute.h

from vtkmodules.vtkFiltersHybrid import vtkGenerateTimeSteps
from vtkmodules.vtkFiltersSources import vtkSphereSource
from vtkmodules.util.numpy_support import vtk_to_numpy



sphere0 = vtkSphereSource()
sphere0.SetPhiResolution(30)
sphere0.SetThetaResolution(30)
sphere0.SetRadius(10)

sphere1 = vtkSphereSource()
sphere1.SetPhiResolution(30)
sphere1.SetThetaResolution(30)
sphere1.SetRadius(10)
sphere1.SetCenter(15, 15, 15)

# store the spheres in a single partitioned data set
groupDataSets = vtkGroupDataSetsFilter()
groupDataSets.AddInputConnection(sphere0.GetOutputPort())
groupDataSets.AddInputConnection(sphere1.GetOutputPort())
groupDataSets.SetOutputTypeToPartitionedDataSet()

# generate time steps
timeSteps = vtkGenerateTimeSteps()
timeSteps.SetInputConnection(groupDataSets.GetOutputPort())
timeValues = np.linspace(0.0, 2*np.pi, 100, endpoint=False)
timeSteps.SetTimeStepValues(100, timeValues)

# generate fields
addFields = vtkSpatioTemporalHarmonicsAttribute()
harmonics = np.array([
[1.0, 1.0, 0.6283, 0.6283, 0.6283, 0.0],
[3.0, 1.0, 0.6283, 0.0, 0.0, 1.5708],
[2.0, 2.0, 0.0, 0.6283, 0.0, 3.1416],
[1.0, 3.0, 0.0, 0.0, 0.6283, 4.7124]
])
for iH in range(harmonics.shape[0]):
addFields.AddHarmonic(harmonics[iH, 0],
harmonics[iH, 1],
harmonics[iH, 2],
harmonics[iH, 3],
harmonics[iH, 4],
harmonics[iH, 5])

addFields.SetInputConnection(timeSteps.GetOutputPort())

# warp spheres
warp = vtkWarpScalar()
warp.SetInputConnection(addFields.GetOutputPort())
warp.SetInputArrayToProcess(0, 0, 0,
vtkDataObject.FIELD_ASSOCIATION_POINTS,
'SpatioTemporalHarmonics')

# update the entire thing
warp.Update()

0 comments on commit 2d648b1

Please sign in to comment.