r2169: *** empty log message ***
[ctsim.git] / src / graph3dview.cpp
index a3343ab8a9523b5a6ce57d372c6b3be7399bb5ef..7d08275fb45e47a1775c98e7181bfce6cfc5ebfd 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: graph3dview.cpp,v 1.28 2002/06/03 16:57:22 kevin Exp $
+**  $Id: graph3dview.cpp,v 1.29 2002/06/27 03:19:23 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -286,7 +286,7 @@ Graph3dFileView::CreateDisplayList()
     p3[0] = dXPos; p3[1] = actScale * (v[ix][1] + actOffset); p3[2] = dYPos + 1;
     CalculateVectorNormal<double> (p1, p2, p3, &n1[0], &n1[1], &n1[2]);
 
-    double dIntensity1, dIntensity2;
+    double dIntensity1 = 0., dIntensity2 = 0.;
     if (m_bColor) {
       dIntensity1 = (v[ix][0] - dMin) / dIntensityScale;
       dIntensity2 = (v[ix+1][0] - dMin) / dIntensityScale;
@@ -296,12 +296,13 @@ Graph3dFileView::CreateDisplayList()
       intensityToColor (dIntensity1, vecColor);
       glColor3fv (vecColor);
     }
-    glVertex3dv (p1); 
-    glNormal3dv (n1);                                  
+    glVertex3dv (p1); glNormal3dv (n1);                                        
+    if (m_bColor) {
       intensityToColor (dIntensity2, vecColor);
       glColor3fv (vecColor);
-    glVertex3dv (p2); 
-    glNormal3dv (n1);                                  
+    }
+    glVertex3dv (p2); glNormal3dv (n1);                                        
+
     double lastP[3];
     lastP[0] = ix; lastP[1] = actScale * (v[ix][0] + actOffset); lastP[2] = 0; 
     for (unsigned int iy = 1; iy < ny - 1; iy++, dYPos++) {       
@@ -309,14 +310,18 @@ Graph3dFileView::CreateDisplayList()
       p2[0] = dXPos+1;  p2[1] = actScale * (v[ix+1][iy] + actOffset); p2[2] = dYPos;
       CalculateVectorNormal (p1, p2, lastP, &n1[0], &n1[1], &n1[2]);
       lastP[0] = p1[0]; lastP[1] = p1[1]; lastP[2] = p1[2];
-        dIntensity1 = (v[ix][iy] - dMin) / dIntensityScale;
-        dIntensity2 = (v[ix+1][iy] - dMin) / dIntensityScale;
-        intensityToColor (dIntensity1, vecColor);
-        glColor3fv (vecColor);
-      glVertex3dv (p1); glNormal3dv (n1);                                      
-        intensityToColor (dIntensity2, vecColor);
-        glColor3fv (vecColor);
-      glVertex3dv (p2); glNormal3dv (n1);                                      
+      if (m_bColor) {
+       dIntensity1 = (v[ix][iy] - dMin) / dIntensityScale;
+       dIntensity2 = (v[ix+1][iy] - dMin) / dIntensityScale;
+       intensityToColor (dIntensity1, vecColor);
+       glColor3fv (vecColor);
+      }
+      glVertex3dv (p1); glNormal3dv (n1);              
+      if (m_bColor) {
+       intensityToColor (dIntensity2, vecColor);
+       glColor3fv (vecColor);
+      }
+      glVertex3dv (p2); glNormal3dv (n1);
     }                  
     glEnd(); // QUAD_STRIP
   }
@@ -682,7 +687,7 @@ Graph3dFileView::OnScaleSet (wxCommandEvent& event)
   unsigned int nx = GetDocument()->nx();
   unsigned int ny = GetDocument()->ny();
   const ImageFileArrayConst v = GetDocument()->getArray();
-  double dMin, dMax;
+  double dMin = 0., dMax = 0.;
   if (! m_bColorScaleMinSet && ! m_bColorScaleMaxSet) {
     dMax = dMin = v[0][0];
     for (unsigned ix = 0; ix < nx; ix++)