Changeset 19778


Ignore:
Timestamp:
11/20/15 22:15:36 (9 years ago)
Author:
Eric.Larour
Message:

CHG: fixed some issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/plot/plot_mesh.js

    r19772 r19778  
    4747        var edgecolor=options.getfieldvalue('edgecolor','black');
    4848
    49         /*//plot mesh
    50         if (is2d){
    51                 A=elements(:,1); B=elements(:,2); C=elements(:,3);
    52                 patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
     49        // populate arrays
     50        //node plot {{{
     51        if (elements[0].length==6){ //prisms
     52                /*A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
     53                  patch( 'Faces', [A B C],  'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
     54                  patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
     55                  patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
     56                  patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
     57                  patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
     58                  */
    5359        }
    54         */
    55        
    56         // populate arrays {{{
    57         switch(datatype){
    58                 //element plot {{{
    59                 case 1:
    60                         break;
    61                 //}}}
    62                 //node plot {{{
    63                 case 2:
    64                         if (elements[0].length==6){ //prisms
    65                                 /*A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
    66                                 patch( 'Faces', [A B C],  'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
    67                                 patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
    68                                 patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
    69                                 patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
    70                                 patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
    71                                 */
    72                         }
    73                         else if (elements[0].length==4){ //tetras
    74                                 /*A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4);
    75                                 patch( 'Faces',[A B C],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
    76                                 patch( 'Faces',[A B D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
    77                                 patch( 'Faces',[B C D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
    78                                 patch( 'Faces',[C A D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
    79                                 */
    80                         }
    81                         else{ //2D triangular elements
    82                                 vertices.itemSize = 3;
    83                                 for(var i = 0; i < x.length; i++){
    84                                         vertices[vertices.length] = x[i];
    85                                         vertices[vertices.length] = y[i];
    86                                         //vertices[vertices.length] = z[i];
    87                                         vertices[vertices.length] = 0;
     60        else if (elements[0].length==4){ //tetras
     61                /*A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4);
     62                  patch( 'Faces',[A B C],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
     63                  patch( 'Faces',[A B D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
     64                  patch( 'Faces',[B C D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
     65                  patch( 'Faces',[C A D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
     66                  */
     67        }
     68        else{ //2D triangular elements
     69                vertices.itemSize = 3;
     70                for(var i = 0; i < x.length; i++){
     71                        vertices[vertices.length] = x[i];
     72                        vertices[vertices.length] = y[i];
     73                        //vertices[vertices.length] = z[i];
     74                        vertices[vertices.length] = 0;
    8875
    89                                         //handle mesh/qinterest size mismatch
    90                                         rgbcolor = [0.0, 0.0, 0.0];
    91                                         colors[colors.length] = rgbcolor[0];
    92                                         colors[colors.length] = rgbcolor[1];
    93                                         colors[colors.length] = rgbcolor[2];
    94                                         colors[colors.length] = 1.0;
    95                                 }
     76                        //handle mesh/qinterest size mismatch
     77                        rgbcolor = [0.0, 0.0, 0.0];
     78                        colors[colors.length] = rgbcolor[0];
     79                        colors[colors.length] = rgbcolor[1];
     80                        colors[colors.length] = rgbcolor[2];
     81                        colors[colors.length] = 1.0;
     82                }
    9683
    97                                 //linearize the elements array:
    98                                
    99                                 for(var i = 0; i < elements.length; i++){
    100                                         //convert tris to line edges; generates more edges than necessary, should optimize using node connectivity
    101                                         //matlab indices from 1, so decrement indices.
    102                                         indices[indices.length] = elements[i][0] - 1;
    103                                         indices[indices.length] = elements[i][1] - 1;
    104                                         indices[indices.length] = elements[i][1] - 1;
    105                                         indices[indices.length] = elements[i][2] - 1;
    106                                         indices[indices.length] = elements[i][2] - 1;
    107                                         indices[indices.length] = elements[i][0] - 1;
    108                                 }
    109                                 indices.itemSize = 1;
    110                         }
    111                         break;
    112                 //}}}
    113                 //quiver plot {{{
    114                 case 3:
     84                //linearize the elements array:
    11585
    116                         if (is2d){
    117                                 //plot_quiver(x,y,data(:,1),data(:,2),options);
    118                         }
    119                         else{
    120                                 //plot_quiver3(x,y,z,data(:,1),data(:,2),data(:,3),options);
    121                         }
    122 
    123                 //}}}
    124                 default:
    125                         throw Error(sprintf("%s%i%s\n",'case ',datatype,' not supported'));
     86                for(var i = 0; i < elements.length; i++){
     87                        //convert tris to line edges; generates more edges than necessary, should optimize using node connectivity
     88                        //matlab indices from 1, so decrement indices.
     89                        indices[indices.length] = elements[i][0] - 1;
     90                        indices[indices.length] = elements[i][1] - 1;
     91                        indices[indices.length] = elements[i][1] - 1;
     92                        indices[indices.length] = elements[i][2] - 1;
     93                        indices[indices.length] = elements[i][2] - 1;
     94                        indices[indices.length] = elements[i][0] - 1;
     95                }
     96                indices.itemSize = 1;
    12697        }
    12798        //}}}
Note: See TracChangeset for help on using the changeset viewer.