1 // Created on: 1993-03-24
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Geom2d_Transformation_HeaderFile
18 #define _Geom2d_Transformation_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
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;
37 class Geom2d_Transformation;
38 DEFINE_STANDARD_HANDLE(Geom2d_Transformation, MMgt_TShared)
41 //! The class Transformation allows to create Translation,
42 //! Rotation, Symmetry, Scaling and complex transformations
43 //! obtained by combination of the previous elementary
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 :
57 //! | a11 a12 a14 | | x | | x'|
58 //! | a21 a22 a24 | | y | | y'|
59 //! | 0 0 1 | | 1 | | 1 |
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
79 //! Creates an identity transformation.
80 Standard_EXPORT Geom2d_Transformation();
82 //! Creates a persistent copy of T.
83 Standard_EXPORT Geom2d_Transformation(const gp_Trsf2d& T);
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);
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);
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);
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);
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);
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);
119 //! Makes the transformation into a translation.
120 //! V is the vector of the translation.
121 Standard_EXPORT void SetTranslation (const gp_Vec2d& V);
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);
129 //! Makes the transformation into a transformation T from
131 Standard_EXPORT void SetTrsf2d (const gp_Trsf2d& T);
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;
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;
145 //! Returns the scale value of the transformation.
146 Standard_EXPORT Standard_Real ScaleFactor() const;
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;
154 //! Returns the coefficients of the global matrix of tranformation.
155 //! It is a 2 rows X 3 columns matrix.
157 //! Raised if Row < 1 or Row > 2 or Col < 1 or Col > 2
159 //! Computes the reverse transformation.
160 Standard_EXPORT Standard_Real Value (const Standard_Integer Row, const Standard_Integer Col) const;
162 //! Computes the inverse of this transformation.
163 //! and assigns the result to this transformatio
165 //! Raised if the the transformation is singular. This means that
166 //! the ScaleFactor is lower or equal to Resolution from
168 Standard_EXPORT void Invert();
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;
176 //! Computes the transformation composed with Other and <me>.
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
182 return Multiplied(Other);
186 //! Computes the transformation composed with Other and <me> .
187 //! <me> = <me> * Other.
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)
200 //! Raised if N < 0 and if the transformation is not inversible
201 Standard_EXPORT void Power (const Standard_Integer N);
204 //! Raised if N < 0 and if the transformation is not inversible
205 Standard_EXPORT Handle(Geom2d_Transformation) Powered (const Standard_Integer N) const;
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);
213 //! Applies the transformation <me> to the triplet {X, Y}.
214 Standard_EXPORT void Transforms (Standard_Real& X, Standard_Real& Y) const;
216 //! Creates a new object, which is a copy of this transformation.
217 Standard_EXPORT Handle(Geom2d_Transformation) Copy() const;
222 DEFINE_STANDARD_RTTI(Geom2d_Transformation,MMgt_TShared)
243 #endif // _Geom2d_Transformation_HeaderFile