PlainMap.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.3 $
00022 // $Date: 2003/02/14 23:01:58 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/renderer/PlainMap.cpp,v $
00024                                                                         
00025 // Written: fmk 
00026 // Created: 10/98
00027 //
00028 // Description: This file contains the class definition for PlainMap.
00029 // PlainMap is an abstract base class. An PlainMap object is used
00030 // to determine the r,g,b values given an input value.
00031 //
00032 // What: "@(#) PlainMap.h, revA"
00033 
00034 #include <PlainMap.h>
00035 #include <OPS_Stream.h>
00036 #include <stdlib.h>
00037 #include <math.h>
00038 
00039 static float jet[64*3] = {
00040   0,         0,    0.5625,
00041   0,         0,    0.6250,
00042   0,         0,    0.6875,
00043   0,         0,    0.7500,
00044   0,         0,    0.8125,
00045   0,         0,    0.8750,
00046   0,         0,    0.9375,
00047   0,         0,    1.0000,
00048   0,    0.0625,    1.0000,
00049   0,    0.1250,    1.0000,
00050   0,    0.1875,    1.0000,
00051   0,    0.2500,    1.0000,
00052   0,    0.3125,    1.0000,
00053   0,    0.3750,    1.0000,
00054   0,    0.4375,    1.0000,
00055   0,    0.5000,    1.0000,
00056   0,    0.5625,    1.0000,
00057   0,    0.6250,    1.0000,
00058   0,    0.6875,    1.0000,
00059   0,    0.7500,    1.0000,
00060   0,    0.8125,    1.0000,
00061   0,    0.8750,    1.0000,
00062   0,    0.9375,    1.0000,
00063   0,    1.0000,    1.0000,
00064   0.0625,    1.0000,    1.0000,
00065   0.1250,    1.0000,    0.9375,
00066   0.1875,    1.0000,    0.8750,
00067   0.2500,    1.0000,    0.8125,
00068   0.3125,    1.0000,    0.7500,
00069   0.3750,    1.0000,    0.6875,
00070   0.4375,    1.0000,    0.6250,
00071   0.5000,    1.0000,    0.5625,
00072   0.5625,    1.0000,    0.5000,
00073   0.6250,    1.0000,    0.4375,
00074   0.6875,    1.0000,    0.3750,
00075   0.7500,    1.0000,    0.3125,
00076   0.8125,    1.0000,    0.2500,
00077   0.8750,    1.0000,    0.1875,
00078   0.9375,    1.0000,    0.1250,
00079   1.0000,    1.0000,    0.0625,
00080   1.0000,    1.0000,         0,
00081   1.0000,    0.9375,         0,
00082   1.0000,    0.8750,         0,
00083   1.0000,    0.8125,         0,
00084   1.0000,    0.7500,         0,
00085   1.0000,    0.6875,         0,
00086   1.0000,    0.6250,         0,
00087   1.0000,    0.5625,         0,
00088   1.0000,    0.5000,         0,
00089   1.0000,    0.4375,         0,
00090   1.0000,    0.3750,         0,
00091   1.0000,    0.3125,         0,
00092   1.0000,    0.2500,         0,
00093   1.0000,    0.1875,         0,
00094   1.0000,    0.1250,         0,
00095   1.0000,    0.0625,         0,
00096   1.0000,         0,         0,
00097   0.9375,         0,         0,
00098   0.8750,         0,         0,
00099   0.8125,         0,         0,
00100   0.7500,         0,         0,
00101   0.6875,         0,         0,
00102   0.6250,         0,         0,
00103   0.5625,         0,         0};
00104 
00105 
00106 
00107 PlainMap::PlainMap()
00108   :max(0.0), min(0.0), maxLast(0.0), minLast(0.0)
00109 {
00110   data = jet;
00111   sizeData = 64;
00112 }
00113 
00114 
00115 float 
00116 PlainMap::getRed(float value){
00117   if (value > max)
00118     max = value;
00119   else if (value < min)
00120     min = value;
00121 
00122   if (maxLast == minLast) {
00123     int index = sizeData/2;
00124     return data[index*3-3];
00125 
00126   } else if (value > maxLast) 
00127     return data[sizeData*3-3];
00128   else if (value < minLast)
00129     return data[0];
00130   else {
00131     int index = (floor)((value-minLast)*sizeData/((maxLast-minLast)));
00132     return data[index*3-3];
00133   }
00134     
00135   return 0.0;
00136 }
00137       
00138 
00139 float 
00140 PlainMap::getGreen(float value) {
00141   if (value > max)
00142     max = value;
00143   else if (value < min)
00144     min = value;
00145 
00146   if (maxLast == minLast) {
00147     int index = sizeData/2;
00148     return data[index*3-2];
00149 
00150   } else if (value > maxLast) 
00151     return data[sizeData*3-2];
00152   else if (value < minLast)
00153     return data[1];
00154   else {
00155     int index = (floor)((value-minLast)*sizeData/((maxLast-minLast)));
00156     return data[index*3-2];
00157   }
00158     
00159   return 0.0;
00160 }
00161 
00162 float 
00163 PlainMap::getBlue(float value) {
00164   if (value > max)
00165     max = value;
00166   else if (value < min)
00167     min = value;
00168 
00169   if (maxLast == minLast) {
00170     int index = sizeData/2;
00171     return data[index*3-1];
00172 
00173   } else if (value > maxLast) 
00174     return data[sizeData*3-1];
00175   else if (value < minLast)
00176     return data[2];
00177   else {
00178     int index = (floor)((value-minLast)*sizeData/((maxLast-minLast)));
00179     return data[index*3-1];
00180   }
00181     
00182   return 0.0;
00183 }
00184 
00185 int
00186 PlainMap::getRGB(float value, float &red, float &blue, float &green) {
00187   red = this->getRed(value);
00188   green = this->getGreen(value);
00189   blue = this->getBlue(value);
00190   return 0;
00191 }
00192     
00193 
00194 
00195 int
00196 PlainMap::startImage()
00197 {
00198   maxLast = max;
00199   minLast = min;
00200   max = 0;
00201   min = 0;
00202 
00203   if (maxLast > -minLast)
00204     maxLast = -minLast;
00205   if (minLast < -maxLast)
00206     minLast = -maxLast;
00207   return 0;
00208 }

Generated on Mon Oct 23 15:05:27 2006 for OpenSees by doxygen 1.5.0