Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 173)
+++ /trunk/src/civ.m	(revision 174)
@@ -267,15 +267,24 @@
     oldfile=filebase;
 end
-testall=get(handles.ImaDoc,'UserData');
+% testall=get(handles.ImaDoc,'UserData');
 ind_opening=1;%default
 browse.incr_pair=[0 0]; %default
-if testall
-    menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
-        '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'};
-else % menu selecting only .civ or .avi files
-    menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
-        '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';...
-        '*.*', 'All Files (*.*)'};
-end
+% if testall
+%     menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
+%         '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'};
+% else % menu selecting only .civ or .avi files
+ menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
+       '*.xml',  '.xml files '; ...
+        '*.civ',  '.civ files '; ...
+        '*.png','.png image files'; ...
+        '*.jpg',' jpeg image files'; ...
+        '*.tif','.tif image files'; ...
+        '*.avi;*.AVI','.avi movie files'; ...
+        '*.nc','.netcdf files'; ...
+        '*.*',  'All Files (*.*)'};
+   % menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
+     %   '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';...
+    %    '*.*', 'All Files (*.*)'};
+% end
 [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile);
 fileinput=[PathName FileName];%complete file name
@@ -431,6 +440,6 @@
 end
 set(handles.browse_root,'UserData',browse);% store information from browser
-testall=isequal(menu(filtindex,1),{'*.*'});
-set(handles.ImaDoc,'UserData',testall);
+% testall=isequal(menu(filtindex,1),{'*.*'});
+% set(handles.ImaDoc,'UserData',testall);
 
 RootName_Callback(hObject, eventdata, handles);
@@ -1868,13 +1877,14 @@
             civAllxml=set(civAllxml,1,'name','CivDoc');
         end
-        filename_cmx=filecell.nc.civ1{ifile,j};%output netcdf file
-        filename_cmx(end-1:end+1)='cmx';%name of cmx file
+        %filename_cur=filecell.nc.civ1{ifile,j};%output netcdf file
+        [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention)
+        %filename_cmx(end-1:end+6)='civ1.cmx';%name of cmx file
         if batch
-            [Rootbat,Filebat,extbat]=fileparts(filename_cmx);
-            filename_bat=fullfile(Rootbat,['job_' Filebat extbat]);
+%             [Rootbat,Filebat,extbat]=fileparts(filename_cmx);
+            filename_bat=fullfile(Rootbat,['job_' Filebat]);
          else
-            filename_bat=filename_cmx;
-        end
-        filename_bat(end-2:end)='bat';
+            filename_bat=fullfile(Rootbat,Filebat);
+        end
+        filename_bat=[filename_bat '.bat'];
         
         %CIV1
@@ -1882,5 +1892,5 @@
             par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j};
             par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j};
-            namelog=[filename_cmx([1:end-3]) 'log'];
+            namelog=[fullfile(Rootbat,Filebat) '.civ1.log'];
             par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j)));
             par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2);
@@ -1935,8 +1945,8 @@
             i_cmd=i_cmd+1;
             if isequal(civAll,0)
-                cmd=[cmd CIV1_CMD(filename_cmx(1:end-4),namelog,par_civ1,handles,sparam) '\n'];
+                cmd=[cmd CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam) '\n'];
             else
                 civAllCmd=[civAllCmd ' civ1 '];
-                str=CIV1_CMD_Unified(filename_cmx([1:end-4]),namelog,par_civ1);
+                str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1);
                 fieldnames=fields(str);
                 [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1');
@@ -2054,5 +2064,6 @@
             par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j};
             %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension
-            namelog=[filename_cmx([1:end-3]) 'log'];
+            [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention)
+            namelog=[fullfile(Rootbat,Filebat) '.civ2.log'];
             par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j)));
             par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2);
@@ -2108,11 +2119,12 @@
             %endTESTgrid
             i_cmd=i_cmd+1;
-            cmd_CIV2=CIV2_CMD(filename_cmx(1:end-4),namelog,par_civ2,sparam);
+            cmd_CIV2=CIV2_CMD(fullfile(Rootbat,Filebat),[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx]
             if isequal(civAll,0)
+                flname=fullfile(Rootbat,Filebat);
                 if(isunix)
-                    cmd=[cmd 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2 '\n'];
+                     cmd=[cmd 'cp -f ' flname '.civ2.cmx ' flname '.cmx\n' cmd_CIV2 '\n'];
                 else
-                    filename_cmx=regexprep(filename_cmx,'\\','\\\\');
-                    cmd=[cmd 'copy /Y "' filename_cmx '2" "' filename_cmx '"\n' cmd_CIV2 '\n'];
+                    flname=regexprep(flname,'\\','\\\\');
+                    cmd=[cmd 'copy /Y "' flname '.civ2.cmx" "' flname '.cmx"\n' cmd_CIV2 '\n'];
                 end
             else
@@ -2253,5 +2265,4 @@
             end
             super_cmd=[super_cmd cmd_str '\n'];         
-            %             eval(cmd_str);
             disp(cmd_str);
         end
@@ -2478,5 +2489,5 @@
 subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data
 subdir_civ2=get(handles.subdir_civ2,'String');
-if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir
+if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir
 if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir
 currentdir=pwd;%store the current working directory
@@ -2708,5 +2719,5 @@
         %create the new subdir_civ2_new
         if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir')
-            [xx,m2]=mkdir(subdir_civ2_new);
+            [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new));
             [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g)
             if ~isequal(m2,'')
@@ -4043,5 +4054,5 @@
 
 %changes : filename_cmx -> filename ( no extension )
-
+% input namelog not used
 if isequal(par.Dt,'0')
     par.Dt='1' ;%case of 'displacement' mode
@@ -4086,13 +4097,19 @@
 % namelog=regexprep(namelog,'\\','\\\\');
 if(isunix)
-    [Rootbat,Filebat,extbat]=fileparts(namelog);
-    ncName=fullfile(Rootbat,[ Filebat '.nc']);
-    cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file
-    cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog  ' ' regexprep(namelog,'\.log','') '.civ1.log' '\n' 'chmod g+w ' ncName];
+%     filename
+%     namelog
+%     
+%     [Rootbat,Filebat,extbat]=fileparts(namelog);
+%     ncName=fullfile(Rootbat,[ Filebat '.nc']);
+    cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx
+    cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting
+    cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx
 else %Windows system
+    filename=regexprep(filename,'\\','\\\\');
     cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file
     cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\');
     namelog=regexprep(namelog,'\\','\\\\');
-    cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' namelog '" "' regexprep(namelog,'\.log','') '.civ1.log"']; 
+    cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; 
+    cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"'];
 end
 
@@ -4197,8 +4214,12 @@
     par.Dt='1' ;%case of 'displacement' mode
 end
-
 par.filename_ima_a=regexprep(par.filename_ima_a,'.png','');
 par.filename_ima_b=regexprep(par.filename_ima_b,'.png','');% bug : .png appears two times ?
-fid=fopen([filename '.cmx2'],'w');
+[fid,errormsg]=fopen([filename '.civ2.cmx'],'w');
+if isequal(fid,-1)
+    msgbox_uvmat('ERROR',errormsg)
+    cmd_CIV2='';
+    return
+end
 fprintf(fid,['##############   CMX file' '\n' ]);
 fprintf(fid,   ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility
@@ -4234,13 +4255,20 @@
 
 if(isunix)
-    cmd_CIV2=[sparam.Civ2Bin ' -f ' filename  '.cmx >' filename '.log' ]; % redirect standard output to the log file
-    [Rootbat,Filebat,extbat]=fileparts(namelog);
-    ncName=fullfile(Rootbat,[ Filebat '.nc']);
-    cmd_CIV2=[cmd_CIV2 '\n' 'mv ' namelog  ' ' regexprep(namelog,'\.log','') '.civ2.log' '\n' 'chmod g+w ' ncName];
+%         cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx
+%     cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];
+%     cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx, the result file is named [filename '.nc'] by CIVx
+    
+    cmd_CIV2=[sparam.Civ2Bin ' -f ' filename  '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx
+    cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];
+    cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.civ2.cmx' '\n'];%rename .cmx as .civ2.cmx, the result file is named [filename '.nc'] by CIVx
+%     [Rootbat,Filebat,extbat]=fileparts(namelog);
+%     ncName=fullfile(Rootbat,[ Filebat '.nc']);
+%    cmd_CIV2=[cmd_CIV2 '\n' 'mv ' namelog  ' ' regexprep(namelog,'\.log','') '.civ2.log' '\n' 'chmod g+w ' ncName];
 else 
+    filename=regexprep(filename,'\\','\\\\');
     cmd_CIV2=['"' sparam.Civ2Bin '" -f "' filename  '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file
     cmd_CIV2=regexprep(cmd_CIV2,'\\','\\\\');
-    namelog=regexprep(namelog,'\\','\\\\');
-    cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' namelog '" "' regexprep(namelog,'\.log','') '.civ2.log"'];
+    cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"'];
+     cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ2.cmx"'];
 end
 
Index: /trunk/src/proj_field.m
===================================================================
--- /trunk/src/proj_field.m	(revision 173)
+++ /trunk/src/proj_field.m	(revision 174)
@@ -918,6 +918,5 @@
 %-----------------------------------------------------------------
 
-%initialisation of the input parameters of the projection plane
-%-----------------------------------------------------------------
+%% initialisation of the input parameters of the projection plane
 ProjMode='projection';%direct projection by default
 if isfield(ObjectData,'ProjMode'),ProjMode=ObjectData.ProjMode; end;
@@ -948,11 +947,4 @@
 NormVec_Y=cos(Phi)*sin(Theta);
 NormVec_Z=cos(Theta);
-
-% test for 3D fields
-test3D=0;
-if isfield(FieldData,'nb_dim')
-    test3D=isequal(FieldData.nb_dim,3);
-end
-test3C=test3D; %default 3 vel components
 
 %mesh sizes DX and DY
@@ -1248,5 +1240,5 @@
         Coord_y=[];
         Coord_x=[];   
-        nb_dim=numel(size(DimValue));
+        nb_dim=numel(DimValue);
         for idim=1:nb_dim %loop on space dimensions
             test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
@@ -1296,5 +1288,5 @@
         if nb_dim==3
             DZ=abs(DCoord_min(1));
-            Coord_z=linspace(Coord{1}(1),Coord{1}(end),npz);
+            Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));
             test_direct_z=test_direct(1);
         end  
@@ -1342,5 +1334,5 @@
         % case with no rotation and interpolation
         if isequal(ProjMode,'projection') && isequal(Phi,0) && isequal(Theta,0) && isequal(Psi,0)
-            if ~testXMin && ~testXMax && ~testYMin && ~testYMax
+            if ~testXMin && ~testXMax && ~testYMin && ~testYMax && nb_dim==2
                 ProjData=FieldData; 
             else
@@ -1367,4 +1359,10 @@
                     Xbound(1)=Coord{2}(1)+DXinit*(min_ind2-1);
                 end 
+                if nb_dim==3 %TODO: to update 
+                    min_ind3=ceil((Coord{1}(1)-ZMax)/DZinit)+1;
+                    max_ind2=floor((Coord{1}(2)-XMin)/DZinit)+1;
+                    Zbound(2)=Coord{1}(1)+DXinit*(max_ind2-1);
+                    Zbound(1)=Coord{1}(1)+DXinit*(min_ind2-1);
+                end
                 min_ind1=max(min_ind1,1);% deals with margin (bound lower than the first index)
                 min_ind2=max(min_ind2,1);
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 173)
+++ /trunk/src/uvmat.m	(revision 174)
@@ -426,5 +426,5 @@
 end
 [FileName, PathName] = uigetfile( ...
-       {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx ,*.fig,*.log,*.dat,*.bat)';
+       {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx,*.fig,*.log,*.dat,*.bat)';
        '*.xml',  '.xml files '; ...
         '*.xls',  '.xls files '; ...
@@ -437,6 +437,5 @@
         '*.nc','.netcdf files'; ...
         '*.cdf','.netcdf files'; ...
-        '*.cmx','.cmx text files';...
-        '*.cmx2','.cmx2 text files';...
+        '*.cmx','.cmx text files ';...
         '*.fig','.fig files (matlab fig)';...
         '*.log','.log text files ';...
@@ -2205,4 +2204,5 @@
 %read images
 if ~isempty(filename) && isequal(FieldName,'image')
+    Npz=1;%default
      switch FileType
         case 'movie'
@@ -2223,4 +2223,8 @@
         case 'vol'
             A=imread(filename);
+            if isfield(UvData.XmlData,'Npy')
+                Npz=size(A,1)/UvData.XmlData.Npy;
+                A=reshape(A,Npz,UvData.XmlData.Npy,UvData.XmlData.Npx);
+            end
         case 'multimage'
             A=imread(filename,num_i1);
@@ -2235,13 +2239,22 @@
     Field{1}.AName='image';
     Field{1}.ListVarName={'AY','AX','A'}; % 
-    if size(A,3)==3;%color
-        Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
+    if ndims(A)==3 
+        if Npz==1;%color
+             Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
+             Field{1}.AY=[npxy(1)-0.5 0.5];
+             Field{1}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
+        else
+            Field{1}.ListVarName=['AZ' Field{1}.ListVarName];
+            Field{1}.VarDimName={'AZ','AY','AX',{'AZ','AY','AX'}}; 
+            Field{1}.AZ=[0.5 npxy(1)-0.5];
+            Field{1}.AY=[npxy(2)-0.5 0.5];
+            Field{1}.AX=[0.5 npxy(3)-0.5]; % coordinates of the first and last pixel centers
+        end
     else
         Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
-    end
-    Field{1}.AY=Rangy;
-    Field{1}.AX=Rangx;
+        Field{1}.AY=[npxy(1)-0.5 0.5];
+       Field{1}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
+    end
     Field{1}.A=A;
-   % Field{1}.CoordType='px'; %used for mouse_motion
     Field{1}.CoordUnit='pixel'; %used for mouse_motion
 end
@@ -2488,6 +2501,6 @@
 test_x=0;
 test_z=0;% test for unstructured z coordinate
-UvData.ZMax=0;
-UvData.ZMin=0;%default
+% UvData.ZMax=0;
+% UvData.ZMin=0;%default
 %UvData.Mesh=1; %default
 [UvData.Field,errormsg]=check_field_structure(UvData.Field);
@@ -2522,6 +2535,7 @@
     YName=UvData.Field.ListVarName{VarType{imax}.coord(2)};
     XName=UvData.Field.ListVarName{VarType{imax}.coord(3)};
-end
-
+    eval(['ZMax=max(UvData.Field.' ZName ');'])
+    eval(['ZMin=min(UvData.Field.' ZName ');'])
+end
 eval(['XMax=max(UvData.Field.' XName ');'])
 eval(['XMin=min(UvData.Field.' XName ');'])
@@ -2565,5 +2579,5 @@
 UvData.Field.YMax=XMax;
 UvData.Field.YMin=XMin;
-if test_z
+if NbDim==3
     UvData.Field.ZMax=ZMax;
     UvData.Field.ZMin=ZMin;
@@ -2642,6 +2656,6 @@
 if NbDim==3 && UvData.NewSeries
     UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
-    UvData.Object{1}.RangeZ=Field.Mesh;%main plotting plane
-    UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
+    UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
+    UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
     UvData.Object{1}.Phi=0;
     UvData.Object{1}.Theta=0;
@@ -2649,6 +2663,6 @@
     UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR  
     PlotHandles=get_plot_handles(handles);
-    ZBounds(1)=UvData.ZMin; %minimum for the Z slider
-    ZBounds(2)=UvData.ZMax;%maximum for the Z slider
+    ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
+    ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
     UvData.Object{1}.Name='1-PLANE';
     UvData.Object{1}.enable_plot=1;
