42cf5bc1 |
1 | // Created on: 1992-03-12 |
2 | // Created by: Christophe MARION |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _HLRAlgo_Projector_HeaderFile |
18 | #define _HLRAlgo_Projector_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Integer.hxx> |
25 | #include <Standard_Boolean.hxx> |
26 | #include <Standard_Real.hxx> |
27 | #include <gp_Trsf.hxx> |
28 | #include <gp_Vec2d.hxx> |
29 | class Standard_NoSuchObject; |
30 | class gp_Ax2; |
31 | class gp_Trsf; |
32 | class gp_Vec2d; |
33 | class gp_Vec; |
34 | class gp_Pnt; |
35 | class gp_Pnt2d; |
36 | class gp_Lin; |
37 | |
38 | |
39 | //! Implements a projector object. |
40 | //! To transform and project Points and Planes. |
41 | //! This object is designed to be used in the |
42 | //! removal of hidden lines and is returned by the |
43 | //! Prs3d_Projector::Projector function. |
44 | //! You define the projection of the selected shape |
45 | //! by calling one of the following functions: |
46 | //! - HLRBRep_Algo::Projector, or |
47 | //! - HLRBRep_PolyAlgo::Projector |
48 | //! The choice depends on the algorithm, which you are using. |
49 | //! The parameters of the view are defined at the |
50 | //! time of construction of a Prs3d_Projector object. |
51 | class HLRAlgo_Projector |
52 | { |
53 | public: |
54 | |
55 | DEFINE_STANDARD_ALLOC |
56 | |
57 | |
58 | Standard_EXPORT HLRAlgo_Projector(); |
59 | |
60 | //! Creates an axonometric projector. <CS> is the |
61 | //! viewing coordinate system. |
62 | Standard_EXPORT HLRAlgo_Projector(const gp_Ax2& CS); |
63 | |
64 | //! Creates a perspective projector. <CS> is the |
65 | //! viewing coordinate system. |
66 | Standard_EXPORT HLRAlgo_Projector(const gp_Ax2& CS, const Standard_Real Focus); |
67 | |
68 | //! build a Projector with automatic minmax directions. |
69 | Standard_EXPORT HLRAlgo_Projector(const gp_Trsf& T, const Standard_Boolean Persp, const Standard_Real Focus); |
70 | |
71 | //! build a Projector with given minmax directions. |
72 | Standard_EXPORT HLRAlgo_Projector(const gp_Trsf& T, const Standard_Boolean Persp, const Standard_Real Focus, const gp_Vec2d& v1, const gp_Vec2d& v2, const gp_Vec2d& v3); |
73 | |
74 | Standard_EXPORT void Set (const gp_Trsf& T, const Standard_Boolean Persp, const Standard_Real Focus); |
75 | |
76 | void Directions (gp_Vec2d& D1, gp_Vec2d& D2, gp_Vec2d& D3) const; |
77 | |
78 | //! to compute with the given scale and translation. |
79 | Standard_EXPORT void Scaled (const Standard_Boolean On = Standard_False); |
80 | |
81 | //! Returns True if there is a perspective transformation. |
82 | Standard_Boolean Perspective() const; |
83 | |
84 | //! Returns the active transformation. |
85 | Standard_EXPORT const gp_Trsf& Transformation() const; |
86 | |
87 | //! Returns the active inverted transformation. |
88 | const gp_Trsf& InvertedTransformation() const; |
89 | |
90 | //! Returns the original transformation. |
91 | const gp_Trsf& FullTransformation() const; |
92 | |
93 | //! Returns the focal length. |
94 | Standard_Real Focus() const; |
95 | |
96 | void Transform (gp_Vec& D) const; |
97 | |
98 | void Transform (gp_Pnt& Pnt) const; |
99 | |
100 | //! Transform and apply perspective if needed. |
101 | Standard_EXPORT void Project (const gp_Pnt& P, gp_Pnt2d& Pout) const; |
102 | |
103 | //! Transform and apply perspective if needed. |
104 | Standard_EXPORT void Project (const gp_Pnt& P, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const; |
105 | |
106 | //! Transform and apply perspective if needed. |
107 | Standard_EXPORT void Project (const gp_Pnt& P, const gp_Vec& D1, gp_Pnt2d& Pout, gp_Vec2d& D1out) const; |
108 | |
109 | //! return a line going through the eye towards the |
110 | //! 2d point <X,Y>. |
111 | Standard_EXPORT gp_Lin Shoot (const Standard_Real X, const Standard_Real Y) const; |
112 | |
113 | |
114 | |
115 | |
116 | protected: |
117 | |
118 | |
119 | |
120 | |
121 | |
122 | private: |
123 | |
124 | |
125 | Standard_EXPORT void SetDirection(); |
126 | |
127 | |
128 | Standard_Integer myType; |
129 | Standard_Boolean myPersp; |
130 | Standard_Real myFocus; |
131 | gp_Trsf myScaledTrsf; |
132 | gp_Trsf myTrsf; |
133 | gp_Trsf myInvTrsf; |
134 | gp_Vec2d myD1; |
135 | gp_Vec2d myD2; |
136 | gp_Vec2d myD3; |
137 | |
138 | |
139 | }; |
140 | |
141 | |
142 | #include <HLRAlgo_Projector.lxx> |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | #endif // _HLRAlgo_Projector_HeaderFile |