0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / Geom / Geom_Transformation.hxx
CommitLineData
42cf5bc1 1// Created on: 1993-03-10
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 _Geom_Transformation_HeaderFile
18#define _Geom_Transformation_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <gp_Trsf.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>
29class Standard_ConstructionError;
30class Standard_OutOfRange;
31class gp_Trsf;
32class gp_Pnt;
33class gp_Ax1;
34class gp_Ax2;
35class gp_Ax3;
36class gp_Vec;
37
38
39class Geom_Transformation;
40DEFINE_STANDARD_HANDLE(Geom_Transformation, MMgt_TShared)
41
42//! Describes how to construct the following elementary transformations
43//! - translations,
44//! - rotations,
45//! - symmetries,
46//! - scales.
47//! The Transformation class can also be used to
48//! construct complex transformations by combining these
49//! elementary transformations.
50//! However, these transformations can never change
51//! the type of an object. For example, the projection
52//! transformation can change a circle into an ellipse, and
53//! therefore change the real type of the object. Such a
54//! transformation is forbidden in this environment and
55//! cannot be a Geom_Transformation.
56//! The transformation can be represented as follow :
57//!
58//! V1 V2 V3 T
59//! | a11 a12 a13 a14 | | x | | x'|
60//! | a21 a22 a23 a24 | | y | | y'|
61//! | a31 a32 a33 a34 | | z | = | z'|
62//! | 0 0 0 1 | | 1 | | 1 |
63//!
64//! where {V1, V2, V3} defines the vectorial part of the
65//! transformation and T defines the translation part of
66//! the transformation.
67//! Note: Geom_Transformation transformations
68//! provide the same kind of "geometric" services as
69//! gp_Trsf ones but have more complex data structures.
70//! The geometric objects provided by the Geom
71//! package use gp_Trsf transformations in the syntaxes
72//! Transform and Transformed.
73//! Geom_Transformation transformations are used in
74//! a context where they can be shared by several
75//! objects contained inside a common data structure.
76class Geom_Transformation : public MMgt_TShared
77{
78
79public:
80
81
82 //! Creates an identity transformation.
83 Standard_EXPORT Geom_Transformation();
84
85 //! Creates a transient copy of T.
86 Standard_EXPORT Geom_Transformation(const gp_Trsf& T);
87
88
89 //! Makes the transformation into a symmetrical transformation
90 //! with respect to a point P.
91 //! P is the center of the symmetry.
92 Standard_EXPORT void SetMirror (const gp_Pnt& P);
93
94
95 //! Makes the transformation into a symmetrical transformation
96 //! with respect to an axis A1.
97 //! A1 is the center of the axial symmetry.
98 Standard_EXPORT void SetMirror (const gp_Ax1& A1);
99
100
101 //! Makes the transformation into a symmetrical transformation
102 //! with respect to a plane. The plane of the symmetry is
103 //! defined with the axis placement A2. It is the plane
104 //! (Location, XDirection, YDirection).
105 Standard_EXPORT void SetMirror (const gp_Ax2& A2);
106
107
108 //! Makes the transformation into a rotation.
109 //! A1 is the axis rotation and Ang is the angular value
110 //! of the rotation in radians.
111 Standard_EXPORT void SetRotation (const gp_Ax1& A1, const Standard_Real Ang);
112
113
114 //! Makes the transformation into a scale. P is the center of
115 //! the scale and S is the scaling value.
116 Standard_EXPORT void SetScale (const gp_Pnt& P, const Standard_Real S);
117
118
119 //! Makes a transformation allowing passage from the coordinate
120 //! system "FromSystem1" to the coordinate system "ToSystem2".
121 //! Example :
122 //! In a C++ implementation :
123 //! Real x1, y1, z1; // are the coordinates of a point in the
124 //! // local system FromSystem1
125 //! Real x2, y2, z2; // are the coordinates of a point in the
126 //! // local system ToSystem2
127 //! gp_Pnt P1 (x1, y1, z1)
128 //! Geom_Transformation T;
129 //! T.SetTransformation (FromSystem1, ToSystem2);
130 //! gp_Pnt P2 = P1.Transformed (T);
131 //! P2.Coord (x2, y2, z2);
132 Standard_EXPORT void SetTransformation (const gp_Ax3& FromSystem1, const gp_Ax3& ToSystem2);
133
134
135 //! Makes the transformation allowing passage from the basic
136 //! coordinate system
137 //! {P(0.,0.,0.), VX (1.,0.,0.), VY (0.,1.,0.), VZ (0., 0. ,1.) }
138 //! to the local coordinate system defined with the Ax2 ToSystem.
139 //! Same utilisation as the previous method. FromSystem1 is
140 //! defaulted to the absolute coordinate system.
141 Standard_EXPORT void SetTransformation (const gp_Ax3& ToSystem);
142
143
144 //! Makes the transformation into a translation.
145 //! V is the vector of the translation.
146 Standard_EXPORT void SetTranslation (const gp_Vec& V);
147
148
149 //! Makes the transformation into a translation from the point
150 //! P1 to the point P2.
151 Standard_EXPORT void SetTranslation (const gp_Pnt& P1, const gp_Pnt& P2);
152
153 //! Converts the gp_Trsf transformation T into this transformation.
154 Standard_EXPORT void SetTrsf (const gp_Trsf& T);
155
156 //! Checks whether this transformation is an indirect
157 //! transformation: returns true if the determinant of the
158 //! matrix of the vectorial part of the transformation is less than 0.
159 Standard_EXPORT Standard_Boolean IsNegative() const;
160
161 //! Returns the nature of this transformation as a value
162 //! of the gp_TrsfForm enumeration.
163 Standard_EXPORT gp_TrsfForm Form() const;
164
165 //! Returns the scale value of the transformation.
166 Standard_EXPORT Standard_Real ScaleFactor() const;
167
168
169 //! Returns a non transient copy of <me>.
170 Standard_EXPORT const gp_Trsf& Trsf() const;
171
172
173 //! Returns the coefficients of the global matrix of tranformation.
174 //! It is a 3 rows X 4 columns matrix.
175 //!
176 //! Raised if Row < 1 or Row > 3 or Col < 1 or Col > 4
177 //!
178 //! Computes the reverse transformation.
179 Standard_EXPORT Standard_Real Value (const Standard_Integer Row, const Standard_Integer Col) const;
180
181
182 //! Raised if the the transformation is singular. This means that
183 //! the ScaleFactor is lower or equal to Resolution from
184 //! package gp.
185 Standard_EXPORT void Invert();
186
187
188 //! Raised if the the transformation is singular. This means that
189 //! the ScaleFactor is lower or equal to Resolution from
190 //! package gp.
191 Standard_EXPORT Handle(Geom_Transformation) Inverted() const;
192
193
194 //! Computes the transformation composed with Other and <me>.
195 //! <me> * Other.
196 //! Returns a new transformation
197 Standard_EXPORT Handle(Geom_Transformation) Multiplied (const Handle(Geom_Transformation)& Other) const;
198
199
200 //! Computes the transformation composed with Other and <me> .
201 //! <me> = <me> * Other.
202 Standard_EXPORT void Multiply (const Handle(Geom_Transformation)& Other);
203
204
205 //! Computes the following composition of transformations
206 //! if N > 0 <me> * <me> * .......* <me>.
207 //! if N = 0 Identity
208 //! if N < 0 <me>.Invert() * .........* <me>.Invert()
209 //!
210 //! Raised if N < 0 and if the transformation is not inversible
211 Standard_EXPORT void Power (const Standard_Integer N);
212
213
214 //! Raised if N < 0 and if the transformation is not inversible
215 Standard_EXPORT Handle(Geom_Transformation) Powered (const Standard_Integer N) const;
216
217
218 //! Computes the matrix of the transformation composed with
219 //! <me> and Other. <me> = Other * <me>
220 Standard_EXPORT void PreMultiply (const Handle(Geom_Transformation)& Other);
221
222
223 //! Applies the transformation <me> to the triplet {X, Y, Z}.
224 Standard_EXPORT void Transforms (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const;
225
226 //! Creates a new object which is a copy of this transformation.
227 Standard_EXPORT Handle(Geom_Transformation) Copy() const;
228
229
230
231
92efcf78 232 DEFINE_STANDARD_RTTIEXT(Geom_Transformation,MMgt_TShared)
42cf5bc1 233
234protected:
235
236
237
238
239private:
240
241
242 gp_Trsf gpTrsf;
243
244
245};
246
247
248
249
250
251
252
253#endif // _Geom_Transformation_HeaderFile