ViewProj.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2005 Imetric 3D GmbH                                    *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef BASE_VIEWPROJ_H
00025 #define BASE_VIEWPROJ_H
00026 
00027 #include "Vector3D.h"
00028 #include "Matrix.h"
00029 
00030 
00031 namespace Base {
00032 
00036 class BaseExport ViewProjMethod
00037 {
00038 public:
00039     virtual ~ViewProjMethod(){};
00040     virtual bool isValid() const { return true; };
00042     virtual Vector3f operator()(const Vector3f &rclPt) const = 0;
00044     virtual Vector3d operator()(const Vector3d &rclPt) const = 0;
00046     virtual Vector3f inverse (const Vector3f &rclPt) const = 0;
00048     virtual Vector3d inverse (const Vector3d &rclPt) const = 0;
00050     virtual Matrix4D getProjectionMatrix (void) const = 0; 
00051 
00052 protected:
00053     ViewProjMethod(){};
00054 };
00055 
00060 class BaseExport ViewProjMatrix : public ViewProjMethod
00061 {
00062 public:
00063     ViewProjMatrix (const Matrix4D &rclMtx) : _clMtx(rclMtx) {  _clMtxInv = _clMtx; _clMtxInv.inverse(); };
00064     virtual ~ViewProjMatrix(){};
00065 
00066     inline Vector3f operator()(const Vector3f &rclPt) const;
00067     inline Vector3d operator()(const Vector3d &rclPt) const;
00068     inline Vector3f inverse (const Vector3f &rclPt) const;
00069     inline Vector3d inverse (const Vector3d &rclPt) const;
00070 
00071     Matrix4D getProjectionMatrix (void) const { return _clMtx; }
00072 
00073 protected:
00074     Matrix4D _clMtx, _clMtxInv;
00075 };
00076 
00077 inline Vector3f ViewProjMatrix::operator()(const Vector3f &rclPt) const
00078 {
00079     return Vector3f(_clMtx * rclPt);
00080 }
00081 
00082 inline Vector3d ViewProjMatrix::operator()(const Vector3d &rclPt) const
00083 {
00084     return Vector3d(_clMtx * rclPt);
00085 }
00086 
00087 inline Vector3f ViewProjMatrix::inverse (const Vector3f &rclPt) const
00088 {
00089     return Vector3f(_clMtxInv * rclPt);
00090 }
00091 
00092 inline Vector3d ViewProjMatrix::inverse (const Vector3d &rclPt) const
00093 {
00094     return Vector3d(_clMtxInv * rclPt);
00095 }
00096 
00097 } // namespace Base
00098 
00099 #endif // BASE_VIEWPROJ_H

Generated on Wed Nov 23 19:00:57 2011 for FreeCAD by  doxygen 1.6.1