From 255a465e8b41fd25836b06b3eb007eb7295f7085 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 16 Aug 2017 15:18:29 -0400 Subject: [PATCH] sharpened error detection and reporting --- processing/post/vtk_addPointcloudData.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/processing/post/vtk_addPointcloudData.py b/processing/post/vtk_addPointcloudData.py index bc76c7e72..3937413c6 100755 --- a/processing/post/vtk_addPointcloudData.py +++ b/processing/post/vtk_addPointcloudData.py @@ -52,7 +52,7 @@ parser.set_defaults(data = [], (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 os.path.splitext(options.vtk)[1] == '.vtp': @@ -66,16 +66,16 @@ elif os.path.splitext(options.vtk)[1] == '.vtk': reader.Update() Polydata = reader.GetPolyDataOutput() else: - parser.error('Unsupported VTK file type extension.') + parser.error('unsupported VTK file type extension.') Npoints = Polydata.GetNumberOfPoints() Ncells = Polydata.GetNumberOfCells() Nvertices = Polydata.GetNumberOfVerts() 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 ------------------------------------------------------------------------- @@ -97,16 +97,19 @@ for name in filenames: VTKarray = {} 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], ['color' ,3,options.color], ]: for i,dim in enumerate(table.label_dimension(label)): me = label[i] 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: - 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) if remarks != []: damask.util.croak(remarks)