PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kkvoxext.m

http://github.com/aludnam/MATLAB
Objective C | 213 lines | 210 code | 3 blank | 0 comment | 56 complexity | 96c7887782fa7b67eb3fc7c324c7323a MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kkvoxext 'Get voxel density at each point in the surface described by its coordinates '
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros kvoxext.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i1 '3D Data', required: 'Input scene (gray or binary scene)'
  6. % InputFile: i2 'Coordinates', required: 'Coordinates at z-buffer distance (surface)'
  7. % OutputFile: o 'Voxel Values', required: 'Voxel densities at surface given by the coordinates'
  8. %
  9. % Example: o = kkvoxext({i1, i2}, {'i1','';'i2','';'o',''})
  10. %
  11. % Khoros helpfile follows below:
  12. %
  13. % PROGRAM
  14. % kvoxext - Get voxel densities at given coordinates
  15. %
  16. % DESCRIPTION
  17. %
  18. % The operator "vvoxext"
  19. % extracts voxel values from a 3D scene at given coordinates. Those coordinates
  20. % usually come from a projection view of a 3D scene.
  21. %
  22. % The coordinate input file is an image w x h x 1 x 1 x 3, where each element
  23. % correspond to X,Y and Z coordinates of the voxels at the object's surface.
  24. % Combining a coordinate file generated by kzbuff with a
  25. % diferent 3D scene, computes its projected voxel densities at the intersection
  26. % of the object's surface which generated the coordinate file.
  27. %
  28. % Negative coordinates are mapped into zero value in the output.
  29. %
  30. %
  31. %
  32. % EXAMPLES
  33. % kvoxext -i1 scene.viff -i2 coord.viff -o voxel.viff
  34. %
  35. % The output file voxel.viff will have the same dimentions as coord.viff and
  36. % for each coordinate in coord.viff the corresponding voxel value in the
  37. % scene.viff is copied into voxel.viff.
  38. %
  39. % "SEE ALSO"
  40. % kzbuff, kshad, kisnorm, kvsnorm, ktextu
  41. %
  42. % RESTRICTIONS
  43. % The input objects must have only the value segment.
  44. %
  45. % The input object scene can not have dimention e > 1. The input object
  46. % coordinate must have dimention e=3.
  47. %
  48. % The input object scene can not be of data types KCOMPLEX and KDCOMPLEX.
  49. %
  50. % The input object coordinate can not be of data types KBIT, KFLOAT, KDOUBLE,
  51. % KCOMPLEX and KDCOMPLEX.
  52. %
  53. % In case of t > 1 in the input objects, the operator will be applied to the time
  54. % t=0 only.
  55. %
  56. % None of the input and output objects are referenced, therefore some attributes
  57. % may change, as the VALUE_POSITION, for example.
  58. %
  59. % REFERENCES
  60. %
  61. % COPYRIGHT
  62. % Copyright (C) 1993, 1994, 1995 UNICAMP, R A Lotufo, All rights reserved.
  63. %
  64. function varargout = kkvoxext(varargin)
  65. if nargin ==0
  66. Inputs={};arglist={'',''};
  67. elseif nargin ==1
  68. Inputs=varargin{1};arglist={'',''};
  69. elseif nargin ==2
  70. Inputs=varargin{1}; arglist=varargin{2};
  71. else error('Usage: [out1,..] = kkvoxext(Inputs,arglist).');
  72. end
  73. if size(arglist,2)~=2
  74. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  75. end
  76. narglist={'i1', '__input';'i2', '__input';'o', '__output'};
  77. maxval={0,0,0};
  78. minval={0,0,0};
  79. istoggle=[0,0,0];
  80. was_set=istoggle * 0;
  81. paramtype={'InputFile','InputFile','OutputFile'};
  82. % identify the input arrays and assign them to the arguments as stated by the user
  83. if ~iscell(Inputs)
  84. Inputs = {Inputs};
  85. end
  86. NumReqOutputs=1; nextinput=1; nextoutput=1;
  87. for ii=1:size(arglist,1)
  88. wasmatched=0;
  89. for jj=1:size(narglist,1)
  90. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  91. wasmatched = 1;
  92. was_set(jj) = 1;
  93. if strcmp(narglist{jj,2}, '__input')
  94. if (nextinput > length(Inputs))
  95. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  96. end
  97. narglist{jj,2} = 'OK_in';
  98. nextinput = nextinput + 1;
  99. elseif strcmp(narglist{jj,2}, '__output')
  100. if (nextoutput > nargout)
  101. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  102. end
  103. if (isempty(arglist{ii,2}))
  104. narglist{jj,2} = 'OK_out';
  105. else
  106. narglist{jj,2} = arglist{ii,2};
  107. end
  108. nextoutput = nextoutput + 1;
  109. if (minval{jj} == 0)
  110. NumReqOutputs = NumReqOutputs - 1;
  111. end
  112. elseif isstr(arglist{ii,2})
  113. narglist{jj,2} = arglist{ii,2};
  114. else
  115. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  116. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  117. end
  118. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  119. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  120. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  121. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  122. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  123. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  124. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  125. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  126. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  127. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  128. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  129. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  130. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  131. end
  132. end
  133. end
  134. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  135. narglist{jj,2} = arglist{ii,2};
  136. end
  137. end
  138. end
  139. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  140. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  141. end
  142. end
  143. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  144. for jj=1:size(narglist,1)
  145. if strcmp(paramtype{jj}, 'Toggle')
  146. if (narglist{jj,2} ==0)
  147. narglist{jj,1} = '';
  148. end;
  149. narglist{jj,2} = '';
  150. end;
  151. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  152. narglist{jj,1} = '';
  153. narglist{jj,2} = '';
  154. end;
  155. if strcmp(narglist{jj,2}, '__input')
  156. if (minval{jj} == 0) % meaning this input is required
  157. if (nextinput > size(Inputs))
  158. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  159. else
  160. narglist{jj,2} = 'OK_in';
  161. nextinput = nextinput + 1;
  162. end
  163. else % this is an optional input
  164. if (nextinput <= length(Inputs))
  165. narglist{jj,2} = 'OK_in';
  166. nextinput = nextinput + 1;
  167. else
  168. narglist{jj,1} = '';
  169. narglist{jj,2} = '';
  170. end;
  171. end;
  172. else
  173. if strcmp(narglist{jj,2}, '__output')
  174. if (minval{jj} == 0) % this is a required output
  175. if (nextoutput > nargout & nargout > 1)
  176. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  177. else
  178. narglist{jj,2} = 'OK_out';
  179. nextoutput = nextoutput + 1;
  180. NumReqOutputs = NumReqOutputs-1;
  181. end
  182. else % this is an optional output
  183. if (nargout - nextoutput >= NumReqOutputs)
  184. narglist{jj,2} = 'OK_out';
  185. nextoutput = nextoutput + 1;
  186. else
  187. narglist{jj,1} = '';
  188. narglist{jj,2} = '';
  189. end;
  190. end
  191. end
  192. end
  193. end
  194. if nargout
  195. varargout = cell(1,nargout);
  196. else
  197. varargout = cell(1,1);
  198. end
  199. global KhorosRoot
  200. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  201. w=['"' KhorosRoot];
  202. else
  203. if ispc
  204. w='"C:\Program Files\dip\khorosBin\';
  205. else
  206. [s,w] = system('which cantata');
  207. w=['"' w(1:end-8)];
  208. end
  209. end
  210. [varargout{:}]=callKhoros([w 'kvoxext" '],Inputs,narglist);