math.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004                                                \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program 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             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
00021 *                                                                           *
00022 ****************************************************************************/
00023 /****************************************************************************
00024   History
00025 
00026 $Log: not supported by cvs2svn $
00027 Revision 1.10  2006/02/13 13:05:05  cignoni
00028 Removed glew inclusion
00029 
00030 Revision 1.9  2004/09/30 00:48:07  ponchio
00031 <gl/glew.h> -> <GL/glew.h>
00032 
00033 Revision 1.8  2004/09/28 14:04:36  ganovelli
00034 glGet added
00035 
00036 Revision 1.7  2004/07/13 15:55:57  cignoni
00037 Added test on presence of glTranspose extension (for old hw support)
00038 
00039 Revision 1.6  2004/05/26 15:12:39  cignoni
00040 Removed inclusion of gl extension stuff
00041 
00042 Revision 1.5  2004/05/12 20:54:55  ponchio
00043 *** empty log message ***
00044 
00045 Revision 1.4  2004/05/12 13:07:47  ponchio
00046 Added #include <glew.h>
00047 
00048 Revision 1.3  2004/05/04 23:36:23  cignoni
00049 remove include of gl and added glextgension exploiting,
00050 
00051 Revision 1.2  2004/04/07 10:47:03  cignoni
00052 inlined functions for avoid multiple linking errors
00053 
00054 Revision 1.1  2004/03/31 15:27:17  ponchio
00055 *** empty log message ***
00056 
00057 
00058 ****************************************************************************/
00059 
00060 #ifndef VCG_USE_EIGEN
00061 #include "deprecated_math.h"
00062 #else
00063 
00064 #ifndef VCG_GL_MATH_H
00065 #define VCG_GL_MATH_H
00066 
00067 // Please note that this file assume that you have already included your
00068 // gl-extension wrapping utility, and that therefore all the extension symbol are already defined.
00069 
00070 #include <vcg/math/matrix44.h>
00071 #include <vcg/math/similarity.h>
00072 //#include <GL/glew.h> // please do not include it!
00073 
00074 
00075 namespace vcg {
00076 
00077 template<typename T>
00078 inline void glLoadMatrix(const vcg::Matrix44<T> &m) { assert(0); }
00079 template<> inline void glLoadMatrix(const vcg::Matrix44f &m) {glLoadMatrixf(m.V()); }
00080 template<> inline void glLoadMatrix(const vcg::Matrix44d &m) {glLoadMatrixd(m.V()); }
00081 
00082 template<typename T,int StorageOrder>
00083 inline void glLoadMatrix(const Eigen::Matrix<T,4,4,StorageOrder>& matrix) { assert(0); }
00084 
00085 template<> inline void glLoadMatrix(const Eigen::Matrix<float,4,4>& matrix) { glLoadMatrixf(matrix.data()); }
00086 template<> inline void glLoadMatrix(const Eigen::Matrix<float,4,4,Eigen::RowMajor>& matrix) {
00087     Eigen::Matrix4f tmp(matrix);
00088     glLoadMatrixf(tmp.data());
00089 }
00090 inline void glLoadMatrix(const Eigen::Matrix<double,4,4>& matrix) { glLoadMatrixd(matrix.data()); }
00091 inline void glLoadMatrix(const Eigen::Matrix<double,4,4,Eigen::RowMajor>& matrix) {
00092     Eigen::Matrix4d tmp(matrix);
00093     glLoadMatrixd(tmp.data());
00094 }
00095 template<typename Scalar>
00096 inline void glLoadMatrix(const Eigen::Transform<Scalar,3>& t) { glLoadMatrix(t.matrix()); }
00097 
00098 
00099 template<typename T,int StorageOrder>
00100 inline void glMultMatrix(const Eigen::Matrix<T,4,4,StorageOrder>& matrix) { assert(0); }
00101 
00102 template<> inline void glMultMatrix(const Eigen::Matrix<float,4,4>& matrix) { glMultMatrixf(matrix.data()); }
00103 inline void glMultMatrix(const Eigen::Matrix<float,4,4,Eigen::RowMajor>& matrix) {
00104     Eigen::Matrix<float,4,4> tmp(matrix);
00105     glMultMatrixf(tmp.data());
00106 }
00107 template<> inline void glMultMatrix(const Eigen::Matrix<double,4,4>& matrix) { glMultMatrixd(matrix.data()); }
00108 template<> inline void glMultMatrix(const Eigen::Matrix<double,4,4,Eigen::RowMajor>& matrix) {
00109     Eigen::Matrix<double,4,4> tmp(matrix);
00110     glMultMatrixd(tmp.data());
00111 }
00112 template<typename Scalar>
00113 inline void glMultMatrix(const Eigen::Transform<Scalar,3>& t) { glMultMatrix(t.matrix()); }
00114 
00115 
00116 inline void glMultMatrix(const Similarityf &s) {
00117   glTranslatef(s.tra[0], s.tra[1], s.tra[2]);
00118   glScalef(s.sca, s.sca, s.sca);
00119   float alpha;
00120   Point3f axis;
00121   s.rot.ToAxis(alpha, axis);
00122   glRotatef(math::ToDeg(alpha), axis[0], axis[1], axis[2]);
00123 }
00124 
00125 inline void glMultMatrix(const Similarityd &s) {
00126   glTranslated(s.tra[0], s.tra[1], s.tra[2]);
00127   double alpha;
00128   Point3d axis;
00129   s.rot.ToAxis(alpha, axis);
00130   glRotated(math::ToDeg(alpha), axis[0], axis[1], axis[2]);
00131   glScaled(s.sca, s.sca, s.sca);
00132 }
00133 
00134 inline void glGetv(const GLenum  pname, Eigen::Matrix<float,4,4>& matrix){
00135     glGetFloatv(pname,matrix.data());
00136 }
00137 inline void glGetv(const GLenum pname, Eigen::Matrix<double,4,4>& matrix){
00138     glGetDoublev(pname,matrix.data());
00139 }
00140 inline void glGetv(const GLenum pname, Eigen::Matrix<float,4,4,Eigen::RowMajor>& matrix){
00141     glGetFloatv(pname,matrix.data());
00142     matrix.transposeInPlace();
00143 }
00144 inline void glGetv(const GLenum pname, Eigen::Matrix<double,4,4,Eigen::RowMajor>& matrix){
00145     glGetDoublev(pname,matrix.data());
00146     matrix.transposeInPlace();
00147 }
00148 template<typename Scalar>
00149 inline void glGetv(const GLenum pname, const Eigen::Transform<Scalar,3>& t)
00150 { glGetv(pname,t.matrix()); }
00151 
00152 }//namespace
00153 #endif
00154 
00155 #endif


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:32:58