easier visualization if verts have a point-cell
This commit is contained in:
parent
93a791abd1
commit
201a62d7c9
|
@ -108,11 +108,18 @@ class VTK:
|
|||
Spatial position of the points.
|
||||
|
||||
"""
|
||||
N = points.shape[0]
|
||||
vtk_points = vtk.vtkPoints()
|
||||
vtk_points.SetData(np_to_vtk(points))
|
||||
|
||||
vtk_cells = vtk.vtkCellArray()
|
||||
vtk_cells.SetNumberOfCells(N)
|
||||
vtk_cells.SetCells(N,np_to_vtkIdTypeArray(np.stack((np.ones (N,dtype=np.int64),
|
||||
np.arange(N,dtype=np.int64)),axis=1).ravel(),deep=True))
|
||||
|
||||
vtk_data = vtk.vtkPolyData()
|
||||
vtk_data.SetPoints(vtk_points)
|
||||
vtk_data.SetVerts(vtk_cells)
|
||||
|
||||
return VTK(vtk_data)
|
||||
|
||||
|
@ -164,6 +171,7 @@ class VTK:
|
|||
|
||||
return VTK(vtk_data)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _write(writer):
|
||||
"""Wrapper for parallel writing."""
|
||||
|
@ -192,7 +200,7 @@ class VTK:
|
|||
default_ext = writer.GetDefaultFileExtension()
|
||||
ext = Path(fname).suffix
|
||||
if ext and ext != '.'+default_ext:
|
||||
raise ValueError(f'Given extension {ext} does not match default .{default_ext}')
|
||||
raise ValueError(f'Given extension "{ext}" does not match default ".{default_ext}"')
|
||||
writer.SetFileName(str(Path(fname).with_suffix('.'+default_ext)))
|
||||
if compress:
|
||||
writer.SetCompressorTypeToZLib()
|
||||
|
@ -238,10 +246,10 @@ class VTK:
|
|||
else data).reshape(N_data,-1),deep=True) # avoid large files
|
||||
d.SetName(label)
|
||||
|
||||
if N_data == N_cells:
|
||||
self.vtk_data.GetCellData().AddArray(d)
|
||||
elif N_data == N_points:
|
||||
if N_data == N_points:
|
||||
self.vtk_data.GetPointData().AddArray(d)
|
||||
elif N_data == N_cells:
|
||||
self.vtk_data.GetCellData().AddArray(d)
|
||||
else:
|
||||
raise ValueError(f'Cell / point count ({N_cells} / {N_points}) differs from data ({N_data}).')
|
||||
elif isinstance(data,pd.DataFrame):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<VTKFile type="PolyData" version="0.1" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
|
||||
<PolyData>
|
||||
<Piece NumberOfPoints="10" NumberOfVerts="0" NumberOfLines="0" NumberOfStrips="0" NumberOfPolys="0">
|
||||
<Piece NumberOfPoints="10" NumberOfVerts="10" NumberOfLines="0" NumberOfStrips="0" NumberOfPolys="0">
|
||||
<PointData>
|
||||
<DataArray type="Float32" Name="coordinates" NumberOfComponents="3" format="binary" RangeMin="0.7453560147132696" RangeMax="2.449489742783178">
|
||||
AQAAAACAAAB4AAAAVgAAAA==eF5jYICBhv2WfY9tLfuS7Ypk3PeDaCDf7okF3/7Vq1bZrV6lZQ+k94HEgHL2QHovUM7+iUUfiG0LlQdhkH77Ipnj9iB5qFp7kBjQDiBmcADRANsaLXM=
|
||||
|
@ -31,11 +31,11 @@
|
|||
</DataArray>
|
||||
</Points>
|
||||
<Verts>
|
||||
<DataArray type="Int64" Name="connectivity" format="binary" RangeMin="1e+299" RangeMax="-1e+299">
|
||||
AAAAAACAAAAAAAAA
|
||||
<DataArray type="Int64" Name="connectivity" format="binary" RangeMin="0" RangeMax="9">
|
||||
AQAAAACAAABQAAAAIgAAAA==eF4txbcBACAIADAsiP7/sAPJkog2PL28nT4uXz9/BXgALg==
|
||||
</DataArray>
|
||||
<DataArray type="Int64" Name="offsets" format="binary" RangeMin="1e+299" RangeMax="-1e+299">
|
||||
AAAAAACAAAAAAAAA
|
||||
<DataArray type="Int64" Name="offsets" format="binary" RangeMin="1" RangeMax="10">
|
||||
AQAAAACAAABQAAAAIgAAAA==eF4txbcBACAIADA76v8HM5As6a0MTy9vH4evn78TBzAAOA==
|
||||
</DataArray>
|
||||
</Verts>
|
||||
<Lines>
|
||||
|
|
Loading…
Reference in New Issue