PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/matlab_tools/Converted/kgcuberille.m

http://github.com/aludnam/MATLAB
Objective C | 203 lines | 200 code | 3 blank | 0 comment | 55 complexity | 054ea844a5ccb42a3e19dcad99e89874 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kgcuberille 'Volume Visualization using Geometric Icons.'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros gcuberille.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input 3D Data Object', required: 'input 3d data object'
  6. % InputFile: cmap 'Vis Colormap ', required: 'input vis colormap'
  7. % Double: shrink 'Shrink Factor', default: 1: 'ratio of cuberille size to grid block size.'
  8. % String: name 'Name', default: 'cuberille': 'object name'
  9. % OutputFile: o 'Output Geometry Data', required: 'Resulting output data object'
  10. %
  11. % Example: o = kgcuberille({i, cmap}, {'i','';'cmap','';'shrink',1;'name','cuberille';'o',''})
  12. %
  13. % Khoros helpfile follows below:
  14. %
  15. % PROGRAM
  16. % gcuberille - Volume Visualization using Geometric Icons.
  17. %
  18. % DESCRIPTION
  19. %
  20. %
  21. % This method of volume visualization will place a cube icon at each grid
  22. % location in a volume of data, color coding the vertices of the cube according
  23. % to the value of the grid vertices. The size of the cubes (in relation to
  24. % the size of the grid block they are used to represent) may be scaled down
  25. % so that one can "see through" the volume of data. This is a way to visualize
  26. % three dimensional data. The visualization colormap (created with
  27. % .B ggencmap
  28. % or some other tool) is used to specify data-to-color mapping.
  29. %
  30. %
  31. % The volume data accepted by this code must consist of scalar value data
  32. % and either curvilinear or uniform location data (support for rectilinear
  33. % data will be online in a future release).
  34. %
  35. %
  36. % The output from this code is geometry which may then be rendered using
  37. % rmonster.
  38. %
  39. %
  40. %
  41. % EXAMPLES
  42. % kmakecmap -> cuberille -> rmonster
  43. %
  44. % "SEE ALSO"
  45. % kmakecmap - to create a visualization colormap.
  46. %
  47. % RESTRICTIONS
  48. %
  49. % REFERENCES
  50. %
  51. % COPYRIGHT
  52. % Copyright (C) 1996,1997 , The Regents of the University of California. All rights reserved.
  53. %
  54. function varargout = kgcuberille(varargin)
  55. if nargin ==0
  56. Inputs={};arglist={'',''};
  57. elseif nargin ==1
  58. Inputs=varargin{1};arglist={'',''};
  59. elseif nargin ==2
  60. Inputs=varargin{1}; arglist=varargin{2};
  61. else error('Usage: [out1,..] = kgcuberille(Inputs,arglist).');
  62. end
  63. if size(arglist,2)~=2
  64. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  65. end
  66. narglist={'i', '__input';'cmap', '__input';'shrink', 1;'name', 'cuberille';'o', '__output'};
  67. maxval={0,0,1,0,0};
  68. minval={0,0,0,0,0};
  69. istoggle=[0,0,1,1,0];
  70. was_set=istoggle * 0;
  71. paramtype={'InputFile','InputFile','Double','String','OutputFile'};
  72. % identify the input arrays and assign them to the arguments as stated by the user
  73. if ~iscell(Inputs)
  74. Inputs = {Inputs};
  75. end
  76. NumReqOutputs=1; nextinput=1; nextoutput=1;
  77. for ii=1:size(arglist,1)
  78. wasmatched=0;
  79. for jj=1:size(narglist,1)
  80. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  81. wasmatched = 1;
  82. was_set(jj) = 1;
  83. if strcmp(narglist{jj,2}, '__input')
  84. if (nextinput > length(Inputs))
  85. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  86. end
  87. narglist{jj,2} = 'OK_in';
  88. nextinput = nextinput + 1;
  89. elseif strcmp(narglist{jj,2}, '__output')
  90. if (nextoutput > nargout)
  91. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  92. end
  93. if (isempty(arglist{ii,2}))
  94. narglist{jj,2} = 'OK_out';
  95. else
  96. narglist{jj,2} = arglist{ii,2};
  97. end
  98. nextoutput = nextoutput + 1;
  99. if (minval{jj} == 0)
  100. NumReqOutputs = NumReqOutputs - 1;
  101. end
  102. elseif isstr(arglist{ii,2})
  103. narglist{jj,2} = arglist{ii,2};
  104. else
  105. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  106. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  107. end
  108. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  109. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  110. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  111. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  112. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  113. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  114. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  115. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  116. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  117. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  118. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  119. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  120. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  121. end
  122. end
  123. end
  124. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  125. narglist{jj,2} = arglist{ii,2};
  126. end
  127. end
  128. end
  129. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  130. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  131. end
  132. end
  133. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  134. for jj=1:size(narglist,1)
  135. if strcmp(paramtype{jj}, 'Toggle')
  136. if (narglist{jj,2} ==0)
  137. narglist{jj,1} = '';
  138. end;
  139. narglist{jj,2} = '';
  140. end;
  141. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  142. narglist{jj,1} = '';
  143. narglist{jj,2} = '';
  144. end;
  145. if strcmp(narglist{jj,2}, '__input')
  146. if (minval{jj} == 0) % meaning this input is required
  147. if (nextinput > size(Inputs))
  148. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  149. else
  150. narglist{jj,2} = 'OK_in';
  151. nextinput = nextinput + 1;
  152. end
  153. else % this is an optional input
  154. if (nextinput <= length(Inputs))
  155. narglist{jj,2} = 'OK_in';
  156. nextinput = nextinput + 1;
  157. else
  158. narglist{jj,1} = '';
  159. narglist{jj,2} = '';
  160. end;
  161. end;
  162. else
  163. if strcmp(narglist{jj,2}, '__output')
  164. if (minval{jj} == 0) % this is a required output
  165. if (nextoutput > nargout & nargout > 1)
  166. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  167. else
  168. narglist{jj,2} = 'OK_out';
  169. nextoutput = nextoutput + 1;
  170. NumReqOutputs = NumReqOutputs-1;
  171. end
  172. else % this is an optional output
  173. if (nargout - nextoutput >= NumReqOutputs)
  174. narglist{jj,2} = 'OK_out';
  175. nextoutput = nextoutput + 1;
  176. else
  177. narglist{jj,1} = '';
  178. narglist{jj,2} = '';
  179. end;
  180. end
  181. end
  182. end
  183. end
  184. if nargout
  185. varargout = cell(1,nargout);
  186. else
  187. varargout = cell(1,1);
  188. end
  189. global KhorosRoot
  190. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  191. w=['"' KhorosRoot];
  192. else
  193. if ispc
  194. w='"C:\Program Files\dip\khorosBin\';
  195. else
  196. [s,w] = system('which cantata');
  197. w=['"' w(1:end-8)];
  198. end
  199. end
  200. [varargout{:}]=callKhoros([w 'gcuberille" '],Inputs,narglist);