Changeset 20471
- Timestamp:
- 04/07/16 22:46:19 (9 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/plot_mesh.js
r20401 r20471 9 9 var indices = []; 10 10 var colors = []; 11 var rgbcolor = [];11 var nanindices = {}; 12 12 var xmin,xmax; 13 13 var ymin,ymax; … … 85 85 var vertex = vec3.create(); 86 86 var magnitude; 87 var color = [0.0, 0.0, 0.0, 1.0]; 87 var color = [0.0, 0.0, 0.0, 1.0]; 88 x[0] = NaN; 89 x[1] = NaN; 90 x[2] = NaN; 91 x[3] = NaN; 92 x[4] = NaN; 93 x[5] = NaN; 94 x[6] = NaN; 95 x[7] = NaN; 96 x[8] = NaN; 97 x[9] = NaN; 98 x[10] = NaN; 99 x[11] = NaN; 100 x[12] = NaN; 101 x[13] = NaN; 102 x[14] = NaN; 103 x[15] = NaN; 104 x[16] = NaN; 105 x[17] = NaN; 106 x[18] = NaN; 107 x[19] = NaN; 108 x[20] = NaN; 109 x[21] = NaN; 110 x[22] = NaN; 111 x[23] = NaN; 112 x[24] = NaN; 113 x[25] = NaN; 114 x[26] = NaN; 115 x[27] = NaN; 116 x[28] = NaN; 117 x[29] = NaN; 118 x[30] = NaN; 119 x[31] = NaN; 120 x[32] = NaN; 121 x[33] = NaN; 122 x[34] = NaN; 123 x[35] = NaN; 124 x[36] = NaN; 125 x[37] = NaN; 126 x[38] = NaN; 127 x[39] = NaN; 128 x[310] = NaN; 129 x[311] = NaN; 130 x[312] = NaN; 131 x[313] = NaN; 132 x[314] = NaN; 133 x[315] = NaN; 134 x[316] = NaN; 135 x[317] = NaN; 136 x[318] = NaN; 137 x[319] = NaN; 138 x[320] = NaN; 139 x[321] = NaN; 140 x[322] = NaN; 141 x[323] = NaN; 142 x[324] = NaN; 143 x[325] = NaN; 144 x[326] = NaN; 145 x[327] = NaN; 146 x[328] = NaN; 147 x[329] = NaN; 88 148 for(var i = 0; i < x.length; i++){ 149 //Check for NaN values and remove from indices array as necessary, but preserve vertex array spacing 150 if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i])) { 151 nanindices[i] = i; 152 vertices.push.apply(vertices, vertex); 153 continue; 154 } 155 //Scale vertices 156 //Scale vertices 89 157 xyz = vec3.fromValues(x[i], y[i], z[i]); 90 158 magnitude = vec3.length(xyz) + md.geometry.surface[i] * surfacescale; … … 97 165 98 166 //linearize the elements array: 167 var element; 99 168 for(var i = 0; i < elements.length; i++){ 100 //convert tris to line edges; generates more edges than necessary, should optimize using node connectivity matlab indices from 1, so decrement indices. 101 indices.push.apply(indices, [elements[i][0] - 1, elements[i][1] - 1, elements[i][1] - 1, elements[i][2] - 1, elements[i][2] - 1, elements[i][0] - 1]); 169 element = [elements[i][0] - 1, elements[i][1] - 1, elements[i][2] - 1]; 170 if (element[0] in nanindices || element[1] in nanindices || element[2] in nanindices) continue; 171 indices = indices.concat([element[0], element[1], element[1], element[2], element[2], element[0]]); 102 172 } 103 173 indices.itemSize = 1; -
issm/trunk-jpl/src/m/plot/plot_overlay.js
r20401 r20471 12 12 var indices = []; 13 13 var texcoords = []; 14 var nanindices = {}; 14 15 var xmin,xmax; 15 16 var ymin,ymax; … … 109 110 //generate mesh: 110 111 for(var i = 0; i < x.length; i++){ 112 //Check for NaN values and remove from indices array as necessary, but preserve vertex array spacing 113 if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i])) { 114 nanindices[i] = i; 115 vertices.push.apply(vertices, vertex); 116 continue; 117 } 118 //Scale vertices 119 //Scale vertices 111 120 xyz = vec3.fromValues(x[i], y[i], z[i]); 112 121 magnitude = vec3.length(xyz); … … 118 127 } 119 128 120 //linearize the elements array: 121 indices = indices.concat.apply(indices, elements); 129 //linearize the elements array: 130 var element; 131 for(var i = 0; i < elements.length; i++){ 132 element = [elements[i][0] - 1, elements[i][1] - 1, elements[i][2] - 1]; 133 if (element[0] in nanindices || element[1] in nanindices || element[2] in nanindices) continue; 134 indices = indices.concat(element); 135 } 122 136 indices.itemSize = 1; 123 for(var i=0;i<indices.length;i++)indices[i]--; //matlab indices from 1, so decrement.124 137 125 138 /*Initalize buffers: */ -
issm/trunk-jpl/src/m/plot/plot_quiver.js
r20401 r20471 92 92 var color = edgecolor; 93 93 for(var i = 0; i < x.length; i++){ 94 //Check for NaN values and remove from indices array as necessary, but preserve vertex array spacing 95 if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i])) continue; 96 //Scale vertices 94 97 xyz1 = vec3.fromValues(x[i], y[i], z[i]); 95 98 magnitude = vec3.length(xyz1) + md.geometry.surface[i] * surfacescale; -
issm/trunk-jpl/src/m/plot/plot_unit.js
r20437 r20471 11 11 var indices = []; 12 12 var texcoords = []; 13 var rgbcolor = [];13 var nanindices = {}; 14 14 var xmin,xmax; 15 15 var ymin,ymax; … … 23 23 var y = meshresults[1]; 24 24 var z = meshresults[2]; 25 var elements = meshresults[3]; 25 var elements = meshresults[3]; 26 26 var is2d = meshresults[4]; 27 27 var isplanet = meshresults[5]; … … 107 107 var vertex = vec3.create(); 108 108 var magnitude; 109 109 110 110 for(var i = 0; i < x.length; i++){ 111 //Check for NaN values and remove from indices array as necessary, but preserve vertex array spacing 112 if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i])) { 113 nanindices[i] = i; 114 vertices.push.apply(vertices, vertex); 115 continue; 116 } 117 //Scale vertices 111 118 xyz = vec3.fromValues(x[i], y[i], z[i]); 112 119 magnitude = vec3.length(xyz) + md.geometry.surface[i] * surfacescale; … … 119 126 120 127 //linearize the elements array: 121 indices = indices.concat.apply(indices, elements); 128 var element; 129 for(var i = 0; i < elements.length; i++){ 130 element = [elements[i][0] - 1, elements[i][1] - 1, elements[i][2] - 1]; 131 if (element[0] in nanindices || element[1] in nanindices || element[2] in nanindices) continue; 132 indices = indices.concat(element); 133 } 122 134 indices.itemSize = 1; 123 for(var i=0;i<indices.length;i++)indices[i]--; //matlab indices from 1, so decrement.124 135 125 136 } … … 155 166 156 167 for(var i = 0; i < x.length; i++){ 168 //Check for NaN values and remove from indices array as necessary, but preserve vertex array spacing 169 if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i])) { 170 nanindices[i] = i; 171 vertices.push.apply(vertices, vertex); 172 continue; 173 } 174 //Scale vertices 157 175 xyz = vec3.fromValues(x[i], y[i], z[i]); 158 176 magnitude = vec3.length(xyz) + md.geometry.surface[i] * surfacescale; … … 190 208 } 191 209 192 //linearize the elements array: 193 indices = indices.concat.apply(indices, elements); 210 //linearize the elements array: 211 var element; 212 for(var i = 0; i < elements.length; i++){ 213 element = [elements[i][0] - 1, elements[i][1] - 1, elements[i][2] - 1]; 214 if (element[0] in nanindices || element[1] in nanindices || element[2] in nanindices) continue; 215 indices = indices.concat(element); 216 } 194 217 indices.itemSize = 1; 195 for(var i=0;i<indices.length;i++)indices[i]--; //matlab indices from 1, so decrement.196 218 197 219 //Initialize movie loop -
issm/trunk-jpl/src/m/plot/processmesh.js
r20195 r20471 25 25 26 26 if (options.getfieldvalue('coord','xy') !== 'latlon'){ 27 x=md.mesh.x ;28 if ('x2d' in md.mesh) x2d=md.mesh.x2d ;29 y=md.mesh.y ;30 if ('y2d' in md.mesh) y2d=md.mesh.y2d ;27 x=md.mesh.x.slice(); 28 if ('x2d' in md.mesh) x2d=md.mesh.x2d.slice(); 29 y=md.mesh.y.slice(); 30 if ('y2d' in md.mesh) y2d=md.mesh.y2d.slice(); 31 31 } 32 32 else{ 33 x=md.mesh.long ;34 y=md.mesh.lat ;33 x=md.mesh.long.slice(); 34 y=md.mesh.lat.slice(); 35 35 } 36 36 37 37 if ('z' in md.mesh){ 38 z=md.mesh.z ;38 z=md.mesh.z.slice(); 39 39 } 40 40 else{ … … 45 45 z=md[z]; 46 46 } 47 48 if ('elements2d' in md.mesh) elements2d=md.mesh.elements2d; 49 elements=md.mesh.elements; 47 48 //TODO: Make deep copy of elements array to prevent unwanted modification of model (slice creates deep copies for primitive types, shallow copies for obejcts) 49 if ('elements2d' in md.mesh) elements2d=md.mesh.elements2d.slice(); 50 elements=md.mesh.elements.slice(); 50 51 51 52 //is it a 2d plot?
Note:
See TracChangeset
for help on using the changeset viewer.