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_Lin_HeaderFile |
16 | #define _gp_Lin_HeaderFile |
17 | |
18 | #include <Standard.hxx> |
19 | #include <Standard_DefineAlloc.hxx> |
20 | #include <Standard_Handle.hxx> |
21 | |
22 | #include <gp_Ax1.hxx> |
23 | #include <Standard_Real.hxx> |
24 | #include <Standard_Boolean.hxx> |
25 | class Standard_ConstructionError; |
26 | class gp_Ax1; |
27 | class gp_Pnt; |
28 | class gp_Dir; |
29 | class gp_Ax2; |
30 | class gp_Trsf; |
31 | class gp_Vec; |
32 | |
33 | |
34 | |
35 | //! Describes a line in 3D space. |
36 | //! A line is positioned in space with an axis (a gp_Ax1 |
37 | //! object) which gives it an origin and a unit vector. |
38 | //! A line and an axis are similar objects, thus, we can |
39 | //! convert one into the other. A line provides direct access |
40 | //! to the majority of the edit and query functions available |
41 | //! on its positioning axis. In addition, however, a line has |
42 | //! specific functions for computing distances and positions. |
43 | //! See Also |
44 | //! gce_MakeLin which provides functions for more complex |
45 | //! line constructions |
46 | //! Geom_Line which provides additional functions for |
47 | //! constructing lines and works, in particular, with the |
48 | //! parametric equations of lines |
49 | class gp_Lin |
50 | { |
51 | public: |
52 | |
53 | DEFINE_STANDARD_ALLOC |
54 | |
55 | |
56 | //! Creates a Line corresponding to Z axis of the |
57 | //! reference coordinate system. |
58 | gp_Lin(); |
59 | |
60 | //! Creates a line defined by axis A1. |
61 | gp_Lin(const gp_Ax1& A1); |
62 | |
63 | //! Creates a line passing through point P and parallel to |
64 | //! vector V (P and V are, respectively, the origin and |
65 | //! the unit vector of the positioning axis of the line). |
be5c3602 |
66 | gp_Lin(const gp_Pnt& P, const gp_Dir& V); |
67 | |
42cf5bc1 |
68 | void Reverse(); |
69 | |
70 | //! Reverses the direction of the line. |
71 | //! Note: |
72 | //! - Reverse assigns the result to this line, while |
73 | //! - Reversed creates a new one. |
0be7dbe1 |
74 | Standard_NODISCARD gp_Lin Reversed() const; |
42cf5bc1 |
75 | |
76 | //! Changes the direction of the line. |
77 | void SetDirection (const gp_Dir& V); |
78 | |
79 | //! Changes the location point (origin) of the line. |
80 | void SetLocation (const gp_Pnt& P); |
81 | |
82 | |
83 | //! Complete redefinition of the line. |
84 | //! The "Location" point of <A1> is the origin of the line. |
85 | //! The "Direction" of <A1> is the direction of the line. |
86 | void SetPosition (const gp_Ax1& A1); |
87 | |
88 | //! Returns the direction of the line. |
89 | const gp_Dir& Direction() const; |
90 | |
91 | |
92 | //! Returns the location point (origin) of the line. |
93 | const gp_Pnt& Location() const; |
94 | |
95 | |
96 | //! Returns the axis placement one axis whith the same |
97 | //! location and direction as <me>. |
98 | const gp_Ax1& Position() const; |
99 | |
100 | //! Computes the angle between two lines in radians. |
101 | Standard_Real Angle (const gp_Lin& Other) const; |
102 | |
103 | //! Returns true if this line contains the point P, that is, if the |
104 | //! distance between point P and this line is less than or |
105 | //! equal to LinearTolerance.. |
106 | Standard_Boolean Contains (const gp_Pnt& P, const Standard_Real LinearTolerance) const; |
107 | |
108 | //! Computes the distance between <me> and the point P. |
109 | Standard_Real Distance (const gp_Pnt& P) const; |
110 | |
111 | //! Computes the distance between two lines. |
112 | Standard_EXPORT Standard_Real Distance (const gp_Lin& Other) const; |
113 | |
114 | |
115 | //! Computes the square distance between <me> and the point P. |
116 | Standard_Real SquareDistance (const gp_Pnt& P) const; |
117 | |
118 | //! Computes the square distance between two lines. |
119 | Standard_Real SquareDistance (const gp_Lin& Other) const; |
120 | |
121 | |
122 | //! Computes the line normal to the direction of <me>, passing |
123 | //! through the point P. Raises ConstructionError |
124 | //! if the distance between <me> and the point P is lower |
125 | //! or equal to Resolution from gp because there is an infinity of |
126 | //! solutions in 3D space. |
127 | gp_Lin Normal (const gp_Pnt& P) const; |
128 | |
129 | Standard_EXPORT void Mirror (const gp_Pnt& P); |
130 | |
131 | |
132 | //! Performs the symmetrical transformation of a line |
133 | //! with respect to the point P which is the center of |
134 | //! the symmetry. |
6ed44b1c |
135 | Standard_NODISCARD Standard_EXPORT gp_Lin Mirrored (const gp_Pnt& P) const; |
42cf5bc1 |
136 | |
137 | Standard_EXPORT void Mirror (const gp_Ax1& A1); |
138 | |
139 | |
140 | //! Performs the symmetrical transformation of a line |
141 | //! with respect to an axis placement which is the axis |
142 | //! of the symmetry. |
6ed44b1c |
143 | Standard_NODISCARD Standard_EXPORT gp_Lin Mirrored (const gp_Ax1& A1) const; |
42cf5bc1 |
144 | |
145 | Standard_EXPORT void Mirror (const gp_Ax2& A2); |
146 | |
147 | |
148 | //! Performs the symmetrical transformation of a line |
149 | //! with respect to a plane. The axis placement <A2> |
150 | //! locates the plane of the symmetry : |
151 | //! (Location, XDirection, YDirection). |
6ed44b1c |
152 | Standard_NODISCARD Standard_EXPORT gp_Lin Mirrored (const gp_Ax2& A2) const; |
42cf5bc1 |
153 | |
154 | void Rotate (const gp_Ax1& A1, const Standard_Real Ang); |
155 | |
156 | |
157 | //! Rotates a line. A1 is the axis of the rotation. |
158 | //! Ang is the angular value of the rotation in radians. |
0be7dbe1 |
159 | Standard_NODISCARD gp_Lin Rotated (const gp_Ax1& A1, const Standard_Real Ang) const; |
42cf5bc1 |
160 | |
161 | void Scale (const gp_Pnt& P, const Standard_Real S); |
162 | |
163 | |
164 | //! Scales a line. S is the scaling value. |
165 | //! The "Location" point (origin) of the line is modified. |
166 | //! The "Direction" is reversed if the scale is negative. |
0be7dbe1 |
167 | Standard_NODISCARD gp_Lin Scaled (const gp_Pnt& P, const Standard_Real S) const; |
42cf5bc1 |
168 | |
169 | void Transform (const gp_Trsf& T); |
170 | |
171 | |
172 | //! Transforms a line with the transformation T from class Trsf. |
0be7dbe1 |
173 | Standard_NODISCARD gp_Lin Transformed (const gp_Trsf& T) const; |
42cf5bc1 |
174 | |
175 | void Translate (const gp_Vec& V); |
176 | |
177 | |
178 | //! Translates a line in the direction of the vector V. |
179 | //! The magnitude of the translation is the vector's magnitude. |
0be7dbe1 |
180 | Standard_NODISCARD gp_Lin Translated (const gp_Vec& V) const; |
42cf5bc1 |
181 | |
182 | void Translate (const gp_Pnt& P1, const gp_Pnt& P2); |
183 | |
184 | |
185 | //! Translates a line from the point P1 to the point P2. |
0be7dbe1 |
186 | Standard_NODISCARD gp_Lin Translated (const gp_Pnt& P1, const gp_Pnt& P2) const; |
42cf5bc1 |
187 | |
188 | |
189 | |
190 | |
191 | protected: |
192 | |
193 | |
194 | |
195 | |
196 | |
197 | private: |
198 | |
199 | |
200 | |
201 | gp_Ax1 pos; |
202 | |
203 | |
204 | }; |
205 | |
206 | |
207 | #include <gp_Lin.lxx> |
208 | |
209 | |
210 | |
211 | |
212 | |
213 | #endif // _gp_Lin_HeaderFile |