Main Page   Class Hierarchy   Compound List   File List   Compound Members  

color.cpp

00001 /*=============================================================================
00002         File: color.cpp
00003      Purpose:
00004     Revision: $Id: color.cpp,v 1.3 2003/01/13 19:40:54 philosophil Exp $
00005   Created by: Philippe Lavoie          (26 January, 1999)
00006  Modified by: Martin Schuerch
00007 
00008  Copyright notice:
00009           Copyright (C) 1996-1999 Philippe Lavoie
00010  
00011           This library is free software; you can redistribute it and/or
00012           modify it under the terms of the GNU Library General Public
00013           License as published by the Free Software Foundation; either
00014           version 2 of the License, or (at your option) any later version.
00015  
00016           This library is distributed in the hope that it will be useful,
00017           but WITHOUT ANY WARRANTY; without even the implied warranty of
00018           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019           Library General Public License for more details.
00020  
00021           You should have received a copy of the GNU Library General Public
00022           License along with this library; if not, write to the Free
00023           Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024 =============================================================================*/
00025 
00026 #ifndef Color_SOURCES
00027 #define Color_SOURCES
00028 
00029 #include "color.h"
00030 
00031 #include "barray.cpp"
00032 #include "barray2d.cpp"
00033 #include "matrix.cpp"
00034 #include "vector.cpp"
00035 
00038 namespace PLib {
00039 
00040   /*
00041   Color whiteColor(255,255,255);
00042   Color redColor(255,0,0) ;
00043   Color blueColor(0,0,255) ;
00044   Color greenColor(0,255,0) ;
00045   Color yellowColor(255,255,0) ;
00046   Color cyanColor(0,255,255) ;
00047   Color magentaColor(255,0,255);
00048   Color gray80Color(204,204,204) ;
00049   Color gray50Color(127,127,127) ;
00050   Color blackColor(0,0,0) ;
00051   */
00052 
00053   double
00054     Matrix<Color>::norm(void) {
00055 #ifdef USE_EXCEPTION
00056     throw MatrixErr();
00057 #else
00058     Error error("Matrix<Color>::norm()") ;
00059     error << "ERROR: you can't get the norm of a Color matrix\n" ;
00060     error.fatal() ;
00061 #endif
00062     return 0 ;
00063   }
00064 
00065   Matrix<Color>& Matrix<Color>::operator+=(double a)
00066   {
00067 #ifdef USE_EXCEPTION
00068     throw MatrixErr();
00069 #else
00070     Error error("Matrix<Color>::operator+=()") ;
00071     error << "ERROR: you can't increment by a double a Color matrix\n" ;
00072     error.fatal() ;
00073 #endif
00074     return *this ;
00075   }
00076 
00077   Matrix<Color>& Matrix<Color>::operator-=(double a)
00078   {
00079 #ifdef USE_EXCEPTION
00080     throw MatrixErr();
00081 #else
00082     Error error("Matrix<Color>::operator+=()") ;
00083     error << "ERROR: you can't decrement by a double a Color matrix\n" ;
00084     error.fatal() ;
00085 #endif
00086     return *this ;
00087   }
00088 
00089 
00090 #ifndef USING_VCC
00091   int Matrix<Color>::read(char* filename,int r, int c) {
00092     ifstream fin(filename) ;
00093     if(!fin) {
00094       resize(1,1) ;
00095       return 0 ;
00096     }
00097     resize(r,c) ;
00098     Matrix<unsigned char> T(r,c) ;
00099     unsigned char* p = T[0] ;
00100     if(!fin.read((char*)p,sizeof(unsigned char)*r*c)) return 0 ;
00101     int i,j ;
00102     for(i=0;i<r ;++i)
00103       for(j=0;j<c ;++j)
00104         elem(i,j).r = T(i,j) ;
00105     if(!fin.read((char*)p,sizeof(unsigned char)*r*c)) return 0 ;
00106     for(i=0;i<r ;i++)
00107       for(j=0;j<c ;++j)
00108         elem(i,j).g = T(i,j) ;
00109     if(!fin.read((char*)p,sizeof(unsigned char)*r*c)) return 0 ;
00110     for(i=0;i<r ;i++)
00111       for(j=0;j<c ;++j)
00112         elem(i,j).b = T(i,j) ;
00113     return 1 ;
00114   }
00115 #endif
00116 
00117   int Vector<Color>::minIndex() const {
00118 #ifdef USE_EXCEPTION
00119     throw MatrixErr() ;
00120 #else
00121     Error error("Vector<color>::minIndex") ;
00122     error << "ERROR: you can't get the minIndex of a vector of Colors!\n" ;
00123     error.fatal() ;
00124 #endif
00125     return 0 ;
00126   }
00127  
00128 
00129 
00130 
00131 #ifdef  NO_IMPLICIT_TEMPLATES
00132 
00133   // from barray.cpp
00134   template class BasicArray<Color>;
00135   template void resizeBasicArray<Color>(BasicArray<Color>&,int) ;
00136   template int operator==(const BasicArray<Color>&,const BasicArray<Color>&);
00137   template istream& operator>>(istream& is, BasicArray<Color>& ary);
00138   template ostream& operator<<(ostream& os, const BasicArray<Color>& ary);
00139 
00140   // from barray2d.cpp
00141   template class Basic2DArray<Color> ;
00142   template void initBasic2DArray<Color>(Basic2DArray<Color>&,const int,const int) ;
00143   template void resizeKeepBasic2DArray<Color>(Basic2DArray<Color>&,const int,const int) ;
00144   template istream& operator>>(istream& is, Basic2DArray<Color>& ary);
00145   template ostream& operator<<(ostream& os, const Basic2DArray<Color>& ary);
00146 
00147   // Matrix instantiation
00148   template class Matrix<Color> ;
00149 
00150   template Matrix<Color> operator+(const Matrix<Color>&,const Matrix<Color>&);
00151   template Matrix<Color> operator-(const Matrix<Color>&,const Matrix<Color>&);
00152   template Matrix<Color> operator*(const Matrix<Color>&,const Matrix<Color>&);
00153   template Matrix<Color> operator*(const double,const Matrix<Color>&);
00154   template int operator==(const Matrix<Color>&,const Matrix<Color>&);
00155   // template int operator!=(const Matrix<Color>&,const Matrix<Color>&);
00156   template Matrix<Color> comm(const Matrix<Color>&,const Matrix<Color>&);
00157 
00158 
00159  // Vector instantiation
00160 
00161   template class Vector<Color> ;
00162   
00163   template Vector<Color> operator+(const Vector<Color>&, const Vector<Color>&);
00164   template Vector<Color> operator-(const Vector<Color>&, const Vector<Color>&);
00165   template Color operator*(const Vector<Color>&,const Vector<Color>&);
00166   template Vector<Color> operator*(const Vector<Color>& v, const double d);
00167   template Vector<Color> operator*(const Vector<Color>& v, const Complex d);
00168   template int operator==(const Vector<Color>&,const Vector<Color>&);
00169   template int operator!=(const Vector<Color>&,const Vector<Color>&);
00170   template void swap(Color&,Color&) ;
00171 
00172 #endif
00173 
00174 } // end namespace
00175 
00176 #ifdef  NO_IMPLICIT_TEMPLATES
00177 
00178   // add the following for g++-v3 
00179   //template std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::_Setw);
00180 #endif
00181 
00182 #endif
00183 
00184 

Generated on Tue Jun 24 13:26:54 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002