PageRenderTime 26ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kgrake.m

http://github.com/aludnam/MATLAB
Objective C | 182 lines | 179 code | 3 blank | 0 comment | 55 complexity | 7a35542686d4e3b58c4088984b654657 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kgrake 'Create a computational rake.'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros grake.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input Data to Sample', required: 'This data is that from which the rakes location data will be computed.'
  6. % InputFile: i1 'Input Transformation File', optional: 'input file'
  7. % OutputFile: o 'Output Samples', required: 'The sample points.'
  8. % OutputFile: orake_geom 'Output Geometry Icon', required: 'Contains a geometry icon for the rake.'
  9. % Integer: nsamples 'Nsamples', default: 8: 'Number of samples to compute.'
  10. %
  11. % Example: [o, orake_geom] = kgrake({i, i1}, {'i','';'i1','';'o','';'orake_geom','';'nsamples',8})
  12. %
  13. % Khoros helpfile follows below:
  14. %
  15. % PROGRAM
  16. % grake - Create a computational rake.
  17. %
  18. % DESCRIPTION
  19. %
  20. %
  21. %
  22. % EXAMPLES
  23. %
  24. % "SEE ALSO"
  25. %
  26. % RESTRICTIONS
  27. %
  28. % REFERENCES
  29. %
  30. % COPYRIGHT
  31. % Copyright (C) 1996,1997 , The Regents of the University of California. All rights reserved.
  32. %
  33. function varargout = kgrake(varargin)
  34. if nargin ==0
  35. Inputs={};arglist={'',''};
  36. elseif nargin ==1
  37. Inputs=varargin{1};arglist={'',''};
  38. elseif nargin ==2
  39. Inputs=varargin{1}; arglist=varargin{2};
  40. else error('Usage: [out1,..] = kgrake(Inputs,arglist).');
  41. end
  42. if size(arglist,2)~=2
  43. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  44. end
  45. narglist={'i', '__input';'i1', '__input';'o', '__output';'orake_geom', '__output';'nsamples', 8};
  46. maxval={0,1,0,0,64};
  47. minval={0,1,0,0,2};
  48. istoggle=[0,1,0,0,1];
  49. was_set=istoggle * 0;
  50. paramtype={'InputFile','InputFile','OutputFile','OutputFile','Integer'};
  51. % identify the input arrays and assign them to the arguments as stated by the user
  52. if ~iscell(Inputs)
  53. Inputs = {Inputs};
  54. end
  55. NumReqOutputs=2; nextinput=1; nextoutput=1;
  56. for ii=1:size(arglist,1)
  57. wasmatched=0;
  58. for jj=1:size(narglist,1)
  59. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  60. wasmatched = 1;
  61. was_set(jj) = 1;
  62. if strcmp(narglist{jj,2}, '__input')
  63. if (nextinput > length(Inputs))
  64. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  65. end
  66. narglist{jj,2} = 'OK_in';
  67. nextinput = nextinput + 1;
  68. elseif strcmp(narglist{jj,2}, '__output')
  69. if (nextoutput > nargout)
  70. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  71. end
  72. if (isempty(arglist{ii,2}))
  73. narglist{jj,2} = 'OK_out';
  74. else
  75. narglist{jj,2} = arglist{ii,2};
  76. end
  77. nextoutput = nextoutput + 1;
  78. if (minval{jj} == 0)
  79. NumReqOutputs = NumReqOutputs - 1;
  80. end
  81. elseif isstr(arglist{ii,2})
  82. narglist{jj,2} = arglist{ii,2};
  83. else
  84. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  85. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  86. end
  87. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  88. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  89. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  90. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  91. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  92. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  93. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  94. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  95. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  96. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  97. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  98. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  99. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  100. end
  101. end
  102. end
  103. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  104. narglist{jj,2} = arglist{ii,2};
  105. end
  106. end
  107. end
  108. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  109. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  110. end
  111. end
  112. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  113. for jj=1:size(narglist,1)
  114. if strcmp(paramtype{jj}, 'Toggle')
  115. if (narglist{jj,2} ==0)
  116. narglist{jj,1} = '';
  117. end;
  118. narglist{jj,2} = '';
  119. end;
  120. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  121. narglist{jj,1} = '';
  122. narglist{jj,2} = '';
  123. end;
  124. if strcmp(narglist{jj,2}, '__input')
  125. if (minval{jj} == 0) % meaning this input is required
  126. if (nextinput > size(Inputs))
  127. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  128. else
  129. narglist{jj,2} = 'OK_in';
  130. nextinput = nextinput + 1;
  131. end
  132. else % this is an optional input
  133. if (nextinput <= length(Inputs))
  134. narglist{jj,2} = 'OK_in';
  135. nextinput = nextinput + 1;
  136. else
  137. narglist{jj,1} = '';
  138. narglist{jj,2} = '';
  139. end;
  140. end;
  141. else
  142. if strcmp(narglist{jj,2}, '__output')
  143. if (minval{jj} == 0) % this is a required output
  144. if (nextoutput > nargout & nargout > 1)
  145. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  146. else
  147. narglist{jj,2} = 'OK_out';
  148. nextoutput = nextoutput + 1;
  149. NumReqOutputs = NumReqOutputs-1;
  150. end
  151. else % this is an optional output
  152. if (nargout - nextoutput >= NumReqOutputs)
  153. narglist{jj,2} = 'OK_out';
  154. nextoutput = nextoutput + 1;
  155. else
  156. narglist{jj,1} = '';
  157. narglist{jj,2} = '';
  158. end;
  159. end
  160. end
  161. end
  162. end
  163. if nargout
  164. varargout = cell(1,nargout);
  165. else
  166. varargout = cell(1,1);
  167. end
  168. global KhorosRoot
  169. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  170. w=['"' KhorosRoot];
  171. else
  172. if ispc
  173. w='"C:\Program Files\dip\khorosBin\';
  174. else
  175. [s,w] = system('which cantata');
  176. w=['"' w(1:end-8)];
  177. end
  178. end
  179. [varargout{:}]=callKhoros([w 'grake" '],Inputs,narglist);