b311480e |
1 | -- Copyright (c) 1991-1999 Matra Datavision |
2 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
3 | -- |
4 | -- The content of this file is subject to the Open CASCADE Technology Public |
5 | -- License Version 6.5 (the "License"). You may not use the content of this file |
6 | -- except in compliance with the License. Please obtain a copy of the License |
7 | -- at http://www.opencascade.org and read it completely before using this file. |
8 | -- |
9 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
10 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
11 | -- |
12 | -- The Original Code and all software distributed under the License is |
13 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
14 | -- Initial Developer hereby disclaims all such warranties, including without |
15 | -- limitation, any warranties of merchantability, fitness for a particular |
16 | -- purpose or non-infringement. Please see the License for the specific terms |
17 | -- and conditions governing the rights and limitations under the License. |
18 | |
7fd59977 |
19 | |
20 | |
21 | |
22 | class GTrsf from gp inherits Storable |
23 | |
24 | --- Purpose : |
25 | -- Defines a non-persistent transformation in 3D space. |
26 | -- This transformation is a general transformation. |
27 | -- It can be a Trsf from gp, an affinity, or you can define |
28 | -- your own transformation giving the matrix of transformation. |
29 | -- |
30 | -- With a Gtrsf you can transform only a triplet of coordinates |
31 | -- XYZ. It is not possible to transform other geometric objects |
32 | -- because these transformations can change the nature of non- |
33 | -- elementary geometric objects. |
34 | -- The transformation GTrsf can be represented as follow : |
35 | -- |
36 | -- V1 V2 V3 T XYZ XYZ |
37 | -- | a11 a12 a13 a14 | | x | | x'| |
38 | -- | a21 a22 a23 a24 | | y | | y'| |
39 | -- | a31 a32 a33 a34 | | z | = | z'| |
40 | -- | 0 0 0 1 | | 1 | | 1 | |
41 | -- |
42 | -- where {V1, V2, V3} define the vectorial part of the |
43 | -- transformation and T defines the translation part of the |
44 | -- transformation. |
45 | -- Warning |
46 | -- A GTrsf transformation is only applicable to |
47 | -- coordinates. Be careful if you apply such a |
48 | -- transformation to all points of a geometric object, as |
49 | -- this can change the nature of the object and thus |
50 | -- render it incoherent! |
51 | -- Typically, a circle is transformed into an ellipse by an |
52 | -- affinity transformation. To avoid modifying the nature of |
53 | -- an object, use a gp_Trsf transformation instead, as |
54 | -- objects of this class respect the nature of geometric objects. |
55 | uses Ax1 from gp, |
56 | Ax2 from gp, |
57 | Mat from gp, |
58 | Trsf from gp, |
59 | Vec from gp, |
60 | XYZ from gp, |
61 | TrsfForm from gp |
62 | |
63 | raises ConstructionError from Standard, |
64 | OutOfRange from Standard |
65 | |
66 | |
67 | is |
68 | |
69 | |
70 | |
71 | |
72 | Create returns GTrsf; |
73 | ---C++: inline |
74 | --- Purpose : Returns the Identity transformation. |
75 | |
76 | |
77 | Create (T : Trsf) returns GTrsf; |
78 | ---C++: inline |
79 | --- Purpose : |
80 | -- Converts the gp_Trsf transformation T into a |
81 | -- general transformation, i.e. Returns a GTrsf with |
82 | -- the same matrix of coefficients as the Trsf T. |
83 | |
84 | |
85 | Create (M : Mat; V : XYZ) returns GTrsf; |
86 | ---C++: inline |
87 | --- Purpose : |
88 | -- Creates a transformation based on the matrix M and the |
89 | -- vector V where M defines the vectorial part of |
90 | -- the transformation, and V the translation part, or |
91 | |
92 | |
93 | SetAffinity (me : in out; A1 : Ax1; Ratio : Real) is static; |
94 | ---C++: inline |
95 | --- Purpose : Changes this transformation into an affinity of ratio Ratio |
96 | -- with respect to the axis A1. |
97 | -- Note: an affinity is a point-by-point transformation that |
98 | -- transforms any point P into a point P' such that if H is |
99 | -- the orthogonal projection of P on the axis A1 or the |
100 | -- plane A2, the vectors HP and HP' satisfy: |
101 | -- HP' = Ratio * HP. |
102 | |
103 | SetAffinity (me : in out; A2 : Ax2; Ratio : Real) is static; |
104 | ---C++: inline |
105 | --- Purpose : Changes this transformation into an affinity of ratio Ratio |
106 | -- with respect to the plane defined by the origin, the "X Direction" and |
107 | -- the "Y Direction" of coordinate system A2. |
108 | -- Note: an affinity is a point-by-point transformation that |
109 | -- transforms any point P into a point P' such that if H is |
110 | -- the orthogonal projection of P on the axis A1 or the |
111 | -- plane A2, the vectors HP and HP' satisfy: |
112 | -- HP' = Ratio * HP. |
113 | |
114 | SetValue (me : in out; Row, Col : Integer; Value : Real) |
115 | ---C++: inline |
116 | --- Purpose : |
117 | -- Replaces the coefficient (Row, Col) of the matrix representing |
118 | -- this transformation by Value. Raises OutOfRange |
119 | -- if Row < 1 or Row > 3 or Col < 1 or Col > 4 |
120 | raises OutOfRange |
121 | |
122 | is static; |
123 | |
124 | |
125 | SetVectorialPart (me : in out; Matrix : Mat) is static; |
126 | ---C++: inline |
127 | --- Purpose : Replaces the vectorial part of this transformation by Matrix. |
128 | |
129 | |
130 | SetTranslationPart (me : in out; Coord : XYZ) is static; |
131 | --- Purpose : Replaces the translation part of |
132 | -- this transformation by the coordinates of the number triple Coord. |
133 | |
134 | |
135 | SetTrsf (me : in out; T : Trsf) is static; |
136 | ---C++: inline |
137 | --- Purpose : Assigns the vectorial and translation parts of T to this transformation. |
138 | |
139 | IsNegative (me) returns Boolean is static; |
140 | ---C++: inline |
141 | --- Purpose : |
142 | -- Returns true if the determinant of the vectorial part of |
143 | -- this transformation is negative. |
144 | |
145 | |
146 | IsSingular (me) returns Boolean is static; |
147 | ---C++: inline |
148 | --- Purpose : |
149 | -- Returns true if this transformation is singular (and |
150 | -- therefore, cannot be inverted). |
151 | -- Note: The Gauss LU decomposition is used to invert the |
152 | -- transformation matrix. Consequently, the transformation |
153 | -- is considered as singular if the largest pivot found is less |
154 | -- than or equal to gp::Resolution(). |
155 | -- Warning |
156 | -- If this transformation is singular, it cannot be inverted. |
157 | |
158 | Form (me) returns TrsfForm is static; |
159 | --- Purpose : |
160 | -- Returns the nature of the transformation. It can be an |
161 | -- identity transformation, a rotation, a translation, a mirror |
162 | -- transformation (relative to a point, an axis or a plane), a |
163 | -- scaling transformation, a compound transformation or |
164 | -- some other type of transformation. |
165 | |
166 | |
167 | SetForm (me:in out) is static; |
168 | --- Purpose : |
169 | -- verify and set the shape of the GTrsf Other or CompoundTrsf |
170 | -- Ex : |
171 | -- myGTrsf.SetValue(row1,col1,val1); |
172 | -- myGTrsf.SetValue(row2,col2,val2); |
173 | -- ... |
174 | -- myGTrsf.SetForm(); |
175 | |
176 | |
177 | |
178 | TranslationPart (me) returns XYZ is static; |
179 | --- Purpose : Returns the translation part of the GTrsf. |
180 | ---C++: inline |
181 | ---C++: return const& |
182 | |
183 | |
184 | VectorialPart (me) returns Mat is static; |
185 | --- Purpose : |
186 | -- Computes the vectorial part of the GTrsf. The returned Matrix |
187 | -- is a 3*3 matrix. |
188 | ---C++: inline |
189 | ---C++: return const& |
190 | |
191 | |
192 | Value (me; Row, Col : Integer) returns Real |
193 | --- Purpose : |
194 | -- Returns the coefficients of the global matrix of transformation. |
195 | -- Raises OutOfRange if Row < 1 or Row > 3 or Col < 1 or Col > 4 |
196 | ---C++: inline |
197 | ---C++: alias operator() |
198 | |
199 | raises OutOfRange |
200 | |
201 | is static; |
202 | |
203 | |
204 | Invert (me : in out) raises ConstructionError is static; |
205 | |
206 | Inverted (me) returns GTrsf raises ConstructionError is static; |
207 | ---C++: inline |
208 | --- Purpose : |
209 | -- Computes the reverse transformation. |
210 | -- Raises an exception if the matrix of the transformation |
211 | -- is not inversible. |
212 | |
213 | |
214 | |
215 | |
216 | |
217 | Multiply (me : in out; T : GTrsf) is static; |
218 | |
219 | --- Purpose : |
220 | -- Computes the transformation composed from T and <me>. |
221 | -- In a C++ implementation you can also write Tcomposed = <me> * T. |
222 | --- Example : |
223 | -- GTrsf T1, T2, Tcomp; ............... |
224 | -- //composition : |
225 | -- Tcomp = T2.Multiplied(T1); // or (Tcomp = T2 * T1) |
226 | -- // transformation of a point |
227 | -- XYZ P(10.,3.,4.); |
228 | -- XYZ P1(P); |
229 | -- Tcomp.Transforms(P1); //using Tcomp |
230 | -- XYZ P2(P); |
231 | -- T1.Transforms(P2); //using T1 then T2 |
232 | -- T2.Transforms(P2); // P1 = P2 !!! |
233 | -- C++: alias operator *= |
234 | |
235 | |
236 | |
237 | Multiplied (me; T : GTrsf) returns GTrsf is static; |
238 | |
239 | --- Purpose : |
240 | -- Computes the transformation composed with <me> and T. |
241 | -- <me> = T * <me> |
242 | ---C++: inline |
243 | -- C++: alias operator * |
244 | |
245 | PreMultiply (me : in out; T : GTrsf) is static; |
246 | |
247 | ---Purpose: |
248 | -- Computes the product of the transformation T and this |
249 | -- transformation and assigns the result to this transformation. |
250 | -- this = T * this |
251 | |
252 | |
253 | |
254 | Power (me : in out; N : Integer) raises ConstructionError is static; |
255 | |
256 | Powered (me; N : Integer) returns GTrsf raises ConstructionError is static; |
257 | ---C++: inline |
258 | |
259 | |
260 | --- Purpose : |
261 | -- Computes: |
262 | -- - the product of this transformation multiplied by itself |
263 | -- N times, if N is positive, or |
264 | -- - the product of the inverse of this transformation |
265 | -- multiplied by itself |N| times, if N is negative. |
266 | -- If N equals zero, the result is equal to the Identity |
267 | -- transformation. |
268 | -- I.e.: <me> * <me> * .......* <me>, N time. |
269 | -- if N =0 <me> = Identity |
270 | -- if N < 0 <me> = <me>.Inverse() *...........* <me>.Inverse(). |
271 | -- |
272 | -- Raises an exception if N < 0 and if the matrix of the |
273 | -- transformation not inversible. |
274 | |
275 | |
276 | |
277 | |
278 | Transforms (me; Coord : in out XYZ) is static; |
279 | ---C++: inline |
280 | |
281 | Transforms (me; X, Y, Z : in out Real) is static; |
282 | ---C++: inline |
283 | --- Purpose : Transforms a triplet XYZ with a GTrsf. |
284 | |
285 | |
286 | Trsf (me) returns Trsf raises ConstructionError is static; |
287 | ---C++: inline |
288 | |
289 | |
290 | fields |
291 | |
292 | matrix : Mat; |
293 | loc : XYZ; |
294 | shape : TrsfForm; |
295 | scale : Real; |
296 | |
297 | end; |
298 | |
299 | |