<p><b>cahrens@lanl.gov</b> 2010-04-08 13:38:18 -0600 (Thu, 08 Apr 2010)</p><p>Vis tools.  paraview dir has code for tools that convert MPAS-style .nc files to ParaView .vtk file formats.  Included is a translator that does the conversion for a single layer sphere and also tools to do three projections: a multilayer sphere, a multilayered lat/lon projection of a sphere and a multilayered quad rectangle.<br>
</p><hr noshade><pre><font color="gray">Added: branches/ocean_projects/graphics/paraview/projection/Makefile
===================================================================
--- branches/ocean_projects/graphics/paraview/projection/Makefile                                (rev 0)
+++ branches/ocean_projects/graphics/paraview/projection/Makefile        2010-04-08 19:38:18 UTC (rev 186)
@@ -0,0 +1,29 @@
+NETCDF = /usr/projects/climate/mhecht/netcdf-3.6.1
+CC = gcc
+INCLUDES = -I$(NETCDF)/include
+
+LIBS = -L$(NETCDF)/lib -lnetcdf_c++ -lnetcdf \
+        -lstdc++ \
+        -L/opt/Intel/cce/10.0.023/lib/ -lirc
+
+#        -L/usr/lib -lstdc++ \
+#MYDEBUG = -g
+MYDEBUG =
+
+proj3dsphere: proj3dsphere.o convert.o
+        $(CC) $(MYDEBUG) $(INCLUDES) -o $@ $&lt; convert.o $(LIBS)
+
+proj3dsphere.o: proj3dsphere.cpp
+        $(CC) $(MYDEBUG) $(INCLUDES) -c $&lt;
+
+convert.o: convert.c
+        $(CC) $(MYDEBUG) -c $&lt;
+
+projlatlon: projlatlon.cpp
+        $(CC) $(INCLUDES) -o $@ $&lt;  $(LIBS)
+
+proj3dquadrect: proj3dquadrect.cpp
+        $(CC) $(INCLUDES) -o $@ $&lt;  $(LIBS)
+
+clean:
+        rm *.o proj3dsphere projlatlon proj3dquadrect

Added: branches/ocean_projects/graphics/paraview/projection/proj3dquadrect.cpp
===================================================================
--- branches/ocean_projects/graphics/paraview/projection/proj3dquadrect.cpp                                (rev 0)
+++ branches/ocean_projects/graphics/paraview/projection/proj3dquadrect.cpp        2010-04-08 19:38:18 UTC (rev 186)
@@ -0,0 +1,611 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program translates a newpop netCDF data file to dual-grid lat/lon multilayer 
+// projection in legacy, ascii VTK format.
+//
+// Assume all variables are of interest.
+// Assume variable data type is double.
+// Assume variable dims are (Time, nCells|nVertices, nVertLevels|nVertLevelsP1)
+// Assume no more than 100 vars each for cell and point data
+// Does not deal with tracers.
+// Does not deal with edge data.
+// Only vis up to nVertLevels, not nVertLevelsP1.
+// Doubles converted to floats in .vtk files follow these rules:
+//        if a NaN, then become -FLT_MAX.
+//        if positive infinity, then become FLT_MAX
+//        if negative infinity, then become -FLT_MAX
+//        if smaller than a float, then become 0.
+//        if not zero, but between -FLT_MIN and FLT_MIN make -FLT_MIN or FLT_MIN
+//        if outside of -FLT_MAX and FLT_MAX make -FLT_MAX or FLT_MAX
+//
+// Version Beta
+// Christine Ahrens
+// 3/8/2010
+////////////////////////////////////////////////////////////////////////////////
+
+
+#include &lt;iostream&gt;
+#include &lt;fstream&gt;
+#include &lt;sstream&gt;
+#include &quot;stdlib.h&quot;
+#include &quot;vtkCellType.h&quot;
+#include &quot;netcdfcpp.h&quot;
+#include &lt;string&gt;
+#include &lt;cmath&gt;
+//#include &lt;math&gt;
+#include &lt;cfloat&gt;
+
+using namespace std;
+
+#define CHECK_MALLOC(ptr) \
+        if (ptr == NULL) { \
+                cerr &lt;&lt; &quot;malloc failed!</font>
<font color="blue">&quot;; \
+                exit(1); \
+        } 
+
+#define MAX_VARS 100
+#define DEFAULT_LAYER_THICKNESS 60000
+#define MY_PRECISION 12
+using namespace std;
+
+#define BUFF_SIZE 2048
+
+// overwrite outFile if it already exists
+int myCopyFile(string *inFile, string *outFile)
+{
+   char buff[BUFF_SIZE];
+   int readBytes = 1;
+
+   ifstream inFileStream(inFile-&gt;c_str(), ios::in|ios::binary);
+   if(!inFileStream)
+   {
+     return -1;
+   }
+
+   ofstream outFileStream(outFile-&gt;c_str(), ios::out|ios::binary);
+   if(!outFileStream)
+   {
+     return -1;
+   }
+
+   while(readBytes != 0)
+   {
+     inFileStream.read((char*)buff, BUFF_SIZE);
+     readBytes = inFileStream.gcount();
+     outFileStream.write((char*)buff, readBytes);
+   }
+   return 0;
+}
+
+int my_isinf_f(float x){
+        if (isinf(x)) {
+                return (x &lt; 0.0 ? -1 : 1);
+        } else return 0;
+}
+
+float convertDouble2ValidFloat(double inputData) {
+
+        // check for NaN
+        if (inputData != inputData) {
+                //cerr &lt;&lt; &quot;found NaN!&quot; &lt;&lt; endl;
+                return -FLT_MAX;
+        }
+
+        // check for infinity
+        int retval = my_isinf_f((float)inputData);
+        if (retval &lt; 0) {
+                return -FLT_MAX;
+        } else if (retval &gt; 0) {
+                return FLT_MAX;
+        }
+
+        // check number too small for float
+        if (abs(inputData) &lt; 1e-126) return 0.0;
+
+        if ((float)inputData == 0) return 0.0;
+
+        if ((abs(inputData) &gt; 0) &amp;&amp; (abs(inputData) &lt; FLT_MIN)) {
+                if (inputData &lt; 0) return -FLT_MIN; else return FLT_MIN;
+        }
+
+        if (abs(inputData) &gt; FLT_MAX) {
+                if (inputData &lt; 0) return -FLT_MAX; else return FLT_MAX;
+        }
+
+        return (float)inputData;
+}
+
+
+int main(int argc, char* argv[])
+{
+        if ((argc &lt; 3) || (argc &gt; 4))  {
+                cerr &lt;&lt; &quot;Usage: projlatlon infile.nc infile.vtk [layer_thickness]&quot; &lt;&lt; endl;
+                cerr &lt;&lt; &quot;Note: layer_thickness defaults to 10.&quot; &lt;&lt; endl;
+                exit(1);
+        }
+
+                
+        NcFile ncFile(argv[1]);
+
+        if (!ncFile.is_valid()) 
+        {
+                cerr &lt;&lt; &quot;Couldn't open file: &quot; &lt;&lt; argv[1] &lt;&lt; endl;
+                exit(1);
+        }
+
+        NcDim* nCells = ncFile.get_dim(&quot;nCells&quot;);
+        NcDim* nVertices = ncFile.get_dim(&quot;nVertices&quot;);
+        NcDim* vertexDegree = ncFile.get_dim(&quot;vertexDegree&quot;);
+        NcDim* Time = ncFile.get_dim(&quot;Time&quot;);
+        NcDim* nVertLevels = ncFile.get_dim(&quot;nVertLevels&quot;);
+
+        if ((vertexDegree-&gt;size() &lt; 3) || (vertexDegree-&gt;size() &gt; 4)) {
+                        cerr &lt;&lt; &quot;This code is only for hexagonal-primal/triangular-dual grid or quad-rect grid&quot; &lt;&lt; endl;
+                        exit(1);
+        }
+
+        // Can't check for this, b/c if not there it crashes program        
+        //NcDim* nVertLevelsP1 = ncFile.get_dim(&quot;nVertLevelsP1&quot;);
+        int maxNVertLevels = nVertLevels-&gt;size();
+
+        //cout &lt;&lt; &quot;maxNVertLevels: &quot; &lt;&lt; maxNVertLevels &lt;&lt; endl;

+        float layerThickness =  DEFAULT_LAYER_THICKNESS;
+        if (argc == 4) {
+                layerThickness = atof(argv[3]);
+        }
+
+        // figure out what variables to visualize
+        NcVar* dualCellVars[MAX_VARS];
+        NcVar* dualPointVars[MAX_VARS];
+        int dualCellVarIndex = -1;
+        int dualPointVarIndex = -1;
+        int numDualCells = nVertices-&gt;size();
+        //cout &lt;&lt; &quot;numDualCells: &quot; &lt;&lt; numDualCells &lt;&lt; endl;
+        int numDualPoints = nCells-&gt;size()+1;
+        //cout &lt;&lt; &quot;numDualPoints: &quot; &lt;&lt; numDualPoints &lt;&lt; endl;
+        
+        int numVars = ncFile.num_vars();
+
+        bool tracersExist = false;
+
+        for (int i = 0; i &lt; numVars; i++) {
+                NcVar* aVar = ncFile.get_var(i);
+
+                // must have 3 dims 
+                // (Time, nCells | nVertices, nVertLevels | nVertLevelsP1)
+
+                int numDims = aVar-&gt;num_dims();
+                //cout &lt;&lt; &quot;Num Dims of var: &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; is &quot; &lt;&lt; numDims &lt;&lt; endl;
+                if ((numDims != 3) &amp;&amp; (strcmp(aVar-&gt;name(), &quot;tracers&quot;))) {
+                        continue; // try the next var
+                } else {
+                        // TODO, check if it is a double
+                        // assume a double for now
+
+                        // check for Time dim 0
+                        NcToken dim0Name = aVar-&gt;get_dim(0)-&gt;name();
+                        if (strcmp(dim0Name, &quot;Time&quot;)) 
+                                continue;
+
+                        // check for dim 1 being num vertices or cells 
+                        bool isVertexData = false;
+                        bool isCellData = false;
+                        NcToken dim1Name = aVar-&gt;get_dim(1)-&gt;name();
+                        if (!strcmp(dim1Name, &quot;nVertices&quot;)) 
+                                isVertexData = true;
+                        else if (!strcmp(dim1Name, &quot;nCells&quot;)) 
+                                isCellData = true; 
+                        else continue;
+
+                        // check if dim 2 is nVertLevels or nVertLevelsP1, too
+                        NcToken dim2Name = aVar-&gt;get_dim(2)-&gt;name();
+                        if ((strcmp(dim2Name, &quot;nVertLevels&quot;)) 
+                                        &amp;&amp; (strcmp(dim2Name, &quot;nVertLevelsP1&quot;))) {
+                                continue;
+                        }
+
+                        // Add to cell or point var array
+                        if (isVertexData) {  // means it is dual cell data
+                                dualCellVarIndex++;
+                                if (dualCellVarIndex &gt; MAX_VARS-1) {
+                                        cerr &lt;&lt; &quot;Exceeded number of cell vars.&quot; &lt;&lt; endl;
+                                        exit(1);
+                                }
+                                dualCellVars[dualCellVarIndex] = aVar;
+                                //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualCellVars&quot; &lt;&lt; endl;
+                        } else if (isCellData) { // means it is dual vertex data
+                                if (strcmp(aVar-&gt;name(), &quot;tracers&quot;)) {
+                                        dualPointVarIndex++;
+                                        if (dualPointVarIndex &gt; MAX_VARS-1) {
+                                                cerr &lt;&lt; &quot;Exceeded number of point vars.&quot; &lt;&lt; endl;
+                                                exit(1);
+                                        }
+                                        dualPointVars[dualPointVarIndex] = aVar;
+                                        //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualPointVars&quot; &lt;&lt; endl;
+                                } else { // case of tracers, add each as &quot;tracer0&quot;, &quot;tracer1&quot;, etc.
+                                        tracersExist = true;
+                                        int numTracers = aVar-&gt;get_dim(3)-&gt;size();
+                                        for (int t = 0; t &lt; numTracers; t++) {
+                                                dualPointVarIndex++;
+                                                if (dualPointVarIndex &gt; MAX_VARS-1) {
+                                                        cerr &lt;&lt; &quot;Exceeded number of point vars.&quot; &lt;&lt; endl;
+                                                        exit(1);
+                                                }
+                                                dualPointVars[dualPointVarIndex] = aVar;
+                                                //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualPointVars&quot; &lt;&lt; endl;
+                                        }
+                                }
+                        }
+                }
+        }
+
+        // TODO
+         // prompt the user to find out which fields are of interest?
+        // for now, assume all are of interest
+        
+        // get points  (centers of primal-mesh cells)
+
+        // TO DO check malloc return vals.
+
+        double *xCellData = (double*)malloc(nCells-&gt;size() * sizeof(double));
+        CHECK_MALLOC(xCellData);
+        NcVar *xCellVar = ncFile.get_var(&quot;xCell&quot;);
+        xCellVar-&gt;get(xCellData, nCells-&gt;size());
+
+        double *yCellData = (double*)malloc(nCells-&gt;size() * sizeof(double));
+        CHECK_MALLOC(yCellData);
+        NcVar *yCellVar = ncFile.get_var(&quot;yCell&quot;);
+        yCellVar-&gt;get(yCellData, nCells-&gt;size());
+
+        // get dual-mesh cells
+
+        int *cellsOnVertex = (int *) malloc((nVertices-&gt;size()) * vertexDegree-&gt;size() * 
+                sizeof(int));
+        CHECK_MALLOC(cellsOnVertex);
+        int *myCellsOnVertex = (int *) malloc((nVertices-&gt;size()) * vertexDegree-&gt;size() * 
+                sizeof(int));
+        CHECK_MALLOC(myCellsOnVertex);
+
+        NcVar *cellsOnVertexVar = ncFile.get_var(&quot;cellsOnVertex&quot;);
+        //cout &lt;&lt; &quot;getting cellsOnVertexVar</font>
<font color="gray">&quot;;
+        cellsOnVertexVar-&gt;get(cellsOnVertex, nVertices-&gt;size(), vertexDegree-&gt;size());
+
+
+        // Go through all cellsOnVertex and &quot;zero out&quot; the cell if the triangle
+        // formed by the cell centers goes outside the lat/lon perimeter.  
+        // &quot;zero out&quot; means make all the points in the cell (0,0,0). 
+        // This is useful, because when we fetch the data, we don't have to skip
+        // over unused data, it will just be invisible when displayed.
+        // Store new list in myCellsOnVertex
+        
+        int *myptr = myCellsOnVertex;
+
+        for (int j = 0; j &lt; numDualCells; j++ ) {
+                int *dualCells = cellsOnVertex + (j * vertexDegree-&gt;size());
+                int lastk = vertexDegree-&gt;size()-1;
+                bool xWrap = false;
+                bool yWrap = false;
+                for (int k = 0; k &lt; vertexDegree-&gt;size(); k++) {
+                        if (abs(xCellData[dualCells[k]-1]  - xCellData[dualCells[lastk]-1]) &gt; 2000000) xWrap = true;
+                        if (abs(yCellData[dualCells[k]-1]  - yCellData[dualCells[lastk]]-1) &gt; 4000000) yWrap = true;
+                        lastk = k;
+                }
+
+                if (xWrap || yWrap) {
+                        //cerr &lt;&lt; &quot;Cell wrap: &quot; &lt;&lt; j &lt;&lt; endl;
+                }
+
+                if (xWrap) {
+                        //cerr &lt;&lt; &quot;It wrapped in x direction&quot; &lt;&lt; endl;
+                }
+
+                if (yWrap) {
+                        //cerr &lt;&lt; &quot;It wrapped in y direction&quot; &lt;&lt; endl;
+                }
+
+                // if cell doesn't extend past lat/lon perimeter, then add it to myCellsOnVertex
+                if (!xWrap &amp;&amp; !yWrap) {
+                        for (int k=0; k&lt; vertexDegree-&gt;size(); k++) {
+                                *myptr = *(dualCells+k);
+                                myptr++;
+                        }
+                } else { // add (0,0,0) point
+                        for (int k=0; k&lt; vertexDegree-&gt;size(); k++) {
+                                *myptr = 0;
+                                myptr++;
+                        }
+                }
+        }        
+                                                
+        // decls for data storage
+        double* dualCellVarData;
+        double* dualPointVarData;
+
+        // for each variable, allocate space for variables
+
+        //cout &lt;&lt; &quot;dualCellVarIndex: &quot; &lt;&lt; dualCellVarIndex &lt;&lt; endl;
+
+        int varVertLevels = 0;
+/*
+        dualCellVarData = (double*)malloc((sizeof(double))  
+                        * numDualCells * maxNVertLevels);
+        CHECK_MALLOC(dualCellVarData);
+        
+        dualPointVarData = (double*)malloc((sizeof(double))
+                        * nCells-&gt;size() * maxNVertLevels);
+        CHECK_MALLOC(dualPointVarData);
+*/
+        
+// write a file with the geometry.
+
+                ostringstream geoFileName;
+
+                geoFileName &lt;&lt; &quot;geo_&quot; &lt;&lt; argv[2];         
+
+                ofstream geoFile(geoFileName.str().c_str(), ios::out);
+
+                if (!geoFile)
+                {
+                        cerr &lt;&lt; &quot;vtk output file could not be opened&quot; &lt;&lt;endl;
+                        exit(1);
+                }
+
+
+                // write header
+
+                geoFile &lt;&lt; &quot;# vtk DataFile Version 2.0&quot; &lt;&lt; endl;
+                geoFile &lt;&lt; &quot;Project newpop geometry to lat/lon projection from netCDF by Christine Ahrens&quot; 
+                        &lt;&lt; endl;
+                geoFile &lt;&lt; &quot;ASCII&quot; &lt;&lt; endl;
+                geoFile &lt;&lt; &quot;DATASET UNSTRUCTURED_GRID&quot; &lt;&lt; endl;
+
+
+                // write points  (the points are the primal-grid cell centers)
+
+                geoFile &lt;&lt; &quot;POINTS &quot; &lt;&lt; numDualPoints*(maxNVertLevels+1) &lt;&lt; &quot; float&quot; &lt;&lt; endl;
+
+        // write the point at each vertical level, plus one level for last layer
+
+        //cout &lt;&lt; &quot;Writing dummy points&quot; &lt;&lt; endl;
+        for (int levelNum = 0; levelNum &lt; maxNVertLevels+1; levelNum++) {
+                
+                // first write a dummy point, because the climate code
+                // starts their cell numbering at 1 and VTK starts it at
+                // 0
+                geoFile.precision(MY_PRECISION);
+                geoFile &lt;&lt; (float)0.0 &lt;&lt; &quot;\t&quot; &lt;&lt; (float)0.0 &lt;&lt; &quot;\t&quot; &lt;&lt; (float)0.0 
+                        &lt;&lt; endl;
+        }
+
+        //cout &lt;&lt; &quot;Writing points at each level&quot; &lt;&lt; endl;
+
+        for (int j = 0; j &lt; nCells-&gt;size(); j++ )
+        {
+                geoFile.precision(MY_PRECISION);
+        /*        const double PI = 3.141592;
+                xCellData[j] = xCellData[j] * 180.0 / PI;
+                yCellData[j] = yCellData[j] * 180.0 / PI;
+        */
+                if (abs(xCellData[j]) &lt; 1e-126) xCellData[j] = 0;
+                if (abs(yCellData[j]) &lt; 1e-126) yCellData[j] = 0;
+
+                for (int levelNum = 0; levelNum &lt; maxNVertLevels+1; levelNum++) {
+                        geoFile &lt;&lt; xCellData[j] &lt;&lt; &quot;\t&quot; &lt;&lt; yCellData[j] &lt;&lt; &quot;\t&quot; &lt;&lt; -(((float)levelNum)*layerThickness) &lt;&lt; endl;
+                }
+        }        
+
+                geoFile &lt;&lt; endl;
+
+
+                // Write dual-mesh cells
+                // Dual-mesh cells are triangles with primal-mesh cell 
+                // centers as the vertices.
+                // The number of dual-mesh cells is the number of vertices in the
+                // primal mesh.
+
+                int newDegree = 2*vertexDegree-&gt;size();
+
+                geoFile &lt;&lt; &quot;CELLS &quot; &lt;&lt; numDualCells*maxNVertLevels &lt;&lt; &quot; &quot; 
+                        &lt;&lt; numDualCells * (newDegree + 1) * maxNVertLevels &lt;&lt; endl;        
+
+                // for each dual-mesh cell, write number of points for each
+                // and then list the points by number
+
+                //cout &lt;&lt; &quot;Writing Cells&quot; &lt;&lt; endl;
+
+                for (int j = 0; j &lt; numDualCells ; j++) {
+
+                        // since primal vertex(pt) numbers  == dual cell numbers
+                        // we go through the primal vertices, find the cells around
+                        // them, and since those primal cell numbers are dual 
+                        // point numbers,  
+                        // we can write the cell numbers for the cellsOnVertex
+                        // and those will be the numbers of the dual vertices (pts).
+                        
+                        int* dualCells = myCellsOnVertex + (j * vertexDegree-&gt;size());
+
+                        // for each level, write the prism
+                        for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++) {
+                                geoFile &lt;&lt; newDegree &lt;&lt; &quot;\t&quot; ;
+                                for (int k = 0; k &lt; vertexDegree-&gt;size(); k++) 
+                                {                
+                                        geoFile &lt;&lt; (dualCells[k]*(maxNVertLevels+1)) + levelNum &lt;&lt; &quot;\t&quot;;
+                                }
+                                for (int k = 0; k &lt; vertexDegree-&gt;size(); k++) 
+                                {                
+                                        geoFile &lt;&lt; (dualCells[k]*(maxNVertLevels+1)) + levelNum+1 &lt;&lt; &quot;\t&quot;;
+                                }
+                                geoFile &lt;&lt; endl;
+                        }
+                }        
+
+                // write cell types 
+                int cellType;
+                if (vertexDegree-&gt;size()==3) {
+                        cellType = VTK_WEDGE;
+                } else {
+                        cellType = VTK_HEXAHEDRON;
+                } 
+
+                geoFile &lt;&lt; &quot;CELL_TYPES &quot; &lt;&lt; numDualCells*maxNVertLevels &lt;&lt; endl;
+
+//multiply by number of levels
+                for (int j = 0; j &lt; numDualCells*maxNVertLevels; j++)
+                {
+                        geoFile &lt;&lt; cellType &lt;&lt; endl;
+                }
+
+        // release resources
+        geoFile.close();
+        free(xCellData);
+        free(yCellData);
+        free(cellsOnVertex);
+        free(myCellsOnVertex);
+
+        // For each timestep, write data for each level
+
+        dualCellVarData = (double*)malloc((sizeof(double))  * numDualCells * maxNVertLevels);
+        CHECK_MALLOC(dualCellVarData);
+
+        dualPointVarData = (double*)malloc((sizeof(double)) * nCells-&gt;size() * maxNVertLevels);
+        CHECK_MALLOC(dualPointVarData);
+
+        // for each timestep, copy the geometry file, since we don't want to
+        // have to recompute the points
+        for (int i = 0; i &lt; Time-&gt;size(); i++) {
+                ostringstream vtkFileName;
+                vtkFileName &lt;&lt; i &lt;&lt; argv[2];
+
+                string geoFileNameString = geoFileName.str();
+                string vtkFileNameString = vtkFileName.str();
+                int copyRetVal = myCopyFile(&amp;geoFileNameString, &amp;vtkFileNameString);
+                //cout &lt;&lt; &quot;myCopyFile returned: &quot; &lt;&lt; copyRetVal &lt;&lt; endl;
+
+                ofstream vtkFile(vtkFileName.str().c_str(), ios::out|ios::app);
+                if (!vtkFile)
+                {
+                        cerr &lt;&lt; &quot;vtk output file could not be opened&quot; &lt;&lt;endl;
+                        exit(1);
+                }
+
+                if (!vtkFile)
+                {
+                        cerr &lt;&lt; &quot;vtk output file could not be opened&quot; &lt;&lt;endl;
+                        exit(1);
+                }
+
+                vtkFile.precision(MY_PRECISION);
+
+                // If by point, write out point data
+
+                if (dualPointVarIndex &gt;= 0) vtkFile &lt;&lt; &quot;POINT_DATA &quot; &lt;&lt; numDualPoints*(maxNVertLevels+1) &lt;&lt; endl;
+
+                int printstep = -1;
+
+                if (i == printstep) cout &lt;&lt; &quot;TIME STEP: &quot; &lt;&lt; i &lt;&lt; endl;
+
+                int tracerNum = 0;
+
+                for (int v = 0; v &lt;= dualPointVarIndex; v++) {
+
+                        // Read variable number v data for that timestep
+
+                        varVertLevels = dualPointVars[v]-&gt;get_dim(2)-&gt;size();
+
+                        bool isTracer = false;
+
+                        if (!strcmp(dualPointVars[v]-&gt;name(), &quot;tracers&quot;)) {
+                                isTracer = true;
+                        // Uncomment if want to exclude tracers.  
+                        //        continue;
+                        }
+
+                        // Write variable number v data for that timestep
+                        vtkFile &lt;&lt; &quot;SCALARS &quot; &lt;&lt; dualPointVars[v]-&gt;name();
+                        if (isTracer) vtkFile &lt;&lt; tracerNum+1;
+                        vtkFile &lt;&lt; &quot; float 1&quot; &lt;&lt;  endl;
+                        vtkFile &lt;&lt; &quot;LOOKUP_TABLE default&quot; &lt;&lt; endl;
+
+
+                        if (isTracer) {
+                                dualPointVars[v]-&gt;set_cur(i, 0, 0, tracerNum);
+                                dualPointVars[v]-&gt;get(dualPointVarData, 1, nCells-&gt;size(), maxNVertLevels, 1);
+                        } else {
+                                dualPointVars[v]-&gt;set_cur(i, 0, 0);
+                                dualPointVars[v]-&gt;get(dualPointVarData, 1, nCells-&gt;size(), maxNVertLevels);
+                        }
+
+
+                        float defaultPointVal = 0.0;
+
+                        vtkFile.precision(MY_PRECISION);
+                        //write dummy
+
+                        double *var_target = dualPointVarData;
+                        float validData;
+
+                        for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++) {
+
+                                validData = convertDouble2ValidFloat (*var_target);
+
+                                // write dummy
+                                vtkFile &lt;&lt; validData &lt;&lt; endl;
+        
+                                var_target++;
+                        }
+
+                        // write highest level dummy point
+                        vtkFile &lt;&lt; validData &lt;&lt; endl;
+
+                        var_target = dualPointVarData;
+
+                        for (int j = 0; j &lt; nCells-&gt;size(); j++) {
+
+                                // write data for one point lowest level to highest
+                                for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++) {
+
+                                        validData = convertDouble2ValidFloat (*var_target);
+                                        vtkFile &lt;&lt; validData &lt;&lt; endl;
+                                        var_target++;
+                                }
+                        
+                                // for last layer of dual points, repeat last level's values
+                                // Need Mark's input on this one
+                                vtkFile &lt;&lt; validData &lt;&lt; endl;
+                        }
+
+                        if (isTracer) tracerNum++;
+                }
+
+                // if by cell, then write out cell data
+
+                if (dualCellVarIndex &gt;= 0) vtkFile &lt;&lt; &quot;CELL_DATA &quot; &lt;&lt; numDualCells*maxNVertLevels &lt;&lt; endl;
+
+                for (int v = 0; v &lt;= dualCellVarIndex; v++) {
+
+                        // Write variable number v data for that timestep
+                        vtkFile &lt;&lt; &quot;SCALARS &quot; &lt;&lt; dualCellVars[v]-&gt;name() &lt;&lt; &quot; float 1&quot; &lt;&lt;  endl;
+                        vtkFile &lt;&lt; &quot;LOOKUP_TABLE default&quot; &lt;&lt; endl;
+
+                        // Read variable number v data for that timestep and level
+                        dualCellVars[v]-&gt;set_cur(i, 0, 0);
+                        dualCellVars[v]-&gt;get(dualCellVarData, 1, numDualCells, maxNVertLevels);
+
+                        vtkFile.precision(MY_PRECISION);
+                        for (int j = 0; j &lt; numDualCells; j++) {
+
+                                double *var_target = dualCellVarData;
+
+                                for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++)
+                                {
+                                        float validData = convertDouble2ValidFloat (*var_target);
+                                        vtkFile &lt;&lt; validData &lt;&lt; endl;
+
+                                        var_target++;
+                                }
+                        }
+                }
+        }
+}
+


Property changes on: branches/ocean_projects/graphics/paraview/projection/proj3dquadrect.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/x-c++src
Name: svn:keywords
   + Author Date ID Revision
Name: svn:eol-style
   + native

Added: branches/ocean_projects/graphics/paraview/projection/proj3dsphere.cpp
===================================================================
--- branches/ocean_projects/graphics/paraview/projection/proj3dsphere.cpp                                (rev 0)
+++ branches/ocean_projects/graphics/paraview/projection/proj3dsphere.cpp        2010-04-08 19:38:18 UTC (rev 186)
@@ -0,0 +1,569 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program translates a newpop netCDF data file to dual-grid legacy, ascii VTK format
+// The variables that have time dim are automatically written.
+// Version Beta
+//
+// Assume all variables are of interest.
+// Assume variable data type is double.
+// Assume variable dims are (Time, nCells|nVertices, nVertLevels|nVertLevelsP1, [nTracers])
+// Assume no more than 100 vars each for cell and point data
+// Does not deal with edge data.
+// Only vis up to nVertLevels, not nVertLevelsP1.
+// Doubles converted to floats in .vtk files follow these rules:
+//        if a NaN, then become -FLT_MAX.
+//        if positive infinity, then become FLT_MAX
+//        if negative infinity, then become -FLT_MAX
+//        if smaller than a float, then become 0.
+//        if not zero, but between -FLT_MIN and FLT_MIN make -FLT_MIN or FLT_MIN
+//        if outside of -FLT_MAX and FLT_MAX make -FLT_MAX or FLT_MAX
+//
+// Christine Ahrens
+// 3/8/2010
+//
+////////////////////////////////////////////////////////////////////////////////
+
+
+#include &lt;iostream&gt;
+#include &lt;fstream&gt;
+#include &lt;sstream&gt;
+#include &quot;stdlib.h&quot;
+#include &quot;vtkCellType.h&quot;
+#include &quot;netcdfcpp.h&quot;
+#include &lt;string&gt;
+#include &lt;cmath&gt;
+#include &lt;cfloat&gt;
+
+using namespace std;
+
+#define CHECK_MALLOC(ptr) \
+        if (ptr == NULL) { \
+                cerr &lt;&lt; &quot;malloc failed!</font>
<font color="blue">&quot;; \
+                exit(1); \
+        } 
+
+#define MAX_VARS 100
+#define DEFAULT_LAYER_THICKNESS 100000
+
+extern &quot;C&quot; {
+        void CartesianToSpherical(float x, float y, float z, float* rho, float* phi, float* theta);
+        void SphericalToCartesian(float rho, float phi, float theta, float* x, float* y, float* z);
+}        
+
+// START
+#include &lt;fstream&gt;
+#include &lt;iostream&gt;
+#include &lt;string&gt;
+
+using namespace std;
+
+#define BUFF_SIZE 2048
+
+// overwrite outFile if it already exists
+int myCopyFile(string *inFile, string *outFile)
+{
+   char buff[BUFF_SIZE];
+   int readBytes = 1;
+
+   ifstream inFileStream(inFile-&gt;c_str(), ios::in|ios::binary);
+   if(!inFileStream)
+   {
+     return -1;
+   }
+
+   ofstream outFileStream(outFile-&gt;c_str(), ios::out|ios::binary);
+   if(!outFileStream)
+   {
+     return -1;
+   }
+
+   while(readBytes != 0)
+   {
+     inFileStream.read((char*)buff, BUFF_SIZE);
+     readBytes = inFileStream.gcount();
+     outFileStream.write((char*)buff, readBytes);
+   }
+   return 0;
+}
+
+int my_isinf_f(float x){
+        if (isinf(x)) {
+                return (x &lt; 0.0 ? -1 : 1);
+        } else return 0;
+}
+
+float convertDouble2ValidFloat(double inputData) {
+
+        // check for NaN
+        if (inputData != inputData) {
+                cerr &lt;&lt; &quot;found NaN!&quot; &lt;&lt; endl;
+                return -FLT_MAX;
+        }
+
+        // check for infinity
+        int retval = my_isinf_f((float)inputData);
+        if (retval &lt; 0) {
+                return -FLT_MAX;
+        } else if (retval &gt; 0) {
+                return FLT_MAX;
+        }
+
+        // check number too small for float
+        if (abs(inputData) &lt; 1e-126) return 0.0;
+
+        if ((float)inputData == 0) return 0.0;
+
+        if ((abs(inputData) &gt; 0) &amp;&amp; (abs(inputData) &lt; FLT_MIN)) {
+                if (inputData &lt; 0) return -FLT_MIN; else return FLT_MIN;
+        }
+        
+        if (abs(inputData) &gt; FLT_MAX) {
+                if (inputData &lt; 0) return -FLT_MAX; else return FLT_MAX;
+        }
+
+        return (float)inputData;
+}
+
+int main(int argc, char* argv[])
+{
+        if ((argc &lt; 3) || (argc &gt; 4))  {
+                cerr &lt;&lt; &quot;Usage: proj3dsphere infile.nc infile.vtk [layer_thickness]&quot; &lt;&lt; endl;
+                cerr &lt;&lt; &quot;Note: layer_thickness defaults to 100000.&quot; &lt;&lt; endl;
+                exit(1);
+        }
+
+        //cerr &lt;&lt; &quot;FLT_MAX: &quot; &lt;&lt; FLT_MAX &lt;&lt; &quot; FLT_MIN: &quot; &lt;&lt; FLT_MIN &lt;&lt; endl;
+
+        NcFile ncFile(argv[1]);
+
+        if (!ncFile.is_valid()) 
+        {
+                cerr &lt;&lt; &quot;Couldn't open file: &quot; &lt;&lt; argv[1] &lt;&lt; endl;
+                exit(1);
+        }
+
+        int layerThickness =  DEFAULT_LAYER_THICKNESS;
+        if (argc == 4) {
+                layerThickness = atoi(argv[3]);
+        }
+
+        NcDim* nCells = ncFile.get_dim(&quot;nCells&quot;);
+        NcDim* nVertices = ncFile.get_dim(&quot;nVertices&quot;);
+        NcDim* vertexDegree = ncFile.get_dim(&quot;vertexDegree&quot;);
+        NcDim* Time = ncFile.get_dim(&quot;Time&quot;);
+        NcDim* nVertLevels = ncFile.get_dim(&quot;nVertLevels&quot;);
+
+        // Can't check for this, b/c if not there it crashes program        
+        //NcDim* nVertLevelsP1 = ncFile.get_dim(&quot;nVertLevelsP1&quot;);
+        int maxNVertLevels = nVertLevels-&gt;size();
+
+        //cout &lt;&lt; &quot;maxNVertLevels: &quot; &lt;&lt; maxNVertLevels &lt;&lt; endl;
+
+        // figure out what variables to visualize
+        NcVar* dualCellVars[MAX_VARS];
+        NcVar* dualPointVars[MAX_VARS];
+        int dualCellVarIndex = -1;
+        int dualPointVarIndex = -1;
+        int numDualCells = nVertices-&gt;size();
+        int numDualPoints = nCells-&gt;size()+1;
+
+        int numVars = ncFile.num_vars();
+
+        bool tracersExist = false;
+
+        for (int i = 0; i &lt; numVars; i++) {
+                NcVar* aVar = ncFile.get_var(i);
+
+                // must have 3 dims 
+                // (Time, nCells | nVertices, nVertLevels | nVertLevelsP1)
+
+                int numDims = aVar-&gt;num_dims();
+                //cout &lt;&lt; &quot;Num Dims of var: &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; is &quot; &lt;&lt; numDims &lt;&lt; endl;
+                if ((numDims != 3) &amp;&amp; (strcmp(aVar-&gt;name(), &quot;tracers&quot;))) {
+                        continue; // try the next var
+                } else {
+                        // TODO, check if it is a double
+                        // assume a double for now
+
+                        // check for Time dim 0
+                        NcToken dim0Name = aVar-&gt;get_dim(0)-&gt;name();
+                        if (strcmp(dim0Name, &quot;Time&quot;)) 
+                                continue;
+
+                        // check for dim 1 being num vertices or cells 
+                        bool isVertexData = false;
+                        bool isCellData = false;
+                        NcToken dim1Name = aVar-&gt;get_dim(1)-&gt;name();
+                        if (!strcmp(dim1Name, &quot;nVertices&quot;)) 
+                                isVertexData = true;
+                        else if (!strcmp(dim1Name, &quot;nCells&quot;)) 
+                                isCellData = true; 
+                        else continue;
+
+                        // check if dim 2 is nVertLevels or nVertLevelsP1, too
+                        NcToken dim2Name = aVar-&gt;get_dim(2)-&gt;name();
+                        if ((strcmp(dim2Name, &quot;nVertLevels&quot;)) 
+                                        &amp;&amp; (strcmp(dim2Name, &quot;nVertLevelsP1&quot;))) {
+                                continue;
+                        }
+
+                        // Add to cell or point var array
+                        if (isVertexData) {  // means it is dual cell data
+                                dualCellVarIndex++;
+                                if (dualCellVarIndex &gt; MAX_VARS-1) {
+                                        cerr &lt;&lt; &quot;Exceeded number of cell vars.&quot; &lt;&lt; endl;
+                                        exit(1);
+                                }
+                                dualCellVars[dualCellVarIndex] = aVar;
+                                //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualCellVars&quot; &lt;&lt; endl;
+                        } else if (isCellData) { // means it is dual vertex data
+                                if (strcmp(aVar-&gt;name(), &quot;tracers&quot;)) {
+                                        dualPointVarIndex++;
+                                        if (dualPointVarIndex &gt; MAX_VARS-1) {
+                                                cerr &lt;&lt; &quot;Exceeded number of point vars.&quot; &lt;&lt; endl;
+                                                exit(1);
+                                        }
+                                        dualPointVars[dualPointVarIndex] = aVar;
+                                        //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualPointVars&quot; &lt;&lt; endl;
+                                } else { // case of tracers, add each as &quot;tracer0&quot;, &quot;tracer1&quot;, etc.
+                                        tracersExist = true;
+                                        int numTracers = aVar-&gt;get_dim(3)-&gt;size();
+                                        for (int t = 0; t &lt; numTracers; t++) {
+                                                dualPointVarIndex++;
+                                                if (dualPointVarIndex &gt; MAX_VARS-1) {
+                                                        cerr &lt;&lt; &quot;Exceeded number of point vars.&quot; &lt;&lt; endl;
+                                                        exit(1);
+                                                }
+                                                dualPointVars[dualPointVarIndex] = aVar;
+                                                //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualPointVars&quot; &lt;&lt; endl;
+                                        }
+                                }
+                        }
+                }
+        }
+
+        // TODO
+        // prompt the user to find out which fields are of interest?
+        // for now, assume all are of interest
+
+        // get points  (centers of primal-mesh cells)
+
+        // TO DO check malloc return vals.
+
+        double *xCellData = (double*)malloc(nCells-&gt;size() 
+                        * sizeof(double));
+        CHECK_MALLOC(xCellData);
+        NcVar *xCellVar = ncFile.get_var(&quot;xCell&quot;);
+        xCellVar-&gt;get(xCellData, nCells-&gt;size());
+
+        double *yCellData = (double*)malloc(nCells-&gt;size() 
+                        * sizeof(double));
+        CHECK_MALLOC(yCellData);
+        NcVar *yCellVar = ncFile.get_var(&quot;yCell&quot;);
+        yCellVar-&gt;get(yCellData, nCells-&gt;size());
+
+        double *zCellData = (double*)malloc(nCells-&gt;size() 
+                        * sizeof(double));
+        //cout &lt;&lt; &quot;ptr for zCellData&quot;  &lt;&lt; zCellData &lt;&lt; endl;
+        CHECK_MALLOC(zCellData);
+        NcVar *zCellVar = ncFile.get_var(&quot;zCell&quot;);
+        zCellVar-&gt;get(zCellData, nCells-&gt;size());
+
+        // get dual-mesh cells
+
+        int *cellsOnVertex = (int *) malloc((nVertices-&gt;size()) * vertexDegree-&gt;size() * 
+                        sizeof(int));
+        //cout &lt;&lt; &quot;ptr for cellsOnVertex&quot;  &lt;&lt; cellsOnVertex &lt;&lt; endl;
+        CHECK_MALLOC(cellsOnVertex);
+        NcVar *cellsOnVertexVar = ncFile.get_var(&quot;cellsOnVertex&quot;);
+        //cout &lt;&lt; &quot;getting cellsOnVertexVar</font>
<font color="gray">&quot;;
+        cellsOnVertexVar-&gt;get(cellsOnVertex, nVertices-&gt;size(), vertexDegree-&gt;size());
+
+        // decls for data storage
+        double* dualCellVarData;
+        double* dualPointVarData;
+
+        // for each variable, allocate space for variables
+
+        //cout &lt;&lt; &quot;dualCellVarIndex: &quot; &lt;&lt; dualCellVarIndex &lt;&lt; endl;
+
+        int varVertLevels = 0;
+
+
+        // write a file with the geometry.
+
+        ostringstream geoFileName;
+
+        geoFileName &lt;&lt; &quot;geo_&quot; &lt;&lt; argv[2];         
+
+        ofstream geoFile(geoFileName.str().c_str(), ios::out);
+
+        if (!geoFile)
+        {
+                cerr &lt;&lt; &quot;vtk output file could not be opened&quot; &lt;&lt;endl;
+                exit(1);
+        }
+
+
+        // write header
+
+        geoFile &lt;&lt; &quot;# vtk DataFile Version 2.0&quot; &lt;&lt; endl;
+        geoFile &lt;&lt; &quot;Translated newpop geometry to dual grid on 3D sphere from netCDF by Christine Ahrens&quot; 
+                &lt;&lt; endl;
+        geoFile &lt;&lt; &quot;ASCII&quot; &lt;&lt; endl;
+        geoFile &lt;&lt; &quot;DATASET UNSTRUCTURED_GRID&quot; &lt;&lt; endl;
+
+
+        // write points  (the points are the primal-grid cell centers)
+
+        geoFile &lt;&lt; &quot;POINTS &quot; &lt;&lt; numDualPoints*(maxNVertLevels+1) &lt;&lt; &quot; float&quot; &lt;&lt; endl;
+
+        // write the point at each vertical level, plus one level for last layer
+
+        //cout &lt;&lt; &quot;Writing dummy points&quot; &lt;&lt; endl;
+        for (int levelNum = 0; levelNum &lt; maxNVertLevels+1; levelNum++) {
+
+                // first write a dummy point, because the climate code
+                // starts their cell numbering at 1 and VTK starts it at
+                // 0
+                geoFile.precision(16);
+                geoFile &lt;&lt; (float)0.0 &lt;&lt; &quot;\t&quot; &lt;&lt; (float)0.0 &lt;&lt; &quot;\t&quot; &lt;&lt; (float)0.0 
+                        &lt;&lt; endl;
+        }
+
+        //cout &lt;&lt; &quot;Writing points at each level&quot; &lt;&lt; endl;
+        for (int j = 0; j &lt; nCells-&gt;size(); j++ )
+        {
+                geoFile.precision(16);
+                if (abs(xCellData[j]) &lt; 1e-126) xCellData[j] = 0;
+                if (abs(yCellData[j]) &lt; 1e-126) yCellData[j] = 0;
+                if (abs(zCellData[j]) &lt; 1e-126) zCellData[j] = 0;
+
+                float rho, rholevel, theta, phi, x, y, z;
+
+                CartesianToSpherical((float)xCellData[j], (float)yCellData[j], (float)zCellData[j], 
+                                &amp;rho, &amp;phi, &amp;theta);
+
+                for (int levelNum = 0; levelNum &lt; maxNVertLevels+1; levelNum++) {
+
+                        // decrease rho, so we go down (inwards towards the center of the sphere)
+                        rholevel = rho - (layerThickness * levelNum);
+
+                        SphericalToCartesian(rholevel, phi, theta, &amp;x, &amp;y, &amp;z);
+
+                        geoFile &lt;&lt; x &lt;&lt; &quot;\t&quot; &lt;&lt; y &lt;&lt; &quot;\t&quot; &lt;&lt; z &lt;&lt; endl;
+                }
+        }        
+
+        geoFile &lt;&lt; endl;
+
+
+        // Write dual-mesh cells
+        // Dual-mesh cells are triangles with primal-mesh cell 
+        // centers as the vertices.
+        // The number of dual-mesh cells is the number of vertices in the
+        // primal mesh.
+
+        int newDegree = 6;
+
+        geoFile &lt;&lt; &quot;CELLS &quot; &lt;&lt; numDualCells*maxNVertLevels &lt;&lt; &quot; &quot; 
+                &lt;&lt; numDualCells * (newDegree + 1) * maxNVertLevels &lt;&lt; endl;        
+
+        // for each dual-mesh cell, write number of points for each
+        // and then list the points by number
+
+        //cout &lt;&lt; &quot;Writing Cells&quot; &lt;&lt; endl;
+
+        for (int j = 0; j &lt; numDualCells ; j++) {
+
+                // since primal vertex(pt) numbers  == dual cell numbers
+                // we go through the primal vertices, find the cells around
+                // them, and since those primal cell numbers are dual 
+                // point numbers,  
+                // we can write the cell numbers for the cellsOnVertex
+                // and those will be the numbers of the dual vertices (pts).
+
+                int* dualCells = cellsOnVertex + (j * vertexDegree-&gt;size());
+
+                // for each level, write the prism
+                for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++) {
+                        geoFile &lt;&lt; newDegree &lt;&lt; &quot;\t&quot; ;
+                        for (int k = 0; k &lt; vertexDegree-&gt;size(); k++) 
+                        {                
+                                geoFile &lt;&lt; (dualCells[k]*(maxNVertLevels+1)) + levelNum &lt;&lt; &quot;\t&quot;;
+                        }
+                        for (int k = 0; k &lt; vertexDegree-&gt;size(); k++) 
+                        {                
+                                geoFile &lt;&lt; (dualCells[k]*(maxNVertLevels+1)) + levelNum+1 &lt;&lt; &quot;\t&quot;;
+                        }
+                        geoFile &lt;&lt; endl;
+                }
+        }        
+        geoFile &lt;&lt; endl;
+
+
+        // write cell types 
+        int cellType;
+
+        if (vertexDegree-&gt;size() == 3) 
+                cellType = VTK_WEDGE;
+
+        geoFile &lt;&lt; &quot;CELL_TYPES &quot; &lt;&lt; numDualCells*maxNVertLevels &lt;&lt; endl;
+
+        //multiply by number of levels
+        for (int j = 0; j &lt; numDualCells*maxNVertLevels; j++)
+        {
+                geoFile &lt;&lt; cellType &lt;&lt; endl;
+        }
+        geoFile &lt;&lt; endl;
+
+
+        // release resources
+        geoFile.close();
+        free(xCellData);
+        free(yCellData);
+        free(zCellData);
+        free(cellsOnVertex);
+
+        // For each timestep, write data for each level
+
+        dualCellVarData = (double*)malloc((sizeof(double))  * numDualCells * maxNVertLevels);
+        CHECK_MALLOC(dualCellVarData);
+
+        dualPointVarData = (double*)malloc((sizeof(double)) * nCells-&gt;size() * maxNVertLevels);
+        CHECK_MALLOC(dualPointVarData);
+
+        // for each timestep, copy the geometry file, since we don't want to
+        // have to recompute the points
+        for (int i = 0; i &lt; Time-&gt;size(); i++) {
+                ostringstream vtkFileName;
+                vtkFileName &lt;&lt; i &lt;&lt; argv[2];
+
+                string geoFileNameString = geoFileName.str();
+                string vtkFileNameString = vtkFileName.str();
+                int copyRetVal = myCopyFile(&amp;geoFileNameString, &amp;vtkFileNameString);
+                //cout &lt;&lt; &quot;myCopyFile returned: &quot; &lt;&lt; copyRetVal &lt;&lt; endl;
+
+                ofstream vtkFile(vtkFileName.str().c_str(), ios::out|ios::app);
+                if (!vtkFile)
+                {
+                        cerr &lt;&lt; &quot;vtk output file could not be opened&quot; &lt;&lt;endl;
+                        exit(1);
+                }
+
+                if (!vtkFile)
+                {
+                        cerr &lt;&lt; &quot;vtk output file could not be opened&quot; &lt;&lt;endl;
+                        exit(1);
+                }
+
+                vtkFile.precision(16);
+
+                // If by point, write out point data
+
+                if (dualPointVarIndex &gt;= 0) vtkFile &lt;&lt; &quot;POINT_DATA &quot; &lt;&lt; numDualPoints*(maxNVertLevels+1) &lt;&lt; endl;
+
+                int printstep = -1;
+
+                if (i == printstep) cout &lt;&lt; &quot;TIME STEP: &quot; &lt;&lt; i &lt;&lt; endl;
+
+                int tracerNum = 0;
+
+                for (int v = 0; v &lt;= dualPointVarIndex; v++) {
+
+                        // Read variable number v data for that timestep
+
+                        varVertLevels = dualPointVars[v]-&gt;get_dim(2)-&gt;size();
+
+                        bool isTracer = false;
+
+                        if (!strcmp(dualPointVars[v]-&gt;name(), &quot;tracers&quot;)) {
+                                isTracer = true;
+                        // Uncomment if want to exclude tracers.  
+                        //        continue;
+                        }
+                        // Write variable number v data for that timestep
+                        vtkFile &lt;&lt; &quot;SCALARS &quot; &lt;&lt; dualPointVars[v]-&gt;name();
+                        if (isTracer) vtkFile &lt;&lt; tracerNum+1;
+                        vtkFile &lt;&lt; &quot; float 1&quot; &lt;&lt;  endl;
+                        vtkFile &lt;&lt; &quot;LOOKUP_TABLE default&quot; &lt;&lt; endl;
+
+
+                        if (isTracer) {
+                                dualPointVars[v]-&gt;set_cur(i, 0, 0, tracerNum);
+                                dualPointVars[v]-&gt;get(dualPointVarData, 1, nCells-&gt;size(), maxNVertLevels, 1);
+                        } else {
+                                dualPointVars[v]-&gt;set_cur(i, 0, 0);
+                                dualPointVars[v]-&gt;get(dualPointVarData, 1, nCells-&gt;size(), maxNVertLevels);
+                        }
+
+
+                        float defaultPointVal = 0.0;
+
+                        //write dummy
+
+                        double *var_target = dualPointVarData;
+                        float validData;
+
+                        for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++) {
+
+                                validData = convertDouble2ValidFloat (*var_target);
+
+                                // write dummy
+                                vtkFile &lt;&lt; validData &lt;&lt; endl;
+        
+                                var_target++;
+                        }
+
+                        // write highest level dummy point
+                        vtkFile &lt;&lt; validData &lt;&lt; endl;
+
+                        var_target = dualPointVarData;
+
+                        for (int j = 0; j &lt; nCells-&gt;size(); j++) {
+
+                                // write data for one point lowest level to highest
+                                for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++) {
+
+                                        validData = convertDouble2ValidFloat (*var_target);
+                                        vtkFile &lt;&lt; validData &lt;&lt; endl;
+                                        var_target++;
+                                }
+                        
+                                // for last layer of dual points, repeat last level's values
+                                // Need Mark's input on this one
+                                vtkFile &lt;&lt; validData &lt;&lt; endl;
+                        }
+
+                        if (isTracer) tracerNum++;
+                }
+
+                // if by cell, then write out cell data
+
+                if (dualCellVarIndex &gt;= 0) vtkFile &lt;&lt; &quot;CELL_DATA &quot; &lt;&lt; numDualCells*maxNVertLevels &lt;&lt; endl;
+
+                for (int v = 0; v &lt;= dualCellVarIndex; v++) {
+
+                        // Write variable number v data for that timestep
+                        vtkFile &lt;&lt; &quot;SCALARS &quot; &lt;&lt; dualCellVars[v]-&gt;name() &lt;&lt; &quot; float 1&quot; &lt;&lt;  endl;
+                        vtkFile &lt;&lt; &quot;LOOKUP_TABLE default&quot; &lt;&lt; endl;
+
+                        // Read variable number v data for that timestep and level
+                        dualCellVars[v]-&gt;set_cur(i, 0, 0);
+                        dualCellVars[v]-&gt;get(dualCellVarData, 1, numDualCells, maxNVertLevels);
+
+                        for (int j = 0; j &lt; numDualCells; j++) {
+
+                                double *var_target = dualCellVarData;
+
+                                for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++)
+                                {
+                                        float validData = convertDouble2ValidFloat (*var_target);
+                                        vtkFile &lt;&lt; validData &lt;&lt; endl;
+
+                                        var_target++;
+                                }
+                        }
+                }
+        }
+}


Property changes on: branches/ocean_projects/graphics/paraview/projection/proj3dsphere.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/x-c++src
Name: svn:keywords
   + Author Date ID Revision
Name: svn:eol-style
   + native

Added: branches/ocean_projects/graphics/paraview/projection/projlatlon.cpp
===================================================================
--- branches/ocean_projects/graphics/paraview/projection/projlatlon.cpp                                (rev 0)
+++ branches/ocean_projects/graphics/paraview/projection/projlatlon.cpp        2010-04-08 19:38:18 UTC (rev 186)
@@ -0,0 +1,779 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program translates a newpop netCDF data file to dual-grid lat/lon multilayer 
+// projection in legacy, ascii VTK format.
+//
+// Assume all variables are of interest.
+// Assume variable data type is double.
+// Assume variable dims are (Time, nCells|nVertices, nVertLevels|nVertLevelsP1)
+// Assume no more than 100 vars each for cell and point data
+// Does not deal with tracers.
+// Does not deal with edge data.
+// Only vis up to nVertLevels, not nVertLevelsP1.
+// Doubles converted to floats in .vtk files follow these rules:
+//        if a NaN, then become -FLT_MAX.
+//        if positive infinity, then become FLT_MAX
+//        if negative infinity, then become -FLT_MAX
+//        if smaller than a float, then become 0.
+//        if not zero, but between -FLT_MIN and FLT_MIN make -FLT_MIN or FLT_MIN
+//        if outside of -FLT_MAX and FLT_MAX make -FLT_MAX or FLT_MAX
+//
+// Version Beta
+// Christine Ahrens
+// 3/8/2010
+////////////////////////////////////////////////////////////////////////////////
+
+
+#include &lt;iostream&gt;
+#include &lt;fstream&gt;
+#include &lt;sstream&gt;
+#include &quot;stdlib.h&quot;
+#include &quot;vtkCellType.h&quot;
+#include &quot;netcdfcpp.h&quot;
+#include &lt;string&gt;
+#include &lt;cmath&gt;
+//#include &lt;math&gt;
+#include &lt;cfloat&gt;
+
+using namespace std;
+
+#define CHECK_MALLOC(ptr) \
+        if (ptr == NULL) { \
+                cerr &lt;&lt; &quot;malloc failed!</font>
<font color="blue">&quot;; \
+                exit(1); \
+        } 
+
+#define MAX_VARS 100
+#define DEFAULT_LAYER_THICKNESS 10
+using namespace std;
+
+#define BUFF_SIZE 2048
+
+// overwrite outFile if it already exists
+int myCopyFile(string *inFile, string *outFile)
+{
+   char buff[BUFF_SIZE];
+   int readBytes = 1;
+
+   ifstream inFileStream(inFile-&gt;c_str(), ios::in|ios::binary);
+   if(!inFileStream)
+   {
+     return -1;
+   }
+
+   ofstream outFileStream(outFile-&gt;c_str(), ios::out|ios::binary);
+   if(!outFileStream)
+   {
+     return -1;
+   }
+
+   while(readBytes != 0)
+   {
+     inFileStream.read((char*)buff, BUFF_SIZE);
+     readBytes = inFileStream.gcount();
+     outFileStream.write((char*)buff, readBytes);
+   }
+   return 0;
+}
+
+int my_isinf_f(float x){
+        if (isinf(x)) {
+                return (x &lt; 0.0 ? -1 : 1);
+        } else return 0;
+}
+
+float convertDouble2ValidFloat(double inputData) {
+
+        // check for NaN
+        if (inputData != inputData) {
+                cerr &lt;&lt; &quot;found NaN!&quot; &lt;&lt; endl;
+                return -FLT_MAX;
+        }
+
+        // check for infinity
+        int retval = my_isinf_f((float)inputData);
+        if (retval &lt; 0) {
+                return -FLT_MAX;
+        } else if (retval &gt; 0) {
+                return FLT_MAX;
+        }
+
+        // check number too small for float
+        if (abs(inputData) &lt; 1e-126) return 0.0;
+
+        if ((float)inputData == 0) return 0.0;
+
+        if ((abs(inputData) &gt; 0) &amp;&amp; (abs(inputData) &lt; FLT_MIN)) {
+                if (inputData &lt; 0) return -FLT_MIN; else return FLT_MIN;
+        }
+
+        if (abs(inputData) &gt; FLT_MAX) {
+                if (inputData &lt; 0) return -FLT_MAX; else return FLT_MAX;
+        }
+
+        return (float)inputData;
+}
+
+
+int main(int argc, char* argv[])
+{
+        if ((argc &lt; 3) || (argc &gt; 4))  {
+                cerr &lt;&lt; &quot;Usage: projlatlon infile.nc infile.vtk [layer_thickness]&quot; &lt;&lt; endl;
+                cerr &lt;&lt; &quot;Note: layer_thickness defaults to 10.&quot; &lt;&lt; endl;
+                exit(1);
+        }
+
+                
+        NcFile ncFile(argv[1]);
+
+        if (!ncFile.is_valid()) 
+        {
+                cerr &lt;&lt; &quot;Couldn't open file: &quot; &lt;&lt; argv[1] &lt;&lt; endl;
+                exit(1);
+        }
+
+        NcDim* nCells = ncFile.get_dim(&quot;nCells&quot;);
+        NcDim* nVertices = ncFile.get_dim(&quot;nVertices&quot;);
+        NcDim* vertexDegree = ncFile.get_dim(&quot;vertexDegree&quot;);
+        NcDim* Time = ncFile.get_dim(&quot;Time&quot;);
+        NcDim* nVertLevels = ncFile.get_dim(&quot;nVertLevels&quot;);
+
+        if (vertexDegree-&gt;size() != 3)  {
+                cerr &lt;&lt; &quot;This code is only for hexagonal-primal/triangular-dual grid&quot; &lt;&lt; endl;
+                exit(1);
+        }
+
+        // Can't check for this, b/c if not there it crashes program        
+        //NcDim* nVertLevelsP1 = ncFile.get_dim(&quot;nVertLevelsP1&quot;);
+        int maxNVertLevels = nVertLevels-&gt;size();
+
+        //cout &lt;&lt; &quot;maxNVertLevels: &quot; &lt;&lt; maxNVertLevels &lt;&lt; endl;

+        int outputVertLevel = 0;
+
+        float layerThickness =  DEFAULT_LAYER_THICKNESS;
+        if (argc == 4) {
+                layerThickness = atof(argv[3]);
+        }
+
+        // figure out what variables to visualize
+        NcVar* dualCellVars[MAX_VARS];
+        NcVar* dualPointVars[MAX_VARS];
+        int dualCellVarIndex = -1;
+        int dualPointVarIndex = -1;
+        int numDualCells = nVertices-&gt;size();
+        int numDualPoints = nCells-&gt;size()+1;
+        
+        int numVars = ncFile.num_vars();
+
+        bool tracersExist = false;
+
+        for (int i = 0; i &lt; numVars; i++) {
+                NcVar* aVar = ncFile.get_var(i);
+
+                // must have 3 dims 
+                // (Time, nCells | nVertices, nVertLevels | nVertLevelsP1)
+
+                int numDims = aVar-&gt;num_dims();
+                //cout &lt;&lt; &quot;Num Dims of var: &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; is &quot; &lt;&lt; numDims &lt;&lt; endl;
+                if ((numDims != 3) &amp;&amp; (strcmp(aVar-&gt;name(), &quot;tracers&quot;))) {
+                        continue; // try the next var
+                } else {
+                        // TODO, check if it is a double
+                        // assume a double for now
+
+                        // check for Time dim 0
+                        NcToken dim0Name = aVar-&gt;get_dim(0)-&gt;name();
+                        if (strcmp(dim0Name, &quot;Time&quot;)) 
+                                continue;
+
+                        // check for dim 1 being num vertices or cells 
+                        bool isVertexData = false;
+                        bool isCellData = false;
+                        NcToken dim1Name = aVar-&gt;get_dim(1)-&gt;name();
+                        if (!strcmp(dim1Name, &quot;nVertices&quot;)) 
+                                isVertexData = true;
+                        else if (!strcmp(dim1Name, &quot;nCells&quot;)) 
+                                isCellData = true; 
+                        else continue;
+
+                        // check if dim 2 is nVertLevels or nVertLevelsP1, too
+                        NcToken dim2Name = aVar-&gt;get_dim(2)-&gt;name();
+                        if ((strcmp(dim2Name, &quot;nVertLevels&quot;)) 
+                                        &amp;&amp; (strcmp(dim2Name, &quot;nVertLevelsP1&quot;))) {
+                                continue;
+                        }
+
+                        // Add to cell or point var array
+                        if (isVertexData) {  // means it is dual cell data
+                                dualCellVarIndex++;
+                                if (dualCellVarIndex &gt; MAX_VARS-1) {
+                                        cerr &lt;&lt; &quot;Exceeded number of cell vars.&quot; &lt;&lt; endl;
+                                        exit(1);
+                                }
+                                dualCellVars[dualCellVarIndex] = aVar;
+                                //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualCellVars&quot; &lt;&lt; endl;
+                        } else if (isCellData) { // means it is dual vertex data
+                                if (strcmp(aVar-&gt;name(), &quot;tracers&quot;)) {
+                                        dualPointVarIndex++;
+                                        if (dualPointVarIndex &gt; MAX_VARS-1) {
+                                                cerr &lt;&lt; &quot;Exceeded number of point vars.&quot; &lt;&lt; endl;
+                                                exit(1);
+                                        }
+                                        dualPointVars[dualPointVarIndex] = aVar;
+                                        //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualPointVars&quot; &lt;&lt; endl;
+                                } else { // case of tracers, add each as &quot;tracer0&quot;, &quot;tracer1&quot;, etc.
+                                        tracersExist = true;
+                                        int numTracers = aVar-&gt;get_dim(3)-&gt;size();
+                                        for (int t = 0; t &lt; numTracers; t++) {
+                                                dualPointVarIndex++;
+                                                if (dualPointVarIndex &gt; MAX_VARS-1) {
+                                                        cerr &lt;&lt; &quot;Exceeded number of point vars.&quot; &lt;&lt; endl;
+                                                        exit(1);
+                                                }
+                                                dualPointVars[dualPointVarIndex] = aVar;
+                                                //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualPointVars&quot; &lt;&lt; endl;
+                                        }
+                                }
+                        }
+                }
+        }
+
+        // TODO
+         // prompt the user to find out which fields are of interest?
+        // for now, assume all are of interest
+        
+        // get points  (centers of primal-mesh cells)
+
+        // TO DO check malloc return vals.
+
+    const float BLOATFACTOR = .5;
+        int myCellSize = floor(nCells-&gt;size()*(1.0 + BLOATFACTOR));
+        double *xCellData = (double*)malloc(myCellSize * sizeof(double));
+        CHECK_MALLOC(xCellData);
+        NcVar *xCellVar = ncFile.get_var(&quot;lonCell&quot;);
+        xCellVar-&gt;get(xCellData+1, nCells-&gt;size());
+    // point 0 is 0.0
+    *xCellData = 0.0;
+
+        double *yCellData = (double*)malloc(myCellSize * sizeof(double));
+        CHECK_MALLOC(yCellData);
+        NcVar *yCellVar = ncFile.get_var(&quot;latCell&quot;);
+        yCellVar-&gt;get(yCellData+1, nCells-&gt;size());
+    // point 0 is 0.0
+    *yCellData = 0.0;
+
+        // get dual-mesh cells
+
+        int *cellsOnVertex = (int *) malloc((nVertices-&gt;size()) * vertexDegree-&gt;size() * 
+                sizeof(int));
+        CHECK_MALLOC(cellsOnVertex);
+
+        int myCOVSize = floor(nVertices-&gt;size()*(1.0 + BLOATFACTOR))+1;
+        int *myCellsOnVertex = (int *) malloc(myCOVSize * vertexDegree-&gt;size() * sizeof(int));
+        CHECK_MALLOC(myCellsOnVertex);
+
+        NcVar *cellsOnVertexVar = ncFile.get_var(&quot;cellsOnVertex&quot;);
+        //cout &lt;&lt; &quot;getting cellsOnVertexVar</font>
<font color="gray">&quot;;
+        cellsOnVertexVar-&gt;get(cellsOnVertex, nVertices-&gt;size(), vertexDegree-&gt;size());
+
+        // allocate an array to map the extra points and cells to the original
+        // so that when obtaining data, we know where to get it
+        int *pointMap = (int*)malloc(floor(nCells-&gt;size()*BLOATFACTOR) * sizeof(int));
+        CHECK_MALLOC(pointMap);
+        int *cellMap = (int*)malloc(floor(nVertices-&gt;size()*BLOATFACTOR) * sizeof(int));
+        CHECK_MALLOC(cellMap);
+
+        
+        int *myptr = myCellsOnVertex;
+        int *myExtraX;
+        int *myExtraY;
+        int currentExtraPoint = numDualPoints;
+        int currentExtraCell = numDualCells;
+    const double PI = 3.141592;
+
+    // For each cell, examine vertices
+        // Add new points and cells where needed to account for wraparound.
+
+    int acell = 775;
+    int mirrorcell;
+    int apoint;
+    int mirrorpoint;
+
+        for (int j = 0; j &lt; numDualCells; j++ ) {
+                int *dualCells = cellsOnVertex + (j * vertexDegree-&gt;size());
+                int lastk = vertexDegree-&gt;size()-1;
+                bool xWrap = false;
+                bool yWrap = false;
+                for (int k = 0; k &lt; vertexDegree-&gt;size(); k++) {
+                        if (abs(xCellData[dualCells[k]]  - xCellData[dualCells[lastk]]) &gt; 5.5) xWrap = true;
+                        //if (abs(yCellData[dualCells[k]]  - yCellData[dualCells[lastk]]) &gt; 2) yWrap = true;
+                        lastk = k;
+                }
+
+                if (xWrap || yWrap) {
+                        //cerr &lt;&lt; &quot;Cell wrap: &quot; &lt;&lt; j &lt;&lt; endl;
+                }
+
+                if (xWrap) {
+                        //cerr &lt;&lt; &quot;It wrapped in x direction&quot; &lt;&lt; endl;
+                        double anchorX = xCellData[dualCells[0]];
+                        double anchorY = yCellData[dualCells[0]];
+                        *myptr = *(dualCells);
+                        myptr++;
+
+            if (j == acell) { 
+               //cout &lt;&lt; &quot;cell &quot; &lt;&lt; acell &lt;&lt; &quot; anchor x: &quot; &lt;&lt; anchorX &lt;&lt; &quot; y: &quot; &lt;&lt; anchorY &lt;&lt; endl;
+            }
+
+                        // modify existing cell, so it doesn't wrap
+                        // move points to one side
+
+                        // first point is anchor it doesn't move
+            for (int k = 1; k &lt; vertexDegree-&gt;size(); k++) {
+                                double neighX = xCellData[dualCells[k]];
+                                double neighY = yCellData[dualCells[k]];
+
+                if (j == acell) { 
+                   //cout &lt;&lt; &quot;cell &quot; &lt;&lt; acell &lt;&lt; &quot; k: &quot; &lt;&lt; k &lt;&lt; &quot; x: &quot; &lt;&lt; neighX &lt;&lt; &quot; y: &quot; &lt;&lt; neighY &lt;&lt; endl;
+                }
+
+                                // add a new point, figure out east or west
+                                if (abs(neighX - anchorX) &gt; 5.5)  {
+                                        double neighEastX;
+                                        double neighWestX;
+
+                                        // add on east
+                                        if (neighX &lt; anchorX) {
+                        if (j == acell) { 
+                           //cout &lt;&lt; &quot;add on east&quot; &lt;&lt; endl;
+                        }
+                                                neighEastX = neighX + (2*PI);
+                                                xCellData[currentExtraPoint] = neighEastX;
+                                                yCellData[currentExtraPoint] = neighY;
+                                        } else { 
+                                                // add on west
+                        if (j == acell) { 
+                           //cout &lt;&lt; &quot;add on west&quot; &lt;&lt; endl;
+                        }
+                                                neighWestX = neighX - (2*PI);
+                                                xCellData[currentExtraPoint] = neighWestX;
+                                                yCellData[currentExtraPoint] = neighY;
+                                        }
+                        
+                    if (j == acell) {    
+                           //cout &lt;&lt; &quot;x: &quot; &lt;&lt; xCellData[currentExtraPoint] &lt;&lt; &quot; y: &quot; &lt;&lt; yCellData[currentExtraPoint] &lt;&lt; endl;
+                    }
+
+                    if (j == acell) { 
+                       //cout &lt;&lt; &quot;currentExtraPoint: &quot; &lt;&lt; currentExtraPoint &lt;&lt; endl;
+                    }
+
+                                        // add the new point to list of vertices
+                                        *myptr = currentExtraPoint;
+
+                                        // record mapping
+                                        *(pointMap + (currentExtraPoint - numDualPoints)) = dualCells[k];
+
+                    if (j == acell) { 
+                       mirrorpoint = currentExtraPoint;
+                       apoint = dualCells[k];
+                       //cout &lt;&lt; &quot;mirror point &quot; &lt;&lt; mirrorpoint &lt;&lt; &quot; has pointMap to: &quot; &lt;&lt; dualCells[k] &lt;&lt; endl;
+                    }
+
+                                        myptr++;
+                                        currentExtraPoint++;
+                                } else {
+                                        // use existing kth point 
+                    if (j == acell) {
+                        //cout &lt;&lt; &quot;use existing point&quot; &lt;&lt; endl;
+                    }
+                                        *myptr = dualCells[k];
+                                        myptr++;
+                                }
+                        }
+
+                        // add a mirror image cell on other side so there are no
+                        // gaps in the map
+
+                        // move anchor to other side
+                        if (anchorX &gt; PI) {
+                                anchorX = anchorX - (2*PI);
+                        } else {
+                                anchorX = anchorX + (2*PI);
+                        }
+        
+            if (j == acell) { 
+               //cout &lt;&lt; &quot;add new cell &quot; &lt;&lt; currentExtraCell &lt;&lt; &quot; to mirror &quot; &lt;&lt; acell &lt;&lt; &quot; anchorX: &quot; &lt;&lt; anchorX &lt;&lt; &quot; anchorY: &quot; &lt;&lt; anchorY &lt;&lt; endl;
+               mirrorcell = currentExtraCell;
+            }
+
+            // move addedCellsPtr to myCellsOnVertex extra cells area
+            int* addedCellsPtr = myCellsOnVertex + (currentExtraCell * vertexDegree-&gt;size());
+
+            // add point coord and add to list of cells
+                        xCellData[currentExtraPoint] = anchorX;
+                        yCellData[currentExtraPoint] = anchorY;
+                        *addedCellsPtr = currentExtraPoint;
+
+                        // record mapping
+                        *(pointMap + (currentExtraPoint - numDualPoints)) = dualCells[0];
+
+                        addedCellsPtr++;
+                        currentExtraPoint++;
+
+                        for (int k = 1; k &lt; vertexDegree-&gt;size(); k++) {
+                                double neighX = xCellData[dualCells[k]];
+                                double neighY = yCellData[dualCells[k]];
+
+                                // add a new point, figure out east or west
+                                if (abs(neighX - anchorX) &gt; 5.5)  {
+                                        double neighEastX;
+                                        double neighWestX;
+
+                                        // add on east
+                                        if (neighX &lt; anchorX) {
+                                                neighEastX = neighX + (2*PI);
+                                                xCellData[currentExtraPoint] = neighEastX;
+                                                yCellData[currentExtraPoint] = neighY;
+                                        } else { 
+                                                // add on west
+                                                neighWestX = neighX - (2*PI);
+                                                xCellData[currentExtraPoint] = neighWestX;
+                                                yCellData[currentExtraPoint] = neighY;
+                                        }
+
+                                        // add the new point to list of vertices
+                                        *addedCellsPtr = currentExtraPoint;
+
+                                        // record mapping
+                                        *(pointMap + (currentExtraPoint - numDualPoints)) = dualCells[k];
+
+                                        addedCellsPtr++;
+                                        currentExtraPoint++;
+                                } else {
+                                        // use existing kth point 
+                                        *addedCellsPtr = dualCells[k];
+                                        addedCellsPtr++;
+                                }
+                        }
+                        *(cellMap + (currentExtraCell - numDualCells)) = j;
+                        currentExtraCell++;
+                }
+
+                if (yWrap) {
+                        //cerr &lt;&lt; &quot;It wrapped in y direction&quot; &lt;&lt; endl;
+                }
+
+                // if cell doesn't extend past lat/lon perimeter, then add it to myCellsOnVertex
+                if (!xWrap &amp;&amp; !yWrap) {
+                        for (int k=0; k&lt; vertexDegree-&gt;size(); k++) {
+                                *myptr = *(dualCells+k);
+                                myptr++;
+                        }
+                }
+                if (currentExtraCell &gt; myCOVSize) {
+                        cerr &lt;&lt; &quot;Exceeded storage for extra cells!&quot; &lt;&lt; endl;
+                        return 1;
+                }
+                if (currentExtraPoint &gt; myCellSize) {
+                        cerr &lt;&lt; &quot;Exceeded storage for extra points!&quot; &lt;&lt; endl;
+                        return 1;
+                }
+        }        
+                                                
+        // decls for data storage
+        double* dualCellVarData;
+        double* dualPointVarData;
+
+        // for each variable, allocate space for variables
+
+        //cout &lt;&lt; &quot;dualCellVarIndex: &quot; &lt;&lt; dualCellVarIndex &lt;&lt; endl;
+
+        int varVertLevels = 0;
+        
+        // write a file with the geometry.
+
+        ostringstream geoFileName;
+
+        geoFileName &lt;&lt; &quot;geo_&quot; &lt;&lt; argv[2];         
+
+        ofstream geoFile(geoFileName.str().c_str(), ios::out);
+
+        if (!geoFile)
+        {
+                cerr &lt;&lt; &quot;vtk output file could not be opened&quot; &lt;&lt;endl;
+                exit(1);
+        }
+
+
+        // write header
+
+        geoFile &lt;&lt; &quot;# vtk DataFile Version 2.0&quot; &lt;&lt; endl;
+        geoFile &lt;&lt; &quot;Project newpop geometry to lat/lon projection from netCDF by Christine Ahrens&quot; 
+                &lt;&lt; endl;
+        geoFile &lt;&lt; &quot;ASCII&quot; &lt;&lt; endl;
+        geoFile &lt;&lt; &quot;DATASET UNSTRUCTURED_GRID&quot; &lt;&lt; endl;
+
+
+        // write points  (the points are the primal-grid cell centers)
+
+        geoFile &lt;&lt; &quot;POINTS &quot; &lt;&lt; currentExtraPoint*(maxNVertLevels+1) &lt;&lt; &quot; float&quot; &lt;&lt; endl;
+
+        // write the point at each vertical level, plus one level for last layer
+
+        //cout &lt;&lt; &quot;Writing points at each level&quot; &lt;&lt; endl;
+
+        for (int j = 0; j &lt; currentExtraPoint; j++ )
+        {
+                geoFile.precision(16);
+                const double PI = 3.141592;
+                xCellData[j] = xCellData[j] * 180.0 / PI;
+                yCellData[j] = yCellData[j] * 180.0 / PI;
+                if (abs(xCellData[j]) &lt; 1e-126) xCellData[j] = 0;
+                if (abs(yCellData[j]) &lt; 1e-126) yCellData[j] = 0;
+
+                for (int levelNum = 0; levelNum &lt; maxNVertLevels+1; levelNum++) {
+                        geoFile &lt;&lt; xCellData[j] &lt;&lt; &quot;\t&quot; &lt;&lt; yCellData[j] &lt;&lt; &quot;\t&quot; &lt;&lt; -(((float)levelNum)*layerThickness) &lt;&lt; endl;
+                }
+        }        
+
+                geoFile &lt;&lt; endl;
+
+
+                // Write dual-mesh cells
+                // Dual-mesh cells are triangles with primal-mesh cell 
+                // centers as the vertices.
+                // The number of dual-mesh cells is the number of vertices in the
+                // primal mesh.
+
+                int newDegree = vertexDegree-&gt;size()*2;
+
+                geoFile &lt;&lt; &quot;CELLS &quot; &lt;&lt; currentExtraCell*maxNVertLevels &lt;&lt; &quot; &quot; 
+                        &lt;&lt; currentExtraCell * (newDegree + 1) * maxNVertLevels &lt;&lt; endl;        
+
+                // for each dual-mesh cell, write number of points for each
+                // and then list the points by number
+
+                //cout &lt;&lt; &quot;Writing Cells&quot; &lt;&lt; endl;
+
+                for (int j = 0; j &lt; currentExtraCell ; j++) {
+
+                        // since primal vertex(pt) numbers  == dual cell numbers
+                        // we go through the primal vertices, find the cells around
+                        // them, and since those primal cell numbers are dual 
+                        // point numbers,  
+                        // we can write the cell numbers for the cellsOnVertex
+                        // and those will be the numbers of the dual vertices (pts).
+                        
+                        int* dualCells = myCellsOnVertex + (j * vertexDegree-&gt;size());
+
+                        // for each level, write the prism
+                        for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++) {
+                                geoFile &lt;&lt; newDegree &lt;&lt; &quot;\t&quot; ;
+                                for (int k = 0; k &lt; vertexDegree-&gt;size(); k++) 
+                                {                
+                                        geoFile &lt;&lt; (dualCells[k]*(maxNVertLevels+1)) + levelNum &lt;&lt; &quot;\t&quot;;
+                                }
+                                for (int k = 0; k &lt; vertexDegree-&gt;size(); k++) 
+                                {                
+                                        geoFile &lt;&lt; (dualCells[k]*(maxNVertLevels+1)) + levelNum+1 &lt;&lt; &quot;\t&quot;;
+                                }
+                                geoFile &lt;&lt; endl;
+                        }
+                }        
+
+                // write cell types 
+                int cellType = VTK_WEDGE;
+
+                geoFile &lt;&lt; &quot;CELL_TYPES &quot; &lt;&lt; currentExtraCell*maxNVertLevels &lt;&lt; endl;
+
+//multiply by number of levels
+                for (int j = 0; j &lt; currentExtraCell*maxNVertLevels; j++)
+                {
+                        geoFile &lt;&lt; cellType &lt;&lt; endl;
+                }
+
+        // release resources
+        geoFile.close();
+        free(xCellData);
+        free(yCellData);
+        free(cellsOnVertex);
+        free(myCellsOnVertex);
+
+        // For each timestep, write data for each level
+
+        dualCellVarData = (double*)malloc((sizeof(double))  * currentExtraCell * maxNVertLevels);
+        CHECK_MALLOC(dualCellVarData);
+
+        dualPointVarData = (double*)malloc((sizeof(double)) * currentExtraPoint * maxNVertLevels);
+        CHECK_MALLOC(dualPointVarData);
+
+        // for each timestep, copy the geometry file, since we don't want to
+        // have to recompute the points
+        for (int i = 0; i &lt; Time-&gt;size(); i++) {
+                ostringstream vtkFileName;
+                vtkFileName &lt;&lt; i &lt;&lt; argv[2];
+
+                string geoFileNameString = geoFileName.str();
+                string vtkFileNameString = vtkFileName.str();
+                int copyRetVal = myCopyFile(&amp;geoFileNameString, &amp;vtkFileNameString);
+                //cout &lt;&lt; &quot;myCopyFile returned: &quot; &lt;&lt; copyRetVal &lt;&lt; endl;
+
+                ofstream vtkFile(vtkFileName.str().c_str(), ios::out|ios::app);
+                if (!vtkFile)
+                {
+                        cerr &lt;&lt; &quot;vtk output file could not be opened&quot; &lt;&lt;endl;
+                        exit(1);
+                }
+
+                if (!vtkFile)
+                {
+                        cerr &lt;&lt; &quot;vtk output file could not be opened&quot; &lt;&lt;endl;
+                        exit(1);
+                }
+
+                vtkFile.precision(16);
+
+                // If by point, write out point data
+
+                if (dualPointVarIndex &gt;= 0) vtkFile &lt;&lt; &quot;POINT_DATA &quot; &lt;&lt; currentExtraPoint*(maxNVertLevels+1) &lt;&lt; endl;
+
+                int printstep = -1;
+
+                if (i == printstep) cout &lt;&lt; &quot;TIME STEP: &quot; &lt;&lt; i &lt;&lt; endl;
+
+                int tracerNum = 0;
+
+                for (int v = 0; v &lt;= dualPointVarIndex; v++) {
+
+                        // Read variable number v data for that timestep
+
+                        varVertLevels = dualPointVars[v]-&gt;get_dim(2)-&gt;size();
+
+                        bool isTracer = false;
+
+                        if (!strcmp(dualPointVars[v]-&gt;name(), &quot;tracers&quot;)) {
+                                isTracer = true;
+                        // Uncomment if want to exclude tracers.  
+                        //        continue;
+                        }
+
+                        // Write variable number v data for that timestep
+                        vtkFile &lt;&lt; &quot;SCALARS &quot; &lt;&lt; dualPointVars[v]-&gt;name();
+                        if (isTracer) vtkFile &lt;&lt; tracerNum+1;
+                        vtkFile &lt;&lt; &quot; float 1&quot; &lt;&lt;  endl;
+                        vtkFile &lt;&lt; &quot;LOOKUP_TABLE default&quot; &lt;&lt; endl;
+
+
+                        if (isTracer) {
+                                dualPointVars[v]-&gt;set_cur(i, 0, 0, tracerNum);
+                                dualPointVars[v]-&gt;get(dualPointVarData+maxNVertLevels, 1, nCells-&gt;size(), maxNVertLevels, 1);
+                        } else {
+                                dualPointVars[v]-&gt;set_cur(i, 0, 0);
+                                dualPointVars[v]-&gt;get(dualPointVarData+maxNVertLevels, 1, nCells-&gt;size(), maxNVertLevels);
+                        }
+
+
+                        float defaultPointVal = 0.0;
+
+                        //write dummy
+
+                        double *var_target = dualPointVarData + maxNVertLevels;
+                        float validData;
+
+                        for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++) {
+
+                                validData = convertDouble2ValidFloat (*var_target);
+
+                                // write dummy
+                                vtkFile &lt;&lt; validData &lt;&lt; endl;
+                var_target++;
+        
+                        }
+
+                        // write highest level dummy point
+                        vtkFile &lt;&lt; validData &lt;&lt; endl;
+
+                        var_target = dualPointVarData + maxNVertLevels;
+
+                        for (int j = 1; j &lt; numDualPoints; j++) {
+
+                                // write data for one point -- lowest level to highest
+                                for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++) {
+                                        validData = convertDouble2ValidFloat (*var_target);
+                                        vtkFile &lt;&lt; validData &lt;&lt; endl;
+                                        var_target++;
+                                }
+                        
+                                // for last layer of dual points, repeat last level's values
+                                // Need Mark's input on this one
+                                vtkFile &lt;&lt; validData &lt;&lt; endl;
+                        }
+
+                        // put out data for extra points
+                        for (int j = numDualPoints; j &lt; currentExtraPoint; j++) {
+                if (j == mirrorpoint) {
+                    //cout &lt;&lt; &quot;data for mirror point &quot; &lt;&lt; mirrorpoint &lt;&lt; &quot; from point &quot; &lt;&lt; *(pointMap + j - numDualPoints) &lt;&lt; endl;
+                }
+                // use map to find out what point data we are using
+                                var_target = dualPointVarData + ((*(pointMap + j - numDualPoints))*maxNVertLevels);
+
+                                // write data for one point -- lowest level to highest
+                                for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++) {
+                                        validData = convertDouble2ValidFloat (*var_target);
+                                        vtkFile &lt;&lt; validData &lt;&lt; endl;
+                                        var_target++;
+                                }
+                        
+                                // for last layer of dual points, repeat last level's values
+                                // Need Mark's input on this one
+                                vtkFile &lt;&lt; validData &lt;&lt; endl;
+                        }
+                        if (isTracer) tracerNum++;
+                }
+
+                // if by cell, then write out cell data
+
+                if (dualCellVarIndex &gt;= 0) vtkFile &lt;&lt; &quot;CELL_DATA &quot; &lt;&lt; currentExtraCell*maxNVertLevels &lt;&lt; endl;
+
+                for (int v = 0; v &lt;= dualCellVarIndex; v++) {
+
+                        // Write variable number v data for that timestep
+                        vtkFile &lt;&lt; &quot;SCALARS &quot; &lt;&lt; dualCellVars[v]-&gt;name() &lt;&lt; &quot; float 1&quot; &lt;&lt;  endl;
+                        vtkFile &lt;&lt; &quot;LOOKUP_TABLE default&quot; &lt;&lt; endl;
+
+                        // Read variable number v data for that timestep and level
+                        dualCellVars[v]-&gt;set_cur(i, 0, 0);
+                        dualCellVars[v]-&gt;get(dualCellVarData, 1, numDualCells, maxNVertLevels);
+
+            double *var_target = dualCellVarData;
+
+                        for (int j = 0; j &lt; numDualCells; j++) {
+
+                                for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++)
+                                {
+                                        float validData = convertDouble2ValidFloat (*var_target);
+                                        vtkFile &lt;&lt; validData &lt;&lt; endl;
+                                        var_target++;
+                                }
+                        }
+
+                        for (int j = numDualCells; j &lt; currentExtraCell; j++) {
+                if (j == mirrorcell) { 
+                   //cout &lt;&lt; &quot;data for mirror cell &quot; &lt;&lt; mirrorcell &lt;&lt; &quot; from cell &quot; &lt;&lt; *(cellMap + j - numDualCells) &lt;&lt; endl;
+                }
+
+                
+                var_target = dualCellVarData + (*(cellMap + j - numDualCells))*maxNVertLevels;
+                for (int levelNum = 0; levelNum &lt; maxNVertLevels; levelNum++)
+                {
+                    float validData = convertDouble2ValidFloat (*var_target);
+                    vtkFile &lt;&lt; validData &lt;&lt; endl;
+                    var_target++;
+                }
+            }            
+        }
+    }
+}
+


Property changes on: branches/ocean_projects/graphics/paraview/projection/projlatlon.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/x-c++src
Name: svn:keywords
   + Author Date ID Revision
Name: svn:eol-style
   + native

Added: branches/ocean_projects/graphics/paraview/projection/vtkCellType.h
===================================================================
--- branches/ocean_projects/graphics/paraview/projection/vtkCellType.h                                (rev 0)
+++ branches/ocean_projects/graphics/paraview/projection/vtkCellType.h        2010-04-08 19:38:18 UTC (rev 186)
@@ -0,0 +1,98 @@
+/*=========================================================================
+
+  Program:   Visualization Toolkit
+  Module:    $RCSfile: vtkCellType.h,v $
+
+  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
+  All rights reserved.
+  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+// .NAME vtkCellType - define types of cells
+// .SECTION Description
+// vtkCellType defines the allowable cell types in the visualization 
+// library (vtk). In vtk, datasets consist of collections of cells. 
+// Different datasets consist of different cell types. The cells may be 
+// explicitly represented (as in vtkPolyData), or may be implicit to the
+// data type (as in vtkStructuredPoints).
+
+#ifndef __vtkCellType_h
+#define __vtkCellType_h
+
+// To add a new cell type, define a new integer type flag here, then
+// create a subclass of vtkCell to implement the proper behavior. You 
+// may have to modify the following methods: vtkDataSet (and subclasses) 
+// GetCell() and vtkGenericCell::SetCellType(). Also, to do the job right,
+// you'll also have to modify some filters (vtkGeometryFilter...) and
+// regression tests (example scripts) to reflect the new cell addition.
+// Also, make sure to update vtkCellTypesStrings in vtkCellTypes.cxx.
+
+// .SECTION Caveats
+// An unstructured grid stores the types of its cells as a
+// unsigned char array. Therefore, the maximum encoding number for a cell type
+// is 255.
+
+typedef enum {
+  // Linear cells
+  VTK_EMPTY_CELL       = 0,
+  VTK_VERTEX           = 1,
+  VTK_POLY_VERTEX      = 2,
+  VTK_LINE             = 3,
+  VTK_POLY_LINE        = 4,
+  VTK_TRIANGLE         = 5,
+  VTK_TRIANGLE_STRIP   = 6,
+  VTK_POLYGON          = 7,
+  VTK_PIXEL            = 8,
+  VTK_QUAD             = 9,
+  VTK_TETRA            = 10,
+  VTK_VOXEL            = 11,
+  VTK_HEXAHEDRON       = 12,
+  VTK_WEDGE            = 13,
+  VTK_PYRAMID          = 14,
+  VTK_PENTAGONAL_PRISM = 15,
+  VTK_HEXAGONAL_PRISM  = 16,
+
+  // Quadratic, isoparametric cells
+  VTK_QUADRATIC_EDGE                   = 21,
+  VTK_QUADRATIC_TRIANGLE               = 22,
+  VTK_QUADRATIC_QUAD                   = 23,
+  VTK_QUADRATIC_TETRA                  = 24,
+  VTK_QUADRATIC_HEXAHEDRON             = 25,
+  VTK_QUADRATIC_WEDGE                  = 26,
+  VTK_QUADRATIC_PYRAMID                = 27,
+  VTK_BIQUADRATIC_QUAD                 = 28,
+  VTK_TRIQUADRATIC_HEXAHEDRON          = 29,
+  VTK_QUADRATIC_LINEAR_QUAD            = 30,
+  VTK_QUADRATIC_LINEAR_WEDGE           = 31,
+  VTK_BIQUADRATIC_QUADRATIC_WEDGE      = 32,
+  VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON = 33,
+
+  // Special class of cells formed by convex group of points
+  VTK_CONVEX_POINT_SET = 41,
+
+  // Higher order cells in parametric form
+  VTK_PARAMETRIC_CURVE        = 51,
+  VTK_PARAMETRIC_SURFACE      = 52,
+  VTK_PARAMETRIC_TRI_SURFACE  = 53,
+  VTK_PARAMETRIC_QUAD_SURFACE = 54,
+  VTK_PARAMETRIC_TETRA_REGION = 55,
+  VTK_PARAMETRIC_HEX_REGION   = 56,
+
+  // Higher order cells
+  VTK_HIGHER_ORDER_EDGE        = 60,
+  VTK_HIGHER_ORDER_TRIANGLE    = 61,
+  VTK_HIGHER_ORDER_QUAD        = 62,
+  VTK_HIGHER_ORDER_POLYGON     = 63,
+  VTK_HIGHER_ORDER_TETRAHEDRON = 64,
+  VTK_HIGHER_ORDER_WEDGE       = 65,
+  VTK_HIGHER_ORDER_PYRAMID     = 66,
+  VTK_HIGHER_ORDER_HEXAHEDRON  = 67,
+
+  VTK_NUMBER_OF_CELL_TYPES
+} VTKCellType;
+
+#endif


Property changes on: branches/ocean_projects/graphics/paraview/projection/vtkCellType.h
___________________________________________________________________
Name: svn:mime-type
   + text/x-c++hdr
Name: svn:keywords
   + Author Date ID Revision
Name: svn:eol-style
   + native

Added: branches/ocean_projects/graphics/paraview/translator/Makefile
===================================================================
--- branches/ocean_projects/graphics/paraview/translator/Makefile                                (rev 0)
+++ branches/ocean_projects/graphics/paraview/translator/Makefile        2010-04-08 19:38:18 UTC (rev 186)
@@ -0,0 +1,18 @@
+# NETCDF should point to the directory holding the netcdf lib and bin subdirs
+#NETCDF = /usr/projects/climate/bzhao/netcdf-3.6.1
+NETCDF = /usr/projects/climate/mhecht/netcdf-3.6.1
+#CC = gcc -m64
+CC = gcc
+INCLUDES = -I$(NETCDF)/include
+#LIBS = -L$(NETCDF)/lib -lnetcdf_c++ -lnetcdf -L/usr/lib -lstdc++
+
+LIBS = -L$(NETCDF)/lib -lnetcdf_c++ -lnetcdf \
+        -lstdc++ \
+        -L/opt/Intel/cce/10.0.023/lib/ -lirc
+#         -L/opt/Intel/cce/9.1.039/lib/ -lirc
+
+transdual: nc2vtk_dual.cpp
+        $(CC) $(INCLUDES) -o $@ $&lt;  $(LIBS)
+
+clean:
+        rm transdual

Added: branches/ocean_projects/graphics/paraview/translator/nc2vtk_dual.cpp
===================================================================
--- branches/ocean_projects/graphics/paraview/translator/nc2vtk_dual.cpp                                (rev 0)
+++ branches/ocean_projects/graphics/paraview/translator/nc2vtk_dual.cpp        2010-04-08 19:38:18 UTC (rev 186)
@@ -0,0 +1,490 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program translates a newpop netCDF data file to dual-grid legacy, ascii VTK format
+// The variables that have time dim are automatically written.
+//
+// Assume all variables are of interest.
+// Assume variable data type is double.
+// Assume variable dims are (Time, nCells|nVertices, nVertLevels|nVertLevelsP1, [nTracers])
+// Assume no more than 100 vars each for cell and point data
+// Does not deal with edge data.
+// Doubles converted to floats in .vtk files follow these rules:
+//      if a NaN, then become -FLT_MAX.
+//      if positive infinity, then become FLT_MAX
+//      if negative infinity, then become -FLT_MAX
+//      if smaller than a float, then become 0.
+//      if not zero, but between -FLT_MIN and FLT_MIN make -FLT_MIN or FLT_MIN
+//      if outside of -FLT_MAX and FLT_MAX make -FLT_MAX or FLT_MAX
+//
+//
+// Version 1.3
+// Christine Ahrens
+// 3/8/2010
+//
+////////////////////////////////////////////////////////////////////////////////
+
+
+#include &lt;iostream&gt;
+#include &lt;fstream&gt;
+#include &lt;sstream&gt;
+#include &quot;stdlib.h&quot;
+#include &quot;vtkCellType.h&quot;
+#include &quot;netcdfcpp.h&quot;
+#include &lt;string&gt;
+#include &lt;cmath&gt;
+#include &lt;cfloat&gt;
+
+using namespace std;
+
+#define CHECK_MALLOC(ptr) \
+        if (ptr == NULL) { \
+                cerr &lt;&lt; &quot;malloc failed!</font>
<font color="blue">&quot;; \
+                exit(1); \
+        } 
+#define MAX_VARS 100
+
+int my_isinf_f(float x){
+              if (isinf(x)) {
+                return (x &lt; 0.0 ? -1 : 1);
+        } else return 0;
+}
+
+float convertDouble2ValidFloat(double inputData) {
+
+        // check for NaN
+        if (inputData != inputData) {
+                //cerr &lt;&lt; &quot;found NaN!&quot; &lt;&lt; endl;
+                return -FLT_MAX;
+        }
+
+        // check for infinity
+        int retval = my_isinf_f((float)inputData);
+        if (retval &lt; 0) {
+                return -FLT_MAX;
+        } else if (retval &gt; 0) {
+                return FLT_MAX;
+        }
+
+        // check number too small for float
+        if (abs(inputData) &lt; 1e-126) return 0.0;
+
+        if ((float)inputData == 0) return 0.0;
+
+        if ((abs(inputData) &gt; 0) &amp;&amp; (abs(inputData) &lt; FLT_MIN)) {
+                if (inputData &lt; 0) return -FLT_MIN; else return FLT_MIN;
+        }
+
+        if (abs(inputData) &gt; FLT_MAX) {
+                if (inputData &lt; 0) return -FLT_MAX; else return FLT_MAX;
+        }
+
+        return (float)inputData;
+}
+
+int main(int argc, char* argv[])
+{
+        if ((argc &lt; 3) || (argc &gt; 4))  {
+                cerr &lt;&lt; &quot;Usage: transdual infile.nc outfile.vtk [verticalLevel]&quot; &lt;&lt; endl;
+                cerr &lt;&lt; &quot;Variables with time and vertical level are written out.&quot; &lt;&lt; endl;
+                cerr &lt;&lt; &quot;Tracer vars are named tracer1, tracer2, etc.&quot; &lt;&lt; endl;
+                cerr &lt;&lt; &quot;If vertical level is not specified, default is 0.&quot; &lt;&lt; endl;
+                cerr &lt;&lt; &quot;A series of vtk files will be created, one file for each time step.&quot; &lt;&lt; endl;
+                cerr &lt;&lt; &quot;with time prepended to the file name (e.g. 0outfile.vtk).&quot; &lt;&lt; endl;
+                cerr &lt;&lt; &quot;vtk datafile Version 2.0, transdual Version 1.2&quot; &lt;&lt; endl;
+                exit(1);
+        }
+
+                
+        NcFile ncFile(argv[1]);
+
+        if (!ncFile.is_valid()) 
+        {
+                cerr &lt;&lt; &quot;Couldn't open file: &quot; &lt;&lt; argv[1] &lt;&lt; endl;
+                exit(1);
+        }
+
+        NcDim* nCells = ncFile.get_dim(&quot;nCells&quot;);
+        NcDim* nVertices = ncFile.get_dim(&quot;nVertices&quot;);
+        NcDim* vertexDegree = ncFile.get_dim(&quot;vertexDegree&quot;);
+        NcDim* Time = ncFile.get_dim(&quot;Time&quot;);
+        NcDim* nVertLevels = ncFile.get_dim(&quot;nVertLevels&quot;);
+        NcDim* nTracers = ncFile.get_dim(&quot;nTracers&quot;);
+
+        // Can't check for this, b/c if not there it crashes program        
+        //NcDim* nVertLevelsP1 = ncFile.get_dim(&quot;nVertLevelsP1&quot;);
+        int maxNVertLevels = nVertLevels-&gt;size() + 1;
+        /*if (nVertLevelsP1 != NULL) {
+                maxNVertLevels = nVertLevelsP1-&gt;size();
+        }
+*/

+        int outputVertLevel = 0;
+
+        if (argc == 4) {
+                outputVertLevel = atoi(argv[3]);
+                // cout &lt;&lt; &quot;outputVertLevel: &quot; &lt;&lt; outputVertLevel &lt;&lt; endl;
+                if (outputVertLevel &gt; (maxNVertLevels-1)) {
+                        cerr &lt;&lt; &quot;Specified vertical level &quot; &lt;&lt; outputVertLevel;
+                        cerr &lt;&lt; &quot; doesn't exist.  The highest level is level &quot;;
+                        cerr &lt;&lt; maxNVertLevels-1 &lt;&lt; &quot;.&quot; &lt;&lt; endl;
+                        exit(1);
+                }
+        }
+
+
+        // figure out what variables to visualize
+        NcVar* dualCellVars[MAX_VARS];
+        NcVar* dualPointVars[MAX_VARS];
+        int dualCellVarIndex = -1;
+        int dualPointVarIndex = -1;
+        int numDualCells = nVertices-&gt;size();
+        int numDualPoints = nCells-&gt;size()+1;
+        
+        int numVars = ncFile.num_vars();
+
+        bool tracersExist = false;
+
+        for (int i = 0; i &lt; numVars; i++) {
+                NcVar* aVar = ncFile.get_var(i);
+
+                // must have 3 dims 
+                // (Time, nCells | nVertices, nVertLevels | nVertLevelsP1)
+
+                int numDims = aVar-&gt;num_dims();
+                //cout &lt;&lt; &quot;Num Dims of var: &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; is &quot; &lt;&lt; numDims &lt;&lt; endl;
+                
+                if ((numDims != 3) &amp;&amp; (strcmp(aVar-&gt;name(), &quot;tracers&quot;))) {
+                        continue;
+                } else {
+                        // TODO, check if it is a double
+                        // assume a double for now
+
+                        // check for Time dim 0
+                        NcToken dim0Name = aVar-&gt;get_dim(0)-&gt;name();
+                        if (strcmp(dim0Name, &quot;Time&quot;)) 
+                                continue;
+
+                        // check for dim 1 being num vertices or cells 
+                        bool isVertexData = false;
+                        bool isCellData = false;
+                        NcToken dim1Name = aVar-&gt;get_dim(1)-&gt;name();
+                        if (!strcmp(dim1Name, &quot;nVertices&quot;)) 
+                                isVertexData = true;
+                        else if (!strcmp(dim1Name, &quot;nCells&quot;)) 
+                                isCellData = true; 
+                        else continue;
+
+                        // check if dim 2 is nVertLevels or nVertLevelsP1, too
+                        NcToken dim2Name = aVar-&gt;get_dim(2)-&gt;name();
+                        if ((strcmp(dim2Name, &quot;nVertLevels&quot;)) 
+                                &amp;&amp; (strcmp(dim2Name, &quot;nVertLevelsP1&quot;))) {
+                                continue;
+                        }
+
+                        // check if we have data for the selected level
+                        if (aVar-&gt;get_dim(2)-&gt;size()-1 &lt; outputVertLevel) {
+                                cout &lt;&lt; &quot;No data found for level &quot;;
+                                cout &lt;&lt; outputVertLevel &lt;&lt; &quot; for variable &quot;;
+                                cout &lt;&lt; aVar-&gt;name() &lt;&lt; endl;
+                                continue;
+                        }
+
+                        // Add to cell or point var array
+                        if (isVertexData) {  // means it is dual cell data
+                                dualCellVarIndex++;
+                                if (dualCellVarIndex &gt; MAX_VARS-1) {
+                                        cerr &lt;&lt; &quot;Exceeded number of cell vars.&quot; &lt;&lt; endl;
+                                        exit(1);
+                                }
+                                dualCellVars[dualCellVarIndex] = aVar;
+                                //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualCellVars&quot; &lt;&lt; endl;
+                        } else if (isCellData) { // means it is dual vertex data
+                                if (strcmp(aVar-&gt;name(), &quot;tracers&quot;)) {
+                                        dualPointVarIndex++;
+                                        if (dualPointVarIndex &gt; MAX_VARS-1) {
+                                                cerr &lt;&lt; &quot;Exceeded number of point vars.&quot; &lt;&lt; endl;
+                                                exit(1);
+                                        }
+                                        dualPointVars[dualPointVarIndex] = aVar;
+                                        //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualPointVars&quot; &lt;&lt; endl;
+                                } else { // case of tracers, add each as &quot;tracer0&quot;, &quot;tracer1&quot;, etc.
+                                        tracersExist = true;
+                                        int numTracers = aVar-&gt;get_dim(3)-&gt;size();
+                                        for (int t = 0; t &lt; numTracers; t++) {
+                                                dualPointVarIndex++;
+                                                if (dualPointVarIndex &gt; MAX_VARS-1) {
+                                                        cerr &lt;&lt; &quot;Exceeded number of point vars.&quot; &lt;&lt; endl;
+                                                        exit(1);
+                                                }
+                                                dualPointVars[dualPointVarIndex] = aVar;
+                                                //cout &lt;&lt; &quot;Adding var &quot; &lt;&lt; aVar-&gt;name() &lt;&lt; &quot; to dualPointVars&quot; &lt;&lt; endl;
+                                        }
+                                }        
+                        }
+                }
+        }
+
+        // TODO
+         // prompt the user to find out which fields are of interest?
+        // for now, assume all are of interest
+        
+        // get points  (centers of primal-mesh cells)
+
+        // TO DO check malloc return vals.
+
+        double *xCellData = (double*)malloc(nCells-&gt;size() 
+                * sizeof(double));
+        CHECK_MALLOC(xCellData);
+        NcVar *xCellVar = ncFile.get_var(&quot;xCell&quot;);
+        xCellVar-&gt;get(xCellData, nCells-&gt;size());
+
+        double *yCellData = (double*)malloc(nCells-&gt;size() 
+                * sizeof(double));
+        CHECK_MALLOC(yCellData);
+        NcVar *yCellVar = ncFile.get_var(&quot;yCell&quot;);
+        yCellVar-&gt;get(yCellData, nCells-&gt;size());
+
+        double *zCellData = (double*)malloc(nCells-&gt;size() 
+                * sizeof(double));
+        //cout &lt;&lt; &quot;ptr for zCellData&quot;  &lt;&lt; zCellData &lt;&lt; endl;
+        CHECK_MALLOC(zCellData);
+        NcVar *zCellVar = ncFile.get_var(&quot;zCell&quot;);
+        zCellVar-&gt;get(zCellData, nCells-&gt;size());
+
+        // get dual-mesh cells
+
+        int *cellsOnVertex = (int *) malloc((nVertices-&gt;size()) * vertexDegree-&gt;size() * 
+                sizeof(int));
+        //cout &lt;&lt; &quot;ptr for cellsOnVertex&quot;  &lt;&lt; cellsOnVertex &lt;&lt; endl;
+        CHECK_MALLOC(cellsOnVertex);
+        NcVar *cellsOnVertexVar = ncFile.get_var(&quot;cellsOnVertex&quot;);
+        //cout &lt;&lt; &quot;getting cellsOnVertexVar</font>
<font color="gray">&quot;;
+        cellsOnVertexVar-&gt;get(cellsOnVertex, nVertices-&gt;size(), vertexDegree-&gt;size());
+
+        // decls for data storage
+        double* dualCellVarData;
+        double* dualPointVarData;
+
+        // for each variable, allocate space for variables
+
+        //cout &lt;&lt; &quot;dualCellVarIndex: &quot; &lt;&lt; dualCellVarIndex &lt;&lt; endl;
+
+        int varVertLevels = 0;
+
+        dualCellVarData = (double*)malloc((sizeof(double))  * numDualCells);
+        CHECK_MALLOC(dualCellVarData);
+
+        dualPointVarData = (double*)malloc((sizeof(double)) * nCells-&gt;size());
+        CHECK_MALLOC(dualPointVarData);
+        
+
+        // for each time step, write a file with the time prepended to filename
+        for (int i = 0; i &lt; Time-&gt;size(); i++) 
+        {
+
+                ostringstream vtkFileName;
+
+                vtkFileName &lt;&lt; i &lt;&lt; argv[2];         
+
+                ofstream vtkFile(vtkFileName.str().c_str(), ios::out);
+
+                if (!vtkFile)
+                {
+                        cerr &lt;&lt; &quot;vtk output file could not be opened&quot; &lt;&lt;endl;
+                        exit(1);
+                }
+
+
+                // write header
+
+                vtkFile &lt;&lt; &quot;# vtk DataFile Version 2.0, transdual Version 1.2&quot; &lt;&lt; endl;
+                vtkFile &lt;&lt; &quot;Translated newpop data to dual grid for timestep &quot; &lt;&lt; i &lt;&lt; &quot; from netCDF by Christine Ahrens&quot; 
+                        &lt;&lt; endl;
+                vtkFile &lt;&lt; &quot;ASCII&quot; &lt;&lt; endl;
+                vtkFile &lt;&lt; &quot;DATASET UNSTRUCTURED_GRID&quot; &lt;&lt; endl;
+
+
+                // write points  (the points are the primal-grid cell centers)
+
+                vtkFile &lt;&lt; &quot;POINTS &quot; &lt;&lt; numDualPoints &lt;&lt; &quot; float&quot; &lt;&lt; endl;
+
+                // first write a dummy point, because the climate code
+                // starts their cell numbering at 1 and VTK starts it at
+                // 0
+                vtkFile.precision(16);
+                vtkFile &lt;&lt; (float)0.0 &lt;&lt; &quot;\t&quot; &lt;&lt; (float)0.0 &lt;&lt; &quot;\t&quot; &lt;&lt; (float)0.0 
+                        &lt;&lt; endl;
+
+                for (int j = 0; j &lt; nCells-&gt;size(); j++ )
+                {
+                        vtkFile.precision(16);
+                        if (abs(xCellData[j]) &lt; 1e-126) xCellData[j] = 0;
+                        if (abs(yCellData[j]) &lt; 1e-126) yCellData[j] = 0;
+                        if (abs(zCellData[j]) &lt; 1e-126) zCellData[j] = 0;
+                        vtkFile &lt;&lt; (float)xCellData[j] &lt;&lt; &quot;\t&quot; &lt;&lt; (float)yCellData[j] &lt;&lt; &quot;\t&quot;
+                                &lt;&lt; (float)zCellData[j] &lt;&lt; endl;
+                }        
+                vtkFile &lt;&lt; endl;
+
+
+                // Write dual-mesh cells
+                // Dual-mesh cells are triangles with primal-mesh cell 
+                // centers as the vertices.
+                // The number of dual-mesh cells is the number of vertices in the
+                // primal mesh.
+
+                vtkFile &lt;&lt; &quot;CELLS &quot; &lt;&lt; numDualCells &lt;&lt; &quot; &quot; 
+                        &lt;&lt; numDualCells * (vertexDegree-&gt;size() + 1) &lt;&lt; endl;        
+
+                // for each dual-mesh cell, write number of points for each
+                // and then list the points by number
+
+                for (int j = 0; j &lt; numDualCells ; j++) {
+
+                        vtkFile &lt;&lt; vertexDegree-&gt;size() &lt;&lt; &quot;\t&quot; ;
+
+                        // since primal vertex(pt) numbers  == dual cell numbers
+                        // we go through the primal vertices, find the cells around
+                        // them, and since those primal cell numbers are dual 
+                        // point numbers,  
+                        // we can write the cell numbers for the cellsOnVertex
+                        // and those will be the numbers of the dual vertices (pts).
+                        
+                        int* dualCells = cellsOnVertex + (j * vertexDegree-&gt;size());
+
+                        for (int k = 0; k &lt; vertexDegree-&gt;size(); k++) 
+                        {                
+                                vtkFile &lt;&lt; dualCells[k] &lt;&lt; &quot;\t&quot;;
+                        }
+
+                        vtkFile &lt;&lt; endl;
+                }        
+                vtkFile &lt;&lt; endl;
+
+
+                // write cell types 
+                int cellType;
+                if (vertexDegree-&gt;size() == 3) 
+                        cellType = VTK_TRIANGLE;
+                else if (vertexDegree-&gt;size() == 4)
+                        cellType = VTK_QUAD;
+                else cellType = VTK_POLYGON;
+
+                vtkFile &lt;&lt; &quot;CELL_TYPES &quot; &lt;&lt; numDualCells &lt;&lt; endl;
+
+                for (int j = 0; j &lt; numDualCells; j++)
+                {
+                        vtkFile &lt;&lt; cellType &lt;&lt; endl;
+                }
+                vtkFile &lt;&lt; endl;
+
+                // Write attributes of dual-mesh cell data (attributes of primal-mesh
+                // vertex data)
+
+                // for each var, figure out if it is by cell or by point
+
+
+                vtkFile.precision(16);
+
+                // If by point, write out point data
+
+                if (dualPointVarIndex &gt;= 0) vtkFile &lt;&lt; &quot;POINT_DATA &quot; &lt;&lt; numDualPoints &lt;&lt; endl;
+
+                int printstep = -1;
+
+                if (i == printstep) cout &lt;&lt; &quot;TIME STEP: &quot; &lt;&lt; i &lt;&lt; endl;
+
+                int tracerNum = 0;
+
+                for (int v = 0; v &lt;= dualPointVarIndex; v++) {
+        
+                        // Read variable number v data for that timestep
+
+                        varVertLevels = dualPointVars[v]-&gt;get_dim(2)-&gt;size();
+
+                        bool isTracer = false;
+
+                        if (!strcmp(dualPointVars[v]-&gt;name(), &quot;tracers&quot;)) {
+                                isTracer = true;                                
+                                dualPointVars[v]-&gt;set_cur(i, 0, outputVertLevel, tracerNum);
+                                dualPointVars[v]-&gt;get(dualPointVarData, 1, nCells-&gt;size(), 1, 1);
+                        } else {        
+                                dualPointVars[v]-&gt;set_cur(i, 0, outputVertLevel);
+                                dualPointVars[v]-&gt;get(dualPointVarData, 1, nCells-&gt;size(), 1);
+                        }
+
+                        // Write variable number v data for that timestep
+                        vtkFile &lt;&lt; &quot;SCALARS &quot; &lt;&lt; dualPointVars[v]-&gt;name();
+                        if (isTracer) vtkFile &lt;&lt; tracerNum+1;
+                        vtkFile &lt;&lt; &quot; float 1&quot; &lt;&lt;  endl;
+                        vtkFile &lt;&lt; &quot;LOOKUP_TABLE default&quot; &lt;&lt; endl;
+
+                        //debugging
+                        if (i == printstep) cout &lt;&lt; &quot;SCALARS &quot; &lt;&lt; dualPointVars[v]-&gt;name() &lt;&lt; &quot; float 1&quot; &lt;&lt;  endl;
+                        if (i==printstep) {
+                                for (int z = 0; z &lt; varVertLevels; z++) {
+                                        cout &lt;&lt; z &lt;&lt; &quot;:&quot; &lt;&lt; *(dualPointVarData + z) &lt;&lt; endl;
+                                }
+                        }
+
+                        // get starting point
+                        double *var_target = dualPointVarData;
+
+                        float validData;
+
+                        validData = convertDouble2ValidFloat (*var_target);
+                        
+                        // write dummy
+                        vtkFile &lt;&lt; validData  &lt;&lt; endl;
+                
+                        // write data        
+                        for (int j = 0; j &lt; nCells-&gt;size(); j++) 
+                        {
+                                validData = convertDouble2ValidFloat (*var_target);
+                                vtkFile &lt;&lt; validData &lt;&lt; endl;
+                                var_target++;
+                        }
+
+                        if (isTracer) tracerNum++;
+                }
+
+                // if by cell, then write out cell data
+
+                if (dualCellVarIndex &gt;= 0) vtkFile &lt;&lt; &quot;CELL_DATA &quot; &lt;&lt; numDualCells &lt;&lt; endl;
+
+                for (int v = 0; v &lt;= dualCellVarIndex; v++) {
+
+                        // Read variable number v data for that timestep
+                        varVertLevels = dualCellVars[v]-&gt;get_dim(2)-&gt;size();
+                        dualCellVars[v]-&gt;set_cur(i, 0, outputVertLevel);
+                        dualCellVars[v]-&gt;get(dualCellVarData, 1, numDualCells, 1);
+
+                        // Write variable number v data for that timestep
+                        vtkFile &lt;&lt; &quot;SCALARS &quot; &lt;&lt; dualCellVars[v]-&gt;name() &lt;&lt; &quot; float 1&quot; &lt;&lt;  endl;
+                        vtkFile &lt;&lt; &quot;LOOKUP_TABLE default&quot; &lt;&lt; endl;
+
+                        // debugging
+                        if (i==printstep) cout &lt;&lt; &quot;SCALARS &quot; &lt;&lt; dualCellVars[v]-&gt;name() &lt;&lt; &quot; float 1&quot; &lt;&lt;  endl;
+                        if (i==printstep) {
+                                for (int z = 0; z &lt; varVertLevels; z++) {
+                                        cout &lt;&lt; z &lt;&lt; &quot;:&quot; &lt;&lt; *(dualCellVarData + z) &lt;&lt; endl;
+                                }
+                        }
+
+                        double *var_target = dualCellVarData; 
+                        float validData;
+
+                        for (int j = 0; j &lt; numDualCells; j++) 
+                        {
+                                validData = convertDouble2ValidFloat (*var_target);
+                                vtkFile &lt;&lt; validData &lt;&lt; endl;
+                                var_target++;
+                        }
+                }
+
+        }
+
+        return(0);
+
+}        
+


Property changes on: branches/ocean_projects/graphics/paraview/translator/nc2vtk_dual.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/x-c++src
Name: svn:keywords
   + Author Date ID Revision
Name: svn:eol-style
   + native

Added: branches/ocean_projects/graphics/paraview/translator/vtkCellType.h
===================================================================
--- branches/ocean_projects/graphics/paraview/translator/vtkCellType.h                                (rev 0)
+++ branches/ocean_projects/graphics/paraview/translator/vtkCellType.h        2010-04-08 19:38:18 UTC (rev 186)
@@ -0,0 +1,98 @@
+/*=========================================================================
+
+  Program:   Visualization Toolkit
+  Module:    $RCSfile: vtkCellType.h,v $
+
+  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
+  All rights reserved.
+  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+// .NAME vtkCellType - define types of cells
+// .SECTION Description
+// vtkCellType defines the allowable cell types in the visualization 
+// library (vtk). In vtk, datasets consist of collections of cells. 
+// Different datasets consist of different cell types. The cells may be 
+// explicitly represented (as in vtkPolyData), or may be implicit to the
+// data type (as in vtkStructuredPoints).
+
+#ifndef __vtkCellType_h
+#define __vtkCellType_h
+
+// To add a new cell type, define a new integer type flag here, then
+// create a subclass of vtkCell to implement the proper behavior. You 
+// may have to modify the following methods: vtkDataSet (and subclasses) 
+// GetCell() and vtkGenericCell::SetCellType(). Also, to do the job right,
+// you'll also have to modify some filters (vtkGeometryFilter...) and
+// regression tests (example scripts) to reflect the new cell addition.
+// Also, make sure to update vtkCellTypesStrings in vtkCellTypes.cxx.
+
+// .SECTION Caveats
+// An unstructured grid stores the types of its cells as a
+// unsigned char array. Therefore, the maximum encoding number for a cell type
+// is 255.
+
+typedef enum {
+  // Linear cells
+  VTK_EMPTY_CELL       = 0,
+  VTK_VERTEX           = 1,
+  VTK_POLY_VERTEX      = 2,
+  VTK_LINE             = 3,
+  VTK_POLY_LINE        = 4,
+  VTK_TRIANGLE         = 5,
+  VTK_TRIANGLE_STRIP   = 6,
+  VTK_POLYGON          = 7,
+  VTK_PIXEL            = 8,
+  VTK_QUAD             = 9,
+  VTK_TETRA            = 10,
+  VTK_VOXEL            = 11,
+  VTK_HEXAHEDRON       = 12,
+  VTK_WEDGE            = 13,
+  VTK_PYRAMID          = 14,
+  VTK_PENTAGONAL_PRISM = 15,
+  VTK_HEXAGONAL_PRISM  = 16,
+
+  // Quadratic, isoparametric cells
+  VTK_QUADRATIC_EDGE                   = 21,
+  VTK_QUADRATIC_TRIANGLE               = 22,
+  VTK_QUADRATIC_QUAD                   = 23,
+  VTK_QUADRATIC_TETRA                  = 24,
+  VTK_QUADRATIC_HEXAHEDRON             = 25,
+  VTK_QUADRATIC_WEDGE                  = 26,
+  VTK_QUADRATIC_PYRAMID                = 27,
+  VTK_BIQUADRATIC_QUAD                 = 28,
+  VTK_TRIQUADRATIC_HEXAHEDRON          = 29,
+  VTK_QUADRATIC_LINEAR_QUAD            = 30,
+  VTK_QUADRATIC_LINEAR_WEDGE           = 31,
+  VTK_BIQUADRATIC_QUADRATIC_WEDGE      = 32,
+  VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON = 33,
+
+  // Special class of cells formed by convex group of points
+  VTK_CONVEX_POINT_SET = 41,
+
+  // Higher order cells in parametric form
+  VTK_PARAMETRIC_CURVE        = 51,
+  VTK_PARAMETRIC_SURFACE      = 52,
+  VTK_PARAMETRIC_TRI_SURFACE  = 53,
+  VTK_PARAMETRIC_QUAD_SURFACE = 54,
+  VTK_PARAMETRIC_TETRA_REGION = 55,
+  VTK_PARAMETRIC_HEX_REGION   = 56,
+
+  // Higher order cells
+  VTK_HIGHER_ORDER_EDGE        = 60,
+  VTK_HIGHER_ORDER_TRIANGLE    = 61,
+  VTK_HIGHER_ORDER_QUAD        = 62,
+  VTK_HIGHER_ORDER_POLYGON     = 63,
+  VTK_HIGHER_ORDER_TETRAHEDRON = 64,
+  VTK_HIGHER_ORDER_WEDGE       = 65,
+  VTK_HIGHER_ORDER_PYRAMID     = 66,
+  VTK_HIGHER_ORDER_HEXAHEDRON  = 67,
+
+  VTK_NUMBER_OF_CELL_TYPES
+} VTKCellType;
+
+#endif


Property changes on: branches/ocean_projects/graphics/paraview/translator/vtkCellType.h
___________________________________________________________________
Name: svn:mime-type
   + text/x-c++hdr
Name: svn:keywords
   + Author Date ID Revision
Name: svn:eol-style
   + native

</font>
</pre>