-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3283b47
commit 1293fa2
Showing
15 changed files
with
1,575 additions
and
1,408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]>"] | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
60 changes: 30 additions & 30 deletions
60
pythonVtk/vtkService/makeLittleVtk.py → python-vtk/vtkService/makeLittleVtk.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
82 changes: 41 additions & 41 deletions
82
pythonVtk/vtkService/vtkAddData_not_used.py → python-vtk/vtkService/vtkAddData_not_used.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.