PageRenderTime 73ms CodeModel.GetById 18ms RepoModel.GetById 2ms app.codeStats 0ms

/matlab_tools/Converted/kkasc2loc.m

http://github.com/aludnam/MATLAB
Objective C | 205 lines | 202 code | 3 blank | 0 comment | 55 complexity | 390cc2dcd2c91c32cafa53f13e42098d MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kkasc2loc 'Import ASCII Data File to Location Segment'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros kasc2loc.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i1 'ASCII Input File', required: 'ASCII input data file containing new data segment'
  6. % InputFile: i2 'Data Object Input', optional: 'data object input to insert the new segment into'
  7. % Integer: so 'Start Offset ', default: 0: 'starting point in ASCII file to start importing at'
  8. % Integer: sf 'Skip Factor ', default: 0: 'number of points in ASCII file to skip between reads'
  9. % Integer: wsize ' ', default: 1: 'width size must be > 0'
  10. % Integer: hsize ' ', default: 1: 'height size must be > 0'
  11. % Integer: dsize ' ', default: 1: 'depth size must be > 0'
  12. % Integer: nsize ' ', default: 1: 'dimension size must be > 0'
  13. % OutputFile: o 'Output Object', required: 'output data object'
  14. %
  15. % Example: o = kkasc2loc({i1, i2}, {'i1','';'i2','';'so',0;'sf',0;'wsize',1;'hsize',1;'dsize',1;'nsize',1;'o',''})
  16. %
  17. % Khoros helpfile follows below:
  18. %
  19. % PROGRAM
  20. % kasc2loc - Import ASCII Data File to Location Segment
  21. %
  22. % DESCRIPTION
  23. % This routine will import an ASCII data file and insert it into a data
  24. % object if it is specified. If there is no source object to insert the
  25. % new segment into, the data object specified as the output file will be
  26. % created. The new segment will be inserted into this data object in the
  27. % location segment. If a source object was specified, then all of its
  28. % data segments and the global object attributes will be copied to the
  29. % destination.
  30. % The index order is specified by setting the -windex, -hindex, -dindex
  31. % and -nindex flags. They can not be set to the same value.
  32. % The start offset is the point to start importing in the ASCII data.
  33. % All points before this one are ignored.
  34. % The skip factor is the number of points to skip in the ASCII data
  35. % between reads. If the size of the new segment's lowest index is 40
  36. % and the skip factor is 5, then this routine will read in 40 points
  37. % skip 5 and read in 40 more, etc. until the entire ASCII file read in.
  38. % Complex values in ASCII are represented by number pairs, surrounded
  39. % by parenthesis and separated by a comma. For example, (8, 3) represents
  40. % the complex number 8+3i.
  41. %
  42. %
  43. %
  44. % EXAMPLES
  45. %
  46. % "SEE ALSO"
  47. % kasc2val, kasc2map, kasc2time, kasc2mask, kimportasc
  48. %
  49. % RESTRICTIONS
  50. %
  51. % REFERENCES
  52. %
  53. % COPYRIGHT
  54. % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
  55. %
  56. function varargout = kkasc2loc(varargin)
  57. if nargin ==0
  58. Inputs={};arglist={'',''};
  59. elseif nargin ==1
  60. Inputs=varargin{1};arglist={'',''};
  61. elseif nargin ==2
  62. Inputs=varargin{1}; arglist=varargin{2};
  63. else error('Usage: [out1,..] = kkasc2loc(Inputs,arglist).');
  64. end
  65. if size(arglist,2)~=2
  66. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  67. end
  68. narglist={'i1', '__input';'i2', '__input';'so', 0;'sf', 0;'wsize', 1;'hsize', 1;'dsize', 1;'nsize', 1;'o', '__output'};
  69. maxval={0,1,1,1,2,2,2,2,0};
  70. minval={0,1,1,1,2,2,2,2,0};
  71. istoggle=[0,1,1,1,1,1,1,1,0];
  72. was_set=istoggle * 0;
  73. paramtype={'InputFile','InputFile','Integer','Integer','Integer','Integer','Integer','Integer','OutputFile'};
  74. % identify the input arrays and assign them to the arguments as stated by the user
  75. if ~iscell(Inputs)
  76. Inputs = {Inputs};
  77. end
  78. NumReqOutputs=1; nextinput=1; nextoutput=1;
  79. for ii=1:size(arglist,1)
  80. wasmatched=0;
  81. for jj=1:size(narglist,1)
  82. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  83. wasmatched = 1;
  84. was_set(jj) = 1;
  85. if strcmp(narglist{jj,2}, '__input')
  86. if (nextinput > length(Inputs))
  87. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  88. end
  89. narglist{jj,2} = 'OK_in';
  90. nextinput = nextinput + 1;
  91. elseif strcmp(narglist{jj,2}, '__output')
  92. if (nextoutput > nargout)
  93. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  94. end
  95. if (isempty(arglist{ii,2}))
  96. narglist{jj,2} = 'OK_out';
  97. else
  98. narglist{jj,2} = arglist{ii,2};
  99. end
  100. nextoutput = nextoutput + 1;
  101. if (minval{jj} == 0)
  102. NumReqOutputs = NumReqOutputs - 1;
  103. end
  104. elseif isstr(arglist{ii,2})
  105. narglist{jj,2} = arglist{ii,2};
  106. else
  107. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  108. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  109. end
  110. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  111. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  112. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  113. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  114. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  115. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  116. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  117. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  118. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  119. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  120. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  121. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  122. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  123. end
  124. end
  125. end
  126. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  127. narglist{jj,2} = arglist{ii,2};
  128. end
  129. end
  130. end
  131. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  132. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  133. end
  134. end
  135. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  136. for jj=1:size(narglist,1)
  137. if strcmp(paramtype{jj}, 'Toggle')
  138. if (narglist{jj,2} ==0)
  139. narglist{jj,1} = '';
  140. end;
  141. narglist{jj,2} = '';
  142. end;
  143. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  144. narglist{jj,1} = '';
  145. narglist{jj,2} = '';
  146. end;
  147. if strcmp(narglist{jj,2}, '__input')
  148. if (minval{jj} == 0) % meaning this input is required
  149. if (nextinput > size(Inputs))
  150. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  151. else
  152. narglist{jj,2} = 'OK_in';
  153. nextinput = nextinput + 1;
  154. end
  155. else % this is an optional input
  156. if (nextinput <= length(Inputs))
  157. narglist{jj,2} = 'OK_in';
  158. nextinput = nextinput + 1;
  159. else
  160. narglist{jj,1} = '';
  161. narglist{jj,2} = '';
  162. end;
  163. end;
  164. else
  165. if strcmp(narglist{jj,2}, '__output')
  166. if (minval{jj} == 0) % this is a required output
  167. if (nextoutput > nargout & nargout > 1)
  168. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  169. else
  170. narglist{jj,2} = 'OK_out';
  171. nextoutput = nextoutput + 1;
  172. NumReqOutputs = NumReqOutputs-1;
  173. end
  174. else % this is an optional output
  175. if (nargout - nextoutput >= NumReqOutputs)
  176. narglist{jj,2} = 'OK_out';
  177. nextoutput = nextoutput + 1;
  178. else
  179. narglist{jj,1} = '';
  180. narglist{jj,2} = '';
  181. end;
  182. end
  183. end
  184. end
  185. end
  186. if nargout
  187. varargout = cell(1,nargout);
  188. else
  189. varargout = cell(1,1);
  190. end
  191. global KhorosRoot
  192. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  193. w=['"' KhorosRoot];
  194. else
  195. if ispc
  196. w='"C:\Program Files\dip\khorosBin\';
  197. else
  198. [s,w] = system('which cantata');
  199. w=['"' w(1:end-8)];
  200. end
  201. end
  202. [varargout{:}]=callKhoros([w 'kasc2loc" '],Inputs,narglist);