Changeset 4330


Ignore:
Timestamp:
06/30/10 08:52:00 (15 years ago)
Author:
Mathieu Morlighem
Message:

enabled patch plotting

Location:
issm/trunk/src/m/classes/public/plot
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/public/plot/plot_basaldrag.m

    r3994 r4330  
    3939
    4040        %process data and model
    41         [x y z elements is2d]=processmesh(md,options);
    42         [basal_drag isongrid isquiver]=processdata(md,drag,options);
     41        [x y z elements is2d]=processmesh(md,[],options);
     42        [basal_drag datatype]=processdata(md,drag,options);
    4343
    4444        %plot basaldrag
    4545        subplot(width,width,i);
    46         plot_unit(x,y,z,elements,basal_drag,isongrid,is2d,isquiver,options);
     46        plot_unit(x,y,z,elements,basal_drag,is2d,datatype,options);
    4747
    4848        %apply options
  • issm/trunk/src/m/classes/public/plot/plot_boundaries.m

    r2439 r4330  
    1313        options=removefield(options,'layer',1);
    1414end
    15 [x y z elements is2d]=processmesh(md,options);
     15[x y z elements is2d]=processmesh(md,[],options);
    1616
    1717for i=1:size(md.segments,1),
  • issm/trunk/src/m/classes/public/plot/plot_contour.m

    r2439 r4330  
    88
    99%process data and model
    10 [x y z index is2d]=processmesh(md,options);
    11 [data isongrid isquiver]=processdata(md,datain,options);
     10[x y z index is2d]=processmesh(md,[],options);
     11[data datatype]=processdata(md,datain,options);
    1212
    1313%check is2d
     
    1717
    1818%first, process data: must be on grids
    19 if isquiver
     19if datatype==2,
    2020        %take norm
    2121        data=sqrt(sum(datain.*datain,2));
    22 end
    23 if ~isongrid
     22elseif datatype==1,
    2423        %take average
    2524        data=averaging(md,data,0);
     25else
     26        error('datatype not supported yet');
    2627end
    2728
  • issm/trunk/src/m/classes/public/plot/plot_drivingstress.m

    r2439 r4330  
    1111
    1212%process data and model
    13 [x y z elements is2d]=processmesh(md,options);
    14 [dstress isongrid isquiver]=processdata(md,s,options);
     13[x y z elements is2d]=processmesh(md,[],options);
     14[dstress datatype]=processdata(md,s,options);
    1515dstress=dstress/1000;
    1616
    1717%plot mesh quivervel
    1818subplot(width,width,i);
    19 plot_unit(x,y,z,elements,dstress,isongrid,is2d,isquiver,options)
     19plot_unit(x,y,z,elements,dstress,is2d,datatype,options)
    2020
    2121%apply options
  • issm/trunk/src/m/classes/public/plot/plot_elementnumbering.m

    r2439 r4330  
    1010
    1111%process data and model
    12 [x y z elements is2d]=processmesh(md,options);
    13 [elementnumbers isgrid]=processdata(md,[1:md.numberofelements]',options);
     12[x y z elements is2d]=processmesh(md,[],options);
     13[elementnumbers datatype]=processdata(md,[1:md.numberofelements]',options);
    1414
    1515%plot
  • issm/trunk/src/m/classes/public/plot/plot_elementstype.m

    r2439 r4330  
    88
    99%process data and model
    10 [x y z elements is2d]=processmesh(md,options);
    11 [data1 isongrid isquiver]=processdata(md,md.elements_type(:,1),options);
    12 [data2 isongrid isquiver]=processdata(md,md.elements_type(:,2),options);
     10[x y z elements is2d]=processmesh(md,[],options);
     11[data1 datatype]=processdata(md,md.elements_type(:,1),options);
     12[data2 datatype]=processdata(md,md.elements_type(:,2),options);
    1313data=[data1 data2];
    1414
  • issm/trunk/src/m/classes/public/plot/plot_gridnumbering.m

    r2439 r4330  
    88
    99%process data and model
    10 [x y z elements is2d]=processmesh(md,options);
    11 [gridnumbers isongrid isquiver]=processdata(md,[1:md.numberofgrids]',options);
     10[x y z elements is2d]=processmesh(md,[],options);
     11[gridnumbers datatype]=processdata(md,[1:md.numberofgrids]',options);
    1212
    1313%plot
  • issm/trunk/src/m/classes/public/plot/plot_highlightelements.m

    r2439 r4330  
    1111
    1212%process data and model
    13 [x y z elements is2d]=processmesh(md,options);
    14 [elementnumbers isgrid]=processdata(md,[1:md.numberofelements]',options);
     13[x y z elements is2d]=processmesh(md,[],options);
     14[elementnumbers datatype]=processdata(md,[1:md.numberofelements]',options);
    1515
    1616%plot
  • issm/trunk/src/m/classes/public/plot/plot_highlightgrids.m

    r2511 r4330  
    88
    99%process data and model
    10 [x y z elements is2d]=processmesh(md,options);
    11 [gridnumbers isongrid isquiver]=processdata(md,[1:md.numberofgrids]',options);
     10[x y z elements is2d]=processmesh(md,[],options);
     11[gridnumbers datatype]=processdata(md,[1:md.numberofgrids]',options);
    1212
    1313%plot
  • issm/trunk/src/m/classes/public/plot/plot_importancefactors.m

    r2439 r4330  
    6464
    6565%process data and model
    66 [x y z elements is2d]=processmesh(md,options);
     66[x y z elements is2d]=processmesh(md,[],options);
    6767
    6868%edgecolor
  • issm/trunk/src/m/classes/public/plot/plot_manager.m

    r3547 r4330  
    127127
    128128%process data and model
    129 [x y z elements is2d]=processmesh(md,options);
    130 [data2 isongrid isquiver]=processdata(md,data,options);
     129[x y z elements is2d]=processmesh(md,data,options);
     130[data2 datatype]=processdata(md,data,options);
    131131
    132132%standard plot:
     
    139139
    140140%plot unit
    141 plot_unit(x,y,z,elements,data2,isongrid,is2d,isquiver,options);
     141plot_unit(x,y,z,elements,data2,is2d,datatype,options);
    142142
    143143%apply all options
    144 if isquiver
     144if datatype==3,
    145145        options=changefieldvalue(options,'colorbar',2);
     146        if exist(options,'contourlevels'),
     147                data2=data;
     148        end
    146149end
    147 if isquiver & exist(options,'contourlevels'),
    148         data2=data;
    149 end
     150
    150151applyoptions(md,data2,options);
    151152
     
    169170        axes('pos',PosInset);
    170171        box('on')
    171         plot_unit(x,y,z,elements,data2,isongrid,is2d,isquiver,options);
     172        plot_unit(x,y,z,elements,data2,is2d,datatype,options);
    172173
    173174        %applay options
  • issm/trunk/src/m/classes/public/plot/plot_mesh.m

    r2871 r4330  
    88
    99%process data and model
    10 [x y z elements is2d]=processmesh(md,options);
     10[x y z elements is2d]=processmesh(md,[],options);
    1111
    1212%plot mesh
  • issm/trunk/src/m/classes/public/plot/plot_overlay.m

    r3547 r4330  
    88
    99%process mesh and data
    10 [x y z elements is2d]=processmesh(md,options);
    11 [data isongrid isquiver]=processdata(md,data,options);
     10[x y z elements is2d]=processmesh(md,[],options);
     11[data datatype]=processdata(md,data,options);
    1212
    1313%check is2d
     
    1515        error('buildoverlay error message: overlay not supported for 3d meshes, project on a layer');
    1616end
    17 if isquiver
     17if datatype==3,
    1818        error('buildoverlay error message: overlay not supported for quiver plots');
    1919end
  • issm/trunk/src/m/classes/public/plot/plot_penalties.m

    r3994 r4330  
    88
    99%process data and model
    10 [x y z elements is2d]=processmesh(md,options);
     10[x y z elements is2d]=processmesh(md,[],options);
    1111
    1212%plot mesh penalties
  • issm/trunk/src/m/classes/public/plot/plot_pressureload.m

    r3994 r4330  
    1111
    1212%process mesh and data
    13 [x y z elements is2d]=processmesh(md,options);
     13[x y z elements is2d]=processmesh(md,[],options);
    1414pressureload=md.pressureload;
    1515
  • issm/trunk/src/m/classes/public/plot/plot_riftfraction.m

    r3202 r4330  
    1313
    1414%process data and model
    15 [x y z elements is2d]=processmesh(md,options);
     15[x y z elements is2d]=processmesh(md,[],options);
    1616
    1717subplot(nlines,ncols,index);
  • issm/trunk/src/m/classes/public/plot/plot_riftpenetration.m

    r3202 r4330  
    88
    99%process data and model
    10 [x y z elements is2d]=processmesh(md,options);
     10[x y z elements is2d]=processmesh(md,[],options);
    1111
    1212subplot(nlines,ncols,index);
  • issm/trunk/src/m/classes/public/plot/plot_riftrelvel.m

    r3202 r4330  
    2626
    2727%process data and model
    28 [x y z elements is2d]=processmesh(md,options);
    29 [vel isongrid isquiver]=processdata(md,[u v],options);
     28[x y z elements is2d]=processmesh(md,[],options);
     29[vel datatype]=processdata(md,[u v],options);
    3030[quivers,palette]=quiver_process(x,y,vel(:,1),vel(:,2),options);
    3131
  • issm/trunk/src/m/classes/public/plot/plot_rifts.m

    r3260 r4330  
    88
    99%process data and model
    10 [x y z elements is2d]=processmesh(md,options);
     10[x y z elements is2d]=processmesh(md,[],options);
    1111
    1212%plot mesh
  • issm/trunk/src/m/classes/public/plot/plot_riftvel.m

    r3202 r4330  
    2626
    2727%process data and model
    28 [x y z elements is2d]=processmesh(md,options);
    29 [vel isongrid isquiver]=processdata(md,[u v],options);
     28[x y z elements is2d]=processmesh(md,[],options);
     29[vel datatype]=processdata(md,[u v],options);
    3030[quivers,palette]=quiver_process(x,y,vel(:,1),vel(:,2),options);
    3131
  • issm/trunk/src/m/classes/public/plot/plot_section.m

    r3994 r4330  
    2121
    2222%process data and model
    23 [x_m y_m z_m elements_m is2d]=processmesh(md,options);
    24 [data isongrid isquiver]=processdata(md,data,options);
     23[x_m y_m z_m elements_m is2d]=processmesh(md,[],options);
     24[data datatype]=processdata(md,data,options);
    2525
    2626%replug x and y onto model so that SectionValue treats the problem correctly
     
    3838
    3939%Compute section value
    40 if isquiver
     40if datatype==3,
    4141        [elements,x,y,z,s,data_s1]=SectionValues(md,data(:,1),getfieldvalue(options,'sectionvalue'),resolution);
    4242        [elements,x,y,z,s,data_s2]=SectionValues(md,data(:,2),getfieldvalue(options,'sectionvalue'),resolution);
     
    6565                %plot section only with labels
    6666                subplot(width,width,index2)
    67                 plot_unit(x_m,y_m,z_m,elements_m,data,isongrid,is2d,isquiver,options)
     67                plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options)
    6868                hold on
    6969                text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
     
    7979        %plot section value
    8080        subplot(width,width,index1)
    81         if isquiver
     81        if datatype==3,
    8282                plot(s,data_s1,s,data_s2);
    8383        else
     
    108108                        %plot section only with labels
    109109                        subplot(width,width,index2)
    110                         plot_unit(x_m,y_m,z_m,elements_m,data,isongrid,is2d,isquiver,options)
     110                        plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options)
    111111                        hold on
    112112                        text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
     
    143143                        %plot section only with labels
    144144                        subplot(width,width,index2)
    145                         plot_unit(x_m,y_m,z_m,elements_m,data,isongrid,is2d,isquiver,options)
     145                        plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options)
    146146                        hold on
    147147                        text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
  • issm/trunk/src/m/classes/public/plot/plot_segmentnumbering.m

    r2439 r4330  
    1111
    1212%process data and model
    13 [x y z segments is2d]=processmesh(md,options);
     13[x y z segments is2d]=processmesh(md,[],options);
    1414
    1515error('not implemented yet');
  • issm/trunk/src/m/classes/public/plot/plot_segments.m

    r3994 r4330  
    1111
    1212%process mesh and data
    13 [x y z elements is2d]=processmesh(md,options);
     13[x y z elements is2d]=processmesh(md,[],options);
    1414segments=md.segments;
    1515
  • issm/trunk/src/m/classes/public/plot/plot_streamlines.m

    r2650 r4330  
    66
    77%process data and model
    8 [x y z index is2d]=processmesh(md,options);
    9 [u isongrid isquiver]=processdata(md,md.vx,options);
    10 [v isongrid isquiver]=processdata(md,md.vy,options);
     8[x y z index is2d]=processmesh(md,[],options);
     9[u datatype]=processdata(md,md.vx,options);
     10[v datatype]=processdata(md,md.vy,options);
    1111
    1212%some checks
  • issm/trunk/src/m/classes/public/plot/plot_tensor_components.m

    r3994 r4330  
    2424
    2525%process data and model
    26 [x y z elements is2d]=processmesh(md,options);
    27 [tensor.xx isongrid isquiver]=processdata(md,tensor.xx,options);
    28 [tensor.yy isongrid isquiver]=processdata(md,tensor.yy,options);
    29 [tensor.xy isongrid isquiver]=processdata(md,tensor.xy,options);
     26[x y z elements is2d]=processmesh(md,[],options);
     27[tensor.xx datatype]=processdata(md,tensor.xx,options);
     28[tensor.yy datatype]=processdata(md,tensor.yy,options);
     29[tensor.xy datatype]=processdata(md,tensor.xy,options);
    3030if  md.dim==3
    31         [tensor.xz isongrid isquiver]=processdata(md,tensor.xz,options);
    32         [tensor.yz isongrid isquiver]=processdata(md,tensor.yz,options);
    33         [tensor.zz isongrid isquiver]=processdata(md,tensor.zz,options);
     31        [tensor.xz datatype]=processdata(md,tensor.xz,options);
     32        [tensor.yz datatype]=processdata(md,tensor.yz,options);
     33        [tensor.zz datatype]=processdata(md,tensor.zz,options);
    3434end
    3535
    3636if ((md.dim==2)),
    3737        subplot(2*width,2*width,index1),
    38         plot_unit(x,y,z,elements,tensor.xx,isongrid,is2d,isquiver,options)
     38        plot_unit(x,y,z,elements,tensor.xx,is2d,datatype,options)
    3939        Apply_options_tensor(md,options,type,'xx')
    4040        subplot(2*width,2*width,index2),
    41         plot_unit(x,y,z,elements,tensor.yy,isongrid,is2d,isquiver,options)
     41        plot_unit(x,y,z,elements,tensor.yy,is2d,datatype,options)
    4242        Apply_options_tensor(md,options,type,'yy')
    4343        subplot(2*width,2*width,index3),
    44         plot_unit(x,y,z,elements,tensor.xy,isongrid,is2d,isquiver,options)
     44        plot_unit(x,y,z,elements,tensor.xy,is2d,datatype,options)
    4545        Apply_options_tensor(md,options,type,'xy')
    4646else
    4747        subplot(3*width,3*width,index1),
    48         plot_unit(x,y,z,elements,tensor.xx,isongrid,is2d,isquiver,options)
     48        plot_unit(x,y,z,elements,tensor.xx,is2d,datatype,options)
    4949        Apply_options_tensor(md,options,type,'xx')
    5050        subplot(3*width,3*width,index2),
    51         plot_unit(x,y,z,elements,tensor.yy,isongrid,is2d,isquiver,options)
     51        plot_unit(x,y,z,elements,tensor.yy,is2d,datatype,options)
    5252        Apply_options_tensor(md,options,type,'yy')
    5353        subplot(3*width,3*width,index3),
    54         plot_unit(x,y,z,elements,tensor.zz,isongrid,is2d,isquiver,options)
     54        plot_unit(x,y,z,elements,tensor.zz,is2d,datatype,options)
    5555        Apply_options_tensor(md,options,type,'zz')
    5656        subplot(3*width,3*width,index4),
    57         plot_unit(x,y,z,elements,tensor.xy,isongrid,is2d,isquiver,options)
     57        plot_unit(x,y,z,elements,tensor.xy,is2d,datatype,options)
    5858        Apply_options_tensor(md,options,type,'xy')
    5959        subplot(3*width,3*width,index5),
    60         plot_unit(x,y,z,elements,tensor.xz,isongrid,is2d,isquiver,options)
     60        plot_unit(x,y,z,elements,tensor.xz,is2d,datatype,options)
    6161        Apply_options_tensor(md,options,type,'xz')
    6262        subplot(3*width,3*width,index6),
    63         plot_unit(x,y,z,elements,tensor.yz,isongrid,is2d,isquiver,options)
     63        plot_unit(x,y,z,elements,tensor.yz,is2d,datatype,options)
    6464        Apply_options_tensor(md,options,type,'yz')
    6565end
  • issm/trunk/src/m/classes/public/plot/plot_tensor_principal.m

    r3994 r4330  
    3737
    3838%now plot principal values
    39 [x y z elements is2d]=processmesh(md,options);
    40 [tensor.principalvalue1 isongrid isquiver]=processdata(md,tensor.principalvalue1,options);
    41 [tensor.principalvalue2 isongrid isquiver]=processdata(md,tensor.principalvalue2,options);
     39[x y z elements is2d]=processmesh(md,[],options);
     40[tensor.principalvalue1 datatype]=processdata(md,tensor.principalvalue1,options);
     41[tensor.principalvalue2 datatype]=processdata(md,tensor.principalvalue2,options);
    4242if  md.dim==3
    43         [tensor.principalvalue3 isongrid isquiver]=processdata(md,tensor.principalvalue3,options);
     43        [tensor.principalvalue3 datatype]=processdata(md,tensor.principalvalue3,options);
    4444end
    4545
    4646if ((md.dim==2)),
    4747        subplot(2*width,2*width,index3)
    48         plot_unit(x,y,z,elements,tensor.principalvalue1,isongrid,is2d,isquiver,options)
     48        plot_unit(x,y,z,elements,tensor.principalvalue1,is2d,datatype,options)
    4949        Apply_options_tensor(md,options,type,'principal value 1')
    5050        subplot(2*width,2*width,index4)
    51         plot_unit(x,y,z,elements,tensor.principalvalue2,isongrid,is2d,isquiver,options)
     51        plot_unit(x,y,z,elements,tensor.principalvalue2,is2d,datatype,options)
    5252        Apply_options_tensor(md,options,type,'principal value 2')
    5353else
    5454        subplot(3*width,3*width,index4)
    55         plot_unit(x,y,z,elements,tensor.principalvalue1,isongrid,is2d,isquiver,options)
     55        plot_unit(x,y,z,elements,tensor.principalvalue1,is2d,datatype,options)
    5656        Apply_options_tensor(md,options,type,'principal value 1')
    5757        subplot(3*width,3*width,index5)
    58         plot_unit(x,y,z,elements,tensor.principalvalue2,isongrid,is2d,isquiver,options)
     58        plot_unit(x,y,z,elements,tensor.principalvalue2,is2d,datatype,options)
    5959        Apply_options_tensor(md,options,type,'principal value 2')
    6060        subplot(3*width,3*width,index6)
    61         plot_unit(x,y,z,elements,tensor.principalvalue3,isongrid,is2d,isquiver,options)
     61        plot_unit(x,y,z,elements,tensor.principalvalue3,is2d,datatype,options)
    6262        Apply_options_tensor(md,options,type,'principal value 3')
    6363end
  • issm/trunk/src/m/classes/public/plot/plot_tensor_principalaxis.m

    r3994 r4330  
    1111
    1212%process data and model
    13 [x y z elements is2d]=processmesh(md,options);
     13[x y z elements is2d]=processmesh(md,[],options);
    1414
    1515if ((md.dim==2)),
    1616        eval(['Vx=tensor.principalaxis' type(end) '(:,1); Vy=tensor.principalaxis' type(end) '(:,2);'])
    1717        eval(['value=tensor.principalvalue' type(end) ';']);
    18         [Vx isongrid isquiver]=processdata(md,Vx,options);
    19         [Vy isongrid isquiver]=processdata(md,Vy,options);
    20         [value isongrid isquiver]=processdata(md,value,options);
     18        [Vx datatype]=processdata(md,Vx,options);
     19        [Vy datatype]=processdata(md,Vy,options);
     20        [value datatype]=processdata(md,value,options);
    2121else
    2222        eval(['Vx=tensor.principalaxis' type(end) '(:,1); Vy=tensor.principalaxis' type(end) '(:,2); Vz=tensor.principalaxis' type(end) '(:,3);'])
    23         [Vx isongrid isquiver]=processdata(md,Vx,options);
    24         [Vy isongrid isquiver]=processdata(md,Vy,options);
    25         [Vz isongrid isquiver]=processdata(md,Vz,options);
    26         [value isongrid isquiver]=processdata(md,value,options);
     23        [Vx datatype]=processdata(md,Vx,options);
     24        [Vy datatype]=processdata(md,Vy,options);
     25        [Vz datatype]=processdata(md,Vz,options);
     26        [value datatype]=processdata(md,value,options);
    2727end
    2828
    2929%take the center of each element if ~isongrid
    30 if ~isongrid
     30if datatype==1,
    3131        x=mean(md.x(md.elements'))'; y=mean(md.y(md.elements'))'; z=mean(md.z(md.elements'))';
    3232end
  • issm/trunk/src/m/classes/public/plot/plot_transient_field.m

    r2563 r4330  
    4444
    4545%process mes only once
    46 [x y z elements is2d]=processmesh(md,options);
     46[x y z elements is2d]=processmesh(md,[],options);
    4747
    4848%plot data for all steps
     
    5050
    5151        %process data and change title if needed
    52         [data isongrid isquiver]=processdata(md,md.results.transient(steps(i)).(field),options);
     52        [data datatype]=processdata(md,md.results.transient(steps(i)).(field),options);
    5353        options=changefieldvalue(options,'title',[field ' at time ' num2str(md.results.transient(steps(i)).time) ' a']);
    5454
    5555        %create plot of step i
    5656        subplot(subplotwidth,subplotwidth,i);
    57         plot_unit(x,y,z,elements,data,isongrid,is2d,isquiver,options)
     57        plot_unit(x,y,z,elements,data,is2d,datatype,options)
    5858        applyoptions(md,data,options);
    5959
  • issm/trunk/src/m/classes/public/plot/plot_transient_movie.m

    r2667 r4330  
    1717
    1818        %process model
    19         [x y z elements is2d]=processmesh(md,options);
     19        [x y z elements is2d]=processmesh(md,[],options);
    2020
    2121        %loop over the time steps
     
    2424
    2525                %process data
    26                 [data isongrid isquiver]=processdata(md,data,options);
     26                [data datatype]=processdata(md,data,options);
    2727                titlestring=[field ' at time ' num2str(md.results.transient(i).time) ' year'];
    28                 plot_unit(x,y,z,elements,data,isongrid,is2d,isquiver,options)
     28                plot_unit(x,y,z,elements,data,is2d,datatype,options)
    2929                apply_options_movie(md,options,titlestring);
    3030               
  • issm/trunk/src/m/classes/public/plot/plot_unit.m

    r3547 r4330  
    1 function plot_unit(x,y,z,elements,data,isongrid,is2d,isquiver,options)
     1function plot_unit(x,y,z,elements,data,is2d,datatype,options)
    22%PLOT_UNIT - unit plot, display data
    33%
    44%   Usage:
    5 %      plot_unit(x,y,z,elements,data,isongrid,is2d,isquiver,options);
     5%      plot_unit(x,y,z,elements,data,is2d,datatype,options);
    66%
    77%   See also: PLOTMODEL, PLOT_MANAGER
     
    1414%set(gca,'pos',P);
    1515
    16 %regular plot
    17 if ~isquiver,
     16switch datatype,
    1817
    19         %element data
    20         if ~isongrid
     18        %element plot
     19        case 1,
     20
    2121                pos=find(~isnan(data)); %needed fpr element on water
    2222                if is2d,
     
    3232                end
    3333
    34         %grid data
    35         elseif isongrid
     34        %node plot
     35        case 2,
     36
    3637                if is2d,
    3738                        A=elements(:,1); B=elements(:,2); C=elements(:,3);
     
    4546                        patch( 'Faces', [C A D F ], 'Vertices', [x y z],'FaceVertexCData', data(:),'FaceColor','interp','EdgeColor',edgecolor);
    4647                end
    47         end
    4848
    49 %quiver
    50 elseif isquiver,
     49        %quiver plot
     50        case 3,
    5151
    52         %grid data
    53         if isongrid,
    5452                if is2d,
    5553                        plot_quiver(x,y,data(:,1),data(:,2),options);
     
    5755                        plot_quiver3(x,y,z,data(:,1),data(:,2),data(:,3),options);
    5856                end
    59         else
    60                 error('plot_unit error message: element quiver not implemented yet')
     57
     58        %Patch plot
     59        case 4,
     60
     61                if is2d,
     62                        patch( 'Faces',elements,'Vertices',[x y],'CData',data,'FaceColor','interp','EdgeColor',edgecolor);
     63                else
     64                        A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
     65                        patch( 'Faces', [A B C], 'Vertices', [x y z],'CData', data,'FaceColor','flat','EdgeColor',edgecolor);
     66                        patch( 'Faces', [D E F], 'Vertices', [x y z],'CData', data,'FaceColor','flat','EdgeColor',edgecolor);
     67                        patch( 'Faces', [A B E D], 'Vertices', [x y z],'CData', data,'FaceColor','flat','EdgeColor',edgecolor);
     68                        patch( 'Faces', [B E F C ], 'Vertices', [x y z],'CData', data,'FaceColor','flat','EdgeColor',edgecolor);
     69                        patch( 'Faces', [C A D F ], 'Vertices', [x y z],'CData', data,'FaceColor','flat','EdgeColor',edgecolor);
     70                end
     71
     72        otherwise,
     73                error(['case ' num2str(datatype) ' not supported']);
     74
    6175        end
    6276end
  • issm/trunk/src/m/classes/public/plot/processdata.m

    r3994 r4330  
    1 function [data isongrid isquiver]=processdata(md,data,options);
     1function [data datatype]=processdata(md,data,options);
    22%PROCESSDATA - process data to be plotted
    33%
     4%   datatype = 1 -> elements
     5%   datatype = 2 -> nodes
     6%   datatype = 3 -> node quivers
     7%   datatype = 4 -> patch
     8%
    49%   Usage:
    5 %      [data isongrid isquiver]=processdata(md,data,options);
     10%      [data datatype]=processdata(md,data,options);
    611%
    712%   See also: PLOTMODEL, PROCESSMESH
    813
    914%check format
    10 if (iscell(data) | isempty(data) | length(data)==1),
     15if (iscell(data) | isempty(data) | length(data)==0),
    1116        error('plotmodel error message: data provided is empty');
    1217end
    1318
    14 %transpose data if necessary
    15 if (size(data,2) > size(data,1)),
    16         data=data';
     19%Process Patch
     20if isstruct(data)
     21        if (isfield(data,'index') & isfield(data,'value')),
     22                data=data.value;
     23                data=data';
     24                data=data(:);
     25                datatype=4;
     26        else
     27                error('structure other than Patch not supported yet');
     28        end
     29else
     30        %initialize datatype
     31        datatype=0;
    1732end
     33
     34%get datatype
    1835datasize=size(data);
    1936
    20 %convert to double if necessary
    21 if ~isnumeric(data);
    22         disp('processdata info message: data is not numeric (logical?). Converted to double');
    23         data=double(data);
    24 end
     37%non patch processing
     38if datatype~=4,
    2539
    26 %check length
    27 if datasize(1)~=md.numberofgrids & datasize(1)~=md.numberofelements & datasize(1)~=md.numberofgrids*6 & (md.dim==3 & ~(datasize(1)==md.numberofelements2d | datasize(1)==md.numberofgrids2d))
    28         error('plotmodel error message: data not supported yet');
    29 end
     40        %transpose data if necessary
     41        if (size(data,2) > size(data,1)),
     42                data=data';
     43        end
     44        datasize=size(data);
    3045
    31 %isquiver?
    32 if datasize(2)>1,
    33         isquiver=1;
    34 
    35         %check number of columns, add zeros if necessary,
    36         if (md.dim==3)
    37                 if datasize(2)==2,
    38                         data=[data, zeros(datasize(1),1)];
    39                 elseif datasize(2)~=3,
    40                         error('plotmodel error message: data provided should have 2 or 3 columns for quiver plot, and 1 for regular plot');
    41                 end
    42         elseif ((md.dim==2) & datasize(2)~=2),
    43                 error('plotmodel error message: data provided should have 2 columns for quiver plot, and 1 for regular plot');
     46        %convert to double if necessary
     47        if ~isnumeric(data);
     48                disp('processdata info message: data is not numeric (logical?). Converted to double');
     49                data=double(data);
    4450        end
    4551
    46 else
    47         isquiver=0;
    48 end
     52        %check length
     53        if datasize(1)~=md.numberofgrids & datasize(1)~=md.numberofelements & datasize(1)~=md.numberofgrids*6 & (md.dim==3 & ~(datasize(1)==md.numberofelements2d | datasize(1)==md.numberofgrids2d))
     54                error('plotmodel error message: data not supported yet');
     55        end
    4956
    50 %treat the case datasize(1)=6*grids
    51 if datasize(1)==6*md.numberofgrids
    52         %keep the only norm of data
    53         data1=data(1:6:md.numberofgrids*6,:);
    54         data2=data(2:6:md.numberofgrids*6,:);
    55         data=sqrt(data1.^2+data2.^2);
    56         datasize(1)=md.numberofgrids;
    57         %---> go to grid data
    58 end
     57        %quiver?
     58        if datasize(2)>1,
     59                datatype=3;
    5960
    60 %treat the case datasize(1)=grids2d
    61 if (md.dim==3 & datasize(1)==md.numberofgrids2d),
    62         data=project3d(md,data,'node');
    63         datasize(1)=md.numberofgrids;
    64         %---> go to grid data
    65 end
     61                %check number of columns, add zeros if necessary,
     62                if (md.dim==3)
     63                        if datasize(2)==2,
     64                                data=[data, zeros(datasize(1),1)];
     65                        elseif datasize(2)~=3,
     66                                error('plotmodel error message: data provided should have 2 or 3 columns for quiver plot, and 1 for regular plot');
     67                        end
     68                elseif ((md.dim==2) & datasize(2)~=2),
     69                        error('plotmodel error message: data provided should have 2 columns for quiver plot, and 1 for regular plot');
     70                end
     71        end
    6672
    67 %treat the case datasize(1)=grids2d
    68 if (md.dim==3 & datasize(1)==md.numberofelements2d),
    69         data=project3d(md,data,'element');
    70         datasize(1)=md.numberofelements;
    71         %---> go to grid data
    72 end
     73        %treat the case datasize(1)=6*grids
     74        if datasize(1)==6*md.numberofgrids
     75                %keep the only norm of data
     76                data1=data(1:6:md.numberofgrids*6,:);
     77                data2=data(2:6:md.numberofgrids*6,:);
     78                data=sqrt(data1.^2+data2.^2);
     79                datasize(1)=md.numberofgrids;
     80                %---> go to grid data
     81        end
    7382
    74 %smoothing?
    75 if exist(options,'smooth')
    76         data=averaging(md,data,getfieldvalue(options,'smooth'));
    77         datasize(1)=md.numberofgrids;
    78         %---> go to grid data
     83        %treat the case datasize(1)=grids2d
     84        if (md.dim==3 & datasize(1)==md.numberofgrids2d),
     85                data=project3d(md,data,'node');
     86                datasize(1)=md.numberofgrids;
     87                %---> go to grid data
     88        end
     89
     90        %treat the case datasize(1)=grids2d
     91        if (md.dim==3 & datasize(1)==md.numberofelements2d),
     92                data=project3d(md,data,'element');
     93                datasize(1)=md.numberofelements;
     94                %---> go to grid data
     95        end
     96
     97        %smoothing?
     98        if exist(options,'smooth')
     99                data=averaging(md,data,getfieldvalue(options,'smooth'));
     100                datasize(1)=md.numberofgrids;
     101                %---> go to grid data
     102        end
    79103end
    80104
    81105%element data
    82106if datasize(1)==md.numberofelements;
    83         isongrid=0;
     107
     108        %Initialize datatype if non patch
     109        if datatype~=4,
     110                datatype=1;
     111        end
    84112
    85113        %ice sheet only?
     
    104132%grid data
    105133if datasize(1)==md.numberofgrids
    106         isongrid=1;
     134        datatype=1;
    107135        %ice sheet only?
    108136        if getfieldvalue(options,'iceshelf',1)==0,
     
    133161
    134162%control arrow density if quiverplot
    135 if isquiver & exist(options,'density')
     163if datatype==3 & exist(options,'density')
    136164        databak=data;
    137165        data=NaN*ones(datasize);
  • issm/trunk/src/m/classes/public/plot/processmesh.m

    r3994 r4330  
    1 function [x y z elements is2d]=processmesh(md,options);
     1function [x y z elements is2d]=processmesh(md,data,options);
    22%PROCESSMESH - process mesh to be plotted
    33%
    44%   Usage:
    5 %      [x y z elements is2d]=processmesh(md,options)
     5%      [x y z elements is2d]=processmesh(md,data,options)
    66%
    77%   See also: PLOTMODEL, PROCESSDATA
     
    1212end
    1313
    14 %first load x,y, etc ... to speed up plot
    15 x=md.x;
    16 x2d=md.x2d;
    17 y=md.y;
    18 y2d=md.y2d;
    19 z=md.z;
    20 z2d=md.z2d;
    21 elements2d=md.elements2d;
    22 elements=md.elements;
    23 elements_type2d=md.elements_type2d;
     14if (isempty(data) | ~isstruct(data)),
     15        %first load x,y, etc ... to speed up plot
     16        x=md.x;
     17        x2d=md.x2d;
     18        y=md.y;
     19        y2d=md.y2d;
     20        z=md.z;
     21        z2d=md.z2d;
     22        elements2d=md.elements2d;
     23        elements=md.elements;
     24        elements_type2d=md.elements_type2d;
    2425
    25 %is it a 2d plot?
    26 if (md.dim==2);
    27         is2d=1;
    28 else
    29         if getfieldvalue(options,'layer',0)>=1,
     26        %is it a 2d plot?
     27        if (md.dim==2);
    3028                is2d=1;
    3129        else
    32                 is2d=0;
     30                if getfieldvalue(options,'layer',0)>=1,
     31                        is2d=1;
     32                else
     33                        is2d=0;
     34                end
    3335        end
    34 end
    3536
    36 %layer projection?
    37 if getfieldvalue(options,'layer',0)>=1,
    38         %we modify the mesh temporarily to a 2d mesh from which the 3d mesh was extruded.
    39         x=x2d;
    40         y=y2d;
    41         z=z2d;
    42         elements=elements2d;
    43         elements_type=elements_type2d;
     37        %layer projection?
     38        if getfieldvalue(options,'layer',0)>=1,
     39                %we modify the mesh temporarily to a 2d mesh from which the 3d mesh was extruded.
     40                x=x2d;
     41                y=y2d;
     42                z=z2d;
     43                elements=elements2d;
     44                elements_type=elements_type2d;
     45        end
     46else
     47        %Process Patch
     48        elements=transpose(reshape(1:3*md.numberofelements,3,md.numberofelements));
     49        x=transpose(reshape(md.x(data.index)',1,3*md.numberofelements));
     50        y=transpose(reshape(md.y(data.index)',1,3*md.numberofelements));
     51        z=zeros(3*md.numberofelements,1);
     52        is2d=1;
    4453end
    4554
Note: See TracChangeset for help on using the changeset viewer.