OpenLexocad  28.0
ViewProj.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) 2005 Imetric 3D GmbH *
3  * *
4  * This file is part of the FreeCAD CAx development system. *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Library General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU Library General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Library General Public *
17  * License along with this library; see the file COPYING.LIB. If not, *
18  * write to the Free Software Foundation, Inc., 59 Temple Place, *
19  * Suite 330, Boston, MA 02111-1307, USA *
20  * *
21  ***************************************************************************/
22 
23 
24 #pragma once
25 
26 #include <Base/Matrix.h>
27 
28 
29 namespace Base {
30 
34 class LX_BASE_EXPORT ViewProjMethod
35 {
36 public:
37  virtual ~ViewProjMethod(){}
38  virtual bool isValid() const { return true; }
40  virtual Vector3f operator()(const Vector3f &rclPt) const = 0;
42  virtual Vector3d operator()(const Vector3d &rclPt) const = 0;
44  virtual Vector3f inverse (const Vector3f &rclPt) const = 0;
46  virtual Vector3d inverse (const Vector3d &rclPt) const = 0;
48  virtual Matrix4D getProjectionMatrix (void) const = 0;
50  Matrix4D getComposedProjectionMatrix (void) const;
52  void setTransform(const Base::Matrix4D&);
53  const Base::Matrix4D& getTransform() const {
54  return transform;
55  }
56 
57 protected:
59  void transformInput(const Base::Vector3f&, Base::Vector3f&) const;
60  void transformInput(const Base::Vector3d&, Base::Vector3d&) const;
61 
62 private:
63  bool hasTransform;
65 };
66 
71 class LX_BASE_EXPORT ViewProjMatrix : public ViewProjMethod
72 {
73 public:
74  ViewProjMatrix (const Matrix4D &rclMtx);
75  virtual ~ViewProjMatrix();
76 
77  Vector3f operator()(const Vector3f &rclPt) const;
78  Vector3d operator()(const Vector3d &rclPt) const;
79  Vector3f inverse (const Vector3f &rclPt) const;
80  Vector3d inverse (const Vector3d &rclPt) const;
81 
82  Matrix4D getProjectionMatrix (void) const;
83 
84 protected:
85  bool isOrthographic;
86  Matrix4D _clMtx, _clMtxInv;
87 };
88 
95 class LX_BASE_EXPORT ViewOrthoProjMatrix : public ViewProjMethod
96 {
97 public:
98  ViewOrthoProjMatrix (const Matrix4D &rclMtx);
99  virtual ~ViewOrthoProjMatrix();
100 
101  Vector3f operator()(const Vector3f &rclPt) const;
102  Vector3d operator()(const Vector3d &rclPt) const;
103  Vector3f inverse (const Vector3f &rclPt) const;
104  Vector3d inverse (const Vector3d &rclPt) const;
105 
106  Matrix4D getProjectionMatrix (void) const;
107 
108 protected:
109  Matrix4D _clMtx, _clMtxInv;
110 };
111 
112 } // namespace Base
Base::transform
void transform(Container container, OutputIt out, BinaryFunction function)
Definition: Algorithms.h:30
Base::ViewProjMethod
Definition: ViewProj.h:55
Base::Vector3
Definition: Vector3D.h:77
Base::Vector3d
Vector3< double > Vector3d
Definition: Vector3D.h:246
Base::ViewOrthoProjMatrix
Definition: ViewProj.h:116
Matrix.h
Base::Matrix4D
Definition: Matrix.h:55
Base::Vector3f
Vector3< float > Vector3f
Definition: Vector3D.h:245
Base
Definition: AbstractXMLReader.h:5