Skip to content

Commit

Permalink
2D PolyMesh VTK now UNSTRUCTURED_GRID not POLYDATA
Browse files Browse the repository at this point in the history
  • Loading branch information
kip-hart committed Jul 6, 2020
1 parent 812fc8b commit 3d4ea0c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/microstructpy/meshing/polymesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,8 @@ def write(self, filename, format='txt'):
vtk_s = '# vtk DataFile Version 2.0\n'
vtk_s += 'Polygonal Mesh\n'
vtk_s += 'ASCII\n'
vtk_s += 'DATASET UNSTRUCTURED_GRID\n'
if len(self.points[0]) == 2:
vtk_s += 'DATASET POLYDATA\n'

# Points
vtk_s += 'POINTS {} float\n'.format(len(self.points))
for pt in self.points:
Expand All @@ -312,7 +311,7 @@ def write(self, filename, format='txt'):
# Cells
n_cells = len(self.regions)
n_data_total = 0
cells = 'POLYGONS {}'.format(n_cells) + ' {}\n'
cells = 'CELLS {}'.format(n_cells) + ' {}\n'
pts = np.array(self.points)
for facets in self.regions:
vloop = kp_loop([self.facets[f] for f in facets])
Expand All @@ -331,9 +330,11 @@ def write(self, filename, format='txt'):
n_data_total += 1 + n_kp
vtk_s += cells.format(n_data_total)

else:
vtk_s += 'DATASET UNSTRUCTURED_GRID\n'
# Cell Types
vtk_s += 'CELL_TYPES {}\n'.format(n_cells)
vtk_s += ''.join(n_cells * ['7\n'])

else:
# Points
vtk_s += 'POINTS {} float\n'.format(len(self.points))
for pt in self.points:
Expand Down

0 comments on commit 3d4ea0c

Please sign in to comment.