Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Matrix2D.hh

Go to the documentation of this file.
00001 /*
00002     libpdf++: a C++ Free library to generate PDF file
00003     Copyright (C) 2002 Nestal Wan
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2.1 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00026 #ifndef __PDF_UTIL_MATRIX_HEADER_INCLUDED__
00027 #define __PDF_UTIL_MATRIX_HEADER_INCLUDED__
00028 
00029 #include <ext/algorithm>
00030 #include <iosfwd>
00031 #include <algorithm>
00032 
00033 namespace pdf { namespace util {
00034 
00040 class CMatrix2D
00041 {
00042 private :
00043     static const int matrix_size = 6 ;
00044     double m_matrix[matrix_size] ;
00045 
00046 public :
00047     typedef const double* iterator ;
00048     typedef double        value_type ;
00049     typedef unsigned      size_type ;
00050 
00051 public :
00052     CMatrix2D( ) ;
00053     
00054     template <typename InputIt>
00055     CMatrix2D( InputIt first )
00056     {
00057         __gnu_cxx::copy_n( first, matrix_size, m_matrix ) ;
00058     }
00059     
00060     CMatrix2D( const CMatrix2D& matrix ) ;
00061     CMatrix2D( double d0, double d1, double d2,
00062                double d3, double d4, double d5 ) ;
00063 
00064     void LoadIdentity( ) ;
00065     void Assign( double d0, double d1, double d2,
00066                  double d3, double d4, double d5 ) ;
00067     
00068     iterator begin( ) const { return m_matrix ; }
00069     iterator end( ) const { return m_matrix + matrix_size ; }
00070     
00071     size_type size( ) const { return matrix_size ; }
00072 
00073     std::ostream& Print( std::ostream& os ) const ;
00074     
00075     void Swap( CMatrix2D& m2 ) ;
00076 
00077     bool operator==( const CMatrix2D& matrix ) const ;
00078     bool operator!=( const CMatrix2D& matrix ) const
00079         { return !operator==( matrix ) ; }
00080 
00081     CMatrix2D& operator=( const CMatrix2D& matrix ) ;
00082 } ;
00083 
00084 inline std::ostream& operator<<( std::ostream& os, const CMatrix2D& matrix )
00085 {
00086     return matrix.Print( os ) ;
00087 }
00088 
00089 } } // end of namespace
00090 
00091 namespace std
00092 {
00093     template <>
00094     inline void swap<pdf::util::CMatrix2D>( pdf::util::CMatrix2D& m1,
00095                                             pdf::util::CMatrix2D& m2 )
00096     {
00097         m1.Swap( m2 ) ;
00098     }
00099 }
00100 
00101 #endif

Generated on Sun Feb 2 09:16:05 2003 for libpdf++ by doxygen1.2.16