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

/matlab_tools/Converted/kglinecolor.m

http://github.com/aludnam/MATLAB
Objective C | 214 lines | 211 code | 3 blank | 0 comment | 57 complexity | 771c64a05e3103f81aecdb7b664b04f1 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kglinecolor 'Create Polylines from ASCII XYZ data and a Vis Cmap'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros glinecolor.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input ASCII Data ', required: 'input ASCII data containing polyline points'
  6. % InputFile: cmap 'Vis Colormap ', required: 'Input vis colormap'
  7. % String: name 'Name ', default: 'color lines': 'object name'
  8. % OutputFile: o 'Output Geometry Object', required: 'output geometry object'
  9. %
  10. % Example: o = kglinecolor({i, cmap}, {'i','';'cmap','';'name','color lines';'o',''})
  11. %
  12. % Khoros helpfile follows below:
  13. %
  14. % PROGRAM
  15. % glinecolor - Create Polylines from ASCII XYZ data and a Vis Cmap
  16. %
  17. % DESCRIPTION
  18. % .I glinecolor
  19. % will read in an ASCII file of coordinate information and color indices
  20. % and produce a series of connected polyline primitives.
  21. %
  22. % The ASCII input should contain blocks of information, where each block
  23. % consists of a number indicating how many vertices will be contained in
  24. % the polyline and then a series of XYZ points and color indices, with
  25. % one for each vertex. The format of the input ASCII file is
  26. % illustrated below :
  27. %
  28. %
  29. % number of vertices in first connected polyline
  30. % X value Y value Z value color index
  31. % X value Y value Z value color index
  32. % X value Y value Z value color index
  33. % . . . .
  34. % . . . .
  35. % . . . .
  36. % X value Y value Z value color index
  37. % number of vertices in second connected polyline
  38. % X value Y value Z value color index
  39. % . . . .
  40. % . . . .
  41. % . . . .
  42. %
  43. %
  44. %
  45. % A single connected polyline primitive will be created for each
  46. % successive block of information. A color will be stored for each
  47. % vertex in the line. The color is determined from the provided
  48. % vis colormap; the ASCII color indicies are used to index into
  49. % the vis colormap.
  50. %
  51. %
  52. %
  53. % EXAMPLES
  54. %
  55. % "SEE ALSO"
  56. % plot_xyz
  57. %
  58. % RESTRICTIONS
  59. %
  60. % REFERENCES
  61. %
  62. % COPYRIGHT
  63. % Copyright (C) 1996,1997 , The Regents of the University of California. All rights reserved.
  64. %
  65. function varargout = kglinecolor(varargin)
  66. if nargin ==0
  67. Inputs={};arglist={'',''};
  68. elseif nargin ==1
  69. Inputs=varargin{1};arglist={'',''};
  70. elseif nargin ==2
  71. Inputs=varargin{1}; arglist=varargin{2};
  72. else error('Usage: [out1,..] = kglinecolor(Inputs,arglist).');
  73. end
  74. if size(arglist,2)~=2
  75. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  76. end
  77. narglist={'i', '__input';'cmap', '__input';'name', 'color lines';'o', '__output'};
  78. maxval={0,0,0,0};
  79. minval={0,0,0,0};
  80. istoggle=[0,0,1,0];
  81. was_set=istoggle * 0;
  82. paramtype={'InputFile','InputFile','String','OutputFile'};
  83. % identify the input arrays and assign them to the arguments as stated by the user
  84. if ~iscell(Inputs)
  85. Inputs = {Inputs};
  86. end
  87. NumReqOutputs=1; nextinput=1; nextoutput=1;
  88. for ii=1:size(arglist,1)
  89. wasmatched=0;
  90. for jj=1:size(narglist,1)
  91. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  92. wasmatched = 1;
  93. was_set(jj) = 1;
  94. if strcmp(narglist{jj,2}, '__input')
  95. if (nextinput > length(Inputs))
  96. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  97. end
  98. narglist{jj,2} = 'OK_in';
  99. nextinput = nextinput + 1;
  100. elseif strcmp(narglist{jj,2}, '__output')
  101. if (nextoutput > nargout)
  102. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  103. end
  104. if (isempty(arglist{ii,2}))
  105. narglist{jj,2} = 'OK_out';
  106. else
  107. narglist{jj,2} = arglist{ii,2};
  108. end
  109. nextoutput = nextoutput + 1;
  110. if (minval{jj} == 0)
  111. NumReqOutputs = NumReqOutputs - 1;
  112. end
  113. elseif isstr(arglist{ii,2})
  114. narglist{jj,2} = arglist{ii,2};
  115. else
  116. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  117. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  118. end
  119. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  120. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  121. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  122. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  123. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  124. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  125. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  126. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  127. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  128. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  129. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  130. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  131. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  132. end
  133. end
  134. end
  135. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  136. narglist{jj,2} = arglist{ii,2};
  137. end
  138. end
  139. end
  140. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  141. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  142. end
  143. end
  144. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  145. for jj=1:size(narglist,1)
  146. if strcmp(paramtype{jj}, 'Toggle')
  147. if (narglist{jj,2} ==0)
  148. narglist{jj,1} = '';
  149. end;
  150. narglist{jj,2} = '';
  151. end;
  152. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  153. narglist{jj,1} = '';
  154. narglist{jj,2} = '';
  155. end;
  156. if strcmp(narglist{jj,2}, '__input')
  157. if (minval{jj} == 0) % meaning this input is required
  158. if (nextinput > size(Inputs))
  159. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  160. else
  161. narglist{jj,2} = 'OK_in';
  162. nextinput = nextinput + 1;
  163. end
  164. else % this is an optional input
  165. if (nextinput <= length(Inputs))
  166. narglist{jj,2} = 'OK_in';
  167. nextinput = nextinput + 1;
  168. else
  169. narglist{jj,1} = '';
  170. narglist{jj,2} = '';
  171. end;
  172. end;
  173. else
  174. if strcmp(narglist{jj,2}, '__output')
  175. if (minval{jj} == 0) % this is a required output
  176. if (nextoutput > nargout & nargout > 1)
  177. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  178. else
  179. narglist{jj,2} = 'OK_out';
  180. nextoutput = nextoutput + 1;
  181. NumReqOutputs = NumReqOutputs-1;
  182. end
  183. else % this is an optional output
  184. if (nargout - nextoutput >= NumReqOutputs)
  185. narglist{jj,2} = 'OK_out';
  186. nextoutput = nextoutput + 1;
  187. else
  188. narglist{jj,1} = '';
  189. narglist{jj,2} = '';
  190. end;
  191. end
  192. end
  193. end
  194. end
  195. if nargout
  196. varargout = cell(1,nargout);
  197. else
  198. varargout = cell(1,1);
  199. end
  200. global KhorosRoot
  201. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  202. w=['"' KhorosRoot];
  203. else
  204. if ispc
  205. w='"C:\Program Files\dip\khorosBin\';
  206. else
  207. [s,w] = system('which cantata');
  208. w=['"' w(1:end-8)];
  209. end
  210. end
  211. [varargout{:}]=callKhoros([w 'glinecolor" '],Inputs,narglist);