source: trunk/src/update_imadoc.m @ 17

Last change on this file since 17 was 17, checked in by sommeria, 11 years ago

possibilite de créer une grille physique dans geometry_calib (le faire apres avoir introduit les points sur l'image avec la souris)
petites corrections mineures sur les autres fichiers

File size: 1.8 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    t=xmltree(outputfile); %read the file
13    backupfile=outputfile;
14    testexist=2;
15    while testexist==2
16       backupfile=[backupfile '~'];
17       testexist=exist(backupfile,'file');
18    end
19    [success,message]=copyfile(outputfile,backupfile);%make backup
20    uid=find(t,'ImaDoc');
21    if ~isequal(uid,1)
22        return
23    end
24       
25    %if the xml file is  ImaDoc
26    uid_calib=find(t,'ImaDoc/GeometryCalib');
27    if isempty(uid_calib)  %if GeometryCalib does not already exists, create it
28        [t,uid_calib]=add(t,1,'element','GeometryCalib');
29    else %if GeometryCalib already exists, delete its content
30%         backupfile=outputfile;
31%         testexist=2;
32%         while testexist==2
33%            backupfile=[backupfile '~'];
34%            testexist=exist(backupfile,'file');
35%         end
36%         [success,message]=copyfile(outputfile,backupfile);%make backup
37        if isequal(success,1)
38            delete(outputfile)
39        else
40            return
41        end
42        uid_child=children(t,uid_calib);
43        t=delete(t,uid_child);
44        testappend=1;
45    end
46end
47if ~testappend
48    t=xmltree;
49    t=set(t,1,'name','ImaDoc');
50    [t,uid_calib]=add(t,1,'element','GeometryCalib');
51%     t=struct2xml(GeometryCalib,t,uid_calib);
52end
53t=struct2xml(GeometryCalib,t,uid_calib);
54save(t,outputfile);
Note: See TracBrowser for help on using the repository browser.