<p><b>dwj07@fsu.edu</b> 2012-03-22 10:52:53 -0600 (Thu, 22 Mar 2012)</p><p><br>
        -- BRANCH COMMIT --<br>
<br>
        Adding a sphere to the inside of spherical meshes.<br>
<br>
        This allows only the front half of the sphere to be seen when visualizing it.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/tools/mpas_draw/mpas_draw.cpp
===================================================================
--- branches/tools/mpas_draw/mpas_draw.cpp        2012-03-22 15:57:46 UTC (rev 1694)
+++ branches/tools/mpas_draw/mpas_draw.cpp        2012-03-22 16:52:53 UTC (rev 1695)
@@ -62,6 +62,8 @@
 double getY(double lat, double lon);
 double getZ(double lat, double lon);
 
+void drawSphere(double r, int lats, int longs);
+
 //
 //  Global data.
 //
@@ -71,12 +73,15 @@
 int drawing = 0;
 int draw_lines = 1;
 bool on_sphere;
+double sphere_radius;
 int color_bar = 0;
 
 double line_factor = 1.002;
 double region_line_factor = 1.006;
 double region_center_factor = 1.008;
 double range_factor = 0.80;
+double zNear = 0.1;
+double zFar = 2.5;
 
 double projUpDown = 0.0;
 double projLeftRight = 0.0;
@@ -297,6 +302,10 @@
         translateView ( projUpDown, projLeftRight );
         polarView( projDistance, projTwist, projElevation, projAzimuth );
 
+        if(on_sphere){
+                drawSphere(0.989, 40, 40);
+        }
+
         switch(drawing){
                 case 0:
                         draw_triangles();
@@ -506,6 +515,7 @@
         glLoadIdentity ( );
 
         gluPerspective( 45.0f, (GLfloat)w / (GLfloat)h, 0.1f, 5.0f );
+        //gluPerspective( 45.0f, (GLfloat)w / (GLfloat)h, (GLfloat)zNear, (GLfloat)zFar);
         //glMatrixMode ( GL_MODELVIEW );
 
         return;
@@ -629,6 +639,7 @@
         nedges = netcdf_mpas_read_dim(filename, &quot;nEdges&quot;);
         maxedges = netcdf_mpas_read_dim(filename, &quot;maxEdges&quot;);
         on_sphere = netcdf_mpas_read_onsphere(filename);
+        sphere_radius = netcdf_mpas_read_sphereradius(filename);
 
         cell_cells.reserve((ncells+1)*maxedges*3*3);
         cell_lines.reserve((ncells+1)*maxedges*3*2);
@@ -1090,6 +1101,10 @@
                 xyz_center[i] = ( xyz_min[i] + xyz_max[i] ) / 2.0;
                 xyz_scale = std::max ( xyz_scale, ( xyz_max[i] - xyz_min[i] ) / 2.0 );
         }
+
+        if(on_sphere){
+                xyz_scale = sphere_radius;
+        }
         //
         //  A sphere doesn't need this rescaling.
         //  A box does!
@@ -1170,6 +1185,10 @@
                 xyz_center[i] = ( xyz_min[i] + xyz_max[i] ) / 2.0;
                 xyz_scale = std::max ( xyz_scale, ( xyz_max[i] - xyz_min[i] ) / 2.0 );
         }
+
+        if(on_sphere){
+                xyz_scale = sphere_radius;
+        }
         //
         //  A sphere doesn't need this rescaling.
         //  A box does!
@@ -1853,9 +1872,11 @@
                         break;
                 case KEY_COMMA:
                         projDistance += 0.1;
+                        zFar += 0.1;
                         break;
                 case KEY_PERIOD:
                         projDistance -= 0.1;
+                        zFar -= 0.1;
                         break;
                 case KEY_v:
                         switch(drawing){
@@ -2093,3 +2114,32 @@
         return sin(lat);
 }/*}}}*/
 
+void drawSphere(double r, int lats, int longs) {/*{{{*/
+        int i, j;
+        double z_c;
+
+        z_c = -0.01;
+        z_c = 0.0;
+        for(i = 0; i &lt; lats; i++) {
+                double lat0 = M_PI * (-0.5 + (double) i  / lats);
+                double z0  = sin(lat0);
+                double zr0 =  cos(lat0);
+
+                double lat1 = M_PI * (-0.5 + (double) (i+1) / lats);
+                double z1 = sin(lat1);
+                double zr1 = cos(lat1);
+
+                glBegin(GL_QUAD_STRIP);
+                for(j = 0; j &lt;= longs; j++) {
+                        double lng = 2 * M_PI * (double) (j) / longs;
+                        double x = cos(lng);
+                        double y = sin(lng);
+
+                        glNormal3f(x * zr0, y * zr0, z0);
+                        glVertex3f(r * x * zr0, r * y * zr0, r * (z0+z_c));
+                        glNormal3f(x * zr1, y * zr1, z1);
+                        glVertex3f(r * x * zr1, r * y * zr1, r * (z1+z_c));
+                }
+                glEnd();
+        }
+}/*}}}*/

Modified: branches/tools/mpas_draw/netcdf_utils.cpp
===================================================================
--- branches/tools/mpas_draw/netcdf_utils.cpp        2012-03-22 15:57:46 UTC (rev 1694)
+++ branches/tools/mpas_draw/netcdf_utils.cpp        2012-03-22 16:52:53 UTC (rev 1695)
@@ -90,6 +90,88 @@
 
 }/*}}}*/
 //****************************************************************************80
+double netcdf_mpas_read_sphereradius(string filename){/*{{{*/
+        //****************************************************************************80
+        //
+        //  Purpose:
+        //
+        //    NETCDF_MPAS_READ_SPHERERADIUS determines if the radius of the sphere.
+        //
+        //  Licensing:
+        //
+        //    This code is distributed under the GNU LGPL license.
+        //
+        //  Modified:
+        //
+        //    29 December 2010
+        //
+        //  Author:
+        //
+        //    John Burkardt, Doug Jacobsen
+        //
+        //  Reference:
+        //
+        //    Russ Rew, Glenn Davis, Steve Emmerson, Harvey Davies, Ed Hartne,
+        //    The NETCDF User's Guide,
+        //    Unidata Program Center, March 2009.
+        //
+        //  Parameters:
+        //
+        //    Input, string NC_FILENAME, the name of the NETCDF file to examine.
+        //
+        //    Output, double NETCDF_MPAS_READ_SPHERERADIUS, true or false based on the global
+        //                                                                                     attribute, on_a_sphere
+        //
+        NcAtt *att_id;
+        NcValues *vals;
+        bool valid;
+        string tmp_name;
+        string sph_name = &quot;sphere_radius&quot;;
+        //
+        //  Open the file.
+        //
+        #ifdef _64BITOFFSET
+                NcFile ncid ( filename.c_str ( ), NcFile::ReadOnly, NULL, 0, NcFile::Offset64Bits );
+        #else
+                NcFile ncid ( filename.c_str ( ), NcFile::ReadOnly );
+        #endif
+        //
+        //  Get Ntime, which is a NETCDF dimension.
+        //
+        valid = false;
+
+        for(int i = 0; i &lt; ncid.num_atts() &amp;&amp; !valid; i++){
+                tmp_name = ncid.get_att(i)-&gt;name();
+
+                if(sph_name == tmp_name){
+                        valid = true;
+                }
+        }
+
+        if(valid){
+                att_id = ncid.get_att(sph_name.c_str());
+                
+                vals = att_id -&gt; values();
+
+                sph_name = &quot;YES             &quot;;
+
+                for(int i = 0; i &lt; vals -&gt; num(); i++){
+                        tmp_name = vals -&gt; as_string(i);
+
+                        return atof(vals -&gt; as_string(i));
+                }
+        } else {
+                return 0.0;
+        }
+        //
+        //  Close the file.
+        //
+        ncid.close ( );
+
+        return 0.0;
+
+}/*}}}*/
+//****************************************************************************80
 int netcdf_mpas_read_dim ( string filename, string dim_name ){/*{{{*/
         //****************************************************************************80
         //

Modified: branches/tools/mpas_draw/netcdf_utils.h
===================================================================
--- branches/tools/mpas_draw/netcdf_utils.h        2012-03-22 15:57:46 UTC (rev 1694)
+++ branches/tools/mpas_draw/netcdf_utils.h        2012-03-22 16:52:53 UTC (rev 1695)
@@ -2,6 +2,7 @@
 #include &lt;netcdfcpp.h&gt;
 
 bool netcdf_mpas_read_onsphere(string filename);
+double netcdf_mpas_read_sphereradius(string filename);
 int netcdf_mpas_read_dim ( string filename, string dim_name );
 int netcdf_mpas_read_num_vars(string filename);
 void netcdf_mpas_read_xyzcell ( string filename, int ncells, double xcell[], double ycell[], double zcell[] );

</font>
</pre>