sharpened error detection and reporting
This commit is contained in:
parent
e18c2fd74c
commit
255a465e8b
|
@ -52,7 +52,7 @@ parser.set_defaults(data = [],
|
||||||
|
|
||||||
(options, filenames) = parser.parse_args()
|
(options, filenames) = parser.parse_args()
|
||||||
|
|
||||||
if not options.vtk: parser.error('No VTK file specified.')
|
if not options.vtk: parser.error('no VTK file specified.')
|
||||||
if not os.path.exists(options.vtk): parser.error('VTK file does not exist.')
|
if not os.path.exists(options.vtk): parser.error('VTK file does not exist.')
|
||||||
|
|
||||||
if os.path.splitext(options.vtk)[1] == '.vtp':
|
if os.path.splitext(options.vtk)[1] == '.vtp':
|
||||||
|
@ -66,16 +66,16 @@ elif os.path.splitext(options.vtk)[1] == '.vtk':
|
||||||
reader.Update()
|
reader.Update()
|
||||||
Polydata = reader.GetPolyDataOutput()
|
Polydata = reader.GetPolyDataOutput()
|
||||||
else:
|
else:
|
||||||
parser.error('Unsupported VTK file type extension.')
|
parser.error('unsupported VTK file type extension.')
|
||||||
|
|
||||||
Npoints = Polydata.GetNumberOfPoints()
|
Npoints = Polydata.GetNumberOfPoints()
|
||||||
Ncells = Polydata.GetNumberOfCells()
|
Ncells = Polydata.GetNumberOfCells()
|
||||||
Nvertices = Polydata.GetNumberOfVerts()
|
Nvertices = Polydata.GetNumberOfVerts()
|
||||||
|
|
||||||
if Npoints != Ncells or Npoints != Nvertices:
|
if Npoints != Ncells or Npoints != Nvertices:
|
||||||
parser.error('Number of points, cells, and vertices in VTK differ from each other.')
|
parser.error('number of points, cells, and vertices in VTK differ from each other.')
|
||||||
|
|
||||||
damask.util.croak('{}: {} points, {} vertices, and {} cells...'.format(options.vtk,Npoints,Nvertices,Ncells))
|
damask.util.croak('{}: {} points/vertices/cells...'.format(options.vtk,Npoints))
|
||||||
|
|
||||||
# --- loop over input files -------------------------------------------------------------------------
|
# --- loop over input files -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -97,16 +97,19 @@ for name in filenames:
|
||||||
VTKarray = {}
|
VTKarray = {}
|
||||||
active = defaultdict(list)
|
active = defaultdict(list)
|
||||||
|
|
||||||
for datatype,dimension,label in [['data',99,options.data],
|
for datatype,dimension,label in [['data',0,options.data],
|
||||||
['tensor',9,options.tensor],
|
['tensor',9,options.tensor],
|
||||||
['color' ,3,options.color],
|
['color' ,3,options.color],
|
||||||
]:
|
]:
|
||||||
for i,dim in enumerate(table.label_dimension(label)):
|
for i,dim in enumerate(table.label_dimension(label)):
|
||||||
me = label[i]
|
me = label[i]
|
||||||
if dim == -1: remarks.append('{} "{}" not found...'.format(datatype,me))
|
if dim == -1: remarks.append('{} "{}" not found...'.format(datatype,me))
|
||||||
elif dim > dimension: remarks.append('"{}" not of dimension {}...'.format(me,dimension))
|
elif dimension > 0 \
|
||||||
|
and dim != dimension: remarks.append('"{}" not of dimension {}...'.format(me,dimension))
|
||||||
else:
|
else:
|
||||||
remarks.append('adding {} "{}"...'.format(datatype,me))
|
remarks.append('adding {}{} "{}"...'.format(datatype if dim > 1 else 'scalar',
|
||||||
|
'' if dimension > 0 or dim == 1 else '[{}]'.format(dim),
|
||||||
|
me))
|
||||||
active[datatype].append(me)
|
active[datatype].append(me)
|
||||||
|
|
||||||
if remarks != []: damask.util.croak(remarks)
|
if remarks != []: damask.util.croak(remarks)
|
||||||
|
|
Loading…
Reference in New Issue