Skip to content

Commit

Permalink
Renaming and updating pythonVtk
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeByDrescher committed Jan 6, 2025
1 parent 3283b47 commit 1293fa2
Show file tree
Hide file tree
Showing 15 changed files with 1,575 additions and 1,408 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/NightlyBMDB_CLI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: build pythonVtk package
run: |
cd pythonVtk
cd python=vtk
poetry install
poetry run python -m pytest
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
842 changes: 842 additions & 0 deletions python-vtk/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pythonVtk/pyproject.toml → python-vtk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "pythonvtk"
name = "python-vtk"
version = "0.1.0"
description = ""
authors = ["Jim Schaff <[email protected]>"]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import vtk

import vtkService.vtkService as vtkService

x = [1, 2, 3, 4]
y = [1, 2, 3, 4]
ugrid = vtk.vtkUnstructuredGrid()
points = vtk.vtkPoints()
points.SetDataTypeToDouble()
xyToNode = [[] for i in range(len(x))]
index = 0
for i, xCoord in enumerate(x):
for yCoord in y:
points.InsertNextPoint(xCoord, yCoord, 0.0)
xyToNode[i].append(index)
index += 1
ugrid.SetPoints(points)

# Add the volume elements
for i, xCoord in enumerate(x[:-1]):
for j, yCoord in enumerate(y[:-1]):
idList = vtk.vtkIdList()
idList.InsertNextId(xyToNode[i][j])
idList.InsertNextId(xyToNode[i + 1][j])
idList.InsertNextId(xyToNode[i + 1][j + 1])
idList.InsertNextId(xyToNode[i][j + 1])
ugrid.InsertNextCell(vtk.VTK_QUAD, idList)

vtkService.writevtk(ugrid, "abc.vtu")
vtkService.writeDataArrayToNewVtkFile("abc.vtu", "var", [1., 2., 3., 4., 5., 6., 7., 8., 9.], "abc_var.vtu")
import vtk

import vtkService.vtkService as vtkService

x = [1, 2, 3, 4]
y = [1, 2, 3, 4]
ugrid = vtk.vtkUnstructuredGrid()
points = vtk.vtkPoints()
points.SetDataTypeToDouble()
xyToNode = [[] for i in range(len(x))]
index = 0
for i, xCoord in enumerate(x):
for yCoord in y:
points.InsertNextPoint(xCoord, yCoord, 0.0)
xyToNode[i].append(index)
index += 1
ugrid.SetPoints(points)

# Add the volume elements
for i, xCoord in enumerate(x[:-1]):
for j, yCoord in enumerate(y[:-1]):
idList = vtk.vtkIdList()
idList.InsertNextId(xyToNode[i][j])
idList.InsertNextId(xyToNode[i + 1][j])
idList.InsertNextId(xyToNode[i + 1][j + 1])
idList.InsertNextId(xyToNode[i][j + 1])
ugrid.InsertNextCell(vtk.VTK_QUAD, idList)

vtkService.writevtk(ugrid, "abc.vtu")
vtkService.writeDataArrayToNewVtkFile("abc.vtu", "var", [1., 2., 3., 4., 5., 6., 7., 8., 9.], "abc_var.vtu")
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import argparse

import numpy as np
import vtk

from vtkService.vtkService import writeDataArrayToNewVtkFile


def main():
# try:
parser = argparse.ArgumentParser()
parser.add_argument("invtkfile", help="filename of input vtk mesh (VTK XML unstructured grid")
parser.add_argument("varname", help="name of cell data variable")
parser.add_argument("outvtkfile", help="filename of output vtk mesh (VTK XML unstructured grid")
args = parser.parse_args()

# deserialize raw bytes into VarDataAdd
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(args.invtkfile)
reader.Update()
mesh = reader.GetOutput()
assert isinstance(mesh, vtk.vtkUnstructuredGrid)
num_cells = mesh.GetCells().GetSize()

# write 0..N-1 into data
npdata = np.arange(0, num_cells, 0.1)

writeDataArrayToNewVtkFile(args.invtkfile, args.varname, npdata, args.outvtkfile)
print("done")


# except:
# e = sys.exc_info()[0]
# print("exception "+e)
# sys.exit(-1)
# else:
# sys.exit(0)


if __name__ == '__main__':
main()
import argparse

import numpy as np
import vtk

from vtkService.vtkService import writeDataArrayToNewVtkFile


def main():
# try:
parser = argparse.ArgumentParser()
parser.add_argument("invtkfile", help="filename of input vtk mesh (VTK XML unstructured grid")
parser.add_argument("varname", help="name of cell data variable")
parser.add_argument("outvtkfile", help="filename of output vtk mesh (VTK XML unstructured grid")
args = parser.parse_args()

# deserialize raw bytes into VarDataAdd
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(args.invtkfile)
reader.Update()
mesh = reader.GetOutput()
assert isinstance(mesh, vtk.vtkUnstructuredGrid)
num_cells = mesh.GetCells().GetSize()

# write 0..N-1 into data
npdata = np.arange(0, num_cells, 0.1)

writeDataArrayToNewVtkFile(args.invtkfile, args.varname, npdata, args.outvtkfile)
print("done")


# except:
# e = sys.exc_info()[0]
# print("exception "+e)
# sys.exit(-1)
# else:
# sys.exit(0)


if __name__ == '__main__':
main()
Loading

0 comments on commit 1293fa2

Please sign in to comment.