PageRenderTime 45ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 1ms

/matlab_tools/Converted/kBlobIt.m

http://github.com/aludnam/MATLAB
Objective C | 206 lines | 203 code | 3 blank | 0 comment | 60 complexity | 8a690e8f1f72fc1aa7c8a5290bfe0662 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kBlobIt 'converts 3D data into blob-File to include in povray '
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros BlobIt.pane file
  3. %
  4. % Parameters:
  5. % Double: t 'Threshhold', default: 100: 'threshhold for blobbing data'
  6. % Toggle: rel 'relative', default: 0: 'Threshhold given in Percent of 0 .. Maximum'
  7. % Toggle: v 'Input is Vector file', default: 0: 'input is in vector format'
  8. % Toggle: noblob 'NoBlob', default: 0: 'do not generate blobs but ordenary spheres'
  9. % Toggle: polycol 'PolyCol', default: 0: 'for vestors generate a new color at each new vector'
  10. % Double: dx 'VecSizeX', default: 64: 'Size of Datacube to show in case of vector file usage'
  11. % Double: dy 'Y', default: 64: 'Size of Datacube to show in case of vector file usage'
  12. % Double: dz 'Z', default: 64: 'Size of Datacube to show in case of vector file usage'
  13. % String: titX 'TitleX', default: 'X-axis': 'Text for Axis Title'
  14. % String: titY 'Y', default: 'Y-axis': 'Text for Axis Title'
  15. % String: titZ 'Z', default: 'Z-axis': 'Text for Axis Title'
  16. % Integer: sb 'ScaleBar Units', default: 2000: 'Number of basic units to form length of scalebar'
  17. % String: unit 'Text', default: '2\mm': 'Text to write at Scale Bar'
  18. % Toggle: vrml 'Generate VRML', default: 0: 'generate vrml instaed of povray format'
  19. % Toggle: faces 'Generate Faces', default: 0: 'generate only faces and no cubes'
  20. % Toggle: nospix 'no subpixel approximations', default: 0: 'do only use full integer pixel coordinates'
  21. % Double: smoothfac 'Smoothing', default: 2.5: 'this factor can be adjusted for optimal smoothing'
  22. % Double: pixXY 'Voxelsize XY', default: 77.8: 'Size of a voxel in nm XY-direction'
  23. % Double: zoom 'Zoom', default: 1: 'Zooms every coordinate'
  24. % Double: sr 'Sphere Radius', default: 2.2: 'Radius of blobs'
  25. % Double: pixZ 'Voxelsize Z', default: 162.1: 'Size of a voxel in nm Z-direction'
  26. % Double: mx 'Midpoint X', default: 0.5: 'view is centered on this point'
  27. % Double: my 'Y', default: 0.5: 'view is centered on this point'
  28. % Double: mz 'Z', default: 0.5: 'view is centered on this point'
  29. % InputFile: i 'Input ', required: 'First Input data object'
  30. % OutputFile: ao 'OutputBlobFile', required: 'Resulting ascii output data object'
  31. % InputFile: bf 'StartFile', optional: 'Povray file for the start declarations'
  32. % InputFile: tf 'Texture-File-Begin', optional: 'Filename will be +#Elem.txb and +#Elem.txe'
  33. % InputFile: ef 'EndFile', optional: 'File to be included at the end'
  34. %
  35. % Example: ao = kBlobIt({i, bf, tf, ef}, {'t',100;'rel',0;'v',0;'noblob',0;'polycol',0;'dx',64;'dy',64;'dz',64;'titX','X-axis';'titY','Y-axis';'titZ','Z-axis';'sb',2000;'unit','2\mm';'vrml',0;'faces',0;'nospix',0;'smoothfac',2.5;'pixXY',77.8;'zoom',1;'sr',2.2;'pixZ',162.1;'mx',0.5;'my',0.5;'mz',0.5;'i','';'ao','';'bf','';'tf','';'ef',''})
  36. %
  37. % Khoros helpfile follows below:
  38. %
  39. % PROGRAM
  40. % BlobIt - converts 3D data into blob-File to include in povray
  41. %
  42. % DESCRIPTION
  43. %
  44. %
  45. %
  46. % EXAMPLES
  47. %
  48. % "SEE ALSO"
  49. %
  50. % RESTRICTIONS
  51. %
  52. % REFERENCES
  53. %
  54. % COPYRIGHT
  55. % Copyright (C) 1996-2003, Rainer Heintzmann, All rights reserved.
  56. %
  57. function varargout = kBlobIt(varargin)
  58. if nargin ==0
  59. Inputs={};arglist={'',''};
  60. elseif nargin ==1
  61. Inputs=varargin{1};arglist={'',''};
  62. elseif nargin ==2
  63. Inputs=varargin{1}; arglist=varargin{2};
  64. else error('Usage: [out1,..] = kBlobIt(Inputs,arglist).');
  65. end
  66. if size(arglist,2)~=2
  67. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  68. end
  69. narglist={'t', 100;'rel', 0;'v', 0;'noblob', 0;'polycol', 0;'dx', 64;'dy', 64;'dz', 64;'titX', 'X-axis';'titY', 'Y-axis';'titZ', 'Z-axis';'sb', 2000;'unit', '2\mm';'vrml', 0;'faces', 0;'nospix', 0;'smoothfac', 2.5;'pixXY', 77.8;'zoom', 1;'sr', 2.2;'pixZ', 162.1;'mx', 0.5;'my', 0.5;'mz', 0.5;'i', '__input';'ao', '__output';'bf', '__input';'tf', '__input';'ef', '__input'};
  70. maxval={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1,1,1};
  71. minval={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1,1,1};
  72. istoggle=[0,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1];
  73. was_set=istoggle * 0;
  74. paramtype={'Double','Toggle','Toggle','Toggle','Toggle','Double','Double','Double','String','String','String','Integer','String','Toggle','Toggle','Toggle','Double','Double','Double','Double','Double','Double','Double','Double','InputFile','OutputFile','InputFile','InputFile','InputFile'};
  75. % identify the input arrays and assign them to the arguments as stated by the user
  76. if ~iscell(Inputs)
  77. Inputs = {Inputs};
  78. end
  79. NumReqOutputs=1; nextinput=1; nextoutput=1;
  80. for ii=1:size(arglist,1)
  81. wasmatched=0;
  82. for jj=1:size(narglist,1)
  83. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  84. wasmatched = 1;
  85. was_set(jj) = 1;
  86. if strcmp(narglist{jj,2}, '__input')
  87. if (nextinput > length(Inputs))
  88. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  89. end
  90. narglist{jj,2} = 'OK_in';
  91. nextinput = nextinput + 1;
  92. elseif strcmp(narglist{jj,2}, '__output')
  93. if (nextoutput > nargout)
  94. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  95. end
  96. if (isempty(arglist{ii,2}))
  97. narglist{jj,2} = 'OK_out';
  98. else
  99. narglist{jj,2} = arglist{ii,2};
  100. end
  101. nextoutput = nextoutput + 1;
  102. if (minval{jj} == 0)
  103. NumReqOutputs = NumReqOutputs - 1;
  104. end
  105. elseif isstr(arglist{ii,2})
  106. narglist{jj,2} = arglist{ii,2};
  107. else
  108. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  109. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  110. end
  111. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  112. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  113. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  114. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  115. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  116. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  117. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  118. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  119. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  120. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  121. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  122. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  123. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  124. end
  125. end
  126. end
  127. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  128. narglist{jj,2} = arglist{ii,2};
  129. end
  130. end
  131. end
  132. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  133. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  134. end
  135. end
  136. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  137. for jj=1:size(narglist,1)
  138. if strcmp(paramtype{jj}, 'Toggle')
  139. if (narglist{jj,2} ==0)
  140. narglist{jj,1} = '';
  141. end;
  142. narglist{jj,2} = '';
  143. end;
  144. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  145. narglist{jj,1} = '';
  146. narglist{jj,2} = '';
  147. end;
  148. if strcmp(narglist{jj,2}, '__input')
  149. if (minval{jj} == 0) % meaning this input is required
  150. if (nextinput > size(Inputs))
  151. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  152. else
  153. narglist{jj,2} = 'OK_in';
  154. nextinput = nextinput + 1;
  155. end
  156. else % this is an optional input
  157. if (nextinput <= length(Inputs))
  158. narglist{jj,2} = 'OK_in';
  159. nextinput = nextinput + 1;
  160. else
  161. narglist{jj,1} = '';
  162. narglist{jj,2} = '';
  163. end;
  164. end;
  165. else
  166. if strcmp(narglist{jj,2}, '__output')
  167. if (minval{jj} == 0) % this is a required output
  168. if (nextoutput > nargout & nargout > 1)
  169. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  170. else
  171. narglist{jj,2} = 'OK_out';
  172. nextoutput = nextoutput + 1;
  173. NumReqOutputs = NumReqOutputs-1;
  174. end
  175. else % this is an optional output
  176. if (nargout - nextoutput >= NumReqOutputs)
  177. narglist{jj,2} = 'OK_out';
  178. nextoutput = nextoutput + 1;
  179. else
  180. narglist{jj,1} = '';
  181. narglist{jj,2} = '';
  182. end;
  183. end
  184. end
  185. end
  186. end
  187. if nargout
  188. varargout = cell(1,nargout);
  189. else
  190. varargout = cell(1,1);
  191. end
  192. global KhorosRoot
  193. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  194. w=['"' KhorosRoot];
  195. else
  196. if ispc
  197. w='"C:\Program Files\dip\khorosBin\';
  198. else
  199. [s,w] = system('which cantata');
  200. w=['"' w(1:end-8)];
  201. end
  202. end
  203. [varargout{:}]=callKhoros([w 'blobit" -k'],Inputs,narglist);