42cf5bc1 |
1 | // Created on: 1993-03-24 |
2 | // Created by: JCV |
3 | // Copyright (c) 1993-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 _Geom2d_Transformation_HeaderFile |
18 | #define _Geom2d_Transformation_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <gp_Trsf2d.hxx> |
24 | #include <MMgt_TShared.hxx> |
25 | #include <Standard_Real.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | #include <gp_TrsfForm.hxx> |
28 | #include <Standard_Integer.hxx> |
29 | class Standard_ConstructionError; |
30 | class Standard_OutOfRange; |
31 | class gp_Trsf2d; |
32 | class gp_Pnt2d; |
33 | class gp_Ax2d; |
34 | class gp_Vec2d; |
35 | |
36 | |
37 | class Geom2d_Transformation; |
38 | DEFINE_STANDARD_HANDLE(Geom2d_Transformation, MMgt_TShared) |
39 | |
40 | |
41 | //! The class Transformation allows to create Translation, |
42 | //! Rotation, Symmetry, Scaling and complex transformations |
43 | //! obtained by combination of the previous elementary |
44 | //! transformations. |
45 | //! The Transformation class can also be used to |
46 | //! construct complex transformations by combining |
47 | //! these elementary transformations. |
48 | //! However, these transformations can never change |
49 | //! the type of an object. For example, the projection |
50 | //! transformation can change a circle into an ellipse, |
51 | //! and therefore change the real type of the object. |
52 | //! Such a transformation is forbidden in this |
53 | //! environment and cannot be a Geom2d_Transformation. |
54 | //! The transformation can be represented as follow : |
55 | //! |
56 | //! V1 V2 T |
57 | //! | a11 a12 a14 | | x | | x'| |
58 | //! | a21 a22 a24 | | y | | y'| |
59 | //! | 0 0 1 | | 1 | | 1 | |
60 | //! |
61 | //! where {V1, V2} defines the vectorial part of the |
62 | //! transformation and T defines the translation part of |
63 | //! the transformation. |
64 | //! - Geom2d_Transformation transformations provide |
65 | //! the same kind of "geometric" services as |
66 | //! gp_Trsf2d ones but have more complex data |
67 | //! structures. The geometric objects provided by the |
68 | //! Geom2d package use gp_Trsf2d transformations |
69 | //! in the syntaxes Transform and Transformed. |
70 | //! - Geom2d_Transformation transformations are |
71 | //! used in a context where they can be shared by |
72 | //! several objects contained inside a common data structure. |
73 | class Geom2d_Transformation : public MMgt_TShared |
74 | { |
75 | |
76 | public: |
77 | |
78 | |
79 | //! Creates an identity transformation. |
80 | Standard_EXPORT Geom2d_Transformation(); |
81 | |
82 | //! Creates a persistent copy of T. |
83 | Standard_EXPORT Geom2d_Transformation(const gp_Trsf2d& T); |
84 | |
85 | |
86 | //! Makes the transformation into a symmetrical transformation |
87 | //! with respect to a point P. |
88 | //! P is the center of the symmetry. |
89 | Standard_EXPORT void SetMirror (const gp_Pnt2d& P); |
90 | |
91 | |
92 | //! Makes the transformation into a symmetrical transformation |
93 | //! with respect to an axis A. |
94 | //! A is the center of the axial symmetry. |
95 | Standard_EXPORT void SetMirror (const gp_Ax2d& A); |
96 | |
97 | //! Assigns to this transformation the geometric |
98 | //! properties of a rotation at angle Ang (in radians) about point P. |
99 | Standard_EXPORT void SetRotation (const gp_Pnt2d& P, const Standard_Real Ang); |
100 | |
101 | |
102 | //! Makes the transformation into a scale. P is the center of |
103 | //! the scale and S is the scaling value. |
104 | Standard_EXPORT void SetScale (const gp_Pnt2d& P, const Standard_Real S); |
105 | |
106 | |
107 | //! Makes a transformation allowing passage from the coordinate |
108 | //! system "FromSystem1" to the coordinate system "ToSystem2". |
109 | Standard_EXPORT void SetTransformation (const gp_Ax2d& FromSystem1, const gp_Ax2d& ToSystem2); |
110 | |
111 | |
112 | //! Makes the transformation allowing passage from the basic |
113 | //! coordinate system |
114 | //! {P(0.,0.,0.), VX (1.,0.,0.), VY (0.,1.,0.)} |
115 | //! to the local coordinate system defined with the Ax2d ToSystem. |
116 | Standard_EXPORT void SetTransformation (const gp_Ax2d& ToSystem); |
117 | |
118 | |
119 | //! Makes the transformation into a translation. |
120 | //! V is the vector of the translation. |
121 | Standard_EXPORT void SetTranslation (const gp_Vec2d& V); |
122 | |
123 | |
124 | //! Makes the transformation into a translation from the point |
125 | //! P1 to the point P2. |
126 | Standard_EXPORT void SetTranslation (const gp_Pnt2d& P1, const gp_Pnt2d& P2); |
127 | |
128 | |
129 | //! Makes the transformation into a transformation T from |
130 | //! package gp. |
131 | Standard_EXPORT void SetTrsf2d (const gp_Trsf2d& T); |
132 | |
133 | //! Checks whether this transformation is an indirect |
134 | //! transformation: returns true if the determinant of the |
135 | //! matrix of the vectorial part of the transformation is less than 0. |
136 | Standard_EXPORT Standard_Boolean IsNegative() const; |
137 | |
138 | //! Returns the nature of this transformation as a value |
139 | //! of the gp_TrsfForm enumeration. |
140 | //! Returns the nature of the transformation. It can be |
141 | //! Identity, Rotation, Translation, PntMirror, Ax1Mirror, |
142 | //! Scale, CompoundTrsf |
143 | Standard_EXPORT gp_TrsfForm Form() const; |
144 | |
145 | //! Returns the scale value of the transformation. |
146 | Standard_EXPORT Standard_Real ScaleFactor() const; |
147 | |
148 | //! Converts this transformation into a gp_Trsf2d transformation. |
149 | //! Returns a non persistent copy of <me>. |
150 | //! -C++: return const& |
151 | Standard_EXPORT gp_Trsf2d Trsf2d() const; |
152 | |
153 | |
154 | //! Returns the coefficients of the global matrix of tranformation. |
155 | //! It is a 2 rows X 3 columns matrix. |
156 | //! |
157 | //! Raised if Row < 1 or Row > 2 or Col < 1 or Col > 2 |
158 | //! |
159 | //! Computes the reverse transformation. |
160 | Standard_EXPORT Standard_Real Value (const Standard_Integer Row, const Standard_Integer Col) const; |
161 | |
162 | //! Computes the inverse of this transformation. |
163 | //! and assigns the result to this transformatio |
164 | //! |
165 | //! Raised if the the transformation is singular. This means that |
166 | //! the ScaleFactor is lower or equal to Resolution from |
167 | //! package gp. |
168 | Standard_EXPORT void Invert(); |
169 | |
170 | //! Computes the inverse of this transformation and creates a new one. |
171 | //! Raises ConstructionError if the the transformation is singular. This means that |
172 | //! the ScaleFactor is lower or equal to Resolution from package gp. |
173 | Standard_EXPORT Handle(Geom2d_Transformation) Inverted() const; |
174 | |
175 | |
176 | //! Computes the transformation composed with Other and <me>. |
177 | //! <me> * Other. |
178 | //! Returns a new transformation |
179 | Standard_EXPORT Handle(Geom2d_Transformation) Multiplied (const Handle(Geom2d_Transformation)& Other) const; |
180 | Handle(Geom2d_Transformation) operator * (const Handle(Geom2d_Transformation)& Other) const |
181 | { |
182 | return Multiplied(Other); |
183 | } |
184 | |
185 | |
186 | //! Computes the transformation composed with Other and <me> . |
187 | //! <me> = <me> * Other. |
188 | //! |
189 | //! Computes the following composition of transformations |
190 | //! if N > 0 <me> * <me> * .......* <me>. |
191 | //! if N = 0 Identity |
192 | //! if N < 0 <me>.Invert() * .........* <me>.Invert() |
193 | Standard_EXPORT void Multiply (const Handle(Geom2d_Transformation)& Other); |
194 | void operator *= (const Handle(Geom2d_Transformation)& Other) |
195 | { |
196 | Multiply(Other); |
197 | } |
198 | |
199 | |
200 | //! Raised if N < 0 and if the transformation is not inversible |
201 | Standard_EXPORT void Power (const Standard_Integer N); |
202 | |
203 | |
204 | //! Raised if N < 0 and if the transformation is not inversible |
205 | Standard_EXPORT Handle(Geom2d_Transformation) Powered (const Standard_Integer N) const; |
206 | |
207 | |
208 | //! Computes the matrix of the transformation composed with |
209 | //! <me> and Other. <me> = Other * <me> |
210 | Standard_EXPORT void PreMultiply (const Handle(Geom2d_Transformation)& Other); |
211 | |
212 | |
213 | //! Applies the transformation <me> to the triplet {X, Y}. |
214 | Standard_EXPORT void Transforms (Standard_Real& X, Standard_Real& Y) const; |
215 | |
216 | //! Creates a new object, which is a copy of this transformation. |
217 | Standard_EXPORT Handle(Geom2d_Transformation) Copy() const; |
218 | |
219 | |
220 | |
221 | |
222 | DEFINE_STANDARD_RTTI(Geom2d_Transformation,MMgt_TShared) |
223 | |
224 | protected: |
225 | |
226 | |
227 | |
228 | |
229 | private: |
230 | |
231 | |
232 | gp_Trsf2d gpTrsf2d; |
233 | |
234 | |
235 | }; |
236 | |
237 | |
238 | |
239 | |
240 | |
241 | |
242 | |
243 | #endif // _Geom2d_Transformation_HeaderFile |