1 // Copyright (c) 1991-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _gp_Pln_HeaderFile
16 #define _gp_Pln_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
23 #include <Standard_Real.hxx>
24 #include <Standard_Boolean.hxx>
26 class Standard_ConstructionError;
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.
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
65 //! Creates a plane coincident with OXY plane of the
66 //! reference coordinate system.
70 //! The coordinate system of the plane is defined with the axis
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);
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);
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);
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;
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);
100 //! Changes the origin of the plane.
101 void SetLocation (const gp_Pnt& Loc);
103 //! Changes the local coordinate system of the plane.
104 void SetPosition (const gp_Ax3& A3);
106 //! Reverses the U parametrization of the plane
107 //! reversing the XAxis.
110 //! Reverses the V parametrization of the plane
111 //! reversing the YAxis.
114 //! returns true if the Ax3 is right handed.
115 Standard_Boolean Direct() const;
117 //! Returns the plane's normal Axis.
118 const gp_Ax1& Axis() const;
120 //! Returns the plane's location (origin).
121 const gp_Pnt& Location() const;
123 //! Returns the local coordinate system of the plane .
124 const gp_Ax3& Position() const;
126 //! Computes the distance between <me> and the point <P>.
127 Standard_Real Distance (const gp_Pnt& P) const;
129 //! Computes the distance between <me> and the line <L>.
130 Standard_Real Distance (const gp_Lin& L) const;
132 //! Computes the distance between two planes.
133 Standard_Real Distance (const gp_Pln& Other) const;
136 //! Computes the square distance between <me> and the point <P>.
137 Standard_Real SquareDistance (const gp_Pnt& P) const;
140 //! Computes the square distance between <me> and the line <L>.
141 Standard_Real SquareDistance (const gp_Lin& L) const;
144 //! Computes the square distance between two planes.
145 Standard_Real SquareDistance (const gp_Pln& Other) const;
147 //! Returns the X axis of the plane.
148 gp_Ax1 XAxis() const;
150 //! Returns the Y axis of the plane.
151 gp_Ax1 YAxis() const;
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
161 Standard_Boolean Contains (const gp_Pnt& P, const Standard_Real LinearTolerance) const;
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
171 Standard_Boolean Contains (const gp_Lin& L, const Standard_Real LinearTolerance, const Standard_Real AngularTolerance) const;
173 Standard_EXPORT void Mirror (const gp_Pnt& P);
176 //! Performs the symmetrical transformation of a plane with respect
177 //! to the point <P> which is the center of the symmetry
179 //! The normal direction to the plane is not changed.
180 //! The "XAxis" and the "YAxis" are reversed.
181 Standard_NODISCARD Standard_EXPORT gp_Pln Mirrored (const gp_Pnt& P) const;
183 Standard_EXPORT void Mirror (const gp_Ax1& A1);
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
193 Standard_NODISCARD Standard_EXPORT gp_Pln Mirrored (const gp_Ax1& A1) const;
195 Standard_EXPORT void Mirror (const gp_Ax2& A2);
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.
205 Standard_NODISCARD Standard_EXPORT gp_Pln Mirrored (const gp_Ax2& A2) const;
207 void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
210 //! rotates a plane. A1 is the axis of the rotation.
211 //! Ang is the angular value of the rotation in radians.
212 Standard_NODISCARD gp_Pln Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
214 void Scale (const gp_Pnt& P, const Standard_Real S);
217 //! Scales a plane. S is the scaling value.
218 Standard_NODISCARD gp_Pln Scaled (const gp_Pnt& P, const Standard_Real S) const;
220 void Transform (const gp_Trsf& T);
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.
228 Standard_NODISCARD gp_Pln Transformed (const gp_Trsf& T) const;
230 void Translate (const gp_Vec& V);
233 //! Translates a plane in the direction of the vector V.
234 //! The magnitude of the translation is the vector's magnitude.
235 Standard_NODISCARD gp_Pln Translated (const gp_Vec& V) const;
237 void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
240 //! Translates a plane from the point P1 to the point P2.
241 Standard_NODISCARD gp_Pln Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
244 //! Dumps the content of me into the stream
245 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
265 #include <gp_Pln.lxx>
271 #endif // _gp_Pln_HeaderFile