[io] vview.py, better handling of optional ids
@@ -803,11 +803,12 @@ class IOReader(VTKPythonAlgorithmBase):
imu, 8:11]
self.cf_at_time[mu] = data[
imu, 11:14]
- if len(data[imu,:]) > 26:
+ if data[imu,:].shape[1] > 26:
self.ids_at_time[mu] = data[
imu, 23:26].astype(int)
else:
- self.ids_at_time[mu] = [[nan, nan, nan]]
+ self.ids_at_time[mu] = numpy.array(
+ [[nan, nan, nan]])
else:
for mu in self._mu_coefs:
@@ -815,7 +816,7 @@ class IOReader(VTKPythonAlgorithmBase):
self.cpb_at_time[mu] = [[nan, nan, nan]]
self.cn_at_time[mu] = [[nan, nan, nan]]
self.cf_at_time[mu] = [[nan, nan, nan]]
- self.ids_at_time[mu] = [[nan, nan, nan]]
+ self.ids_at_time[mu] = numpy.array([[nan, nan, nan]])
for mu in self._mu_coefs:
self.cpa[mu] = numpy_support.numpy_to_vtk(
@@ -846,14 +847,13 @@ class IOReader(VTKPythonAlgorithmBase):
self._output[mu].GetPointData().AddArray(self.cn[mu])
self._output[mu].GetPointData().AddArray(self.cf[mu])
- if self.ids_at_time[mu] is not None:
+ if self.ids_at_time[mu].shape[0] > 0:
self.ids[mu] = numpy_support.numpy_to_vtk(
self.ids_at_time[mu])
self.ids[mu].SetName('ids')
self._contact_field[mu].AddArray(self.ids[mu])
self._output[mu].GetPointData().AddArray(self.ids[mu])
- if len(self.ids_at_time[mu]) > 2:
dsa_ids = numpy.unique(self.ids_at_time[mu][:, 1])
dsb_ids = numpy.unique(self.ids_at_time[mu][:, 2])
_i, _i, dsa_pos_ids = numpy.intersect1d(
