Skip to content

Commit

Permalink
feature: Add vtp support
Browse files Browse the repository at this point in the history
  Starting from the vtu implementation worked through adding vtp support.
  Currently meshio doesn't support triangle strips, and not clear
  reason to do so. This means that on read triangle strips get
  converted to triangles, which become polygons on write to vtp.

  Merges triangles, quads, and polygons into polygons on
  write. The read process specifies the cell types into the same
  triangles, quads, and polygons.

  Cell dell data from triangle strips gets duplicated for the
  decomposed triangle strips.

  Rebase/squashed from original draft

  Resolve #527
  • Loading branch information
kayarre committed Dec 20, 2021
1 parent 936bd55 commit b427eab
Show file tree
Hide file tree
Showing 13 changed files with 1,030 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.ply filter=lfs diff=lfs merge=lfs -text
*.vtk filter=lfs diff=lfs merge=lfs -text
*.vtu filter=lfs diff=lfs merge=lfs -text
*.vtp filter=lfs diff=lfs merge=lfs -text
*.ugrid filter=lfs diff=lfs merge=lfs -text
*.mesh filter=lfs diff=lfs merge=lfs -text
*.meshb filter=lfs diff=lfs merge=lfs -text
Expand Down
2 changes: 2 additions & 0 deletions src/meshio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
tetgen,
ugrid,
vtk,
vtp,
vtu,
wkt,
xdmf,
Expand Down Expand Up @@ -70,6 +71,7 @@
"tetgen",
"ugrid",
"vtk",
"vtp",
"vtu",
"wkt",
"xdmf",
Expand Down
2 changes: 2 additions & 0 deletions src/meshio/_cli/_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def ascii(args):
stl.write(args.infile, mesh, binary=False)
elif fmt == "vtk":
vtk.write(args.infile, mesh, binary=False)
elif fmt == "vtp":
vtk.write(args.infile, mesh, binary=False)
elif fmt == "vtu":
vtu.write(args.infile, mesh, binary=False)
elif fmt == "xdmf":
Expand Down
2 changes: 2 additions & 0 deletions src/meshio/_cli/_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def binary(args):
stl.write(args.infile, mesh, binary=True)
elif fmt == "vtk":
vtk.write(args.infile, mesh, binary=True)
elif fmt == "vtp":
vtk.write(args.infile, mesh, binary=True)
elif fmt == "vtu":
vtu.write(args.infile, mesh, binary=True)
elif fmt == "xdmf":
Expand Down
4 changes: 4 additions & 0 deletions src/meshio/_cli/_compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def compress(args):
stl.write(args.infile, mesh, binary=True)
elif fmt == "vtk":
vtk.write(args.infile, mesh, binary=True)
elif fmt == "vtp":
vtu.write(
args.infile, mesh, binary=True, compression="lzma" if args.max else "zlib"
)
elif fmt == "vtu":
vtu.write(
args.infile, mesh, binary=True, compression="lzma" if args.max else "zlib"
Expand Down
3 changes: 3 additions & 0 deletions src/meshio/vtp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ._vtp import read, write

__all__ = ["read", "write"]
Loading

0 comments on commit b427eab

Please sign in to comment.