Index: trunk/src/proj_field.m
===================================================================
--- trunk/src/proj_field.m	(revision 1027)
+++ trunk/src/proj_field.m	(revision 1045)
@@ -554,13 +554,12 @@
     return
 end
-CellInfo=CellInfo(NbDim>=2); %keep only the 2D cells
-%%%%%% TODO: treat 1D fields: project as identity so that P o P=P for projection operation
+CellInfo=CellInfo(NbDim>=2); %keep only the 2D or 3D cells
 cell_select=true(size(CellInfo));
 
 for icell=1:length(CellInfo)
     if isfield(CellInfo{icell},'ProjModeRequest')
-        if ~strcmp(CellInfo{icell}.ProjModeRequest, ProjMode)
-            cell_select(icell)=0;
-        end
+%         if ~strcmp(CellInfo{icell}.ProjModeRequest, ProjMode)
+%             cell_select(icell)=0;
+%         end
         if strcmp(ProjMode,'interp_tps')&& ~strcmp(CellInfo{icell}.CoordType,'tps')
             cell_select(icell)=0;
@@ -851,8 +850,4 @@
                 end
                 
-                
-                
-                
-                
             else
                 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
@@ -929,4 +924,6 @@
                 ProjData.ListVarName=[ProjData.ListVarName {AXName}];
                 ProjData.VarDimName=[ProjData.VarDimName {AXName}];
+                nbvar=numel(ProjData.VarDimName);
+                ProjData.VarAttribute{nbvar}.Role='coord_x';
                 for ivar=VarIndex
                     %VarName{ivar}=FieldData.ListVarName{ivar};
@@ -950,5 +947,6 @@
                     ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName{ivar}];
                     ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate
-                    ProjData.VarAttribute{ivar}.Role='continuous';% for plot with continuous line
+                    nbvar=nbvar+1;
+                    ProjData.VarAttribute{nbvar}.Role='coord_y';% for plot with continuous line
                 end
                 if nbcolor==3
@@ -1122,8 +1120,10 @@
 
 check_grid=zeros(size(CellInfo));% =1 if a grid is needed , =0 otherwise, for each field cell
-ProjMode=cell(size(CellInfo));
-for icell=1:numel(CellInfo)
-    ProjMode{icell}=ObjectData.ProjMode;% projection mode of the plane object
-end
+ProjMode=num2cell(blanks(numel(CellInfo)));
+ProjMode=regexprep(ProjMode,' ',ObjectData.ProjMode);
+%ProjMode=cell(size(CellInfo));
+% for icell=1:numel(CellInfo)
+%     ProjMode{icell}=ObjectData.ProjMode;% projection mode of the plane object
+% end
 icell_grid=[];% field cell index which defines the grid
 if ~strcmp(ObjectData.ProjMode,'projection')&& ~strcmp(ObjectData.Type,'plane_z')% TODO:rationalize
@@ -1202,5 +1202,6 @@
     ProjData.ListVarName={AYName,AXName};
     
-    ProjData.VarAttribute={[],[]};
+    ProjData.VarAttribute{1}.Role='coord_y';
+    ProjData.VarAttribute{2}.Role='coord_x';
 end
     
@@ -1219,5 +1220,5 @@
         continue % only cells represnting 2D or 3D fields are involved
     end
-    VarIndex=CellInfo{icell}.VarIndex;%  indices of the selected variables in the list FieldData.ListVarName
+    VarIndex= CellInfo{icell}.VarIndex;%  indices of the selected variables in the list FieldData.ListVarName
     %dimensions
     DimCell=FieldData.VarDimName{VarIndex(1)};
@@ -1237,9 +1238,9 @@
                 continue %skip for next cell (needs tps field cell)
             end
-            coord_x=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)});% initial x coordinates
-            coord_y=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)});% initial y coordinates
+            coord_x=FieldData.(CellInfo{icell}.XName);% initial x coordinates
+            coord_y=FieldData.(CellInfo{icell}.YName);% initial y coordinates
             check3D=(numel(CellInfo{icell}.CoordIndex)==3);
             if check3D
-                coord_z=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)});
+                coord_z=FieldData.(CellInfo{icell}.ZName);
             end
             
@@ -1256,5 +1257,5 @@
                 fieldZ=norm_plane(1)*coord_x + norm_plane(2)*coord_y+ norm_plane(3)*coord_z;% distance to the plane
                 indcut=find(abs(fieldZ) <= width);
-                for ivar=VarIndex
+                for ivar=[CellInfo{icell}.CoordIndex CellInfo{icell}.VarIndex]
                     VarName=FieldData.ListVarName{ivar};
                     FieldData.(VarName)=FieldData.(VarName)(indcut);
@@ -1305,5 +1306,5 @@
                     return
                 end
-                for ivar=VarIndex
+                for ivar=[CellInfo{icell}.CoordIndex CellInfo{icell}.VarIndex]
                     VarName=FieldData.ListVarName{ivar};
                     FieldData.(VarName)=FieldData.(VarName)(indcut);
@@ -1321,5 +1322,5 @@
                     nbvar=0;
                     %nbvar=numel(ProjData.ListVarName);
-                    for ivar=VarIndex %transfer variables to the projection plane
+                    for ivar=[CellInfo{icell}.CoordIndex CellInfo{icell}.VarIndex] %transfer variables to the projection plane
                         VarName=FieldData.ListVarName{ivar};
                         if ivar==CellInfo{icell}.CoordIndex(end)
@@ -1401,6 +1402,6 @@
                 SubRange=FieldData.(FieldData.ListVarName{CellInfo{icell}.SubRange_tps});
                 checkUV=0;
-                if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')
-                    FieldVar=cat(3,FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x_tps}),FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y_tps}));
+                if strcmp(CellInfo{icell}.VarType,'vector')
+                    FieldVar=cat(3,FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}),FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}));
                     checkUV=1;
                 end
