Skip to content

Commit

Permalink
- new genDoc
Browse files Browse the repository at this point in the history
- new/faster getPrmDflt

git-svn-id: svn+ssh://lumo.ucsd.edu/projects/p1/svnroot/pdollar/toolbox@8174 52fe0c90-79fe-0310-8a18-a0b98ad248f8
  • Loading branch information
vrabaud committed Feb 12, 2008
1 parent 5f6ecc4 commit a81ef7c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 21 deletions.
1 change: 1 addition & 0 deletions external/history.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Version NEW
-optimized images/imtransform2
-optimized getPrmDflt. New way of using it too.
-minor tweak to images/imrectLite

Version 2.02 (31-Oct-07)
Expand Down
25 changes: 18 additions & 7 deletions external/toolboxGenDoc.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
% toolbox/external/m2html/templates/frame-piotr/overview.html
% 1) The version / date
% 2) Link to rar/zip file
%
% After running, remove links to Subsequent directories (*/private and
% */.svn from):
% doc/classify/menu.html
% doc/iamges/menu.html
% doc/filters/menu.html
% doc/matlab/menu.html
%
% USAGE
% toolboxGenDoc
Expand Down Expand Up @@ -41,3 +34,21 @@

% copy history file
copyfile('external\history.txt','doc/history.txt')

% remove links to .svn and private in the menu.html files
d = { './doc' };

while ~isempty(d)
dTmp = dir(d{1});
for i = 1 : length(dTmp)
name = dTmp(i).name;
if strcmp( name,'.') || strcmp( name,'..'); continue; end
if dTmp(i).isdir; d{end+1} = [ d{1} '/' name ]; continue; end
if ~strcmp( name,'menu.html'); continue; end
fid = fopen( [ d{1} '/' name ], 'r' ); c = fread(fid, '*char')'; fclose( fid );
c = regexprep( c, '<li>([^<]*[<]?[^<]*)\.svn([^<]*[<]?[^<]*)</li>', '');
c = regexprep( c, '<li>([^<]*[<]?[^<]*)private([^<]*[<]?[^<]*)</li>', '');
fid = fopen( [ d{1} '/' name ], 'w' ); fwrite( fid, c ); fclose( fid );
end
d(1) = [];
end
55 changes: 43 additions & 12 deletions matlab/getPrmDflt.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,52 @@

function varargout = getPrmDflt( prm, dfs )

if (iscell(prm)); prm = cell2struct( prm(2:2:end), prm(1:2:end), 2 ); end
if(~isstruct(prm)); error('prm must be a struct'); end
if(mod(length(dfs),2)~=0); error('incorrect num dfs'); end
if(mod(length(dfs),2)~=0); error('odd number of default parameters'); end

for i=1:2:length(dfs)
if( ~isfield(prm,dfs{i}) || isempty(prm.(dfs{i})) )
if(strcmp('REQ',dfs{i+1}))
if (iscell(prm)) && (nargout~=1)
if(mod(length(prm),2)~=0); error('odd number of parameters'); end

varargout=dfs(2:2:end);

for i=1:2:length(dfs)
j = 0;
for k=1:2:length(prm)
if strcmp( dfs{i}, prm{k} )
j=k; break;
end
end

if j==0
if strcmp('REQ',dfs{i+1})
error(['Required field ''' dfs{i} ''' not specified.'] );
end
else
varargout{(i+1)*0.5} = prm{j+1};
end
end
else
if (iscell(prm)); prm = cell2struct( prm(2:2:end), prm(1:2:end), 2 ); end
if(~isstruct(prm)); error('prm must be a struct'); end

toDo = isfield( prm, dfs(1:2:end) );
for i=find(~toDo)
if(strcmp('REQ',dfs{2*i}))
error(['Required field ''' dfs{i} ''' not specified.'] );
else
prm.(dfs{i})=dfs{i+1};
prm.(dfs{2*i-1})=dfs{2*i};
end
end

if nargout==1
varargout(1) = {prm};
else
try
varargout = struct2cell( ordedrfields( prm, dfs ) );
catch
varargout=cell(1,nargout);
for i=1:2:length(dfs)
varargout((i+1)/2)={prm.(dfs{i})};
end
end
end
end
if nargout==1; varargout(1)={prm}; return; end
varargout=cell(1,nargout);
for i=1:2:length(dfs)
varargout((i+1)/2)={prm.(dfs{i})};
end
2 changes: 1 addition & 1 deletion matlab/isfield2.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Similar to isfield but also test whether fields are intitialized.
% Similar to isfield but also test whether fields are initialized.
%
% A more comprehensive test of what fields are present [and optionally
% initialized] in a stuct S. fs is either a single field name or a cell
Expand Down
2 changes: 1 addition & 1 deletion matlab/rotationMatrix.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

function varargout=rotationMatrix(varargin)

%%% Find the closest rotation matrix
%%% Find the closest orthonormal matrix
if all(size(varargin{1})==[3 3]) && nargout<=1
[U,S,V]=svd(varargin{1});
varargout{1}=U*V';
Expand Down

0 comments on commit a81ef7c

Please sign in to comment.