Home > polypedal > crosstrack > tkTrackbackpack_trackdir_occl.m

tkTrackbackpack_trackdir_occl

PURPOSE ^

recursively checks this and sub dirs form *stps.mat files and extracts

SYNOPSIS ^

function tkTrackbackpack_trackdir_occl(thedir);

DESCRIPTION ^

 recursively checks this and sub dirs form *stps.mat files and extracts
 their step data, adding to a big catalog.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function tkTrackbackpack_trackdir_occl(thedir);
0002 % recursively checks this and sub dirs form *stps.mat files and extracts
0003 % their step data, adding to a big catalog.
0004 
0005 if nargin == 0
0006     thedir = pwd;
0007 end
0008 
0009 files = dir( thedir );
0010 files = files(3:end);
0011 disp( sprintf( 'Scanning directory %s', thedir ) );
0012 
0013 for i = 1:length(files)
0014     if( files(i).isdir == 0 )
0015         % see if it's a track file: if so, process
0016         if( strfind( files(i).name, 'track.mat' ) )
0017             disp( sprintf( '  Processing %s', files(i).name ) );
0018             
0019             cd( thedir );
0020             
0021             % make sure file has 'ts' var:
0022             varnames = whos( '-file', files(i).name );
0023             % returns struct array with name field:
0024             found = false;
0025             for j = 1:length(varnames)
0026                 if strcmp( varnames(j).name, 'ts' )
0027                     found = true;
0028                 end
0029             end
0030 
0031             if found
0032                 load( files(i).name, 'ts' );
0033 
0034                 if ~isfield( ts, 'x' )
0035                     if ~isfield( ts, 'toptrack' )
0036                         try
0037                             ts = tkTrackbackpack_tracktop( ts );
0038                             save( files(i).name, 'ts' );
0039                             disp( '    Saved file after tracking top.'  );
0040                         catch
0041                             disp( '    ...Failed in top tracking'  );
0042                         end
0043                     else
0044                         disp( '    Found existing toptrack field. Using it...'  );
0045                     end
0046 
0047                     % have or successfully tracked top pin:
0048                     try
0049                         ts = tkTrackbackpack_trackcross_occl( ts );
0050                         tkTrackbackpack_plotresult( ts, true );
0051                         save( files(i).name, 'ts' );
0052                         disp( '    Saved file after tracking cross.'  );
0053                     catch
0054                         disp( '    ...Failed in cross tracking'  );
0055                     end
0056                 else
0057                     disp( '    File already has x variable--presumably already tracked.' );
0058                 end
0059             else
0060                 disp( '    No ts variable in this file.' );
0061             end
0062         end % if strfind( 'track')
0063     else
0064         % it's a directory: recursively call us on it:
0065         if 1  % this could be dangerous, lets do one dir at a time
0066             if files(i).name ~= '.' | files(i).name ~= '..'
0067                 tkTrackbackpack_trackdir( fullfile( thedir, files(i).name ) );
0068             end
0069         end
0070     end
0071 end

Generated on Mon 02-Aug-2010 16:44:38 by m2html © 2003