42cf5bc1 |
1 | // Copyright (c) 1991-1999 Matra Datavision |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
3 | // |
4 | // This file is part of Open CASCADE Technology software library. |
5 | // |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
11 | // |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
14 | |
15 | #ifndef _gp_Ax22d_HeaderFile |
16 | #define _gp_Ax22d_HeaderFile |
17 | |
18 | #include <Standard.hxx> |
19 | #include <Standard_DefineAlloc.hxx> |
20 | #include <Standard_Handle.hxx> |
21 | |
22 | #include <gp_Pnt2d.hxx> |
23 | #include <gp_Dir2d.hxx> |
24 | #include <Standard_Boolean.hxx> |
25 | #include <gp_Ax2d.hxx> |
26 | #include <Standard_Real.hxx> |
27 | class Standard_ConstructionError; |
28 | class gp_Pnt2d; |
29 | class gp_Dir2d; |
30 | class gp_Ax2d; |
31 | class gp_Trsf2d; |
32 | class gp_Vec2d; |
33 | |
34 | |
35 | |
36 | //! Describes a coordinate system in a plane (2D space). |
37 | //! A coordinate system is defined by: |
38 | //! - its origin (also referred to as its "Location point"), and |
39 | //! - two orthogonal unit vectors, respectively, called the "X |
40 | //! Direction" and the "Y Direction". |
41 | //! A gp_Ax22d may be right-handed ("direct sense") or |
42 | //! left-handed ("inverse" or "indirect sense"). |
43 | //! You use a gp_Ax22d to: |
44 | //! - describe 2D geometric entities, in particular to position |
45 | //! them. The local coordinate system of a geometric |
46 | //! entity serves for the same purpose as the STEP |
47 | //! function "axis placement two axes", or |
48 | //! - define geometric transformations. |
49 | //! Note: we refer to the "X Axis" and "Y Axis" as the axes having: |
50 | //! - the origin of the coordinate system as their origin, and |
51 | //! - the unit vectors "X Direction" and "Y Direction", |
52 | //! respectively, as their unit vectors. |
53 | class gp_Ax22d |
54 | { |
55 | public: |
56 | |
57 | DEFINE_STANDARD_ALLOC |
58 | |
59 | |
60 | //! Creates an object representing the reference |
316ea293 |
61 | //! coordinate system (OXY). |
42cf5bc1 |
62 | gp_Ax22d(); |
63 | |
64 | |
65 | //! Creates a coordinate system with origin P and where: |
66 | //! - Vx is the "X Direction", and |
67 | //! - the "Y Direction" is orthogonal to Vx and |
68 | //! oriented so that the cross products Vx^"Y |
69 | //! Direction" and Vx^Vy have the same sign. |
70 | //! Raises ConstructionError if Vx and Vy are parallel (same or opposite orientation). |
71 | gp_Ax22d(const gp_Pnt2d& P, const gp_Dir2d& Vx, const gp_Dir2d& Vy); |
72 | |
73 | |
74 | //! Creates - a coordinate system with origin P and "X Direction" |
75 | //! V, which is: |
76 | //! - right-handed if Sense is true (default value), or |
77 | //! - left-handed if Sense is false |
78 | gp_Ax22d(const gp_Pnt2d& P, const gp_Dir2d& V, const Standard_Boolean Sense = Standard_True); |
79 | |
80 | |
81 | //! Creates - a coordinate system where its origin is the origin of |
82 | //! A and its "X Direction" is the unit vector of A, which is: |
83 | //! - right-handed if Sense is true (default value), or |
84 | //! - left-handed if Sense is false. |
85 | gp_Ax22d(const gp_Ax2d& A, const Standard_Boolean Sense = Standard_True); |
86 | |
87 | |
88 | //! Assigns the origin and the two unit vectors of the |
89 | //! coordinate system A1 to this coordinate system. |
90 | void SetAxis (const gp_Ax22d& A1); |
91 | |
92 | |
93 | //! Changes the XAxis and YAxis ("Location" point and "Direction") |
94 | //! of <me>. |
95 | //! The "YDirection" is recomputed in the same sense as before. |
96 | void SetXAxis (const gp_Ax2d& A1); |
97 | |
98 | //! Changes the XAxis and YAxis ("Location" point and "Direction") of <me>. |
99 | //! The "XDirection" is recomputed in the same sense as before. |
100 | void SetYAxis (const gp_Ax2d& A1); |
101 | |
102 | |
103 | //! Changes the "Location" point (origin) of <me>. |
104 | void SetLocation (const gp_Pnt2d& P); |
105 | |
106 | |
107 | //! Assigns Vx to the "X Direction" of |
108 | //! this coordinate system. The other unit vector of this |
109 | //! coordinate system is recomputed, normal to Vx , |
110 | //! without modifying the orientation (right-handed or |
111 | //! left-handed) of this coordinate system. |
112 | void SetXDirection (const gp_Dir2d& Vx); |
113 | |
114 | //! Assignsr Vy to the "Y Direction" of |
115 | //! this coordinate system. The other unit vector of this |
116 | //! coordinate system is recomputed, normal to Vy, |
117 | //! without modifying the orientation (right-handed or |
118 | //! left-handed) of this coordinate system. |
119 | void SetYDirection (const gp_Dir2d& Vy); |
120 | |
121 | //! Returns an axis, for which |
122 | //! - the origin is that of this coordinate system, and |
123 | //! - the unit vector is either the "X Direction" of this coordinate system. |
124 | //! Note: the result is the "X Axis" of this coordinate system. |
125 | gp_Ax2d XAxis() const; |
126 | |
127 | //! Returns an axis, for which |
128 | //! - the origin is that of this coordinate system, and |
129 | //! - the unit vector is either the "Y Direction" of this coordinate system. |
130 | //! Note: the result is the "Y Axis" of this coordinate system. |
131 | gp_Ax2d YAxis() const; |
132 | |
133 | |
134 | //! Returns the "Location" point (origin) of <me>. |
135 | const gp_Pnt2d& Location() const; |
136 | |
137 | |
138 | //! Returns the "XDirection" of <me>. |
139 | const gp_Dir2d& XDirection() const; |
140 | |
141 | |
142 | //! Returns the "YDirection" of <me>. |
143 | const gp_Dir2d& YDirection() const; |
144 | |
145 | Standard_EXPORT void Mirror (const gp_Pnt2d& P); |
146 | |
147 | |
148 | //! Performs the symmetrical transformation of an axis |
149 | //! placement with respect to the point P which is the |
150 | //! center of the symmetry. |
151 | //! Warnings : |
152 | //! The main direction of the axis placement is not changed. |
153 | //! The "XDirection" and the "YDirection" are reversed. |
154 | //! So the axis placement stay right handed. |
6ed44b1c |
155 | Standard_NODISCARD Standard_EXPORT gp_Ax22d Mirrored (const gp_Pnt2d& P) const; |
42cf5bc1 |
156 | |
157 | Standard_EXPORT void Mirror (const gp_Ax2d& A); |
158 | |
159 | |
160 | //! Performs the symmetrical transformation of an axis |
161 | //! placement with respect to an axis placement which |
162 | //! is the axis of the symmetry. |
163 | //! The transformation is performed on the "Location" |
164 | //! point, on the "XDirection" and "YDirection". |
165 | //! The resulting main "Direction" is the cross product between |
166 | //! the "XDirection" and the "YDirection" after transformation. |
6ed44b1c |
167 | Standard_NODISCARD Standard_EXPORT gp_Ax22d Mirrored (const gp_Ax2d& A) const; |
42cf5bc1 |
168 | |
169 | void Rotate (const gp_Pnt2d& P, const Standard_Real Ang); |
170 | |
171 | |
172 | //! Rotates an axis placement. <A1> is the axis of the |
173 | //! rotation . Ang is the angular value of the rotation |
174 | //! in radians. |
0be7dbe1 |
175 | Standard_NODISCARD gp_Ax22d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const; |
42cf5bc1 |
176 | |
177 | void Scale (const gp_Pnt2d& P, const Standard_Real S); |
178 | |
179 | |
180 | //! Applies a scaling transformation on the axis placement. |
181 | //! The "Location" point of the axisplacement is modified. |
182 | //! Warnings : |
183 | //! If the scale <S> is negative : |
184 | //! . the main direction of the axis placement is not changed. |
185 | //! . The "XDirection" and the "YDirection" are reversed. |
186 | //! So the axis placement stay right handed. |
0be7dbe1 |
187 | Standard_NODISCARD gp_Ax22d Scaled (const gp_Pnt2d& P, const Standard_Real S) const; |
42cf5bc1 |
188 | |
189 | void Transform (const gp_Trsf2d& T); |
190 | |
191 | |
192 | //! Transforms an axis placement with a Trsf. |
193 | //! The "Location" point, the "XDirection" and the |
194 | //! "YDirection" are transformed with T. The resulting |
195 | //! main "Direction" of <me> is the cross product between |
196 | //! the "XDirection" and the "YDirection" after transformation. |
0be7dbe1 |
197 | Standard_NODISCARD gp_Ax22d Transformed (const gp_Trsf2d& T) const; |
42cf5bc1 |
198 | |
199 | void Translate (const gp_Vec2d& V); |
200 | |
201 | |
202 | //! Translates an axis plaxement in the direction of the vector |
203 | //! <V>. The magnitude of the translation is the vector's magnitude. |
0be7dbe1 |
204 | Standard_NODISCARD gp_Ax22d Translated (const gp_Vec2d& V) const; |
42cf5bc1 |
205 | |
206 | void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2); |
207 | |
208 | |
209 | //! Translates an axis placement from the point <P1> to the |
210 | //! point <P2>. |
0be7dbe1 |
211 | Standard_NODISCARD gp_Ax22d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const; |
42cf5bc1 |
212 | |
bc73b006 |
213 | //! Dumps the content of me into the stream |
214 | Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; |
215 | |
42cf5bc1 |
216 | |
217 | |
218 | |
219 | protected: |
220 | |
221 | |
222 | |
223 | |
224 | |
225 | private: |
226 | |
227 | |
228 | |
229 | gp_Pnt2d point; |
230 | gp_Dir2d vydir; |
231 | gp_Dir2d vxdir; |
232 | |
233 | |
234 | }; |
235 | |
236 | |
237 | #include <gp_Ax22d.lxx> |
238 | |
239 | |
240 | |
241 | |
242 | |
243 | #endif // _gp_Ax22d_HeaderFile |