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

  fix: add tests for triangle strip reading
  chore: format
  • Loading branch information
kayarre committed Feb 2, 2022
1 parent 582f3fe commit c034ae7
Show file tree
Hide file tree
Showing 16 changed files with 1,090 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 @@ -71,6 +72,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 @@ -49,6 +49,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 @@ -48,6 +48,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 @@ -61,6 +61,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 c034ae7

Please sign in to comment.