<p><b>ringler@lanl.gov</b> 2009-08-01 19:27:51 -0600 (Sat, 01 Aug 2009)</p><p><br>
code to map grid.nc to a set of ascii files that can be read by OpenDX<br>
<br>
mapping of Voronoi diagram is complete. Well add Delaunay triangulation next.<br>
</p><hr noshade><pre><font color="gray">Added: trunk/swmodel/matlab/MapGridToDx.m
===================================================================
--- trunk/swmodel/matlab/MapGridToDx.m                                (rev 0)
+++ trunk/swmodel/matlab/MapGridToDx.m        2009-08-02 01:27:51 UTC (rev 13)
@@ -0,0 +1,51 @@
+clear all
+
+ncid = netcdf.open('../grid.nc','nc_nowrite')
+
+xV_id = netcdf.inqVarID(ncid,'xVertex')
+yV_id = netcdf.inqVarID(ncid,'yVertex')
+zV_id = netcdf.inqVarID(ncid,'zVertex')
+nEdgesOnCell_id = netcdf.inqVarID(ncid,'nEdgesOnCell')
+verticesOnCell_id = netcdf.inqVarID(ncid,'verticesOnCell')
+areaCell_id = netcdf.inqVarID(ncid,'areaCell')
+
+xV=netcdf.getVar(ncid, xV_id);
+yV=netcdf.getVar(ncid, yV_id);
+zV=netcdf.getVar(ncid, zV_id);
+nEdgesOnCell=netcdf.getVar(ncid, nEdgesOnCell_id);
+verticesOnCell=netcdf.getVar(ncid, verticesOnCell_id);
+areaCell = netcdf.getVar(ncid, areaCell_id);
+
+work=size(nEdgesOnCell(:,1))
+nCells=work(1)
+
+system('rm -f ../dx/vor.position.data')
+system('rm -f ../dx/vor.edge.data')
+system('rm -f ../dx/vor.loop.data')
+system('rm -f ../dx/vor.face.data')
+system('rm -f ../dx/vor.area.data')
+
+iloop=0;
+iedge=0;
+for i=1:nCells
+    dlmwrite('../dx/vor.face.data', i-1, '-append')
+    dlmwrite('../dx/vor.area.data', areaCell(i), ...
+       'precision', '%18.10e', '-append')
+    dlmwrite('../dx/vor.loop.data', iloop, ...
+       'precision', '%10i', '-append')
+    edge(1:nEdgesOnCell(i)) = iedge;
+    for j=1:nEdgesOnCell(i)
+        x(1) = xV(verticesOnCell(j,i));
+        x(2) = yV(verticesOnCell(j,i));
+        x(3) = zV(verticesOnCell(j,i));
+        dlmwrite('../dx/vor.position.data', x, 'delimiter', '\t', ...
+            'precision', '%18.10e', '-append')
+        edge(j) = iedge + j - 1;
+    end;
+    dlmwrite('../dx/vor.edge.data', edge(1:nEdgesOnCell(i)), ...
+        'delimiter', '\t', 'precision', '%10i', '-append')
+    iloop = iloop + nEdgesOnCell(i);
+    iedge = iedge + nEdgesOnCell(i);
+end;
+
+netcdf.close(ncid)
\ No newline at end of file

</font>
</pre>