PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/matlab_tools/Converted/kgquadmesh.m

http://github.com/aludnam/MATLAB
Objective C | 203 lines | 200 code | 3 blank | 0 comment | 56 complexity | 02e6eeca2299ca17d040bd49bff458f2 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kgquadmesh 'Create a Quadmesh Geometry Object from 2D Data'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros gquadmesh.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input 2D Data Object', required: 'input 2d data for quadmesh'
  6. % String: name 'Name ', default: 'quadmesh': 'object name'
  7. % OutputFile: o 'Output Geometry Quadmesh', required: 'ouput geometry quadmesh'
  8. % InputFile: cmap 'Vis Colormap', optional: 'input vis colormap'
  9. % Toggle: tc2d 'Generate 2D Texture Coords', default: 0: 'generate 2D texture coords'
  10. % Toggle: tc3d 'Generate 3D Texture Coords', default: 0: 'generate 3D texture coords'
  11. %
  12. % Example: o = kgquadmesh({i, cmap}, {'i','';'name','quadmesh';'o','';'cmap','';'tc2d',0;'tc3d',0})
  13. %
  14. % Khoros helpfile follows below:
  15. %
  16. % PROGRAM
  17. % gquadmesh - Create a Quadmesh Geometry Object from 2D Data
  18. %
  19. % DESCRIPTION
  20. % .I gquadmesh
  21. % is used to create a "mesh" out of two-dimensional value data. The
  22. % value data must either have an element size of 4 and contain RGBalpha
  23. % values, or an element size of 1, in which case it will be used as map
  24. % indicies into a vis colormap. Location data must also be present in
  25. % the input file. Location data is required to exists in R3 (i.e.,
  26. % each location vector must have and X, Y and Z component).
  27. %
  28. % A vis colormap may be provided for coloring the quadmesh
  29. % vectors. The generated mesh will then contain the color vectors
  30. % determined by mapping the original value points through the vis
  31. % colormap.
  32. %
  33. % The resulting quadmesh will contain location data, color data, and
  34. % normal data. Texture coordinates may be optionally generated which
  35. % can be used to map vertex points on the quadmesh into colors on a
  36. % texture map. A texture map can be associated later using the
  37. % kapplytexture operator. Note that the use of a vis colormap and
  38. % texture coordinates are mutually exclusive.
  39. %
  40. %
  41. %
  42. % EXAMPLES
  43. %
  44. % "SEE ALSO"
  45. % goctmesh, ggencmap, gapplytex
  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 = kgquadmesh(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,..] = kgquadmesh(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';'name', 'quadmesh';'o', '__output';'cmap', '__input';'tc2d', 0;'tc3d', 0};
  67. maxval={0,0,0,1,0,0};
  68. minval={0,0,0,1,0,0};
  69. istoggle=[0,1,0,1,1,1];
  70. was_set=istoggle * 0;
  71. paramtype={'InputFile','String','OutputFile','InputFile','Toggle','Toggle'};
  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 'gquadmesh" '],Inputs,narglist);