source: trunk/src/update_imadoc.m @ 62

Last change on this file since 62 was 29, checked in by sommeria, 14 years ago

read_imadoc suppressed (obsolete, replaced by imadoc2struct)
update_imadoc: bug repaired: existing xml file was erased
various cleaning (deals with non existing input file for series and uvmat)

File size: 1.5 KB
Line 
1%'update_imadoc': update an xml file with geometric calibration parameters
2%--------------------------------------------------------------------------
3%  function update_imadoc(GeometryCalib,outputfile)
4%
5%INPUT:
6% GeometryCalib: structure containing the calibration parameters
7% outputfile: xml file to modify
8%-------------------------------------------------------------
9function update_imadoc(GeometryCalib,outputfile)
10testappend=0;
11if exist(outputfile,'file');%=1 if the output file already exists, 0 else 
12    testappend=1;
13    t=xmltree(outputfile); %read the file
14    backupfile=outputfile;
15    testexist=2;
16    while testexist==2
17       backupfile=[backupfile '~'];
18       testexist=exist(backupfile,'file');
19    end
20    [success,message]=copyfile(outputfile,backupfile);%make backup
21    uid=find(t,'ImaDoc');
22    if ~isequal(uid,1)
23        return
24    end
25       
26    %if the xml file is  ImaDoc
27    uid_calib=find(t,'ImaDoc/GeometryCalib');
28    if isempty(uid_calib)  %if GeometryCalib does not already exists, create it
29        [t,uid_calib]=add(t,1,'element','GeometryCalib');
30    else %if GeometryCalib already exists, delete its content
31        if isequal(success,1)
32            delete(outputfile)
33        else
34            return
35        end
36        uid_child=children(t,uid_calib);
37        t=delete(t,uid_child);
38    end
39end
40if ~testappend
41    t=xmltree;
42    t=set(t,1,'name','ImaDoc');
43    [t,uid_calib]=add(t,1,'element','GeometryCalib');
44end
45t=struct2xml(GeometryCalib,t,uid_calib);
46save(t,outputfile);
Note: See TracBrowser for help on using the repository browser.