0031313: Foundation Classes - Dump improvement for classes
[occt.git] / src / gp / gp_Pln.hxx
CommitLineData
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_Pln_HeaderFile
16#define _gp_Pln_HeaderFile
17
18#include <Standard.hxx>
19#include <Standard_DefineAlloc.hxx>
20#include <Standard_Handle.hxx>
21
22#include <gp_Ax3.hxx>
23#include <Standard_Real.hxx>
24#include <Standard_Boolean.hxx>
25#include <gp_Ax1.hxx>
26class Standard_ConstructionError;
27class gp_Ax3;
28class gp_Pnt;
29class gp_Dir;
30class gp_Ax1;
31class gp_Lin;
32class gp_Ax2;
33class gp_Trsf;
34class gp_Vec;
35
36
37//! Describes a plane.
38//! A plane is positioned in space with a coordinate system
39//! (a gp_Ax3 object), such that the plane is defined by the
40//! origin, "X Direction" and "Y Direction" of this coordinate
41//! system, which is the "local coordinate system" of the
42//! plane. The "main Direction" of the coordinate system is a
43//! vector normal to the plane. It gives the plane an implicit
44//! orientation such that the plane is said to be "direct", if the
45//! coordinate system is right-handed, or "indirect" in the other case.
46//! Note: when a gp_Pln plane is converted into a
47//! Geom_Plane plane, some implicit properties of its local
48//! coordinate system are used explicitly:
49//! - its origin defines the origin of the two parameters of
50//! the planar surface,
51//! - its implicit orientation is also that of the Geom_Plane.
52//! See Also
53//! gce_MakePln which provides functions for more complex
54//! plane constructions
55//! Geom_Plane which provides additional functions for
56//! constructing planes and works, in particular, with the
57//! parametric equations of planes
58class gp_Pln
59{
60public:
61
62 DEFINE_STANDARD_ALLOC
63
64
65 //! Creates a plane coincident with OXY plane of the
66 //! reference coordinate system.
67 gp_Pln();
68
69
70 //! The coordinate system of the plane is defined with the axis
71 //! placement A3.
72 //! The "Direction" of A3 defines the normal to the plane.
73 //! The "Location" of A3 defines the location (origin) of the plane.
74 //! The "XDirection" and "YDirection" of A3 define the "XAxis" and
75 //! the "YAxis" of the plane used to parametrize the plane.
76 gp_Pln(const gp_Ax3& A3);
77
78
79 //! Creates a plane with the "Location" point <P>
80 //! and the normal direction <V>.
81 Standard_EXPORT gp_Pln(const gp_Pnt& P, const gp_Dir& V);
82
83
84 //! Creates a plane from its cartesian equation :
85 //! A * X + B * Y + C * Z + D = 0.0
86 //! Raises ConstructionError if Sqrt (A*A + B*B + C*C) <= Resolution from gp.
87 Standard_EXPORT gp_Pln(const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D);
88
89
90 //! Returns the coefficients of the plane's cartesian equation :
91 //! A * X + B * Y + C * Z + D = 0.
92 void Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D) const;
93
94 //! Modifies this plane, by redefining its local coordinate system so that
95 //! - its origin and "main Direction" become those of the
96 //! axis A1 (the "X Direction" and "Y Direction" are then recomputed).
97 //! Raises ConstructionError if the A1 is parallel to the "XAxis" of the plane.
98 void SetAxis (const gp_Ax1& A1);
99
100 //! Changes the origin of the plane.
101 void SetLocation (const gp_Pnt& Loc);
102
103 //! Changes the local coordinate system of the plane.
104 void SetPosition (const gp_Ax3& A3);
105
106 //! Reverses the U parametrization of the plane
107 //! reversing the XAxis.
108 void UReverse();
109
110 //! Reverses the V parametrization of the plane
111 //! reversing the YAxis.
112 void VReverse();
113
114 //! returns true if the Ax3 is right handed.
115 Standard_Boolean Direct() const;
116
117 //! Returns the plane's normal Axis.
118 const gp_Ax1& Axis() const;
119
120 //! Returns the plane's location (origin).
121 const gp_Pnt& Location() const;
122
123 //! Returns the local coordinate system of the plane .
124 const gp_Ax3& Position() const;
125
126 //! Computes the distance between <me> and the point <P>.
127 Standard_Real Distance (const gp_Pnt& P) const;
128
129 //! Computes the distance between <me> and the line <L>.
130 Standard_Real Distance (const gp_Lin& L) const;
131
132 //! Computes the distance between two planes.
133 Standard_Real Distance (const gp_Pln& Other) const;
134
135
136 //! Computes the square distance between <me> and the point <P>.
137 Standard_Real SquareDistance (const gp_Pnt& P) const;
138
139
140 //! Computes the square distance between <me> and the line <L>.
141 Standard_Real SquareDistance (const gp_Lin& L) const;
142
143
144 //! Computes the square distance between two planes.
145 Standard_Real SquareDistance (const gp_Pln& Other) const;
146
147 //! Returns the X axis of the plane.
148 gp_Ax1 XAxis() const;
149
150 //! Returns the Y axis of the plane.
151 gp_Ax1 YAxis() const;
152
153 //! Returns true if this plane contains the point P. This means that
154 //! - the distance between point P and this plane is less
155 //! than or equal to LinearTolerance, or
156 //! - line L is normal to the "main Axis" of the local
157 //! coordinate system of this plane, within the tolerance
158 //! AngularTolerance, and the distance between the origin
159 //! of line L and this plane is less than or equal to
160 //! LinearTolerance.
161 Standard_Boolean Contains (const gp_Pnt& P, const Standard_Real LinearTolerance) const;
162
163 //! Returns true if this plane contains the line L. This means that
164 //! - the distance between point P and this plane is less
165 //! than or equal to LinearTolerance, or
166 //! - line L is normal to the "main Axis" of the local
167 //! coordinate system of this plane, within the tolerance
168 //! AngularTolerance, and the distance between the origin
169 //! of line L and this plane is less than or equal to
170 //! LinearTolerance.
171 Standard_Boolean Contains (const gp_Lin& L, const Standard_Real LinearTolerance, const Standard_Real AngularTolerance) const;
172
173 Standard_EXPORT void Mirror (const gp_Pnt& P);
174
175
176 //! Performs the symmetrical transformation of a plane with respect
177 //! to the point <P> which is the center of the symmetry
178 //! Warnings :
179 //! The normal direction to the plane is not changed.
180 //! The "XAxis" and the "YAxis" are reversed.
6ed44b1c 181 Standard_NODISCARD Standard_EXPORT gp_Pln Mirrored (const gp_Pnt& P) const;
42cf5bc1 182
183 Standard_EXPORT void Mirror (const gp_Ax1& A1);
184
185 //! Performs the symmetrical transformation of a
186 //! plane with respect to an axis placement which is the axis
187 //! of the symmetry. The transformation is performed on the
188 //! "Location" point, on the "XAxis" and the "YAxis". The
189 //! resulting normal direction is the cross product between
190 //! the "XDirection" and the "YDirection" after transformation
191 //! if the initial plane was right handed, else it is the
192 //! opposite.
6ed44b1c 193 Standard_NODISCARD Standard_EXPORT gp_Pln Mirrored (const gp_Ax1& A1) const;
42cf5bc1 194
195 Standard_EXPORT void Mirror (const gp_Ax2& A2);
196
197 //! Performs the symmetrical transformation of a
198 //! plane with respect to an axis placement. The axis
199 //! placement <A2> locates the plane of the symmetry. The
200 //! transformation is performed on the "Location" point, on
201 //! the "XAxis" and the "YAxis". The resulting normal
202 //! direction is the cross product between the "XDirection"
203 //! and the "YDirection" after transformation if the initial
204 //! plane was right handed, else it is the opposite.
6ed44b1c 205 Standard_NODISCARD Standard_EXPORT gp_Pln Mirrored (const gp_Ax2& A2) const;
42cf5bc1 206
207 void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
208
209
210 //! rotates a plane. A1 is the axis of the rotation.
211 //! Ang is the angular value of the rotation in radians.
0be7dbe1 212 Standard_NODISCARD gp_Pln Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
42cf5bc1 213
214 void Scale (const gp_Pnt& P, const Standard_Real S);
215
216
217 //! Scales a plane. S is the scaling value.
0be7dbe1 218 Standard_NODISCARD gp_Pln Scaled (const gp_Pnt& P, const Standard_Real S) const;
42cf5bc1 219
220 void Transform (const gp_Trsf& T);
221
222
223 //! Transforms a plane with the transformation T from class Trsf.
224 //! The transformation is performed on the "Location"
225 //! point, on the "XAxis" and the "YAxis".
226 //! The resulting normal direction is the cross product between
227 //! the "XDirection" and the "YDirection" after transformation.
0be7dbe1 228 Standard_NODISCARD gp_Pln Transformed (const gp_Trsf& T) const;
42cf5bc1 229
230 void Translate (const gp_Vec& V);
231
232
233 //! Translates a plane in the direction of the vector V.
234 //! The magnitude of the translation is the vector's magnitude.
0be7dbe1 235 Standard_NODISCARD gp_Pln Translated (const gp_Vec& V) const;
42cf5bc1 236
237 void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
238
239
240 //! Translates a plane from the point P1 to the point P2.
0be7dbe1 241 Standard_NODISCARD gp_Pln Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
42cf5bc1 242
243
bc73b006 244 //! Dumps the content of me into the stream
245 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
246
42cf5bc1 247
248
249protected:
250
251
252
253
254
255private:
256
257
258
259 gp_Ax3 pos;
260
261
262};
263
264
265#include <gp_Pln.lxx>
266
267
268
269
270
271#endif // _gp_Pln_HeaderFile