/matlab_tools/Converted/kksegcmp.m
Objective C | 278 lines | 275 code | 3 blank | 0 comment | 69 complexity | 82752e04c88512a190b46d1cec3f50ff MD5 | raw file
Possible License(s): BSD-3-Clause
- %kksegcmp 'Compare Attributes & Data of Input 1 and Input 2'
- % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros ksegcmp.pane file
- %
- % Parameters:
- % InputFile: i1 'Input #1', required: 'first input data object'
- % InputFile: i2 'Input #2', required: 'second input data object'
- % Toggle: cast 'Cast Data to Common Type before Comparing', default: 0: 'cast data to common type before comparing'
- % Toggle: s 'Run Silently', default: 0: 'silent running - do not print to stdout'
- % Toggle: pos '[Position]', default: 0: 'print the position of differing points'
- % Toggle: i1val 'Value', default: 0: 'print value from first input for differing points'
- % Toggle: i1type 'Type', default: 0: 'print data type of first input for differing points'
- % Toggle: i2val 'Value', default: 0: 'print value from second input for differing points'
- % Toggle: i2type 'Type', default: 0: 'print data type of second input for differing points'
- % OutputFile: o 'ASCII Output ', optional: 'output ASCII file for summary'
- % String: var 'Return Results as Cantata Variable ', default: 'equal': 'return results to Cantata '
- % Toggle: all 'Compare ALL Data Segments', default: 0: 'compare all data segments'
- % Toggle: val 'Value', default: 0: 'compare value segments'
- % Toggle: mask 'Mask', default: 0: 'compare mask segments'
- % Toggle: loc 'Location', default: 0: 'compare location segments'
- % Toggle: time 'Time', default: 0: 'compare time segments'
- % Toggle: map 'Map ', default: 0: 'compare map segments'
- % String: segment 'Segment Name', default: 'value': 'explicit segment name to compare'
- %
- % Example: o = kksegcmp({i1, i2}, {'i1','';'i2','';'cast',0;'s',0;'pos',0;'i1val',0;'i1type',0;'i2val',0;'i2type',0;'o','';'var','equal';'all',0;'val',0;'mask',0;'loc',0;'time',0;'map',0;'segment','value'})
- %
- % Khoros helpfile follows below:
- %
- % PROGRAM
- % ksegcmp - Compare Attributes & Data of Input 1 and Input 2
- %
- % DESCRIPTION
- % .I ksegcmp
- % compares the data and attributes between two input data objects,
- % (i1) and (i2), and prints their differences. The data within
- % the specified data segments is compared point by point, allowing
- % for precise comparisons of data objects independent of file format or
- % machine architecture.
- %
- % The user can specify either that all of the data segments contained in both
- % objects be compared, or that only specific data segments be compared.
- % The specific polymorphic segments value (val), mask (mask), location
- % (location), time (time), and map (map) can be called out for comparison,
- % along with an user-specified segment name (segment).
- %
- % The comparison of two segments can only be performed if the segments
- % are of the same size and dimensionality. If the data types of the two
- % segments differ, the user can specify that the data be compared in the
- % higher of the two data types (cast). Additionally, a +/- comparison
- % tolerance can be specified (t). For complex comparisons, this tolerance
- % is applied to both the real and imaginary parts of the values.
- %
- % If desired, the attributes of each segment can be compared (sat).
- % The segment attributes such as size, dimension, and data type, are not
- % compared by here since they would have already been compared during the
- % data comparison.
- % Also if desired, the object-level attributes, such as the comment, can
- % be compared (oat). The date attribute is ignored in this comparison
- % since it is almost always different.
- %
- % The program will print the results of the comparison in ASCII either to an
- % user-specified file (o) or, if no file is specified, to kstdout.
- %
- % The program can optionally print a summary of the differences it finds between
- % each data segment (psum). The program can also optionally print a detailed
- % report on the specific differences found in each segment.
- % At the very minimum, a simple one line report on whether the data objects were
- % determined to be different or identical will be printed.
- % If no output at all is desired, the program can told to run silently (s).
- %
- % The summary printed for each compared segment reports such things as
- % differences in size or data type, as well as the number of points
- % that were determined to be different.
- %
- % The precise report of the specific points that were found to be different
- % between two data segments will be printed in the following format :
- %
- % [POSITION]
- %
- % < Input #1 Value (Input #1 Data Type)
- %
- % > Input #2 Value (Input #2 Data Type)
- %
- % The user may specify which components of this precise report are printed
- % with the use of different flags. The position (pos), the value at that
- % position in the segment from input 1 (i1val), the value at that position
- % in the segment from input 2 (i2val), along with the data types of the values
- % (i1type) and (i2type) can all be specified to be in the detailed report.
- % Note that this program does not allow for the data types of either segment to
- % be printed without their values, because that provides no information.
- %
- % If desired, the exit return status of the program can be set to indicate
- % whether the data objects were determined to be different or identical (rt).
- % A KEXIT_SUCCESS (0) exit status is used to indicate that the objects
- % were identical, while a KEXIT_FAILURE (1) exit status is used to indicate
- % that they are different.
- %
- % Also if desired, this routine can return the exit status to a Cantata
- % variable for use in conditional visual programming operations (var).
- %
- % The comparison is performed "intelligently" using data services, so that
- % that the entire data set from either data object is never read into
- % memory at one time. This allows very large data objects to be compared
- % on machines with limited virtual memory.
- %
- %
- %
- % EXAMPLES
- % ksegcmp -i1 image:ball -i2 image:moon -val -t 220 -pos -i1val -i2val
- %
- % will compare the value segment of the ball image with the value segment
- % of the moon image with a comparison tolerance of +/- 220.0.
- % The position and values of the eight points that are different will be printed.
- %
- % "SEE ALSO"
- % kcpseg, kcptoval, kcpfromval
- %
- % RESTRICTIONS
- % ksegcmp is not yet able to return a variable to Cantata.
- % The segment list when all segments are compared is constructed from
- % the first input object. If the second object contains segments which
- % are not contained in the first object, the comparison will miss them.
- %
- % REFERENCES
- % none
- %
- % COPYRIGHT
- % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
- %
- function varargout = kksegcmp(varargin)
- if nargin ==0
- Inputs={};arglist={'',''};
- elseif nargin ==1
- Inputs=varargin{1};arglist={'',''};
- elseif nargin ==2
- Inputs=varargin{1}; arglist=varargin{2};
- else error('Usage: [out1,..] = kksegcmp(Inputs,arglist).');
- end
- if size(arglist,2)~=2
- error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
- end
- narglist={'i1', '__input';'i2', '__input';'cast', 0;'s', 0;'pos', 0;'i1val', 0;'i1type', 0;'i2val', 0;'i2type', 0;'o', '__output';'var', 'equal';'all', 0;'val', 0;'mask', 0;'loc', 0;'time', 0;'map', 0;'segment', 'value'};
- maxval={0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0};
- minval={0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0};
- istoggle=[0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
- was_set=istoggle * 0;
- paramtype={'InputFile','InputFile','Toggle','Toggle','Toggle','Toggle','Toggle','Toggle','Toggle','OutputFile','String','Toggle','Toggle','Toggle','Toggle','Toggle','Toggle','String'};
- % identify the input arrays and assign them to the arguments as stated by the user
- if ~iscell(Inputs)
- Inputs = {Inputs};
- end
- NumReqOutputs=0; nextinput=1; nextoutput=1;
- for ii=1:size(arglist,1)
- wasmatched=0;
- for jj=1:size(narglist,1)
- if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
- wasmatched = 1;
- was_set(jj) = 1;
- if strcmp(narglist{jj,2}, '__input')
- if (nextinput > length(Inputs))
- error(['Input ' narglist{jj,1} ' has no corresponding input!']);
- end
- narglist{jj,2} = 'OK_in';
- nextinput = nextinput + 1;
- elseif strcmp(narglist{jj,2}, '__output')
- if (nextoutput > nargout)
- error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
- end
- if (isempty(arglist{ii,2}))
- narglist{jj,2} = 'OK_out';
- else
- narglist{jj,2} = arglist{ii,2};
- end
- nextoutput = nextoutput + 1;
- if (minval{jj} == 0)
- NumReqOutputs = NumReqOutputs - 1;
- end
- elseif isstr(arglist{ii,2})
- narglist{jj,2} = arglist{ii,2};
- else
- if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
- error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
- end
- if (minval{jj} ~= 0 | maxval{jj} ~= 0)
- if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
- error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
- elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
- error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
- elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
- error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
- elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
- error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
- elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
- error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
- elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
- error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
- end
- end
- end
- if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
- narglist{jj,2} = arglist{ii,2};
- end
- end
- end
- if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
- error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
- end
- end
- % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
- for jj=1:size(narglist,1)
- if strcmp(paramtype{jj}, 'Toggle')
- if (narglist{jj,2} ==0)
- narglist{jj,1} = '';
- end;
- narglist{jj,2} = '';
- end;
- if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
- narglist{jj,1} = '';
- narglist{jj,2} = '';
- end;
- if strcmp(narglist{jj,2}, '__input')
- if (minval{jj} == 0) % meaning this input is required
- if (nextinput > size(Inputs))
- error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
- else
- narglist{jj,2} = 'OK_in';
- nextinput = nextinput + 1;
- end
- else % this is an optional input
- if (nextinput <= length(Inputs))
- narglist{jj,2} = 'OK_in';
- nextinput = nextinput + 1;
- else
- narglist{jj,1} = '';
- narglist{jj,2} = '';
- end;
- end;
- else
- if strcmp(narglist{jj,2}, '__output')
- if (minval{jj} == 0) % this is a required output
- if (nextoutput > nargout & nargout > 1)
- error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
- else
- narglist{jj,2} = 'OK_out';
- nextoutput = nextoutput + 1;
- NumReqOutputs = NumReqOutputs-1;
- end
- else % this is an optional output
- if (nargout - nextoutput >= NumReqOutputs)
- narglist{jj,2} = 'OK_out';
- nextoutput = nextoutput + 1;
- else
- narglist{jj,1} = '';
- narglist{jj,2} = '';
- end;
- end
- end
- end
- end
- if nargout
- varargout = cell(1,nargout);
- else
- varargout = cell(1,1);
- end
- global KhorosRoot
- if exist('KhorosRoot') && ~isempty(KhorosRoot)
- w=['"' KhorosRoot];
- else
- if ispc
- w='"C:\Program Files\dip\khorosBin\';
- else
- [s,w] = system('which cantata');
- w=['"' w(1:end-8)];
- end
- end
- [varargout{:}]=callKhoros([w 'ksegcmp" '],Inputs,narglist);